Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Apr 2012 18:31:01 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r233800 - stable/7/sys/amd64/amd64
Message-ID:  <201204021831.q32IV1sA010702@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Mon Apr  2 18:31:01 2012
New Revision: 233800
URL: http://svn.freebsd.org/changeset/base/233800

Log:
  MFC:	r233702
  
  Work around Erratum 721 for AMD Family 10h and 12h processors.

Modified:
  stable/7/sys/amd64/amd64/initcpu.c
Directory Properties:
  stable/7/sys/   (props changed)

Modified: stable/7/sys/amd64/amd64/initcpu.c
==============================================================================
--- stable/7/sys/amd64/amd64/initcpu.c	Mon Apr  2 18:27:06 2012	(r233799)
+++ stable/7/sys/amd64/amd64/initcpu.c	Mon Apr  2 18:31:01 2012	(r233800)
@@ -78,6 +78,27 @@ SYSCTL_UINT(_hw, OID_AUTO, via_feature_r
 SYSCTL_UINT(_hw, OID_AUTO, via_feature_xcrypt, CTLFLAG_RD,
 	&via_feature_xcrypt, 0, "VIA C3/C7 xcrypt feature available in CPU");
 
+static void
+init_amd(void)
+{
+
+	/*
+	 * Work around Erratum 721 for Family 10h and 12h processors.
+	 * These processors may incorrectly update the stack pointer
+	 * after a long series of push and/or near-call instructions,
+	 * or a long series of pop and/or near-return instructions.
+	 *
+	 * http://support.amd.com/us/Processor_TechDocs/41322_10h_Rev_Gd.pdf
+	 * http://support.amd.com/us/Processor_TechDocs/44739_12h_Rev_Gd.pdf
+	 */
+	switch (CPUID_TO_FAMILY(cpu_id)) {
+	case 0x10:
+	case 0x12:
+		wrmsr(0xc0011029, rdmsr(0xc0011029) | 1);
+		break;
+	}
+}
+
 /*
  * Initialize special VIA C3/C7 features
  */
@@ -159,10 +180,16 @@ initializecpu(void)
 		wrmsr(MSR_EFER, msr);
 		pg_nx = PG_NX;
 	}
-	if (cpu_vendor_id == CPU_VENDOR_CENTAUR &&
-	    CPUID_TO_FAMILY(cpu_id) == 0x6 &&
-	    CPUID_TO_MODEL(cpu_id) >= 0xf)
-		init_via();
+	switch (cpu_vendor_id) {
+	case CPU_VENDOR_AMD:
+		init_amd();
+		break;
+	case CPU_VENDOR_CENTAUR:
+		if (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
+		    CPUID_TO_MODEL(cpu_id) >= 0xf)
+			init_via();
+		break;
+	}
 }
 
 void



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