Skip to contentSkip to conversation

add support for VCPU event states

RFC PATCH Applied Dongjiu Geng 3 participants 11 messages Sep 27, 2018 – Oct 18, 2018 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

v11 cover add support for VCPU event states

Support KVM_GET/SET_VCPU_EVENTS to get/set the SError exception state, and support the state migration.

Now the VCPU event only includes the SError exception status, it can be extended if needed. When do migration, If source machine has serror pending, the target machine is also needed to pend this serror regardless of whether target machine can support to set the serror syndrome.

Note: Because I do not have arm32 environment, I only this patch in the KVM64, not test it in the KVM32. So I need someone else test it in the 32 bit KVM platform. Thanks.

Dongjiu Geng (2):
linux-headers: Update to linux kernel 4.19-rc5
target/arm: Add support for VCPU event states

 include/standard-headers/linux/input.h |  9 ++---
 linux-headers/asm-arm/kvm.h            | 13 ++++++++
 linux-headers/asm-arm64/kvm.h          | 13 ++++++++
 linux-headers/asm-x86/kvm.h            |  1 +
 linux-headers/linux/kvm.h              |  2 ++
 linux-headers/linux/vhost.h            |  2 +-
 target/arm/cpu.h                       |  7 ++++
 target/arm/kvm.c                       | 60 ++++++++++++++++++++++++++++++++++
 target/arm/kvm32.c                     | 13 ++++++++
 target/arm/kvm64.c                     | 13 ++++++++
 target/arm/kvm_arm.h                   | 24 ++++++++++++++
 target/arm/machine.c                   | 22 +++++++++++++
 12 files changed, 174 insertions(+), 5 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

RFC PATCH v11 1/2 linux-headers: Update to linux kernel 4.19-rc5

Update our kernel headers to upstream 4.19-rc5
(kernel commit 6bf4ca7fbc85d80446ac0)

---
 include/standard-headers/linux/input.h |  9 +++++----
 linux-headers/asm-arm/kvm.h            | 13 +++++++++++++
 linux-headers/asm-arm64/kvm.h          | 13 +++++++++++++
 linux-headers/asm-x86/kvm.h            |  1 +
 linux-headers/linux/kvm.h              |  2 ++
 linux-headers/linux/vhost.h            |  2 +-
 6 files changed, 35 insertions(+), 5 deletions(-)
