From ba7a9eefcf4e571bc73d4be1141f676fc5547057 Mon Sep 17 00:00:00 2001 From: Jeremy Compostella Date: Fri, 1 Sep 2023 16:17:51 -0700 Subject: soc/intel/common: Fix invalid MADT entries creation commit f8ac3dda02f22ebf857efb5b845db97f00598f7d ("soc/intel/common: Order the CPUs based on their APIC IDs") sort algorithnm walks all the `cpu_info' entries without discarding empty ones. Since `cpu_info' is not initialized, the data that is used is undefined and it generally results in the creation of invalid `Local x2APIC' entries in the MADT ("APIC") ACPI table. Depending on the X2APIC ID value the Linux kernel behavior changes (cf. arch/x86/kernel/acpi/boot.c::acpi_register_lapic()): 1. If (int)ID >= MAX_LOCAL_APIC (32768), the Linux kernel discards the entry with the "skipped apicid that is too big" INFO level message. 2. If (int)ID < MAX_LOCAL_APIC (32768) (including negative) this data is taken into account and it can lead to undesirable behavior such as core being disabled as (cf. "native_cpu_up: bad cpu" ERROR kernel message). TEST=Verified the MADT does not contain any invalid entries on rex. Change-Id: I19c7aa51f232bf48201bd6d28f108e9120a21f7e Signed-off-by: Jeremy Compostella Reviewed-on: https://review.coreboot.org/c/coreboot/+/77615 Reviewed-by: Bora Guvendik Tested-by: build bot (Jenkins) Reviewed-by: Wonkyu Kim --- src/arch/x86/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/arch') diff --git a/src/arch/x86/cpu.c b/src/arch/x86/cpu.c index cb616c96ca..f4c18c2643 100644 --- a/src/arch/x86/cpu.c +++ b/src/arch/x86/cpu.c @@ -302,7 +302,7 @@ void arch_bootstate_coreboot_exit(void) /* cpu_info() looks at address 0 at the base of %gs for a pointer to struct cpu_info */ static struct per_cpu_segment_data segment_data[CONFIG_MAX_CPUS]; -struct cpu_info cpu_infos[CONFIG_MAX_CPUS]; +struct cpu_info cpu_infos[CONFIG_MAX_CPUS] = {0}; enum cb_err set_cpu_info(unsigned int index, struct device *cpu) { -- cgit v1.2.3