From 4bb5e60de5b94372de48ff9048043bb0ae7b8e4d Mon Sep 17 00:00:00 2001 From: Zide Chen Date: Tue, 29 May 2018 17:45:20 -0700 Subject: [PATCH] hv: enable MTRR virtualization - unmask MTRR from guest CPUID to enable MTRR - MTRR virtualization can be disabled by commenting out CONFIG_MTRR_ENABLED Signed-off-by: bliu11 Signed-off-by: Zide Chen Reviewed-by: Jason Chen CJ Acked-by: Eddie Dong --- hypervisor/arch/x86/cpuid.c | 2 ++ hypervisor/arch/x86/guest/vcpu.c | 4 ++++ hypervisor/bsp/sbl/include/bsp/bsp_cfg.h | 1 + hypervisor/bsp/uefi/include/bsp/bsp_cfg.h | 1 + 4 files changed, 8 insertions(+) diff --git a/hypervisor/arch/x86/cpuid.c b/hypervisor/arch/x86/cpuid.c index 6285697ff..beb23f29a 100644 --- a/hypervisor/arch/x86/cpuid.c +++ b/hypervisor/arch/x86/cpuid.c @@ -283,8 +283,10 @@ void guest_cpuid(struct vcpu *vcpu, *ebx &= ~APIC_ID_MASK; *ebx |= (apicid & APIC_ID_MASK); +#ifndef CONFIG_MTRR_ENABLED /* mask mtrr */ *edx &= ~CPUID_EDX_MTRR; +#endif /* Patching X2APIC, X2APIC mode is disabled by default. */ if (x2apic_enabled) diff --git a/hypervisor/arch/x86/guest/vcpu.c b/hypervisor/arch/x86/guest/vcpu.c index 28f5c50dc..db56493a5 100644 --- a/hypervisor/arch/x86/guest/vcpu.c +++ b/hypervisor/arch/x86/guest/vcpu.c @@ -107,6 +107,10 @@ int create_vcpu(int cpu_id, struct vm *vm, struct vcpu **rtn_vcpu_handle) /* Create per vcpu vlapic */ vlapic_create(vcpu); +#ifdef CONFIG_MTRR_ENABLED + init_mtrr(vcpu); +#endif + /* Populate the return handle */ *rtn_vcpu_handle = vcpu; diff --git a/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h b/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h index 2c493822f..c9399415c 100644 --- a/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h +++ b/hypervisor/bsp/sbl/include/bsp/bsp_cfg.h @@ -21,4 +21,5 @@ #define CONFIG_LOW_RAM_SIZE 0x000CF000 #define CONFIG_RAM_START 0x6E000000 #define CONFIG_RAM_SIZE 0x02000000 /* 32M */ +#define CONFIG_MTRR_ENABLED 1 #endif /* BSP_CFG_H */ diff --git a/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h b/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h index cf3e0a80e..a882f32bd 100644 --- a/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h +++ b/hypervisor/bsp/uefi/include/bsp/bsp_cfg.h @@ -25,4 +25,5 @@ #define CONFIG_GPU_SBDF 0x00000010 /* 0000:00:02.0 */ #define CONFIG_EFI_STUB 1 #define CONFIG_UEFI_OS_LOADER_NAME "\\EFI\\org.clearlinux\\bootloaderx64.efi" +#define CONFIG_MTRR_ENABLED 1 #endif /* BSP_CFG_H */