Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 May 2016 08:36:12 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r300037 - stable/9/sys/amd64/amd64
Message-ID:  <201605170836.u4H8aCMq056443@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Tue May 17 08:36:12 2016
New Revision: 300037
URL: https://svnweb.freebsd.org/changeset/base/300037

Log:
  MFC r298736,298737: ensure that initial local apic id is sane on AMD 10h systems

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

Modified: stable/9/sys/amd64/amd64/initcpu.c
==============================================================================
--- stable/9/sys/amd64/amd64/initcpu.c	Tue May 17 08:33:40 2016	(r300036)
+++ stable/9/sys/amd64/amd64/initcpu.c	Tue May 17 08:36:12 2016	(r300037)
@@ -84,6 +84,7 @@ SYSCTL_UINT(_hw, OID_AUTO, via_feature_x
 static void
 init_amd(void)
 {
+	uint64_t msr;
 
 	/*
 	 * Work around Erratum 721 for Family 10h and 12h processors.
@@ -106,6 +107,19 @@ init_amd(void)
 			wrmsr(0xc0011029, rdmsr(0xc0011029) | 1);
 		break;
 	}
+
+	/*
+	 * BIOS may fail to set InitApicIdCpuIdLo to 1 as it should per BKDG.
+	 * So, do it here or otherwise some tools could be confused by
+	 * Initial Local APIC ID reported with CPUID Function 1 in EBX.
+	 */
+	if (CPUID_TO_FAMILY(cpu_id) == 0x10) {
+		if ((cpu_feature2 & CPUID2_HV) == 0) {
+			msr = rdmsr(MSR_NB_CFG1);
+			msr |= (uint64_t)1 << 54;
+			wrmsr(MSR_NB_CFG1, msr);
+		}
+	}
 }
 
 /*



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