include/standard-headers/linux/input.h +5 -4
index 6d6128c..c0ad9fc 100644
@@ -267,10 +267,11 @@ struct input_mask {
 /*
  * MT_TOOL types
  */
-#define MT_TOOL_FINGER		0
-#define MT_TOOL_PEN		1
-#define MT_TOOL_PALM		2
-#define MT_TOOL_MAX		2
+#define MT_TOOL_FINGER		0x00
+#define MT_TOOL_PEN		0x01
+#define MT_TOOL_PALM		0x02
+#define MT_TOOL_DIAL		0x0a
+#define MT_TOOL_MAX		0x0f
 
 /*
  * Values describing the status of a force-feedback effect
linux-headers/asm-arm/kvm.h +13 -0
index 72aa226..e1f8b74 100644
@@ -27,6 +27,7 @@
 #define __KVM_HAVE_GUEST_DEBUG
 #define __KVM_HAVE_IRQ_LINE
 #define __KVM_HAVE_READONLY_MEM
+#define __KVM_HAVE_VCPU_EVENTS
 
 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
 
@@ -125,6 +126,18 @@ struct kvm_sync_regs {
 struct kvm_arch_memory_slot {
 };
 
+/* for KVM_GET/SET_VCPU_EVENTS */
+struct kvm_vcpu_events {
+	struct {
+		__u8 serror_pending;
+		__u8 serror_has_esr;
+		/* Align it to 8 bytes */
+		__u8 pad[6];
+		__u64 serror_esr;
+	} exception;
+	__u32 reserved[12];
+};
+
 /* If you need to interpret the index values, here is the key: */
 #define KVM_REG_ARM_COPROC_MASK		0x000000000FFF0000
 #define KVM_REG_ARM_COPROC_SHIFT	16
linux-headers/asm-arm64/kvm.h +13 -0
index 99cb9ad..e6a98c1 100644
@@ -39,6 +39,7 @@
 #define __KVM_HAVE_GUEST_DEBUG
 #define __KVM_HAVE_IRQ_LINE
 #define __KVM_HAVE_READONLY_MEM
+#define __KVM_HAVE_VCPU_EVENTS
 
 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
 
@@ -154,6 +155,18 @@ struct kvm_sync_regs {
 struct kvm_arch_memory_slot {
 };
 
+/* for KVM_GET/SET_VCPU_EVENTS */
+struct kvm_vcpu_events {
+	struct {
+		__u8 serror_pending;
+		__u8 serror_has_esr;
+		/* Align it to 8 bytes */
+		__u8 pad[6];
+		__u64 serror_esr;
+	} exception;
+	__u32 reserved[12];
+};
+
 /* If you need to interpret the index values, here is the key: */
 #define KVM_REG_ARM_COPROC_MASK		0x000000000FFF0000
 #define KVM_REG_ARM_COPROC_SHIFT	16
linux-headers/asm-x86/kvm.h +1 -0
index 86299ef..fd23d57 100644
@@ -377,6 +377,7 @@ struct kvm_sync_regs {
 
 #define KVM_X86_QUIRK_LINT0_REENABLED	(1 << 0)
 #define KVM_X86_QUIRK_CD_NW_CLEARED	(1 << 1)
+#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE	(1 << 2)
 
 #define KVM_STATE_NESTED_GUEST_MODE	0x00000001
 #define KVM_STATE_NESTED_RUN_PENDING	0x00000002
linux-headers/linux/kvm.h +2 -0
index 6679072..83ba4eb 100644
@@ -951,6 +951,8 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_HYPERV_TLBFLUSH 155
 #define KVM_CAP_S390_HPAGE_1M 156
 #define KVM_CAP_NESTED_STATE 157
+#define KVM_CAP_ARM_INJECT_SERROR_ESR 158
+#define KVM_CAP_MSR_PLATFORM_INFO 159
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
linux-headers/linux/vhost.h +1 -1
index 94726cb..c8a8fbe 100644
@@ -176,7 +176,7 @@ struct vhost_memory {
 #define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1
 
 #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64)
-#define VHOST_GET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x26, __u64)
+#define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64)
 
 /* VHOST_NET specific defines */
 
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH RFC v11 1/2] linux-headers: Update to linux kernel 4.19-rc5

Quoted 4 lines · Dongjiu Geng

Update our kernel headers to upstream 4.19-rc5
(kernel commit 6bf4ca7fbc85d80446ac0)

Quoted 8 lines
---
 include/standard-headers/linux/input.h |  9 +++++----
 linux-headers/asm-arm/kvm.h            | 13 +++++++++++++
 linux-headers/asm-arm64/kvm.h          | 13 +++++++++++++
 linux-headers/asm-x86/kvm.h            |  1 +
 linux-headers/linux/kvm.h              |  2 ++
 linux-headers/linux/vhost.h            |  2 +-
 6 files changed, 35 insertions(+), 5 deletions(-)

It looks like a kernel header sync has hit master since this series was posted, so this patch isn't required any more.

thanks
-- PMM

#3 lore raw

RFC PATCH v11 2/2 target/arm: Add support for VCPU event states

In reply to Dongjiu Geng

This patch extends the qemu-kvm state sync logic with support for KVM_GET/SET_VCPU_EVENTS, giving access to yet missing SError exception. And also it can support the exception state migration.

The SError exception states include SError pending state and ESR value, the kvm_put/get_vcpu_events() will be called when set or get system registers. When do migration, if source machine has SError pending, QEMU will do this migration regardless whether the target machine supports to specify guest ESR value, because if target machine does not support that, it can also inject the SError with zero ESR value.

---
Because I do not have arm32 platform, only have arm64 platform, so I only test this patch in arm64, if somebody else can test this patch, I will very appreciate that.

How to test this patch:
1. Apply this patch to enable 32 bit KVM vcpu events support:
https://patchwork.kernel.org/patch/10612479/
2. Source machine is pending a SError, that is 'events.exception.serror_pending = 1', then do migration, to see whether target machine will be also pending this SError.

Change since V10:
Address Andrew's comments:
1. Put kvm_get/put_vcpu_events() into target/arm/kvm.c

Change since V9:
address Andrew's comments:
1. Remove the '= {}' in kvm_put_vcpu_events()
2. Remove a blank line in kvm_get_vcpu_events()
3. Add 32 bit KVM supports

Change since v8:
1. Update the commit message

Change since v7:
address shannon's comments:
1. Change "pending" and "has_esr" from uint32_t to uint8_t for CPUARMState
2. Add error_report() in kvm_get_vcpu_events()

Change since v6:
address Peter's comments:
1. Add cover letter
2. Change name "cpu/ras" to "cpu/serror"
3. Add some comments and check the ioctl return value for kvm_put_vcpu_events()

Change since v5:
address Peter's comments:
1. Move the "struct serror" before the "end_reset_fields" in CPUARMState
2. Remove ARM_FEATURE_RAS_EXT and add a variable have_inject_serror_esr
3. Use the variable have_inject_serror_esr to track whether the kernel has state we need to migrate
4. Remove printf() in kvm_arch_put_registers()
5. ras_needed/vmstate_ras to serror_needed/vmstate_serror
6. Check to use "return env.serror.pending != 0" instead of "arm_feature(env, ARM_FEATURE_RAS_EXT)" in the ras_needed()

Change since v4:
1. Rebase the code to latest

---
 target/arm/cpu.h     |  7 ++++++
 target/arm/kvm.c     | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 target/arm/kvm32.c   | 13 ++++++++++++
 target/arm/kvm64.c   | 13 ++++++++++++
 target/arm/kvm_arm.h | 24 +++++++++++++++++++++
 target/arm/machine.c | 22 +++++++++++++++++++
 6 files changed, 139 insertions(+)
target/arm/cpu.h +7 -0
index 65c0fa0..a8454f5 100644
@@ -530,6 +530,13 @@ typedef struct CPUARMState {
          */
     } exception;
 
+    /* Information associated with an SError */
+    struct {
+        uint8_t pending;
+        uint8_t has_esr;
+        uint64_t esr;
+    } serror;
+
     /* Thumb-2 EE state.  */
     uint32_t teecr;
     uint32_t teehbr;
target/arm/kvm.c +60 -0

78 lines not on this page · raw message

target/arm/kvm32.c +13 -0
index 4e91c11..0f1e94c 100644
@@ -217,6 +217,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
     }
     cpu->mp_affinity = mpidr & ARM32_AFFINITY_MASK;
 
+    /* Check whether userspace can specify guest syndrome value */
+    kvm_arm_init_serror_injection(cs);
+
     return kvm_arm_init_cpreg_list(cpu);
 }
 
@@ -358,6 +361,11 @@ int kvm_arch_put_registers(CPUState *cs, int level)
         return ret;
     }
 
