diff options
author | neel <neel@FreeBSD.org> | 2013-04-11 04:29:45 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2013-04-11 04:29:45 +0000 |
commit | ea145a8678878b2fe9970cf8eb1b49a3fd807dec (patch) | |
tree | ebbe41b7272496899c4f61f8db5999bce8f76424 /sys | |
parent | 042dd07575e9e0a4e598c59543e7af7d4684a70a (diff) | |
download | FreeBSD-src-ea145a8678878b2fe9970cf8eb1b49a3fd807dec.zip FreeBSD-src-ea145a8678878b2fe9970cf8eb1b49a3fd807dec.tar.gz |
Make the code to check if VMX is enabled more readable by using macros
instead of magic numbers.
Discussed with: Chris Torek
Diffstat (limited to 'sys')
-rw-r--r-- | sys/amd64/vmm/intel/vmx.c | 3 | ||||
-rw-r--r-- | sys/x86/include/specialreg.h | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index d927cd9..fb41074 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -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); } diff --git a/sys/x86/include/specialreg.h b/sys/x86/include/specialreg.h index dbf9ba0..fb4a197 100644 --- a/sys/x86/include/specialreg.h +++ b/sys/x86/include/specialreg.h @@ -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. */ |