All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [Qemu-devel] [PATCH v2 1/2] kvm: sync linux headers
  2018-06-05 20:52 ` [Qemu-devel] [PATCH v2 1/2] kvm: sync linux headers Dongjiu Geng
@ 2018-06-05 13:07   ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-06-05 13:07 UTC (permalink / raw)
  To: Dongjiu Geng; +Cc: James Morse, qemu-arm, QEMU Developers, Linuxarm

On 5 June 2018 at 21:52, Dongjiu Geng <gengdongjiu@huawei.com> wrote:
> Import KVM_CAP_ARM_INJECT_SERROR_ESR and struct kvm_vcpu_events
> for arm64
>
> Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>

Was this produced with the update-headers script? If so,
the commit message should say so and also which upstream
kernel commit/tag the sync is against. (See QEMU commit
65a6d8dd3f32 for an example.) If not then this series should
be tagged as an RFC, since it shouldn't be applied until
the kernel API changes have gone into the kernel upstream.

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 0/2] add support for VCPU event states
@ 2018-06-05 20:52 Dongjiu Geng
  2018-06-05 20:52 ` [Qemu-devel] [PATCH v2 1/2] kvm: sync linux headers Dongjiu Geng
  2018-06-05 20:52 ` [Qemu-devel] [PATCH v2 2/2] target: arm: Add support for VCPU event states Dongjiu Geng
  0 siblings, 2 replies; 4+ messages in thread
From: Dongjiu Geng @ 2018-06-05 20:52 UTC (permalink / raw)
  To: peter.maydell, james.morse, qemu-arm, qemu-devel, gengdongjiu, linuxarm

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

change since v1:
1. update the code to fix the build errors

Dongjiu Geng (2):
  kvm: sync linux headers
  target: arm: Add support for VCPU event states

 linux-headers/asm-arm64/kvm.h | 13 +++++++++
 linux-headers/linux/kvm.h     |  1 +
 target/arm/cpu.h              |  5 ++++
 target/arm/kvm64.c            | 64 +++++++++++++++++++++++++++++++++++++++++++
 target/arm/machine.c          |  3 ++
 5 files changed, 86 insertions(+)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] kvm: sync linux headers
  2018-06-05 20:52 [Qemu-devel] [PATCH v2 0/2] add support for VCPU event states Dongjiu Geng
@ 2018-06-05 20:52 ` Dongjiu Geng
  2018-06-05 13:07   ` Peter Maydell
  2018-06-05 20:52 ` [Qemu-devel] [PATCH v2 2/2] target: arm: Add support for VCPU event states Dongjiu Geng
  1 sibling, 1 reply; 4+ messages in thread
From: Dongjiu Geng @ 2018-06-05 20:52 UTC (permalink / raw)
  To: peter.maydell, james.morse, qemu-arm, qemu-devel, gengdongjiu, linuxarm

Import KVM_CAP_ARM_INJECT_SERROR_ESR and struct kvm_vcpu_events
for arm64

Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
---
 linux-headers/asm-arm64/kvm.h | 13 +++++++++++++
 linux-headers/linux/kvm.h     |  1 +
 2 files changed, 14 insertions(+)

diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h
index 17315ab..e240afc 100644
--- a/linux-headers/asm-arm64/kvm.h
+++ b/linux-headers/asm-arm64/kvm.h
@@ -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
 
@@ -153,6 +154,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
diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index cdb148e..cd8be47 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -948,6 +948,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_S390_BPB 152
 #define KVM_CAP_GET_MSR_FEATURES 153
 #define KVM_CAP_HYPERV_EVENTFD 154
+#define KVM_CAP_ARM_INJECT_SERROR_ESR 155
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] target: arm: Add support for VCPU event states
  2018-06-05 20:52 [Qemu-devel] [PATCH v2 0/2] add support for VCPU event states Dongjiu Geng
  2018-06-05 20:52 ` [Qemu-devel] [PATCH v2 1/2] kvm: sync linux headers Dongjiu Geng
@ 2018-06-05 20:52 ` Dongjiu Geng
  1 sibling, 0 replies; 4+ messages in thread
