1 /* SPDX-License-Identifier: GPL-2.0-only */
4 #include <cpu/intel/common/common.h>
7 bool intel_ht_supported(void)
9 /* Is HyperThreading supported? */
10 return !!(cpuid_edx(1) & CPUID_FEATURE_HTT
);
14 * Return true if running thread does not have the smallest lapic ID
17 bool intel_ht_sibling(void)
19 struct cpuid_result result
;
20 unsigned int core_ids
, apic_ids
;
21 unsigned int max_leaf
;
22 uint32_t initial_lapicid
, threads
;
24 if (!intel_ht_supported())
27 max_leaf
= cpuid_get_max_func();
29 /* Detect from 32-bit X2APIC ID. */
30 if (max_leaf
>= 0xb) {
31 result
= cpuid_ext(0xb, 0);
32 threads
= 1 << (result
.eax
& 0x1f);
33 initial_lapicid
= result
.edx
;
34 return initial_lapicid
% threads
> 0;
37 /* Detect from 8-bit XAPIC ID. */
38 result
= cpuid_ext(0x1, 0);
39 initial_lapicid
= result
.ebx
>> 24;
40 apic_ids
= (result
.ebx
>> 16) & 0xff;
46 result
= cpuid_ext(4, 0);
47 core_ids
+= (result
.eax
>> 26) & 0x3f;
50 threads
= (apic_ids
/ core_ids
);
51 return initial_lapicid
% threads
> 0;