Skip to contentSkip to conversation

s390x patches for 2.2

GIT PULL Applied Cornelia Huck 2 participants 10 messages Oct 10, 2014

lore
Share & tools
lore
#0 lore raw

Updates v1->v2:
- rebased against master
- "s390x/migration: migrate CPU state": move vmstate code into target-s390x/machine.c and tweak comment

The following changes since commit fcb2cd928f5519b8241e22411a696be1a7272b1c:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2014-10-09 15:09:05 +0100)

are available in the git repository at:

git://github.com/cohuck/qemu.git tags/s390x-20141010

for you to fetch changes up to 4b7757bae7c94f980969031119db12d540cf2b61:

s390x/virtio-ccw: fix vhost-scsi intialization (2014-10-10 13:32:39 +0200)

----------------------------------------------------------------
various s390x updates:
- cpu state handling in qemu and migration
- vhost-scsi-ccw bugfix

----------------------------------------------------------------

Cornelia Huck (1):
s390x/virtio-ccw: fix vhost-scsi intialization

David Hildenbrand (5):
s390x/kvm: introduce proper states for s390 cpus s390x/kvm: proper use of the cpu states OPERATING and STOPPED s390x/kvm: propagate s390 cpu state to kvm
s390x/kvm: reuse kvm_s390_reset_vcpu() to get rid of ifdefs s390x/kvm: synchronize the cpu state after SIGP (INITIAL) CPU RESET

Jens Freimann (1):
linux-headers: update to 3.17-rc7

Thomas Huth (1):
s390x/migration: migrate CPU state

 hw/s390x/ipl.c                    |    2 +-
 hw/s390x/s390-virtio.c            |   32 -----------
 hw/s390x/virtio-ccw.c             |    2 +-
 linux-headers/asm-mips/kvm_para.h |    6 +-
 linux-headers/asm-powerpc/kvm.h   |    2 +
 linux-headers/asm-x86/kvm.h       |    3 +
 linux-headers/linux/kvm.h         |   13 ++++-
 linux-headers/linux/kvm_para.h    |    3 +
 linux-headers/linux/vfio.h        |   34 +++++++++++
 linux-headers/linux/vhost.h       |    2 +-
 target-s390x/Makefile.objs        |    2 +-
 target-s390x/cpu-qom.h            |    4 ++
 target-s390x/cpu.c                |  114 ++++++++++++++++++++++++++++---------
 target-s390x/cpu.h                |   41 ++++++++++---
 target-s390x/helper.c             |   19 +++----
 target-s390x/kvm.c                |   58 ++++++++++++++++---
 target-s390x/machine.c            |   76 +++++++++++++++++++++++++
 trace-events                      |    6 ++
 18 files changed, 323 insertions(+), 96 deletions(-)
 create mode 100644 target-s390x/machine.c
Signature · 1 line
1.7.9.5
#1 lore raw

[Qemu-devel] [PULL v2 4/8] s390x/kvm: propagate s390 cpu state to kvm

From: David Hildenbrand <[email protected]>

Let QEMU propagate the cpu state to kvm. If kvm doesn't yet support it, it is silently ignored as kvm will still handle the cpu state itself in that case.

The state is not synced back, thus kvm won't have a chance to actively modify the cpu state. To do so, control has to be given back to QEMU (which is already done so in all relevant cases).

Setting of the cpu state can fail either because kvm doesn't support the interface yet, or because the state is invalid/not supported. Failed attempts will be traced

---
 target-s390x/cpu.c |    3 +++
 target-s390x/cpu.h |    5 +++++
 target-s390x/kvm.c |   43 +++++++++++++++++++++++++++++++++++++++++--
 trace-events       |    1 +
 4 files changed, 50 insertions(+), 2 deletions(-)
target-s390x/cpu.c +3 -0
index dc89eb3..9dbb0df 100644
@@ -288,6 +288,9 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
                      cpu_state);
         exit(1);
     }
+    if (kvm_enabled() && cpu->env.cpu_state != cpu_state) {
+        kvm_s390_set_cpu_state(cpu, cpu_state);
+    }
     cpu->env.cpu_state = cpu_state;
 
     return s390_count_running_cpus();
target-s390x/cpu.h +5 -0
index 7b9300e..6b3aaed 100644
@@ -1072,6 +1072,7 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch,
 int kvm_s390_cpu_restart(S390CPU *cpu);
 int kvm_s390_get_memslot_count(KVMState *s);
 void kvm_s390_clear_cmma_callback(void *opaque);
