qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH v2 16/22] i386/xen: handle VCPUOP_register_vcpu_info


From: Paul Durrant
Subject: Re: [RFC PATCH v2 16/22] i386/xen: handle VCPUOP_register_vcpu_info
Date: Wed, 14 Dec 2022 10:28:21 +0000
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1

On 13/12/2022 00:13, David Woodhouse wrote:
On Mon, 2022-12-12 at 14:58 +0000, Paul Durrant wrote:
On 09/12/2022 09:56, David Woodhouse wrote:
From: Joao Martins <
joao.m.martins@oracle.com


Handle the hypercall to set a per vcpu info, and also wire up the
default
vcpu_info in the shared_info page for the first 32 vCPUs.

To avoid deadlock within KVM a vCPU thread must set its *own*
vcpu_info
rather than it being set from the context in which the hypercall is
invoked.

Add the vcpu_info (and default) GPA to the vmstate_x86_cpu for
migration,
and restore it in kvm_arch_put_registers() appropriately.

Signed-off-by: Joao Martins <
joao.m.martins@oracle.com

Signed-off-by: David Woodhouse <
dwmw@amazon.co.uk

---
   target/i386/cpu.h        |  2 ++
   target/i386/kvm/kvm.c    | 19 +++++++++++
   target/i386/machine.c    | 21 ++++++++++++
   target/i386/trace-events |  1 +
   target/i386/xen.c        | 74
+++++++++++++++++++++++++++++++++++++---
   target/i386/xen.h        |  1 +
   6 files changed, 113 insertions(+), 5 deletions(-)

diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index c6c57baed5..109b2e5669 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -1788,6 +1788,8 @@ typedef struct CPUArchState {
   #endif
   #if defined(CONFIG_KVM)
       struct kvm_nested_state *nested_state;
+    uint64_t xen_vcpu_info_gpa;
+    uint64_t xen_vcpu_info_default_gpa;
   #endif
   #if defined(CONFIG_HVF)
       HVFX86LazyFlags hvf_lflags;
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index ebde6bc204..fa45e2f99a 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -1811,6 +1811,9 @@ int kvm_arch_init_vcpu(CPUState *cs)
           has_msr_hv_hypercall = true;
       }
+ env->xen_vcpu_info_gpa = UINT64_MAX;
+    env->xen_vcpu_info_default_gpa = UINT64_MAX;


There was an INVALID_GPA definition for shared info. Looks like we
could use it here too.

There was, and I started trying to use it, but it fell foul of the "is
this going to live in target/ or hw/ and who can include what from
where?" and I decided to just use UINT64_MAX for now and keep typing.

That will work out in the end, I'm sure.

Hopefully https://lore.kernel.org/lkml/20221209023622.274715-1-yu.c.zhang@linux.intel.com/ will help.


Some sanity checks wouldn't go a miss here...

rvi.offset should:
a) be < TARGET_PAGE_SIZE, and
b) ba aligned to vcpu_info_t size

Ack.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]