+    ret = kvm_put_vcpu_events(cpu);
+    if (ret) {
+        return ret;
+    }
+
     /* Note that we do not call write_cpustate_to_list()
      * here, so we are only writing the tuple list back to
      * KVM. This is safe because nothing can change the
@@ -445,6 +453,11 @@ int kvm_arch_get_registers(CPUState *cs)
     }
     vfp_set_fpscr(env, fpscr);
 
+    ret = kvm_get_vcpu_events(cpu);
+    if (ret) {
+        return ret;
+    }
+
     if (!write_kvmstate_to_list(cpu)) {
         return EINVAL;
     }
target/arm/kvm64.c +13 -0
index e0b8246..5411486 100644
@@ -546,6 +546,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
 
     kvm_arm_init_debug(cs);
 
+    /* Check whether user space can specify guest syndrome value */
+    kvm_arm_init_serror_injection(cs);
+
     return kvm_arm_init_cpreg_list(cpu);
 }
 
@@ -727,6 +730,11 @@ int kvm_arch_put_registers(CPUState *cs, int level)
         return ret;
     }
 
+    ret = kvm_put_vcpu_events(cpu);
+    if (ret) {
+        return ret;
+    }
+
     if (!write_list_to_kvmstate(cpu, level)) {
         return EINVAL;
     }
@@ -863,6 +871,11 @@ int kvm_arch_get_registers(CPUState *cs)
     }
     vfp_set_fpcr(env, fpr);
 
+    ret = kvm_get_vcpu_events(cpu);
+    if (ret) {
+        return ret;
+    }
+
     if (!write_kvmstate_to_list(cpu)) {
         return EINVAL;
     }