From: Dongjiu Geng @ 2018-06-05 20:52 UTC (permalink / raw)
  To: peter.maydell, james.morse, qemu-arm, qemu-devel, gengdongjiu, linuxarm

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.

Signed-off-by: Dongjiu Geng <gengdongjiu@huawei.com>
---
 target/arm/cpu.h     |  5 ++++
 target/arm/kvm64.c   | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 target/arm/machine.c |  3 +++
 3 files changed, 72 insertions(+)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 8488273..b3d6682 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -645,6 +645,11 @@ typedef struct CPUARMState {
     const struct arm_boot_info *boot_info;
     /* Store GICv3CPUState to access from this struct */
     void *gicv3state;
+    struct {
+        uint32_t pending;
+        uint32_t has_esr;
+        uint64_t esr;
+    } serror;
 } CPUARMState;
 
 /**
diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c
index e0b8246..45b6911 100644
--- a/target/arm/kvm64.c
+++ b/target/arm/kvm64.c
@@ -600,6 +600,59 @@ int kvm_arm_cpreg_level(uint64_t regidx)
 #define AARCH64_SIMD_CTRL_REG(x)   (KVM_REG_ARM64 | KVM_REG_SIZE_U32 | \
                  KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x))
 
+static bool kvm_can_set_vcpu_esr(ARMCPU *cpu)
+{
+    CPUState *cs = CPU(cpu);
+
+    int ret = kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_INJECT_SERROR_ESR);
+    return (ret) ? true : false;
+}
+
+
+static int kvm_put_vcpu_events(ARMCPU *cpu)
+{
+    CPUARMState *env = &cpu->env;
+    struct kvm_vcpu_events events = {};
+
+    if (!kvm_has_vcpu_events()) {
+        return 0;
+    }
+
+    memset(&events, 0, sizeof(events));
+    events.exception.serror_pending = env->serror.pending;
+
+    if (kvm_can_set_vcpu_esr(cpu)) {
+        events.exception.serror_has_esr = env->serror.has_esr;
+        events.exception.serror_esr = env->serror.esr;
+    }
+
+    return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_VCPU_EVENTS, &events);
+}
+
+static 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 < 0) {
+        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;
+}
+
 int kvm_arch_put_registers(CPUState *cs, int level)
 {
     struct kvm_one_reg reg;
@@ -727,6 +780,12 @@ int kvm_arch_put_registers(CPUState *cs, int level)
         return ret;
     }
 
+    ret = kvm_put_vcpu_events(cpu);
+    if (ret) {
+        printf("return error kvm_put_vcpu_events: %d\n", ret);
+        return ret;
+    }
+
     if (!write_list_to_kvmstate(cpu, level)) {
         return EINVAL;
     }
@@ -863,6 +922,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;
     }
diff --git a/target/arm/machine.c b/target/arm/machine.c
index 2e28d08..5a359f4 100644
--- a/target/arm/machine.c
+++ b/target/arm/machine.c
@@ -695,6 +695,9 @@ const VMStateDescription vmstate_arm_cpu = {
         VMSTATE_UINT32(env.exception.syndrome, ARMCPU),
         VMSTATE_UINT32(env.exception.fsr, ARMCPU),
         VMSTATE_UINT64(env.exception.vaddress, ARMCPU),
+        VMSTATE_UINT32(env.serror.pending, ARMCPU),
+        VMSTATE_UINT32(env.serror.has_esr, ARMCPU),
+        VMSTATE_UINT64(env.serror.esr, ARMCPU),
         VMSTATE_TIMER_PTR(gt_timer[GTIMER_PHYS], ARMCPU),
         VMSTATE_TIMER_PTR(gt_timer[GTIMER_VIRT], ARMCPU),
         {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-05 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 20:52 [Qemu-devel] [PATCH v2 0/2] add support for VCPU event states Dongjiu Geng
2018-06-05 20:52 ` [Qemu-devel] [PATCH v2 1/2] kvm: sync linux headers Dongjiu Geng
2018-06-05 13:07   ` Peter Maydell
2018-06-05 20:52 ` [Qemu-devel] [PATCH v2 2/2] target: arm: Add support for VCPU event states Dongjiu Geng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.