Make the code to check if VMX is enabled more readable by using macros

instead of magic numbers.

Discussed with:	Chris Torek
This commit is contained in:
Neel Natu 2013-04-11 04:29:45 +00:00
parent fbf928f15f
commit 150369ab7c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=249351
2 changed files with 7 additions and 1 deletions

View File

@ -441,7 +441,8 @@ vmx_init(void)
* are set (bits 0 and 2 respectively).
*/
feature_control = rdmsr(MSR_IA32_FEATURE_CONTROL);
if ((feature_control & 0x5) != 0x5) {
if ((feature_control & IA32_FEATURE_CONTROL_LOCK) == 0 ||
(feature_control & IA32_FEATURE_CONTROL_VMX_EN) == 0) {
printf("vmx_init: VMX operation disabled by BIOS\n");
return (ENXIO);
}

View File

@ -418,6 +418,11 @@
#define APICBASE_ENABLED 0x00000800
#define APICBASE_ADDRESS 0xfffff000
/* MSR_IA32_FEATURE_CONTROL related */
#define IA32_FEATURE_CONTROL_LOCK 0x01 /* lock bit */
#define IA32_FEATURE_CONTROL_SMX_EN 0x02 /* enable VMX inside SMX */
#define IA32_FEATURE_CONTROL_VMX_EN 0x04 /* enable VMX outside SMX */
/*
* PAT modes.
*/