target/arm/kvm_arm.h +24 -0
index 863f205..b9335fa 100644
@@ -121,6 +121,30 @@ bool write_kvmstate_to_list(ARMCPU *cpu);
  */
 void kvm_arm_reset_vcpu(ARMCPU *cpu);
 
+/**
+ * kvm_arm_init_serror_injection:
+ * @cs: CPUState
+ *
+ * Check whether KVM can set guest SError syndrome.
+ */
+void kvm_arm_init_serror_injection(CPUState *cs);
+
+/**
+ * kvm_get_vcpu_events:
+ * @cpu: ARMCPU
+ *
+ * Get VCPU related state from kvm.
+ */
+int kvm_get_vcpu_events(ARMCPU *cpu);
+
+/**
+ * kvm_put_vcpu_events:
+ * @cpu: ARMCPU
+ *
+ * Put VCPU related state to kvm.
+ */
+int kvm_put_vcpu_events(ARMCPU *cpu);
+
 #ifdef CONFIG_KVM
 /**
  * kvm_arm_create_scratch_host_vcpu:
target/arm/machine.c +22 -0
index ff4ec22..32bcde0 100644
@@ -172,6 +172,27 @@ static const VMStateDescription vmstate_sve = {
 };
 #endif /* AARCH64 */
 
+static bool serror_needed(void *opaque)
+{
+    ARMCPU *cpu = opaque;
+    CPUARMState *env = &cpu->env;
+
+    return env->serror.pending != 0;
+}
+
+static const VMStateDescription vmstate_serror = {
+    .name = "cpu/serror",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = serror_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8(env.serror.pending, ARMCPU),
+        VMSTATE_UINT8(env.serror.has_esr, ARMCPU),
+        VMSTATE_UINT64(env.serror.esr, ARMCPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static bool m_needed(void *opaque)
 {
     ARMCPU *cpu = opaque;
@@ -726,6 +747,7 @@ const VMStateDescription vmstate_arm_cpu = {
 #ifdef TARGET_AARCH64
         &vmstate_sve,
 #endif
+        &vmstate_serror,
         NULL
     }
 };
Signature · 1 line
2.7.4
Reviewed-by on v11 2/2
#4 lore raw

Re: [Qemu-arm] [Qemu-devel] [PATCH RFC v11 2/2] target/arm: Add support for VCPU event states

Quoted 325 lines · Dongjiu Geng

This patch extends the qemu-kvm state sync logic with support for KVM_GET/SET_VCPU_EVENTS, giving access to yet missing SError exception. And also it can support the exception state migration.

The SError exception states include SError pending state and ESR value, the kvm_put/get_vcpu_events() will be called when set or get system registers. When do migration, if source machine has SError pending, QEMU will do this migration regardless whether the target machine supports to specify guest ESR value, because if target machine does not support that, it can also inject the SError with zero ESR value.

---
Because I do not have arm32 platform, only have arm64 platform, so I only test this patch in arm64, if somebody else can test this patch, I will very appreciate that.

How to test this patch:
1. Apply this patch to enable 32 bit KVM vcpu events support:

   https://patchwork.kernel.org/patch/10612479/

2. Source machine is pending a SError, that is 'events.exception.serror_pending = 1', then do migration, to see whether target machine will be also pending this SError.

Change since V10:
Address Andrew's comments:
1. Put kvm_get/put_vcpu_events() into target/arm/kvm.c

Change since V9:
address Andrew's comments:
1. Remove the '= {}' in kvm_put_vcpu_events()
2. Remove a blank line in kvm_get_vcpu_events()
3. Add 32 bit KVM supports

Change since v8:
1. Update the commit message

Change since v7:
address shannon's comments:
1. Change "pending" and "has_esr" from uint32_t to uint8_t for CPUARMState
2. Add error_report() in kvm_get_vcpu_events()

Change since v6:
address Peter's comments:
1. Add cover letter
2. Change name "cpu/ras" to "cpu/serror"
3. Add some comments and check the ioctl return value for kvm_put_vcpu_events()

Change since v5:
address Peter's comments:
1. Move the "struct serror" before the "end_reset_fields" in CPUARMState
2. Remove ARM_FEATURE_RAS_EXT and add a variable have_inject_serror_esr
3. Use the variable have_inject_serror_esr to track whether the kernel has state we need to migrate
4. Remove printf() in kvm_arch_put_registers()
5. ras_needed/vmstate_ras to serror_needed/vmstate_serror
6. Check to use "return env.serror.pending != 0" instead of "arm_feature(env, ARM_FEATURE_RAS_EXT)" in the ras_needed()

Change since v4:
1. Rebase the code to latest

---
 target/arm/cpu.h     |  7 ++++++
 target/arm/kvm.c     | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 target/arm/kvm32.c   | 13 ++++++++++++
 target/arm/kvm64.c   | 13 ++++++++++++
 target/arm/kvm_arm.h | 24 +++++++++++++++++++++
 target/arm/machine.c | 22 +++++++++++++++++++
 6 files changed, 139 insertions(+)
target/arm/cpu.h +7 -0
index 65c0fa0..a8454f5 100644
@@ -530,6 +530,13 @@ typedef struct CPUARMState {
          */
     } exception;
 
+    /* Information associated with an SError */
+    struct {
+        uint8_t pending;
+        uint8_t has_esr;
+        uint64_t esr;
+    } serror;
+
     /* Thumb-2 EE state.  */
     uint32_t teecr;
     uint32_t teehbr;
target/arm/kvm.c +60 -0
index 65f867d..c45eb91 100644
@@ -34,6 +34,7 @@ const KVMCapabilityInfo kvm_arch_required_capabilities[] = {
 };
 
 static bool cap_has_mp_state;
+static bool cap_has_inject_serror_esr;
 
 static ARMHostCPUFeatures arm_host_cpu_features;
 
@@ -48,6 +49,12 @@ int kvm_arm_vcpu_init(CPUState *cs)
     return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init);
 }
 
