Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 May 2014 23:37:31 +0000 (UTC)
From:      Tycho Nightingale <tychon@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266910 - head/sys/amd64/vmm/intel
Message-ID:  <201405302337.s4UNbVta046570@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tychon
Date: Fri May 30 23:37:31 2014
New Revision: 266910
URL: http://svnweb.freebsd.org/changeset/base/266910

Log:
  If VMX isn't enabled so long as the lock bit isn't set yet in MSR
  IA32_FEATURE_CONTROL it still can be.
  
  Approved by:	grehan (co-mentor)

Modified:
  head/sys/amd64/vmm/intel/vmx.c

Modified: head/sys/amd64/vmm/intel/vmx.c
==============================================================================
--- head/sys/amd64/vmm/intel/vmx.c	Fri May 30 23:28:53 2014	(r266909)
+++ head/sys/amd64/vmm/intel/vmx.c	Fri May 30 23:37:31 2014	(r266910)
@@ -512,6 +512,15 @@ static void
 vmx_enable(void *arg __unused)
 {
 	int error;
+	uint64_t feature_control;
+
+	feature_control = rdmsr(MSR_IA32_FEATURE_CONTROL);
+	if ((feature_control & IA32_FEATURE_CONTROL_LOCK) == 0 ||
+	    (feature_control & IA32_FEATURE_CONTROL_VMX_EN) == 0) {
+		wrmsr(MSR_IA32_FEATURE_CONTROL,
+		    feature_control | IA32_FEATURE_CONTROL_VMX_EN |
+		    IA32_FEATURE_CONTROL_LOCK);
+	}
 
 	load_cr4(rcr4() | CR4_VMXE);
 
@@ -547,7 +556,7 @@ vmx_init(int ipinum)
 	 * are set (bits 0 and 2 respectively).
 	 */
 	feature_control = rdmsr(MSR_IA32_FEATURE_CONTROL);
-	if ((feature_control & IA32_FEATURE_CONTROL_LOCK) == 0 ||
+	if ((feature_control & IA32_FEATURE_CONTROL_LOCK) == 1 &&
 	    (feature_control & IA32_FEATURE_CONTROL_VMX_EN) == 0) {
 		printf("vmx_init: VMX operation disabled by BIOS\n");
 		return (ENXIO);



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