coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
intel_sibling.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <arch/cpu.h>
4 #include <console/console.h>
6 #include <device/device.h>
7 #include <option.h>
8 
9 /* Intel hyper-threading requires serialized CPU init. */
10 
11 static int first_time = 1;
12 static int disable_siblings = !CONFIG(LOGICAL_CPUS);
13 
14 void intel_sibling_init(struct device *cpu)
15 {
16  unsigned int i, siblings;
17  struct cpuid_result result;
18 
19  /* On the bootstrap processor see if I want sibling cpus enabled */
20  if (first_time) {
21  first_time = 0;
23  }
24  result = cpuid(1);
25  /* Is hyperthreading supported */
26  if (!(result.edx & (1 << 28)))
27  return;
28 
29  /* See how many sibling cpus we have */
30  siblings = (result.ebx >> 16) & 0xff;
31  if (siblings < 1)
32  siblings = 1;
33 
34  printk(BIOS_DEBUG, "CPU: %u %d siblings\n",
35  cpu->path.apic.apic_id,
36  siblings);
37 
38  /* See if I am a sibling cpu */
39  if (cpu->path.apic.apic_id & (siblings - 1)) {
40  if (disable_siblings)
41  cpu->enabled = 0;
42  return;
43  }
44 
45  /* I am the primary CPU start up my siblings */
46  for (i = 1; i < siblings; i++) {
47  struct device_path cpu_path;
48  struct device *new;
49  /* Build the CPU device path */
51  cpu_path.apic.apic_id = cpu->path.apic.apic_id + i;
52 
53  /* Allocate new CPU device structure iff sibling CPU
54  * was not in static device tree.
55  */
56  new = alloc_find_dev(cpu->bus, &cpu_path);
57 
58  if (!new)
59  continue;
60 
61  printk(BIOS_DEBUG, "CPU: %u has sibling %u\n",
62  cpu->path.apic.apic_id,
63  new->path.apic.apic_id);
64  }
65 }
#define printk(level,...)
Definition: stdlib.h:16
struct device * alloc_find_dev(struct bus *parent, struct device_path *path)
See if a device structure already exists and if not allocate it.
Definition: device.c:138
@ CONFIG
Definition: dsi_common.h:201
void intel_sibling_init(struct device *cpu)
Definition: intel_sibling.c:14
static int disable_siblings
Definition: intel_sibling.c:12
static int first_time
Definition: intel_sibling.c:11
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
result
Definition: mrc_cache.c:35
unsigned int get_uint_option(const char *name, const unsigned int fallback)
Definition: option.c:116
@ DEVICE_PATH_APIC
Definition: path.h:12
u32 cpuid
unsigned int apic_id
Definition: path.h:72
Definition: path.h:87
struct apic_path apic
Definition: path.h:119
Definition: device.h:107
struct device_path path
Definition: device.h:115
DEVTREE_CONST struct bus * bus
Definition: device.h:108
unsigned int enabled
Definition: device.h:122