i386/xen: handle VCPUOP_register_vcpu_info

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>
Reviewed-by: Paul Durrant <paul@xen.org>
This commit is contained in:
Joao Martins 2018-06-29 10:54:50 -04:00 committed by David Woodhouse
parent d70bd6a485
commit c345104cd1
6 changed files with 191 additions and 3 deletions

View file

@ -6,8 +6,10 @@
#include "kvm/hyperv.h"
#include "hw/i386/x86.h"
#include "kvm/kvm_i386.h"
#include "hw/xen/xen.h"
#include "sysemu/kvm.h"
#include "sysemu/kvm_xen.h"
#include "sysemu/tcg.h"
#include "qemu/error-report.h"
@ -1257,6 +1259,22 @@ static const VMStateDescription vmstate_nested_state = {
}
};
static bool xen_vcpu_needed(void *opaque)
{
return (xen_mode == XEN_EMULATE);
}
static const VMStateDescription vmstate_xen_vcpu = {
.name = "cpu/xen_vcpu",
.version_id = 1,
.minimum_version_id = 1,
.needed = xen_vcpu_needed,
.fields = (VMStateField[]) {
VMSTATE_UINT64(env.xen_vcpu_info_gpa, X86CPU),
VMSTATE_UINT64(env.xen_vcpu_info_default_gpa, X86CPU),
VMSTATE_END_OF_LIST()
}
};
#endif
static bool mcg_ext_ctl_needed(void *opaque)
@ -1716,6 +1734,7 @@ const VMStateDescription vmstate_x86_cpu = {
#endif
#ifdef CONFIG_KVM
&vmstate_nested_state,
&vmstate_xen_vcpu,
#endif
&vmstate_msr_tsx_ctrl,
&vmstate_msr_intel_sgx,