mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 05:57:33 +00:00
Simple get_vmx_cap()
Don't check MSR Control Features in get_vmx_cap Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
parent
05b8f366f6
commit
4f65dd477a
@ -94,38 +94,15 @@ static inline int exec_vmxon(void *addr)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_vmx_support(void)
|
bool get_vmx_cap(void)
|
||||||
{
|
{
|
||||||
uint32_t eax, ebx, ecx, edx;
|
uint32_t eax, ebx, ecx, edx;
|
||||||
int ret_val = 0;
|
|
||||||
uint64_t tmp64;
|
|
||||||
|
|
||||||
/* Run CPUID to determine if VTX support available */
|
/* Run CPUID to determine if VTX support available */
|
||||||
cpuid(CPUID_FEATURES, &eax, &ebx, &ecx, &edx);
|
cpuid(CPUID_FEATURES, &eax, &ebx, &ecx, &edx);
|
||||||
|
|
||||||
/* See if VMX feature bit is set in ECX */
|
/* See if VMX feature bit is set in ECX */
|
||||||
if (!(ecx & CPUID_ECX_VMX)) {
|
return !!(ecx & CPUID_ECX_VMX);
|
||||||
/* Log and return error */
|
|
||||||
pr_fatal("VMX not supported by CPU");
|
|
||||||
ret_val = -EINVAL;
|
|
||||||
} else {
|
|
||||||
/* Read feature control MSR */
|
|
||||||
tmp64 = msr_read(MSR_IA32_FEATURE_CONTROL);
|
|
||||||
|
|
||||||
/* See if feature control MSR is locked and VMX not enabled
|
|
||||||
* appropriately
|
|
||||||
*/
|
|
||||||
if ((tmp64 & MSR_IA32_FEATURE_CONTROL_LOCK) &&
|
|
||||||
(!(tmp64 & MSR_IA32_FEATURE_CONTROL_VMX_NO_SMX))) {
|
|
||||||
/* Log and return error */
|
|
||||||
pr_fatal("MSR_IA32_FEATURE_CONTROL: Lock bit is on and VMXON bit is off");
|
|
||||||
pr_fatal(" Cannot do vmxon");
|
|
||||||
ret_val = -EINVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return status to caller */
|
|
||||||
return ret_val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int exec_vmxon_instr(void)
|
int exec_vmxon_instr(void)
|
||||||
|
@ -152,8 +152,8 @@ int hv_main(int cpu_id)
|
|||||||
"cpu_id/tsc_aux mismatch");
|
"cpu_id/tsc_aux mismatch");
|
||||||
|
|
||||||
/* Check if virtualization extensions are supported */
|
/* Check if virtualization extensions are supported */
|
||||||
ret = check_vmx_support();
|
ret = get_vmx_cap();
|
||||||
ASSERT(ret == 0, "VMX not supported!");
|
ASSERT(ret == 1, "VMX not supported!");
|
||||||
|
|
||||||
/* Enable virtualization extensions */
|
/* Enable virtualization extensions */
|
||||||
ret = exec_vmxon_instr();
|
ret = exec_vmxon_instr();
|
||||||
|
@ -413,7 +413,7 @@
|
|||||||
#define PAGE_PROTECTED_MODE 2
|
#define PAGE_PROTECTED_MODE 2
|
||||||
|
|
||||||
/* External Interfaces */
|
/* External Interfaces */
|
||||||
int check_vmx_support(void);
|
bool get_vmx_cap(void);
|
||||||
int exec_vmxon_instr(void);
|
int exec_vmxon_instr(void);
|
||||||
uint64_t exec_vmread(uint32_t field);
|
uint64_t exec_vmread(uint32_t field);
|
||||||
uint64_t exec_vmread64(uint32_t field_full);
|
uint64_t exec_vmread64(uint32_t field_full);
|
||||||
|
Loading…
Reference in New Issue
Block a user