From 0943a836bd7bcb57b22e79d3cc65b1d25940a4e1 Mon Sep 17 00:00:00 2001 From: Xinyun Liu Date: Thu, 28 Feb 2019 08:44:14 +0800 Subject: [PATCH] [hv] set ECX.bit31 to indicate the presence of a hypervisor ECS.bit31 is not used and always return 0 in SDM Vol.2A 3-195. It's a standard way to indicate whether there is a hypervisor. Tracked-On: #2490 Ref: https://lwn.net/Articles/301888/ Signed-off-by: Xinyun Liu Acked-by: Anthony Xu --- hypervisor/arch/x86/guest/vcpuid.c | 3 +++ hypervisor/include/arch/x86/cpuid.h | 1 + 2 files changed, 4 insertions(+) diff --git a/hypervisor/arch/x86/guest/vcpuid.c b/hypervisor/arch/x86/guest/vcpuid.c index 08b7a9dac..f755ac91b 100644 --- a/hypervisor/arch/x86/guest/vcpuid.c +++ b/hypervisor/arch/x86/guest/vcpuid.c @@ -345,6 +345,9 @@ void guest_cpuid(struct acrn_vcpu *vcpu, uint32_t *eax, uint32_t *ebx, uint32_t /*mask vmx to guest os */ *ecx &= ~CPUID_ECX_VMX; + /* set Hypervisor Present Bit */ + *ecx |= CPUID_ECX_HV; + /*no xsave support for guest if it is not enabled on host*/ if ((*ecx & CPUID_ECX_OSXSAVE) == 0U) { *ecx &= ~CPUID_ECX_XSAVE; diff --git a/hypervisor/include/arch/x86/cpuid.h b/hypervisor/include/arch/x86/cpuid.h index e898d6dd8..0063feb59 100644 --- a/hypervisor/include/arch/x86/cpuid.h +++ b/hypervisor/include/arch/x86/cpuid.h @@ -41,6 +41,7 @@ #define CPUID_ECX_XSAVE (1U<<26U) #define CPUID_ECX_OSXSAVE (1U<<27U) #define CPUID_ECX_AVX (1U<<28U) +#define CPUID_ECX_HV (1U<<31U) #define CPUID_EDX_FPU (1U<<0U) #define CPUID_EDX_VME (1U<<1U) #define CPUID_EDX_DE (1U<<2U)