+int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
 #else
 static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
                                         uint16_t subchannel_nr,
@@ -1102,6 +1103,10 @@ static inline int kvm_s390_get_memslot_count(KVMState *s)
 {
   return MAX_AVAIL_SLOTS;
 }
+static inline int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)
+{
+    return -ENOSYS;
+}
 #endif
 
 static inline void cmma_reset(S390CPU *cpu)
target-s390x/kvm.c +41 -2

53 lines not on this page · raw message

trace-events +1 -0
index 5202f20..5290806 100644
@@ -1369,6 +1369,7 @@ mhp_pc_dimm_assigned_address(uint64_t addr) "0x%"PRIx64
 # target-s390x/kvm.c
 kvm_enable_cmma(int rc) "CMMA: enabling with result code %d"
 kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
+kvm_failed_cpu_state_set(int cpu_index, uint8_t state, const char *msg) "Warning: Unable to set cpu %d state %" PRIu8 " to KVM: %s"
 
 # hw/dma/i8257.c
 i8257_unregistered_dma(int nchan, int dma_pos, int dma_len) "unregistered DMA channel used nchan=%d dma_pos=%d dma_len=%d"
Signature · 1 line
1.7.9.5
#2 lore raw

[Qemu-devel] [PULL v2 2/8] s390x/kvm: introduce proper states for s390 cpus

In reply to Cornelia Huck

From: David Hildenbrand <[email protected]>

Until now, when a s390 cpu was stopped or halted, the number of running CPUs was tracked in a global variable. This was problematic for migration, so Jason came up with a per-cpu running state.
As it turns out, we want to track the full logical state of a target vcpu, so we need real s390 cpu states.

This patch is based on an initial patch by Jason Herne, but was heavily rewritten when adding the cpu states STOPPED and OPERATING. On the way we move add_del_running to cpu.c (the declaration is already in cpu.h) and modify the users where appropriate.

Please note that the cpu is still set to be stopped when it is halted, which is wrong. This will be fixed in the next patch. The LOAD and CHECK-STOP state will not be used in the first step.

[folded Jason's patch into David's patch to avoid add/remove same lines]
CC Andreas Faerber <[email protected]>
---
 hw/s390x/s390-virtio.c |   32 --------------------------------
 target-s390x/cpu.c     |   43 +++++++++++++++++++++++++++++++++++++++++++
 target-s390x/cpu.h     |   14 ++++++++++++++
 3 files changed, 57 insertions(+), 32 deletions(-)
hw/s390x/s390-virtio.c +0 -32
index 9c61246..af0004a 100644
@@ -125,38 +125,6 @@ static void s390_virtio_register_hcalls(void)
                                    s390_virtio_hcall_set_status);
 }
 
