Author: neel
Date: Thu Apr 11 04:29:45 2013
New Revision: 249351
URL: http://svnweb.freebsd.org/changeset/base/249351

Log:
  Make the code to check if VMX is enabled more readable by using macros
  instead of magic numbers.
  
  Discussed with:       Chris Torek

Modified:
  head/sys/amd64/vmm/intel/vmx.c
  head/sys/x86/include/specialreg.h

Modified: head/sys/amd64/vmm/intel/vmx.c
==============================================================================
--- head/sys/amd64/vmm/intel/vmx.c      Wed Apr 10 23:37:15 2013        
(r249350)
+++ head/sys/amd64/vmm/intel/vmx.c      Thu Apr 11 04:29:45 2013        
(r249351)
@@ -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);
        }

Modified: head/sys/x86/include/specialreg.h
==============================================================================
--- head/sys/x86/include/specialreg.h   Wed Apr 10 23:37:15 2013        
(r249350)
+++ head/sys/x86/include/specialreg.h   Thu Apr 11 04:29:45 2013        
(r249351)
@@ -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.
  */
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to