From 2310d99ebf4d92de48758c648054569f6740bccf Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Tue, 20 Aug 2019 09:58:18 +0800 Subject: [PATCH] hv: cleanup vmcs.h -- move 'RFLAGS_AC' to cpu.h -- move 'VMX_SUPPORT_UNRESTRICTED_GUEST' to msr.h and rename it to 'MSR_IA32_MISC_UNRESTRICTED_GUEST' -- move 'get_vcpu_mode' to vcpu.h -- remove deadcode 'vmx_eoi_exit()' Tracked-On: #1842 Signed-off-by: Mingqiang Chi Reviewed-by: Jason Chen CJ Acked-by: Eddie Dong --- hypervisor/arch/x86/cpu_caps.c | 3 +-- hypervisor/arch/x86/guest/guest_memory.c | 1 + hypervisor/arch/x86/guest/vmsr.c | 1 - hypervisor/common/hypercall.c | 2 +- hypervisor/include/arch/x86/cpu.h | 4 ++++ hypervisor/include/arch/x86/guest/vcpu.h | 5 +++++ hypervisor/include/arch/x86/guest/vmcs.h | 19 ------------------- hypervisor/include/arch/x86/msr.h | 3 +++ 8 files changed, 15 insertions(+), 23 deletions(-) diff --git a/hypervisor/arch/x86/cpu_caps.c b/hypervisor/arch/x86/cpu_caps.c index 2ea7b7392..2ad2ce48d 100644 --- a/hypervisor/arch/x86/cpu_caps.c +++ b/hypervisor/arch/x86/cpu_caps.c @@ -323,8 +323,7 @@ static inline bool is_vmx_disabled(void) static inline bool pcpu_has_vmx_unrestricted_guest_cap(void) { - return ((msr_read(MSR_IA32_VMX_MISC) & VMX_SUPPORT_UNRESTRICTED_GUEST) - != 0UL); + return ((msr_read(MSR_IA32_VMX_MISC) & MSR_IA32_MISC_UNRESTRICTED_GUEST) != 0UL); } static int32_t check_vmx_mmu_cap(void) diff --git a/hypervisor/arch/x86/guest/guest_memory.c b/hypervisor/arch/x86/guest/guest_memory.c index 4890374d3..2a9903db7 100644 --- a/hypervisor/arch/x86/guest/guest_memory.c +++ b/hypervisor/arch/x86/guest/guest_memory.c @@ -6,6 +6,7 @@ #include #include +#include #include #include #include diff --git a/hypervisor/arch/x86/guest/vmsr.c b/hypervisor/arch/x86/guest/vmsr.c index ae99ce3e8..c5df9763c 100644 --- a/hypervisor/arch/x86/guest/vmsr.c +++ b/hypervisor/arch/x86/guest/vmsr.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include diff --git a/hypervisor/common/hypercall.c b/hypervisor/common/hypercall.c index 84ef55e3c..937516ffb 100644 --- a/hypervisor/common/hypercall.c +++ b/hypervisor/common/hypercall.c @@ -5,7 +5,7 @@ */ #include -#include +#include #include #include #include diff --git a/hypervisor/include/arch/x86/cpu.h b/hypervisor/include/arch/x86/cpu.h index 8ad203706..14d1d3a84 100644 --- a/hypervisor/include/arch/x86/cpu.h +++ b/hypervisor/include/arch/x86/cpu.h @@ -127,6 +127,10 @@ /*Bits in EFER special registers */ #define EFER_LMA 0x00000400U /* Long mode active (R) */ +#define RFLAGS_C (1U<<0U) +#define RFLAGS_Z (1U<<6U) +#define RFLAGS_AC (1U<<18U) + /* CPU clock frequencies (FSB) */ #define CPU_FSB_83KHZ 83200 #define CPU_FSB_100KHZ 99840 diff --git a/hypervisor/include/arch/x86/guest/vcpu.h b/hypervisor/include/arch/x86/guest/vcpu.h index 3f56a0586..a48205521 100644 --- a/hypervisor/include/arch/x86/guest/vcpu.h +++ b/hypervisor/include/arch/x86/guest/vcpu.h @@ -378,6 +378,11 @@ static inline bool is_vcpu_bsp(const struct acrn_vcpu *vcpu) return (vcpu->vcpu_id == BOOT_CPU_ID); } +static inline enum vm_cpu_mode get_vcpu_mode(const struct acrn_vcpu *vcpu) +{ + return vcpu->arch.cpu_mode; +} + /* do not update Guest RIP for next VM Enter */ static inline void vcpu_retain_rip(struct acrn_vcpu *vcpu) { diff --git a/hypervisor/include/arch/x86/guest/vmcs.h b/hypervisor/include/arch/x86/guest/vmcs.h index 530da68f7..53e5afd43 100644 --- a/hypervisor/include/arch/x86/guest/vmcs.h +++ b/hypervisor/include/arch/x86/guest/vmcs.h @@ -12,7 +12,6 @@ #ifndef ASSEMBLER #include -#include #include #define VMX_VMENTRY_FAIL 0x80000000U @@ -22,11 +21,6 @@ #define TYPE_LINEAR_APIC_INST_READ (0UL << 12U) #define TYPE_LINEAR_APIC_INST_WRITE (1UL << 12U) -static inline uint32_t vmx_eoi_exit(uint32_t vector) -{ - return (VMX_EOI_EXIT0_FULL + ((vector >> 6U) * 2U)); -} - /* VM exit qulifications for APIC-access * Access type: * 0 = linear access for a data read during instruction execution @@ -46,22 +40,9 @@ static inline uint64_t apic_access_offset(uint64_t qual) { return (qual & APIC_ACCESS_OFFSET); } - -#define RFLAGS_C (1U<<0U) -#define RFLAGS_Z (1U<<6U) -#define RFLAGS_AC (1U<<18U) - -#define VMX_SUPPORT_UNRESTRICTED_GUEST (1U<<5U) - void init_vmcs(struct acrn_vcpu *vcpu); void switch_apicv_mode_x2apic(struct acrn_vcpu *vcpu); - -static inline enum vm_cpu_mode get_vcpu_mode(const struct acrn_vcpu *vcpu) -{ - return vcpu->arch.cpu_mode; -} - #endif /* ASSEMBLER */ #endif /* VMCS_H_ */ diff --git a/hypervisor/include/arch/x86/msr.h b/hypervisor/include/arch/x86/msr.h index 1eea6a1a3..c504c12b8 100644 --- a/hypervisor/include/arch/x86/msr.h +++ b/hypervisor/include/arch/x86/msr.h @@ -563,6 +563,9 @@ #define MSR_IA32_MISC_ENABLE_xTPR (1UL << 23U) #define MSR_IA32_MISC_ENABLE_XD_DISABLE (1UL << 34U) +/* Miscellaneous data */ +#define MSR_IA32_MISC_UNRESTRICTED_GUEST (1U<<5U) + #ifndef ASSEMBLER static inline bool pat_mem_type_invalid(uint64_t x) {