From owner-svn-src-all@FreeBSD.ORG Thu Apr 11 04:29:46 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 1B186AE7; Thu, 11 Apr 2013 04:29:46 +0000 (UTC) (envelope-from neel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0D31EE6E; Thu, 11 Apr 2013 04:29:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3B4TjBv011472; Thu, 11 Apr 2013 04:29:45 GMT (envelope-from neel@svn.freebsd.org) Received: (from neel@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3B4TjWx011469; Thu, 11 Apr 2013 04:29:45 GMT (envelope-from neel@svn.freebsd.org) Message-Id: <201304110429.r3B4TjWx011469@svn.freebsd.org> From: Neel Natu Date: Thu, 11 Apr 2013 04:29:45 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Apr 2013 04:29:46 -0000 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. */