|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 1/2] x86/cpuid: Hide XSAVES from nested VMX guests
From: Chunjie Zhu <chunjie.zhu@xxxxxxxxxx>
Hyper-V (hvix64) requires the "enable XSAVES/XRSTORS" secondary
VM-execution control to be available whenever CPUID reports XSAVES, and
refuses to start otherwise. Nested VMX does not offer that control to L1,
so a Hyper-V L1 sees an inconsistent view and fails early during boot.
Clear the XSAVES bit in CPUID.0xD[1].EAX, along with the IA32_XSS supported
bits in ECX:EDX, for HVM guests which have nested virt enabled and are
exposed VMX.
Signed-off-by: Chunjie Zhu <chunjie.zhu@xxxxxxxxxx>
---
xen/arch/x86/cpuid.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index a9aeb2d268ad..0e79ce67dd3f 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -8,6 +8,7 @@
#include <asm/cpu-policy.h>
#include <asm/cpuid.h>
#include <asm/guest-msr.h>
+#include <asm/hvm/nestedhvm.h>
#include <asm/hvm/viridian.h>
#include <asm/xstate.h>
@@ -477,6 +478,19 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
if ( p->xstate.xsavec )
res->b = xstate_compressed_size(v->arch.xcr0 |
v->arch.msrs->xss.raw);
+
+ /*
+ * Hyper-V (hvix64) requires the "enable XSAVES/XRSTORS" secondary
+ * VM-execution control whenever CPUID reports XSAVES. Nested VMX
+ * does not offer that control, so hide XSAVES (and the XSS state
+ * components) from nested VMX guests.
+ */
+ if ( is_hvm_domain(d) && nestedhvm_enabled(d) && p->basic.vmx )
+ {
+ res->a &= ~(1u << 3); /* XSAVES */
+ res->c = 0; /* IA32_XSS supported bits */
+ res->d = 0;
+ }
break;
}
break;
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |