From owner-svn-src-all@FreeBSD.ORG  Sat Sep  8 16:47:53 2012
Return-Path: <owner-svn-src-all@FreeBSD.ORG>
Delivered-To: svn-src-all@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id E442E106564A;
	Sat,  8 Sep 2012 16:47:53 +0000 (UTC) (envelope-from kib@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id D001D8FC1F;
	Sat,  8 Sep 2012 16:47:53 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q88GlrBJ022905;
	Sat, 8 Sep 2012 16:47:53 GMT (envelope-from kib@svn.freebsd.org)
Received: (from kib@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id q88GlrgH022903;
	Sat, 8 Sep 2012 16:47:53 GMT (envelope-from kib@svn.freebsd.org)
Message-Id: <201209081647.q88GlrgH022903@svn.freebsd.org>
From: Konstantin Belousov <kib@FreeBSD.org>
Date: Sat, 8 Sep 2012 16:47:53 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-releng@freebsd.org
X-SVN-Group: releng
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r240240 - releng/9.1/sys/amd64/amd64
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
	user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 08 Sep 2012 16:47:54 -0000

Author: kib
Date: Sat Sep  8 16:47:52 2012
New Revision: 240240
URL: http://svn.freebsd.org/changeset/base/240240

Log:
  MFC r239125:
  Do not apply errata 721 workaround when under hypervisor, since
  typical hypervisor does not implement access to the required MSR,
  causing #GP on boot.
  
  PR:	amd64/170388
  Approved by:	re (kensmith)

Modified:
  releng/9.1/sys/amd64/amd64/initcpu.c
Directory Properties:
  releng/9.1/sys/   (props changed)

Modified: releng/9.1/sys/amd64/amd64/initcpu.c
==============================================================================
--- releng/9.1/sys/amd64/amd64/initcpu.c	Sat Sep  8 16:45:48 2012	(r240239)
+++ releng/9.1/sys/amd64/amd64/initcpu.c	Sat Sep  8 16:47:52 2012	(r240240)
@@ -91,11 +91,17 @@ init_amd(void)
 	 *
 	 * http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf
 	 * http://support.amd.com/us/Processor_TechDocs/44739_12h_Rev_Gd.pdf
+	 *
+	 * Hypervisors do not provide access to the errata MSR,
+	 * causing #GP exception on attempt to apply the errata.  The
+	 * MSR write shall be done on host and persist globally
+	 * anyway, so do not try to do it when under virtualization.
 	 */
 	switch (CPUID_TO_FAMILY(cpu_id)) {
 	case 0x10:
 	case 0x12:
-		wrmsr(0xc0011029, rdmsr(0xc0011029) | 1);
+		if ((cpu_feature2 & CPUID2_HV) == 0)
+			wrmsr(0xc0011029, rdmsr(0xc0011029) | 1);
 		break;
 	}
 }