Attention is currently required from: Patrick Rudolph. Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/58385 )
Change subject: cpu/intel/hyperthreading: Use initial LAPIC IDs ......................................................................
cpu/intel/hyperthreading: Use initial LAPIC IDs
For older CPU models where CPUID leaf 0xb is not supported, use initial LAPIC ID from CPUID instead of LAPIC register space to to detect if logical CPU is a hyperthreading sibling. The one in LAPIC space is more complex to read, and might not reflect CPU topology as it can be modified in XAPIC mode.
Change-Id: I8c458824db1ea66948126622a3e0d0604e391e4b Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/cpu/intel/common/hyperthreading.c 1 file changed, 12 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/85/58385/1
diff --git a/src/cpu/intel/common/hyperthreading.c b/src/cpu/intel/common/hyperthreading.c index 3297b381..f9170b3 100644 --- a/src/cpu/intel/common/hyperthreading.c +++ b/src/cpu/intel/common/hyperthreading.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: GPL-2.0-only */
-#include <cpu/x86/lapic.h> #include <cpu/intel/common/common.h> #include <arch/cpu.h> #include <types.h> @@ -18,22 +17,27 @@ bool intel_ht_sibling(void) { struct cpuid_result result; - unsigned int core_ids, apic_ids, threads; + unsigned int core_ids, apic_ids; unsigned int max_leaf; + uint32_t initial_lapicid, threads;
if (!intel_ht_supported()) return false;
max_leaf = cpuid_get_max_func(); + + /* Detect from 32-bit X2APIC ID. */ if (max_leaf >= 0xb) { result = cpuid_ext(0xb, 0); - const uint32_t div = 1 << (result.eax & 0x1f); - return result.edx % div > 0; + threads = 1 << (result.eax & 0x1f); + initial_lapicid = result.edx; + return initial_lapicid % threads > 0; }
- apic_ids = 1; - if (max_leaf >= 1) - apic_ids = (cpuid_ebx(1) >> 16) & 0xff; + /* Detect from 8-bit XAPIC ID. */ + result = cpuid_ext(0x1, 0); + initial_lapicid = result.ebx >> 24; + apic_ids = (result.ebx >> 16) & 0xff; if (apic_ids == 0) apic_ids = 1;
@@ -44,5 +48,5 @@ }
threads = (apic_ids / core_ids); - return !!(lapicid() & (threads - 1)); + return initial_lapicid % threads > 0; }