+void kvm_arm_init_serror_injection(CPUState *cs)
+{
+    cap_has_inject_serror_esr = kvm_check_extension(cs->kvm_state,
+                                    KVM_CAP_ARM_INJECT_SERROR_ESR);
+}
+
 bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,
                                       int *fdarray,
                                       struct kvm_vcpu_init *init)
@@ -522,6 +529,59 @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu)
     return 0;
 }
 
+int kvm_put_vcpu_events(ARMCPU *cpu)
+{
+    CPUARMState *env = &cpu->env;
+    struct kvm_vcpu_events events;
+    int ret;
+
+    if (!kvm_has_vcpu_events()) {
+        return 0;
+    }
+
+    memset(&events, 0, sizeof(events));
+    events.exception.serror_pending = env->serror.pending;
+
+    /* Inject SError to guest with specified syndrome if host kernel
+     * supports it, otherwise inject SError without syndrome.
+     */
+    if (cap_has_inject_serror_esr) {
+        events.exception.serror_has_esr = env->serror.has_esr;
+        events.exception.serror_esr = env->serror.esr;
+    }
+
+    ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_VCPU_EVENTS, &events);
+    if (ret) {
+        error_report("failed to put vcpu events");
+    }
+
+    return ret;
+}
+
+int kvm_get_vcpu_events(ARMCPU *cpu)
+{
+    CPUARMState *env = &cpu->env;
+    struct kvm_vcpu_events events;
+    int ret;
+
+    if (!kvm_has_vcpu_events()) {
+        return 0;
+    }
+
+    memset(&events, 0, sizeof(events));
+    ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_VCPU_EVENTS, &events);
+    if (ret) {
+        error_report("failed to get vcpu events");
+        return ret;
+    }
+
+    env->serror.pending = events.exception.serror_pending;
+    env->serror.has_esr = events.exception.serror_has_esr;
+    env->serror.esr = events.exception.serror_esr;
+
+    return 0;
+}
+
 void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run)
 {
 }
target/arm/kvm32.c +13 -0
index 4e91c11..0f1e94c 100644
@@ -217,6 +217,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
     }
     cpu->mp_affinity = mpidr & ARM32_AFFINITY_MASK;
 
+    /* Check whether userspace can specify guest syndrome value */
+    kvm_arm_init_serror_injection(cs);
+
     return kvm_arm_init_cpreg_list(cpu);
 }
 
@@ -358,6 +361,11 @@ int kvm_arch_put_registers(CPUState *cs, int level)
         return ret;
     }
 
