Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/69224 )
Change subject: cpu/x86/smm_module_loader: Use struct device instead of cpu index ......................................................................
cpu/x86/smm_module_loader: Use struct device instead of cpu index
The initial lapicid is now present inside struct device so simply loop over those to fill smm_stub params
Change-Id: Ia1c2a889efe54589cf036cd1c3afb36e48d15720 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/arch/x86/cpu.c M src/cpu/x86/smm/smm_module_loader.c M src/include/cpu/cpu.h 3 files changed, 20 insertions(+), 21 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/24/69224/1
diff --git a/src/arch/x86/cpu.c b/src/arch/x86/cpu.c index cee29fd..31e55da 100644 --- a/src/arch/x86/cpu.c +++ b/src/arch/x86/cpu.c @@ -210,7 +210,7 @@ cpu->ops = driver ? driver->ops : NULL; }
-static struct bus *cpu_cluster(void) +struct bus *cpu_cluster(void) { static struct bus *bus; struct device *dev; @@ -249,22 +249,6 @@ return cpu_get_index(initial_lapicid()); }
-/* Returns default APIC id based on logical_cpu number or < 0 on failure. */ -int cpu_get_apic_id(int logical_cpu) -{ - if (logical_cpu >= CONFIG_MAX_CPUS || logical_cpu < 0 || !cpu_cluster()) - return -1; - - struct device *dev = cpu_cluster()->children; - while (dev && logical_cpu != 0) { - dev = dev->sibling; - logical_cpu--; - } - if (!dev) - return -1; - return dev->path.apic.initial_lapicid; -} - void cpu_initialize(unsigned int index) { /* Because we busy wait at the printk spinlock. diff --git a/src/cpu/x86/smm/smm_module_loader.c b/src/cpu/x86/smm/smm_module_loader.c index 0425b4c..660a3fe 100644 --- a/src/cpu/x86/smm/smm_module_loader.c +++ b/src/cpu/x86/smm/smm_module_loader.c @@ -7,6 +7,7 @@ #include <console/console.h> #include <cpu/cpu.h> #include <cpu/x86/smm.h> +#include <device/device.h> #include <rmodule.h> #include <stdio.h> #include <string.h> @@ -268,8 +269,9 @@ stub_params->fxsave_area = (uintptr_t)fxsave_area; stub_params->fxsave_area_size = FXSAVE_SIZE;
- for (int i = 0; i < params->num_cpus; i++) - stub_params->apic_id_to_cpu[i] = cpu_get_apic_id(i); + int i = 0; + for (struct device *dev = cpu_cluster()->children; dev; dev = dev->sibling) + stub_params->apic_id_to_cpu[i++] = dev->path.apic.initial_lapicid;
printk(BIOS_DEBUG, "%s: stack_top = 0x%x\n", __func__, stub_params->stack_top); printk(BIOS_DEBUG, "%s: per cpu stack_size = 0x%x\n", __func__, diff --git a/src/include/cpu/cpu.h b/src/include/cpu/cpu.h index 4b2d7ea..118ce8d 100644 --- a/src/include/cpu/cpu.h +++ b/src/include/cpu/cpu.h @@ -7,8 +7,8 @@ #include <stdint.h>
void cpu_initialize(unsigned int cpu_index); -/* Returns default APIC id based on logical_cpu number or < 0 on failure. */ -int cpu_get_apic_id(int logical_cpu); +/* Return */ +struct bus *cpu_cluster(void); /* Return the CPU logical number based on default APIC id or < 0 on failure. */ int cpu_get_index(const unsigned int lapic_id); uintptr_t cpu_get_lapic_addr(void);