From 11235d68750ff2274e21571210f95c018a295a36 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Mon, 4 Jan 2021 17:56:44 +0100 Subject: cpu/intel/haswell/acpi.c: Correct `get_cores_per_package` CPUID result does not change when HyperThreading is disabled on HT-enabled CPUs, which breaks `generate_cpu_entries`. Use MSR 0x35 instead, which returns the currently-enabled core and thread count. Also rename the function to `get_logical_cores_per_package, which is more accurate. Based on commit 920d2b77f2 (cpu/intel/206ax/acpi.c: Fix get_cores_per_package). The MSR definition is the same for Sandy Bridge and Haswell. Change-Id: I5e1789d3037780b4285c9e367ff0e2b0d4365b39 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/49099 Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) --- src/cpu/intel/haswell/acpi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/cpu/intel/haswell/acpi.c b/src/cpu/intel/haswell/acpi.c index 0f11e5f8d9..401e82bcf0 100644 --- a/src/cpu/intel/haswell/acpi.c +++ b/src/cpu/intel/haswell/acpi.c @@ -32,20 +32,10 @@ static int cstate_set_trad[3] = { C_STATE_C6_LONG_LAT, }; -static int get_cores_per_package(void) +static int get_logical_cores_per_package(void) { - struct cpuinfo_x86 c; - struct cpuid_result result; - int cores = 1; - - get_fms(&c, cpuid_eax(1)); - if (c.x86 != 6) - return 1; - - result = cpuid_ext(0xb, 1); - cores = result.ebx & 0xff; - - return cores; + msr_t msr = rdmsr(MSR_CORE_THREAD_COUNT); + return msr.lo & 0xffff; } static acpi_tstate_t tss_table_fine[] = { @@ -279,7 +269,7 @@ void generate_cpu_entries(const struct device *device) { int coreID, cpuID, pcontrol_blk = get_pmbase(), plen = 6; int totalcores = dev_count_cpu(); - int cores_per_package = get_cores_per_package(); + int cores_per_package = get_logical_cores_per_package(); int numcpus = totalcores/cores_per_package; printk(BIOS_DEBUG, "Found %d CPU(s) with %d core(s) each.\n", -- cgit v1.2.3