-/*
- * The number of running CPUs. On s390 a shutdown is the state of all CPUs
- * being either stopped or disabled (for interrupts) waiting. We have to
- * track this number to call the shutdown sequence accordingly. This
- * number is modified either on startup or while holding the big qemu lock.
- */
-static unsigned s390_running_cpus;
-
-void s390_add_running_cpu(S390CPU *cpu)
-{
-    CPUState *cs = CPU(cpu);
-
-    if (cs->halted) {
-        s390_running_cpus++;
-        cs->halted = 0;
-        cs->exception_index = -1;
-    }
-}
-
-unsigned s390_del_running_cpu(S390CPU *cpu)
-{
-    CPUState *cs = CPU(cpu);
-
-    if (cs->halted == 0) {
-        assert(s390_running_cpus >= 1);
-        s390_running_cpus--;
-        cs->halted = 1;
-        cs->exception_index = EXCP_HLT;
-    }
-    return s390_running_cpus;
-}
-
 void s390_init_ipl_dev(const char *kernel_filename,
                        const char *kernel_cmdline,
                        const char *initrd_filename,
target-s390x/cpu.c +43 -0

49 lines not on this page · raw message

target-s390x/cpu.h +14 -0
index 62940c3..f1a3ad2 100644
@@ -141,6 +141,20 @@ typedef struct CPUS390XState {
     QEMUTimer *tod_timer;
 
     QEMUTimer *cpu_timer;
+
+    /*
+     * The cpu state represents the logical state of a cpu. In contrast to other
+     * architectures, there is a difference between a halt and a stop on s390.
+     * If all cpus are either stopped (including check stop) or in the disabled
+     * wait state, the vm can be shut down.
+     */
+#define CPU_STATE_UNINITIALIZED        0x00
+#define CPU_STATE_STOPPED              0x01
+#define CPU_STATE_CHECK_STOP           0x02
+#define CPU_STATE_OPERATING            0x03
+#define CPU_STATE_LOAD                 0x04
+    uint8_t cpu_state;
+
 } CPUS390XState;
 
 #include "cpu-qom.h"
Signature · 1 line
1.7.9.5
#3 lore raw

[Qemu-devel] [PULL v2 1/8] linux-headers: update to 3.17-rc7

In reply to Cornelia Huck

From: Jens Freimann <[email protected]>

Sync headers with 3.17-rc7

---
 linux-headers/asm-mips/kvm_para.h |    6 +++++-
 linux-headers/asm-powerpc/kvm.h   |    2 ++
 linux-headers/asm-x86/kvm.h       |    3 +++
 linux-headers/linux/kvm.h         |   13 ++++++++++---
 linux-headers/linux/kvm_para.h    |    3 +++
 linux-headers/linux/vfio.h        |   34 ++++++++++++++++++++++++++++++++++
 linux-headers/linux/vhost.h       |    2 +-
 7 files changed, 58 insertions(+), 5 deletions(-)
linux-headers/asm-mips/kvm_para.h +5 -1
index 14fab8f..dbb2464 100644
@@ -1 +1,5 @@
-#include <asm-generic/kvm_para.h>
+#ifndef _ASM_MIPS_KVM_PARA_H
+#define _ASM_MIPS_KVM_PARA_H
+
+
+#endif /* _ASM_MIPS_KVM_PARA_H */
linux-headers/asm-powerpc/kvm.h +2 -0
index 2bc4a94..e0e49db 100644
@@ -548,6 +548,7 @@ struct kvm_get_htab_header {
 
 #define KVM_REG_PPC_VRSAVE	(KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb4)
 #define KVM_REG_PPC_LPCR	(KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb5)
+#define KVM_REG_PPC_LPCR_64	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb5)
 #define KVM_REG_PPC_PPR		(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb6)
 
 /* Architecture compatibility level */
@@ -555,6 +556,7 @@ struct kvm_get_htab_header {
 
 #define KVM_REG_PPC_DABRX	(KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xb8)
 #define KVM_REG_PPC_WORT	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xb9)
+#define KVM_REG_PPC_SPRG9	(KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xba)
 
 /* Transactional Memory checkpointed state:
  * This is all GPRs, all VSX regs and a subset of SPRs
linux-headers/asm-x86/kvm.h +3 -0
index d3a8778..d7dcef5 100644
@@ -23,7 +23,10 @@
 #define GP_VECTOR 13
 #define PF_VECTOR 14
 #define MF_VECTOR 16
+#define AC_VECTOR 17
 #define MC_VECTOR 18
+#define XM_VECTOR 19
+#define VE_VECTOR 20
 
 /* Select x86 specific features in <linux/kvm.h> */
 #define __KVM_HAVE_PIT
linux-headers/linux/kvm.h +10 -3
index f5d2c38..2669938 100644
@@ -162,7 +162,7 @@ struct kvm_pit_config {
 #define KVM_EXIT_TPR_ACCESS       12
 #define KVM_EXIT_S390_SIEIC       13
 #define KVM_EXIT_S390_RESET       14
-#define KVM_EXIT_DCR              15
+#define KVM_EXIT_DCR              15 /* deprecated */
 #define KVM_EXIT_NMI              16
 #define KVM_EXIT_INTERNAL_ERROR   17
 #define KVM_EXIT_OSI              18
@@ -268,7 +268,7 @@ struct kvm_run {
 			__u64 trans_exc_code;
 			__u32 pgm_code;
 		} s390_ucontrol;
-		/* KVM_EXIT_DCR */
+		/* KVM_EXIT_DCR (deprecated) */
 		struct {
 			__u32 dcrn;
 			__u32 data;
@@ -399,13 +399,18 @@ struct kvm_vapic_addr {
 	__u64 vapic_addr;
 };
 
-/* for KVM_SET_MPSTATE */
+/* for KVM_SET_MP_STATE */
 
+/* not all states are valid on all architectures */
 #define KVM_MP_STATE_RUNNABLE          0
 #define KVM_MP_STATE_UNINITIALIZED     1
 #define KVM_MP_STATE_INIT_RECEIVED     2
 #define KVM_MP_STATE_HALTED            3
 #define KVM_MP_STATE_SIPI_RECEIVED     4
+#define KVM_MP_STATE_STOPPED           5
+#define KVM_MP_STATE_CHECK_STOP        6
+#define KVM_MP_STATE_OPERATING         7
+#define KVM_MP_STATE_LOAD              8
 
 struct kvm_mp_state {
 	__u32 mp_state;
@@ -758,6 +763,8 @@ struct kvm_ppc_smmu_info {
 #define KVM_CAP_VM_ATTRIBUTES 101
 #define KVM_CAP_ARM_PSCI_0_2 102
 #define KVM_CAP_PPC_FIXUP_HCALL 103
+#define KVM_CAP_PPC_ENABLE_HCALL 104
+#define KVM_CAP_CHECK_EXTENSION_VM 105
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
linux-headers/linux/kvm_para.h +3 -0
index 2dff783..e61661e 100644
@@ -20,6 +20,9 @@
 #define KVM_HC_FEATURES			3
 #define KVM_HC_PPC_MAP_MAGIC_PAGE	4
 #define KVM_HC_KICK_CPU			5
+#define KVM_HC_MIPS_GET_CLOCK_FREQ	6
+#define KVM_HC_MIPS_EXIT_VM		7
+#define KVM_HC_MIPS_CONSOLE_OUTPUT	8
 
 /*
  * hypercalls use architecture specific
linux-headers/linux/vfio.h +34 -0
index 26c218e..95b591b 100644
@@ -30,6 +30,9 @@
  */
 #define VFIO_DMA_CC_IOMMU		4
 
+/* Check if EEH is supported */
+#define VFIO_EEH			5
+
 /*
  * The IOCTL interface is designed for extensibility by embedding the
  * structure length (argsz) and flags into structures passed between
@@ -455,6 +458,37 @@ struct vfio_iommu_spapr_tce_info {
 
 #define VFIO_IOMMU_SPAPR_TCE_GET_INFO	_IO(VFIO_TYPE, VFIO_BASE + 12)
 
+/*
+ * EEH PE operation struct provides ways to:
+ * - enable/disable EEH functionality;
+ * - unfreeze IO/DMA for frozen PE;
+ * - read PE state;
+ * - reset PE;
+ * - configure PE.
+ */
+struct vfio_eeh_pe_op {
+	__u32 argsz;
+	__u32 flags;
+	__u32 op;
+};
+
+#define VFIO_EEH_PE_DISABLE		0	/* Disable EEH functionality */
+#define VFIO_EEH_PE_ENABLE		1	/* Enable EEH functionality  */
+#define VFIO_EEH_PE_UNFREEZE_IO		2	/* Enable IO for frozen PE   */
+#define VFIO_EEH_PE_UNFREEZE_DMA	3	/* Enable DMA for frozen PE  */
+#define VFIO_EEH_PE_GET_STATE		4	/* PE state retrieval        */
+#define  VFIO_EEH_PE_STATE_NORMAL	0	/* PE in functional state    */
+#define  VFIO_EEH_PE_STATE_RESET	1	/* PE reset in progress      */
+#define  VFIO_EEH_PE_STATE_STOPPED	2	/* Stopped DMA and IO        */
+#define  VFIO_EEH_PE_STATE_STOPPED_DMA	4	/* Stopped DMA only          */
+#define  VFIO_EEH_PE_STATE_UNAVAIL	5	/* State unavailable         */
+#define VFIO_EEH_PE_RESET_DEACTIVATE	5	/* Deassert PE reset         */
+#define VFIO_EEH_PE_RESET_HOT		6	/* Assert hot reset          */
+#define VFIO_EEH_PE_RESET_FUNDAMENTAL	7	/* Assert fundamental reset  */
+#define VFIO_EEH_PE_CONFIGURE		8	/* PE configuration          */
+
+#define VFIO_EEH_PE_OP			_IO(VFIO_TYPE, VFIO_BASE + 21)
+
 /* ***************************************************************** */
 
 #endif /* VFIO_H */
linux-headers/linux/vhost.h +1 -1
index bb5df43..c656f61 100644
@@ -14,7 +14,7 @@
 
 #include <linux/ioctl.h>
 #include <linux/virtio_config.h>
-#include "hw/virtio/virtio_ring.h"
+#include <linux/virtio_ring.h>
 
 struct vhost_vring_state {
 	unsigned int index;
Signature · 1 line
1.7.9.5
#4 lore raw

[Qemu-devel] [PULL v2 3/8] s390x/kvm: proper use of the cpu states OPERATING and STOPPED

In reply to Cornelia Huck

From: David Hildenbrand <[email protected]>

This patch makes sure that halting a cpu and stopping a cpu are two different things. Stopping a cpu will also set the cpu halted - this is needed for common infrastructure to work (note that the stop and stopped flag cannot be used for our purpose because they are already used by other mechanisms).

A cpu can be halted ("waiting") when it is operating. If interrupts are disabled, this is called a "disabled wait", as it can't be woken up anymore. A stopped cpu is treated like a "disabled wait" cpu, but in order to prepare for a proper cpu state synchronization with the kvm part, we need to track the real logical state of a cpu.

---
 hw/s390x/ipl.c        |    2 +-
 target-s390x/cpu.c    |   78 +++++++++++++++++++++++++++++++------------------
 target-s390x/cpu.h    |   14 ++++++---
 target-s390x/helper.c |   19 +++++-------
 target-s390x/kvm.c    |   11 +++----
 trace-events          |    5 ++++
 6 files changed, 79 insertions(+), 50 deletions(-)
hw/s390x/ipl.c +1 -1
index 4fa9cff..3b77c9a 100644
@@ -176,7 +176,7 @@ static void s390_ipl_reset(DeviceState *dev)
         }
     }
 
-    s390_add_running_cpu(cpu);
+    s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
 }
 
 static void s390_ipl_class_init(ObjectClass *klass, void *data)
target-s390x/cpu.c +50 -28

146 lines not on this page · raw message

target-s390x/cpu.h +10 -4
index f1a3ad2..7b9300e 100644
@@ -407,8 +407,9 @@ static inline void kvm_s390_service_interrupt(uint32_t parm)
 }
 #endif
 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr);
-void s390_add_running_cpu(S390CPU *cpu);
-unsigned s390_del_running_cpu(S390CPU *cpu);
+unsigned int s390_cpu_halt(S390CPU *cpu);
+void s390_cpu_unhalt(S390CPU *cpu);
+unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu);
 
 /* service interrupts are floating therefore we must not pass an cpustate */
 void s390_sclp_extint(uint32_t parm);
@@ -417,11 +418,16 @@ void s390_sclp_extint(uint32_t parm);
 extern const hwaddr virtio_size;
 
 #else
-static inline void s390_add_running_cpu(S390CPU *cpu)
+static inline unsigned int s390_cpu_halt(S390CPU *cpu)
+{
+    return 0;
+}
+
+static inline void s390_cpu_unhalt(S390CPU *cpu)
 {
 }
 
-static inline unsigned s390_del_running_cpu(S390CPU *cpu)
+static inline unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
 {
     return 0;
 }
target-s390x/helper.c +7 -12
index e21afe6..09aec7b 100644
@@ -504,23 +504,18 @@ hwaddr s390_cpu_get_phys_addr_debug(CPUState *cs, vaddr vaddr)
 
 void load_psw(CPUS390XState *env, uint64_t mask, uint64_t addr)
 {
+    env->psw.addr = addr;
+    env->psw.mask = mask;
+    env->cc_op = (mask >> 44) & 3;
+
     if (mask & PSW_MASK_WAIT) {
         S390CPU *cpu = s390_env_get_cpu(env);
-        CPUState *cs = CPU(cpu);
-        if (!(mask & (PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK))) {
-            if (s390_del_running_cpu(cpu) == 0) {
+        if (s390_cpu_halt(cpu) == 0) {
 #ifndef CONFIG_USER_ONLY
-                qemu_system_shutdown_request();
+            qemu_system_shutdown_request();
 #endif
-            }
         }
-        cs->halted = 1;
-        cs->exception_index = EXCP_HLT;
     }
-
-    env->psw.addr = addr;
-    env->psw.mask = mask;
-    env->cc_op = (mask >> 44) & 3;
 }
 
 static uint64_t get_psw_mask(CPUS390XState *env)
@@ -818,7 +813,7 @@ void s390_cpu_do_interrupt(CPUState *cs)
     qemu_log_mask(CPU_LOG_INT, "%s: %d at pc=%" PRIx64 "\n",
                   __func__, cs->exception_index, env->psw.addr);
 
-    s390_add_running_cpu(cpu);
+    s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
     /* handle machine checks */
     if ((env->psw.mask & PSW_MASK_MCHECK) &&
         (cs->exception_index == -1)) {
target-s390x/kvm.c +6 -5
index a85a480..415baea 100644
@@ -921,7 +921,7 @@ static void sigp_cpu_start(void *arg)
     CPUState *cs = arg;
     S390CPU *cpu = S390_CPU(cs);
 
-    s390_add_running_cpu(cpu);
+    s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
     DPRINTF("DONE: KVM cpu start: %p\n", &cpu->env);
 }
 
@@ -934,7 +934,7 @@ static void sigp_cpu_restart(void *arg)
     };
 
     kvm_s390_vcpu_interrupt(cpu, &irq);
-    s390_add_running_cpu(cpu);
+    s390_cpu_set_state(CPU_STATE_OPERATING, cpu);
 }
 
 int kvm_s390_cpu_restart(S390CPU *cpu)
@@ -1074,7 +1074,7 @@ static void unmanageable_intercept(S390CPU *cpu, const char *str, int pswoffset)
     error_report("Unmanageable %s! CPU%i new PSW: 0x%016lx:%016lx",
                  str, cs->cpu_index, ldq_phys(cs->as, cpu->env.psa + pswoffset),
                  ldq_phys(cs->as, cpu->env.psa + pswoffset + 8));
-    s390_del_running_cpu(cpu);
+    s390_cpu_halt(cpu);
     guest_panicked();
 }
 
