summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cpu/intel/common/hyperthreading.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/cpu/intel/common/hyperthreading.c b/src/cpu/intel/common/hyperthreading.c
index 3297b381b3..f9170b383a 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_supported(void)
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 @@ bool intel_ht_sibling(void)
}
threads = (apic_ids / core_ids);
- return !!(lapicid() & (threads - 1));
+ return initial_lapicid % threads > 0;
}