+    ret = kvm_put_vcpu_events(cpu);
+    if (ret) {
+        return ret;
+    }
+
     /* Note that we do not call write_cpustate_to_list()
      * here, so we are only writing the tuple list back to
      * KVM. This is safe because nothing can change the
@@ -445,6 +453,11 @@ int kvm_arch_get_registers(CPUState *cs)
     }
     vfp_set_fpscr(env, fpscr);
 
+    ret = kvm_get_vcpu_events(cpu);
+    if (ret) {
+        return ret;
+    }
+
     if (!write_kvmstate_to_list(cpu)) {
         return EINVAL;
     }
target/arm/kvm64.c +13 -0
index e0b8246..5411486 100644
@@ -546,6 +546,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
 
     kvm_arm_init_debug(cs);
 
+    /* Check whether user space can specify guest syndrome value */
+    kvm_arm_init_serror_injection(cs);
+
     return kvm_arm_init_cpreg_list(cpu);
 }
 
@@ -727,6 +730,11 @@ int kvm_arch_put_registers(CPUState *cs, int level)
         return ret;
     }
 
+    ret = kvm_put_vcpu_events(cpu);
+    if (ret) {
+        return ret;
+    }
+
     if (!write_list_to_kvmstate(cpu, level)) {
         return EINVAL;
     }
@@ -863,6 +871,11 @@ int kvm_arch_get_registers(CPUState *cs)
     }
     vfp_set_fpcr(env, fpr);
 
+    ret = kvm_get_vcpu_events(cpu);
+    if (ret) {
+        return ret;
+    }
+
     if (!write_kvmstate_to_list(cpu)) {
         return EINVAL;
     }
target/arm/kvm_arm.h +24 -0
index 863f205..b9335fa 100644
@@ -121,6 +121,30 @@ bool write_kvmstate_to_list(ARMCPU *cpu);
  */
 void kvm_arm_reset_vcpu(ARMCPU *cpu);
 
+/**
+ * kvm_arm_init_serror_injection:
+ * @cs: CPUState
+ *
+ * Check whether KVM can set guest SError syndrome.
+ */
+void kvm_arm_init_serror_injection(CPUState *cs);
+
+/**
+ * kvm_get_vcpu_events:
+ * @cpu: ARMCPU
+ *
+ * Get VCPU related state from kvm.
+ */
+int kvm_get_vcpu_events(ARMCPU *cpu);
+
+/**
+ * kvm_put_vcpu_events:
+ * @cpu: ARMCPU
+ *
+ * Put VCPU related state to kvm.
+ */
+int kvm_put_vcpu_events(ARMCPU *cpu);
+
 #ifdef CONFIG_KVM
 /**
  * kvm_arm_create_scratch_host_vcpu:
target/arm/machine.c +22 -0
index ff4ec22..32bcde0 100644
@@ -172,6 +172,27 @@ static const VMStateDescription vmstate_sve = {
 };
 #endif /* AARCH64 */
 