@@ -1103,7 +1103,8 @@ static int handle_intercept(S390CPU *cpu)
             break;
         case ICPT_WAITPSW:
             /* disabled wait, since enabled wait is handled in kernel */
-            if (s390_del_running_cpu(cpu) == 0) {
+            cpu_synchronize_state(cs);
+            if (s390_cpu_halt(cpu) == 0) {
                 if (is_special_wait_psw(cs)) {
                     qemu_system_shutdown_request();
                 } else {
@@ -1113,7 +1114,7 @@ static int handle_intercept(S390CPU *cpu)
             r = EXCP_HALTED;
             break;
         case ICPT_CPU_STOP:
-            if (s390_del_running_cpu(cpu) == 0) {
+            if (s390_cpu_set_state(CPU_STATE_STOPPED, cpu) == 0) {
                 qemu_system_shutdown_request();
             }
             r = EXCP_HALTED;
trace-events +5 -0
index 011d105..5202f20 100644
@@ -1372,3 +1372,8 @@ kvm_clear_cmma(int rc) "CMMA: clearing with result code %d"
 
 # hw/dma/i8257.c
 i8257_unregistered_dma(int nchan, int dma_pos, int dma_len) "unregistered DMA channel used nchan=%d dma_pos=%d dma_len=%d"
+
+# target-s390x/cpu.c
+cpu_set_state(int cpu_index, uint8_t state) "setting cpu %d state to %" PRIu8
+cpu_halt(int cpu_index) "halting cpu %d"
+cpu_unhalt(int cpu_index) "unhalting cpu %d"
Signature · 1 line
1.7.9.5
#5 lore raw

[Qemu-devel] [PULL v2 6/8] s390x/kvm: synchronize the cpu state after SIGP (INITIAL) CPU RESET

In reply to Cornelia Huck

From: David Hildenbrand <[email protected]>

We need to synchronize registers after a reset has been performed. The current code does that in qemu_system_reset(), load_normal_reset() and modified_clear_reset() for all vcpus. After SIGP (INITIAL) CPU RESET, this needs to be done for the targeted vcpu as well, so let's call cpu_synchronize_post_reset() in the respective handlers.

---
 target-s390x/kvm.c |    2 ++
 1 file changed, 2 insertions(+)
target-s390x/kvm.c +2 -0
index e4c4c8d..5b10a25 100644
@@ -952,6 +952,7 @@ static void sigp_initial_cpu_reset(void *arg)
 
     cpu_synchronize_state(cpu);
     scc->initial_cpu_reset(cpu);
+    cpu_synchronize_post_reset(cpu);
 }
 
 static void sigp_cpu_reset(void *arg)
@@ -961,6 +962,7 @@ static void sigp_cpu_reset(void *arg)
 
     cpu_synchronize_state(cpu);
     scc->cpu_reset(cpu);
+    cpu_synchronize_post_reset(cpu);
 }
 
 #define SIGP_ORDER_MASK 0x000000ff
Signature · 1 line
1.7.9.5
#6 lore raw

[Qemu-devel] [PULL v2 5/8] s390x/kvm: reuse kvm_s390_reset_vcpu() to get rid of ifdefs

In reply to Cornelia Huck

From: David Hildenbrand <[email protected]>

This patch reuses kvm_s390_reset_vcpu() to get rid of some CONFIG_KVM and CONFIG_USER_ONLY ifdefs in cpu.c.

In order to get rid of CONFIG_USER_ONLY, kvm_s390_reset_vcpu() has to provide a dummy implementation - the two definitions are moved to the proper section in cpu.h.

---
 target-s390x/cpu.c |    9 ++-------
 target-s390x/cpu.h |    8 ++++----
 target-s390x/kvm.c |    2 +-
 3 files changed, 7 insertions(+), 12 deletions(-)
target-s390x/cpu.c +2 -7
index 9dbb0df..ec7df90 100644
@@ -117,14 +117,10 @@ static void s390_cpu_initial_reset(CPUState *s)
 
     env->pfault_token = -1UL;
 
-#if defined(CONFIG_KVM)
     /* Reset state inside the kernel that we cannot access yet from QEMU. */
     if (kvm_enabled()) {
-        if (kvm_vcpu_ioctl(s, KVM_S390_INITIAL_RESET, NULL)) {
-            perror("Initial CPU reset failed");
-        }
+        kvm_s390_reset_vcpu(cpu);
     }
-#endif
 }
 
 /* CPUClass:reset() */
@@ -145,11 +141,10 @@ static void s390_cpu_full_reset(CPUState *s)
 
     env->pfault_token = -1UL;
 
-#if !defined(CONFIG_USER_ONLY)
+    /* Reset state inside the kernel that we cannot access yet from QEMU. */
     if (kvm_enabled()) {
         kvm_s390_reset_vcpu(cpu);
     }
-#endif
     tlb_flush(s, 1);
 }
 
