mb/starlabs/{lite_adl,byte_adl}: Don't select MAINBOARD_HAS_TPM2
[coreboot2.git] / src / cpu / intel / common / hyperthreading.c
blobd034129780c1b146a3e03e0fa90dd765f6eeabf3
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <cpu/cpu.h>
4 #include <cpu/intel/common/common.h>
5 #include <types.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
15 * within a CPU core.
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())
25 return false;
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;
41 if (apic_ids == 0)
42 apic_ids = 1;
44 core_ids = 1;
45 if (max_leaf >= 4) {
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;