Verify that VMX operation has been enabled by BIOS before executing the
VMXON instruction. Reported by "s vas" on freebsd-virtualization@
This commit is contained in:
parent
f8ae0403f8
commit
4bff7fad95
@ -427,7 +427,7 @@ static int
|
||||
vmx_init(void)
|
||||
{
|
||||
int error;
|
||||
uint64_t fixed0, fixed1;
|
||||
uint64_t fixed0, fixed1, feature_control;
|
||||
uint32_t tmp;
|
||||
|
||||
/* CPUID.1:ECX[bit 5] must be 1 for processor to support VMX */
|
||||
@ -436,6 +436,16 @@ vmx_init(void)
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that MSR_IA32_FEATURE_CONTROL lock and VMXON enable bits
|
||||
* are set (bits 0 and 2 respectively).
|
||||
*/
|
||||
feature_control = rdmsr(MSR_IA32_FEATURE_CONTROL);
|
||||
if ((feature_control & 0x5) != 0x5) {
|
||||
printf("vmx_init: VMX operation disabled by BIOS\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/* Check support for primary processor-based VM-execution controls */
|
||||
error = vmx_set_ctlreg(MSR_VMX_PROCBASED_CTLS,
|
||||
MSR_VMX_TRUE_PROCBASED_CTLS,
|
||||
|
@ -294,6 +294,7 @@
|
||||
#define MSR_APICBASE 0x01b
|
||||
#define MSR_EBL_CR_POWERON 0x02a
|
||||
#define MSR_TEST_CTL 0x033
|
||||
#define MSR_IA32_FEATURE_CONTROL 0x03a
|
||||
#define MSR_BIOS_UPDT_TRIG 0x079
|
||||
#define MSR_BBL_CR_D0 0x088
|
||||
#define MSR_BBL_CR_D1 0x089
|
||||
|
Loading…
Reference in New Issue
Block a user