Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Apr 2013 04:29:45 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r249351 - in head/sys: amd64/vmm/intel x86/include
Message-ID:  <201304110429.r3B4TjWx011469@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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.
  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304110429.r3B4TjWx011469>