|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 2/2] x86/cpuid: Hide RDRAND and RDSEED from nested VMX guests
From: Chunjie Zhu <chunjie.zhu@xxxxxxxxxx>
Hyper-V (hvix64) requires the "RDRAND exiting" secondary VM-execution
control to be available whenever CPUID reports RDRAND (and likewise
"RDSEED exiting" for RDSEED). Nested VMX does not offer either control to
L1, so a Hyper-V L1 sees an inconsistent view and fails early during boot.
Clear CPUID.1[ECX].RDRAND and CPUID.7[0].EBX.RDSEED 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 | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 0e79ce67dd3f..d89fde27c454 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -281,6 +281,14 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
if ( is_hvm_domain(d) )
res->b |= (v->vcpu_id * 2) << 24;
+ /*
+ * Hyper-V (hvix64) requires the "RDRAND exiting" secondary
VM-execution
+ * control whenever CPUID reports RDRAND. Nested VMX does not offer
+ * it, so hide RDRAND (and RDSEED, below) from nested VMX guests.
+ */
+ if ( is_hvm_domain(d) && nestedhvm_enabled(d) && p->basic.vmx )
+ res->c &= ~cpufeat_mask(X86_FEATURE_RDRAND);
+
/* TODO: Rework vPMU control in terms of toolstack choices. */
if ( vpmu_available(v) &&
vpmu_is_set(vcpu_vpmu(v), VPMU_CPU_HAS_DS) )
@@ -432,6 +440,9 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
? v->arch.pv.ctrlreg[4]
: v->arch.hvm.guest_cr[4]) & X86_CR4_PKE )
res->c |= cpufeat_mask(X86_FEATURE_OSPKE);
+
+ if ( is_hvm_domain(d) && nestedhvm_enabled(d) && p->basic.vmx )
+ res->b &= ~cpufeat_mask(X86_FEATURE_RDSEED);
break;
}
break;
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |