Skip to content

Commit e2869bd

Browse files
kishonvijayabrahambp3tk0v
authored andcommitted
x86/acpi/boot: Do not register processors that cannot be onlined for x2APIC
Section 5.2.12.12 Processor Local x2APIC Structure in the ACPI v6.5 spec mandates that both "enabled" and "online capable" Local APIC Flags should be used to determine if the processor is usable or not. However, Linux doesn't use the "online capable" flag for x2APIC to determine if the processor is usable. As a result, cpu_possible_mask has incorrect value and results in more memory getting allocated for per_cpu variables than it is going to be used. Make sure Linux parses both "enabled" and "online capable" flags for x2APIC to correctly determine if the processor is usable. Fixes: aa06e20 ("x86/ACPI: Don't add CPUs that are not online capable") Reported-by: Leo Duran <[email protected]> Signed-off-by: Kishon Vijay Abraham I <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Zhang Rui <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5353fff commit e2869bd

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

arch/x86/kernel/acpi/boot.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
188188
return cpu;
189189
}
190190

191+
static bool __init acpi_is_processor_usable(u32 lapic_flags)
192+
{
193+
if (lapic_flags & ACPI_MADT_ENABLED)
194+
return true;
195+
196+
if (acpi_support_online_capable && (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
197+
return true;
198+
199+
return false;
200+
}
201+
191202
static int __init
192203
acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
193204
{
@@ -212,6 +223,10 @@ acpi_parse_x2apic(union acpi_subtable_headers *header, const unsigned long end)
212223
if (apic_id == 0xffffffff)
213224
return 0;
214225

226+
/* don't register processors that cannot be onlined */
227+
if (!acpi_is_processor_usable(processor->lapic_flags))
228+
return 0;
229+
215230
/*
216231
* We need to register disabled CPU as well to permit
217232
* counting disabled CPUs. This allows us to size
@@ -250,9 +265,7 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
250265
return 0;
251266

252267
/* don't register processors that can not be onlined */
253-
if (acpi_support_online_capable &&
254-
!(processor->lapic_flags & ACPI_MADT_ENABLED) &&
255-
!(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
268+
if (!acpi_is_processor_usable(processor->lapic_flags))
256269
return 0;
257270

258271
/*

0 commit comments

Comments
 (0)