From owner-svn-src-head@FreeBSD.ORG Fri Mar 30 16:32:42 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0ABD5106566B; Fri, 30 Mar 2012 16:32:42 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EA1198FC1A; Fri, 30 Mar 2012 16:32:41 +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 q2UGWfBQ049236; Fri, 30 Mar 2012 16:32:41 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q2UGWfKB049234; Fri, 30 Mar 2012 16:32:41 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201203301632.q2UGWfKB049234@svn.freebsd.org> From: Jung-uk Kim Date: Fri, 30 Mar 2012 16:32:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r233702 - head/sys/amd64/amd64 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Mar 2012 16:32:42 -0000 Author: jkim Date: Fri Mar 30 16:32:41 2012 New Revision: 233702 URL: http://svn.freebsd.org/changeset/base/233702 Log: Work around Erratum 721 for AMD Family 10h and 12h processors. "Under a highly specific and detailed set of internal timing conditions, the processor 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. The processor must be in 64-bit mode for this erratum to occur." MFC after: 3 days Modified: head/sys/amd64/amd64/initcpu.c Modified: head/sys/amd64/amd64/initcpu.c ============================================================================== --- head/sys/amd64/amd64/initcpu.c Fri Mar 30 15:08:09 2012 (r233701) +++ head/sys/amd64/amd64/initcpu.c Fri Mar 30 16:32:41 2012 (r233702) @@ -79,6 +79,27 @@ SYSCTL_UINT(_hw, OID_AUTO, via_feature_r SYSCTL_UINT(_hw, OID_AUTO, via_feature_xcrypt, CTLFLAG_RD, &via_feature_xcrypt, 0, "VIA 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 features */ @@ -135,8 +156,14 @@ initializecpu(void) wrmsr(MSR_EFER, msr); pg_nx = PG_NX; } - if (cpu_vendor_id == CPU_VENDOR_CENTAUR) + switch (cpu_vendor_id) { + case CPU_VENDOR_AMD: + init_amd(); + break; + case CPU_VENDOR_CENTAUR: init_via(); + break; + } } void