File 5a219aec-x86-avoid-migrate-vCPU-corruption-with-CPUID-faulting.patch of Package xen.openSUSE_Leap_42.3_Update
# Commit b90f86be161c74df8cb69c98d9f22885d9d87114
# Date 2017-12-01 18:09:48 +0000
# Author Andrew Cooper <andrew.cooper3@citrix.com>
# Committer Andrew Cooper <andrew.cooper3@citrix.com>
x86: Avoid corruption on migrate for vcpus using CPUID Faulting
Xen 4.8 and later virtualises CPUID Faulting support for guests. However, the
value of MSR_MISC_FEATURES_ENABLES is omitted from the vcpu state, meaning
that the current cpuid faulting setting is lost on migrate/suspend/resume.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1322,6 +1322,19 @@ long arch_do_domctl(
}
}
+ if ( v->arch.cpuid_faulting )
+ {
+ if ( i < vmsrs->msr_count && !ret )
+ {
+ msr.index = MSR_INTEL_MISC_FEATURES_ENABLES;
+ msr.reserved = 0;
+ msr.value = MSR_MISC_FEATURES_CPUID_FAULTING;
+ if ( copy_to_guest_offset(vmsrs->msrs, i, &msr, 1) )
+ ret = -EFAULT;
+ }
+ ++i;
+ }
+
vcpu_unpause(v);
if ( i > vmsrs->msr_count && !ret )
@@ -1349,6 +1362,11 @@ long arch_do_domctl(
switch ( msr.index )
{
+ case MSR_INTEL_MISC_FEATURES_ENABLES:
+ v->arch.cpuid_faulting = !!(msr.value &
+ MSR_MISC_FEATURES_CPUID_FAULTING);
+ continue;
+
case MSR_AMD64_DR0_ADDRESS_MASK:
if ( !boot_cpu_has(X86_FEATURE_DBEXT) ||
(msr.value >> 32) )
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -903,7 +903,8 @@ static int vmx_load_vmcs_ctxt(struct vcp
static unsigned int __init vmx_init_msr(void)
{
- return (cpu_has_mpx && cpu_has_vmx_mpx) +
+ return 1 /* MISC_FEATURES_ENABLES */ +
+ (cpu_has_mpx && cpu_has_vmx_mpx) +
(cpu_has_xsaves && cpu_has_vmx_xsaves);
}
@@ -911,6 +912,12 @@ static void vmx_save_msr(struct vcpu *v,
{
vmx_vmcs_enter(v);
+ if ( v->arch.cpuid_faulting )
+ {
+ ctxt->msr[ctxt->count].index = MSR_INTEL_MISC_FEATURES_ENABLES;
+ ctxt->msr[ctxt->count++].val = MSR_MISC_FEATURES_CPUID_FAULTING;
+ }
+
if ( cpu_has_mpx && cpu_has_vmx_mpx )
{
__vmread(GUEST_BNDCFGS, &ctxt->msr[ctxt->count].val);
@@ -939,6 +946,10 @@ static int vmx_load_msr(struct vcpu *v,
{
switch ( ctxt->msr[i].index )
{
+ case MSR_INTEL_MISC_FEATURES_ENABLES:
+ v->arch.cpuid_faulting = !!(ctxt->msr[i].val &
+ MSR_MISC_FEATURES_CPUID_FAULTING);
+ break;
case MSR_IA32_BNDCFGS:
if ( cpu_has_mpx && cpu_has_vmx_mpx &&
is_canonical_address(ctxt->msr[i].val) &&