target-s390x/cpu.h +4 -4
index 6b3aaed..fe2f95d 100644
@@ -389,16 +389,12 @@ int s390_virtio_hypercall(CPUS390XState *env);
 void s390_virtio_irq(int config_change, uint64_t token);
 
 #ifdef CONFIG_KVM
-void kvm_s390_reset_vcpu(S390CPU *cpu);
 void kvm_s390_virtio_irq(int config_change, uint64_t token);
 void kvm_s390_service_interrupt(uint32_t parm);
 void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq);
 void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq);
 int kvm_s390_inject_flic(struct kvm_s390_irq *irq);
 #else
-static inline void kvm_s390_reset_vcpu(S390CPU *cpu)
-{
-}
 static inline void kvm_s390_virtio_irq(int config_change, uint64_t token)
 {
 }
@@ -1073,6 +1069,7 @@ int kvm_s390_cpu_restart(S390CPU *cpu);
 int kvm_s390_get_memslot_count(KVMState *s);
 void kvm_s390_clear_cmma_callback(void *opaque);
 int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
+void kvm_s390_reset_vcpu(S390CPU *cpu);
 #else
 static inline void kvm_s390_io_interrupt(uint16_t subchannel_id,
                                         uint16_t subchannel_nr,
@@ -1107,6 +1104,9 @@ static inline int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)
 {
     return -ENOSYS;
 }
