From 22f006eda76c2d7c6cee29ac3b151b822f6b96dd Mon Sep 17 00:00:00 2001 From: avg Date: Tue, 17 May 2016 08:33:40 +0000 Subject: [PATCH] MFC r298736: ensure that initial local apic id is sane on AMD 10h systems git-svn-id: svn://svn.freebsd.org/base/stable/10@300036 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/amd64/amd64/initcpu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 36f2d0f02..f1d81cbef 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -111,6 +111,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); + } + } } /* -- 2.45.0