x86/acpi: Handle bogus MADT APIC tables gracefully

Message ID 8734w3o8ej.ffs@tglx
State New
Headers
Series x86/acpi: Handle bogus MADT APIC tables gracefully |

Commit Message

Thomas Gleixner Dec. 15, 2023, 2:19 p.m. UTC
  The recent fix to ignore invalid x2APIC entries inadvertently broke systems
with creative MADT APIC tables. The affected systems have APIC MADT tables
where all entries have invalid APIC IDs (0xFF), which means they register
exactly zero CPUs.

But the condition to ignore the entries of APIC IDs < 255 in the X2APIC
MADT table is solely based on the count of MADT APIC table entries.

As a consequence the affected machines enumerate no secondary CPUs at
all because the APIC table has entries and therefore the X2APIC table
entries with APIC IDs < 255 are ignored.

Change the condition so that the APIC table preference for APIC IDs <
255 only becomes effective when the APIC table has valid APIC ID
entries. IOW a APIC table full of invalid APIC IDs is considered to be
empty which in consequence enables the X2APIC table entries with a APIC
ID < 255 and restores the expected behaviour.

Fixes: ec9aedb2aa1a ("x86/acpi: Ignore invalid x2APIC entries")
Reported-by: John Sperbeck <jsperbeck@google.com>
Reported-by: Andres Freund <andres@anarazel.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
---
 arch/x86/kernel/acpi/boot.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -293,6 +293,7 @@  acpi_parse_lapic(union acpi_subtable_hea
 			    processor->processor_id, /* ACPI ID */
 			    processor->lapic_flags & ACPI_MADT_ENABLED);
 
+	has_lapic_cpus = true;
 	return 0;
 }
 
@@ -1134,7 +1135,6 @@  static int __init acpi_parse_madt_lapic_
 	if (!count) {
 		count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_APIC,
 					acpi_parse_lapic, MAX_LOCAL_APIC);
-		has_lapic_cpus = count > 0;
 		x2count = acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_X2APIC,
 					acpi_parse_x2apic, MAX_LOCAL_APIC);
 	}