+static inline void kvm_s390_reset_vcpu(S390CPU *cpu)
+{
+}
 #endif
 
 static inline void cmma_reset(S390CPU *cpu)
target-s390x/kvm.c +1 -1
index 7c90b18..e4c4c8d 100644
@@ -198,7 +198,7 @@ void kvm_s390_reset_vcpu(S390CPU *cpu)
      * Before this ioctl cpu_synchronize_state() is called in common kvm
      * code (kvm-all) */
     if (kvm_vcpu_ioctl(cs, KVM_S390_INITIAL_RESET, NULL)) {
-        perror("Can't reset vcpu\n");
+        error_report("Initial CPU reset failed on CPU %i\n", cs->cpu_index);
     }
 }
 
Signature · 1 line
1.7.9.5
#7 lore raw

[Qemu-devel] [PULL v2 7/8] s390x/migration: migrate CPU state

In reply to Cornelia Huck

From: Thomas Huth <[email protected]>

This patch provides the cpu save information for dumps and later life migration and enables migration of the CPU state. The code is based on earlier work from Christian Borntraeger and Jason Herne.

[provide cpu_post_load()]
CC Andreas Faerber <[email protected]>
CC Christian Borntraeger <[email protected]>
CC Jason J. Herne <[email protected]>
[Cornelia Huck: tweaked cpu_post_load() comment]
---
 target-s390x/Makefile.objs |    2 +-
 target-s390x/cpu-qom.h     |    4 +++
 target-s390x/cpu.c         |    7 +---
 target-s390x/machine.c     |   76 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 7 deletions(-)
 create mode 100644 target-s390x/machine.c