+static bool serror_needed(void *opaque)
+{
+    ARMCPU *cpu = opaque;
+    CPUARMState *env = &cpu->env;
+
+    return env->serror.pending != 0;
+}
+
+static const VMStateDescription vmstate_serror = {
+    .name = "cpu/serror",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = serror_needed,
+    .fields = (VMStateField[]) {
+        VMSTATE_UINT8(env.serror.pending, ARMCPU),
+        VMSTATE_UINT8(env.serror.has_esr, ARMCPU),
+        VMSTATE_UINT64(env.serror.esr, ARMCPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 static bool m_needed(void *opaque)
 {
     ARMCPU *cpu = opaque;
@@ -726,6 +747,7 @@ const VMStateDescription vmstate_arm_cpu = {
 #ifdef TARGET_AARCH64
         &vmstate_sve,
 #endif
+        &vmstate_serror,
         NULL
     }
 };
Signature · 1 line
2.7.4
Reviewed-by on v11 2/2
#5 lore raw

Re: [Qemu-arm] [PATCH RFC v11 2/2] target/arm: Add support for VCPU event states

In reply to Dongjiu Geng
Quoted 4 lines · Dongjiu Geng

This patch extends the qemu-kvm state sync logic with support for KVM_GET/SET_VCPU_EVENTS, giving access to yet missing SError exception. And also it can support the exception state migration.

Quoted 8 lines

The SError exception states include SError pending state and ESR value, the kvm_put/get_vcpu_events() will be called when set or get system registers. When do migration, if source machine has SError pending, QEMU will do this migration regardless whether the target machine supports to specify guest ESR value, because if target machine does not support that, it can also inject the SError with zero ESR value.

thanks
-- PMM

#6 lore raw
In reply to Dongjiu Geng
Quoted 11 lines · Dongjiu Geng

Support KVM_GET/SET_VCPU_EVENTS to get/set the SError exception state, and support the state migration.

Now the VCPU event only includes the SError exception status, it can be extended if needed. When do migration, If source machine has serror pending, the target machine is also needed to pend this serror regardless of whether target machine can support to set the serror syndrome.

Note: Because I do not have arm32 environment, I only this patch in the KVM64, not test it in the KVM32. So I need someone else test it in the 32 bit KVM platform. Thanks.

Hi; could you clarify why this patchset is tagged RFC, please? Is it just that it hasn't been tested on 32-bit ?

thanks
-- PMM

#7 lore raw

Hi peter,

Thanks very much for this comments and very sorry for my late response due to business trave.

Yes, the reason that tag the patchset to RFC is that it just hasn't been tested on 32-bit. if someone else can test it on 32-bit platform, it will be great.

I do not have 32-bit environment, so only tested it on 64-bit.

Quoted 11 lines · Dongjiu Geng

Support KVM_GET/SET_VCPU_EVENTS to get/set the SError exception state, and support the state migration.

Now the VCPU event only includes the SError exception status, it can be extended if needed. When do migration, If source machine has serror pending, the target machine is also needed to pend this serror regardless of whether target machine can support to set the serror syndrome.

Note: Because I do not have arm32 environment, I only this patch in the KVM64, not test it in the KVM32. So I need someone else test it in the 32 bit KVM platform. Thanks.

Hi; could you clarify why this patchset is tagged RFC, please? Is it just that it hasn't been tested on 32-bit ?

thanks
-- PMM

#8 lore raw
In reply to Peter Maydell

Hi peter,

Thanks very much for this comments and very sorry for my late response due to business trave.

Yes, the reason that tag the patchset to RFC is that it just hasn't been tested on 32-bit. if someone else can test it on 32-bit platform, it will be great.

I do not have 32-bit environment, so only tested it on 64-bit.

Quoted 11 lines · Dongjiu Geng

Support KVM_GET/SET_VCPU_EVENTS to get/set the SError exception state, and support the state migration.

Now the VCPU event only includes the SError exception status, it can be extended if needed. When do migration, If source machine has serror pending, the target machine is also needed to pend this serror regardless of whether target machine can support to set the serror syndrome.

Note: Because I do not have arm32 environment, I only this patch in the KVM64, not test it in the KVM32. So I need someone else test it in the 32 bit KVM platform. Thanks.

Hi; could you clarify why this patchset is tagged RFC, please? Is it just that it hasn't been tested on 32-bit ?

thanks
-- PMM

#9 lore raw
In reply to Peter Maydell

Hi peter,

Thanks very much for this comments and very sorry for my late response due to business trave.

Yes, the reason that tag the patchset to RFC is that it just hasn't been tested on 32-bit. if someone else can test it on 32-bit platform, it will be great.

I do not have 32-bit environment, so only tested it on 64-bit.

Quoted 11 lines · Dongjiu Geng

Support KVM_GET/SET_VCPU_EVENTS to get/set the SError exception state, and support the state migration.

Now the VCPU event only includes the SError exception status, it can be extended if needed. When do migration, If source machine has serror pending, the target machine is also needed to pend this serror regardless of whether target machine can support to set the serror syndrome.

Note: Because I do not have arm32 environment, I only this patch in the KVM64, not test it in the KVM32. So I need someone else test it in the 32 bit KVM platform. Thanks.

Hi; could you clarify why this patchset is tagged RFC, please? Is it just that it hasn't been tested on 32-bit ?

thanks
-- PMM

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 7 lines · gengdongjiu

Hi peter,

Thanks very much for this comments and very sorry for my late response due to business trave.

Yes, the reason that tag the patchset to RFC is that it just hasn't been tested on 32-bit. if someone else can test it on 32-bit platform, it will be great.

I do not have 32-bit environment, so only tested it on 64-bit.

OK, thanks. I gave it a quick 32-bit test, though I don't have a mechanism for inserting SErrors.

Applied to target-arm.next, thanks.

-- PMM