From 83813c66960ae19e0d1a2ada2837bdac4a631c01 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 12 Nov 2018 19:17:26 +0000 Subject: [PATCH] Apply fix to un-cripple max cpu id on BSP earlier. We need to know actual value for the standard extended features before ifuncs are resolved. Reported and tested by: madpilot Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/amd64/amd64/machdep.c | 1 + sys/x86/include/x86_var.h | 1 + sys/x86/x86/identcpu.c | 20 ++++++++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 6e36ae975239..55db65ffc63c 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1581,6 +1581,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) identify_cpu1(); identify_hypervisor(); + identify_cpu_fixup_bsp(); identify_cpu2(); initializecpucache(); diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index 286c01261f0f..8f53b41fd197 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -129,6 +129,7 @@ void dump_drop_page(vm_paddr_t); void finishidentcpu(void); void identify_cpu1(void); void identify_cpu2(void); +void identify_cpu_fixup_bsp(void); void identify_hypervisor(void); void initializecpu(void); void initializecpucache(void); diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c index 8e406f053baa..56186b2f3ba4 100644 --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -1467,6 +1467,19 @@ identify_cpu2(void) } } +void +identify_cpu_fixup_bsp(void) +{ + u_int regs[4]; + + cpu_vendor_id = find_cpu_vendor_id(); + + if (fix_cpuid()) { + do_cpuid(0, regs); + cpu_high = regs[0]; + } +} + /* * Final stage of CPU identification. */ @@ -1478,12 +1491,7 @@ finishidentcpu(void) u_char ccr3; #endif - cpu_vendor_id = find_cpu_vendor_id(); - - if (fix_cpuid()) { - do_cpuid(0, regs); - cpu_high = regs[0]; - } + identify_cpu_fixup_bsp(); if (cpu_high >= 5 && (cpu_feature2 & CPUID2_MON) != 0) { do_cpuid(5, regs);