target-s390x/Makefile.objs +1 -1
index f873146..2c57494 100644
@@ -1,5 +1,5 @@
 obj-y += translate.o helper.o cpu.o interrupt.o
 obj-y += int_helper.o fpu_helper.o cc_helper.o mem_helper.o misc_helper.o
 obj-y += gdbstub.o
-obj-$(CONFIG_SOFTMMU) += ioinst.o arch_dump.o
+obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o
 obj-$(CONFIG_KVM) += kvm.o
target-s390x/cpu-qom.h +4 -0
index 4f7d4cb..8b376df 100644
@@ -77,6 +77,10 @@ static inline S390CPU *s390_env_get_cpu(CPUS390XState *env)
 
 #define ENV_OFFSET offsetof(S390CPU, env)
 
+#ifndef CONFIG_USER_ONLY
+extern const struct VMStateDescription vmstate_s390_cpu;
+#endif
+
 void s390_cpu_do_interrupt(CPUState *cpu);
 bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void s390_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
target-s390x/cpu.c +1 -6
index ec7df90..d2f6312 100644
@@ -292,11 +292,6 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
 }
 #endif
 
-static const VMStateDescription vmstate_s390_cpu = {
-    .name = "cpu",
-    .unmigratable = 1,
-};
-
 static void s390_cpu_class_init(ObjectClass *oc, void *data)
 {
     S390CPUClass *scc = S390_CPU_CLASS(oc);
@@ -323,11 +318,11 @@ static void s390_cpu_class_init(ObjectClass *oc, void *data)
     cc->handle_mmu_fault = s390_cpu_handle_mmu_fault;
 #else
     cc->get_phys_page_debug = s390_cpu_get_phys_page_debug;
+    cc->vmsd = &vmstate_s390_cpu;
     cc->write_elf64_note = s390_cpu_write_elf64_note;
     cc->write_elf64_qemunote = s390_cpu_write_elf64_qemunote;
     cc->cpu_exec_interrupt = s390_cpu_exec_interrupt;
 #endif
-    dc->vmsd = &vmstate_s390_cpu;
     cc->gdb_num_core_regs = S390_NUM_CORE_REGS;
     cc->gdb_core_xml_file = "s390x-core64.xml";
 }
