mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-24 14:33:38 +00:00
hv: execute vmxon instruction fail don't panic system
Don't panic system when execute vmxon instruction failed. And let's follow that only print error info when error return from library function. Signed-off-by: Li, Fei1 <fei1.li@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
This commit is contained in:
parent
fe4484f5a9
commit
3fb7b75eda
@ -49,9 +49,10 @@ static inline int exec_vmxon(void *addr)
|
||||
uint64_t tmp64;
|
||||
int status = 0;
|
||||
|
||||
if (addr == NULL)
|
||||
status = -EINVAL;
|
||||
ASSERT(status == 0, "Incorrect arguments");
|
||||
if (addr == NULL) {
|
||||
pr_err("%s, Incorrect arguments\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Read Feature ControL MSR */
|
||||
tmp64 = msr_read(MSR_IA32_FEATURE_CONTROL);
|
||||
@ -61,6 +62,7 @@ static inline int exec_vmxon(void *addr)
|
||||
/* See if VMX enabled */
|
||||
if (!(tmp64 & MSR_IA32_FEATURE_CONTROL_VMX_NO_SMX)) {
|
||||
/* Return error - VMX can't be enabled */
|
||||
pr_err("%s, VMX can't be enabled\n", __func__);
|
||||
status = -EINVAL;
|
||||
}
|
||||
} else {
|
||||
@ -81,8 +83,10 @@ static inline int exec_vmxon(void *addr)
|
||||
: "%rax", "cc", "memory");
|
||||
|
||||
/* if carry and zero flags are clear operation success */
|
||||
if (rflags & (RFLAGS_C | RFLAGS_Z))
|
||||
if (rflags & (RFLAGS_C | RFLAGS_Z)) {
|
||||
pr_err("%s, Turn VMX on failed\n", __func__);
|
||||
status = -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Return result to caller */
|
||||
@ -93,7 +97,7 @@ int exec_vmxon_instr(void)
|
||||
{
|
||||
uint64_t tmp64;
|
||||
uint32_t tmp32;
|
||||
int ret_val = -EINVAL;
|
||||
int ret = -ENOMEM;
|
||||
void *vmxon_region_va;
|
||||
uint64_t vmxon_region_pa;
|
||||
|
||||
@ -115,10 +119,12 @@ int exec_vmxon_instr(void)
|
||||
|
||||
/* Turn ON VMX */
|
||||
vmxon_region_pa = HVA2HPA(vmxon_region_va);
|
||||
ret_val = exec_vmxon(&vmxon_region_pa);
|
||||
}
|
||||
ret = exec_vmxon(&vmxon_region_pa);
|
||||
} else
|
||||
pr_err("%s, alloc memory for VMXON region failed\n",
|
||||
__func__);
|
||||
|
||||
return ret_val;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int exec_vmclear(void *addr)
|
||||
|
@ -156,10 +156,8 @@ int hv_main(int cpu_id)
|
||||
|
||||
/* Enable virtualization extensions */
|
||||
ret = exec_vmxon_instr();
|
||||
if (ret != 0) {
|
||||
pr_err("%s, Unable to enable VMX!\n", __func__);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* X2APIC mode is disabled by default. */
|
||||
x2apic_enabled = false;
|
||||
|
Loading…
Reference in New Issue
Block a user