From 920d2b77f274ab511d22bb4a0ff6aa9e5b37b4c8 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Tue, 16 Jun 2020 08:23:09 +0300 Subject: cpu/intel/206ax/acpi.c: Fix get_cores_per_package Current implementation uses CPUID 0Bh function that returns the number of logical cores of requested level. The problem with this approach is that this value doesn't change when HyperThreading is disabled (it's in the Intel docs), so it breaks generate_cpu_entries(). - Use MSR 0x35 instead, which returns the correct number of logical processors with and without HT. - Rename the function to get_logical_cores_per_package, which is more accurate. Tested on ThinkPad X220 with and without HT. Related to CB:29669. Change-Id: Ib32c2d40408cfa42ca43ab42ed661c168e579ada Signed-off-by: Evgeny Zinoviev Reviewed-on: https://review.coreboot.org/c/coreboot/+/42413 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- src/cpu/intel/model_206ax/acpi.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/cpu/intel/model_206ax/acpi.c b/src/cpu/intel/model_206ax/acpi.c index 13ee20a728..b24f411f00 100644 --- a/src/cpu/intel/model_206ax/acpi.c +++ b/src/cpu/intel/model_206ax/acpi.c @@ -13,20 +13,10 @@ #include "model_206ax.h" #include "chip.h" -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 void generate_cstate_entries(acpi_cstate_t *cstates, @@ -288,7 +278,7 @@ void generate_cpu_entries(const struct device *device) { int coreID, cpuID, pcontrol_blk = PMB0_BASE, 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