target-s390x/machine.c new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#8 lore raw

[Qemu-devel] [PULL v2 8/8] s390x/virtio-ccw: fix vhost-scsi intialization

In reply to Cornelia Huck

The vhost-scsi-ccw backend is of type VHostSCSICcw, not VirtIOSCSICcw.

This fixes a segfault when invoking

    qemu-system-s390x -device vhost-scsi-ccw,?
---
 hw/s390x/virtio-ccw.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/virtio-ccw.c +1 -1
index e7d3ea1..18ba29f 100644
@@ -1528,7 +1528,7 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)
 static const TypeInfo vhost_ccw_scsi = {
     .name          = TYPE_VHOST_SCSI_CCW,
     .parent        = TYPE_VIRTIO_CCW_DEVICE,
-    .instance_size = sizeof(VirtIOSCSICcw),
+    .instance_size = sizeof(VHostSCSICcw),
     .instance_init = vhost_ccw_scsi_instance_init,
     .class_init    = vhost_ccw_scsi_class_init,
 };
Signature · 1 line
1.7.9.5
#9 lore raw
In reply to Cornelia Huck
Quoted 16 lines · Cornelia Huck

Updates v1->v2:
- rebased against master
- "s390x/migration: migrate CPU state": move vmstate code into target-s390x/machine.c and tweak comment

The following changes since commit fcb2cd928f5519b8241e22411a696be1a7272b1c:

Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2014-10-09 15:09:05 +0100)

are available in the git repository at:

git://github.com/cohuck/qemu.git tags/s390x-20141010

for you to fetch changes up to 4b7757bae7c94f980969031119db12d540cf2b61:

Quoted 8 lines

s390x/virtio-ccw: fix vhost-scsi intialization (2014-10-10 13:32:39 +0200)

----------------------------------------------------------------
various s390x updates:
- cpu state handling in qemu and migration
- vhost-scsi-ccw bugfix

----------------------------------------------------------------

Applied, thanks.

Something I've realised recently would be useful is if v2 respins of a pullrequest could include the fact that it's a v2 in either the tag commit message or in the tagname itself it would be easier for me to reassure myself that the merge I'm about to push to master is indeed the most recent respin (since it will then appear in the merge commit message). Not critically important, but it would be nice.

-- PMM