1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
5 #include <cpu/intel/hyperthreading.h>
6 #include <device/device.h>
9 /* Intel hyper-threading requires serialized CPU init. */
11 static int first_time
= 1;
12 static int disable_siblings
= !CONFIG(LOGICAL_CPUS
);
14 void intel_sibling_init(struct device
*cpu
)
16 unsigned int i
, siblings
;
17 struct cpuid_result result
;
19 /* On the bootstrap processor see if I want sibling cpus enabled */
22 disable_siblings
= get_uint_option("hyper_threading", disable_siblings
);
25 /* Is hyperthreading supported */
26 if (!(result
.edx
& (1 << 28)))
29 /* See how many sibling cpus we have */
30 siblings
= (result
.ebx
>> 16) & 0xff;
34 printk(BIOS_DEBUG
, "CPU: %u %d siblings\n",
35 cpu
->path
.apic
.apic_id
,
38 /* See if I am a sibling cpu */
39 if (cpu
->path
.apic
.apic_id
& (siblings
- 1)) {
45 /* I am the primary CPU start up my siblings */
46 for (i
= 1; i
< siblings
; i
++) {
47 struct device_path cpu_path
;
49 /* Build the CPU device path */
50 cpu_path
.type
= DEVICE_PATH_APIC
;
51 cpu_path
.apic
.apic_id
= cpu
->path
.apic
.apic_id
+ i
;
53 /* Allocate new CPU device structure iff sibling CPU
54 * was not in static device tree.
56 new = alloc_find_dev(cpu
->bus
, &cpu_path
);
61 printk(BIOS_DEBUG
, "CPU: %u has sibling %u\n",
62 cpu
->path
.apic
.apic_id
,
63 new->path
.apic
.apic_id
);