Skip to content

Commit adbf61c

Browse files
yghannamingomolnar
authored andcommitted
x86/acpi/boot: Correct acpi_is_processor_usable() check again
ACPI v6.3 defined a new "Online Capable" MADT LAPIC flag. This bit is used in conjunction with the "Enabled" MADT LAPIC flag to determine if a CPU can be enabled/hotplugged by the OS after boot. Before the new bit was defined, the "Enabled" bit was explicitly described like this (ACPI v6.0 wording provided): "If zero, this processor is unusable, and the operating system support will not attempt to use it" This means that CPU hotplug (based on MADT) is not possible. Many BIOS implementations follow this guidance. They may include LAPIC entries in MADT for unavailable CPUs, but since these entries are marked with "Enabled=0" it is expected that the OS will completely ignore these entries. However, QEMU will do the same (include entries with "Enabled=0") for the purpose of allowing CPU hotplug within the guest. Comment from QEMU function pc_madt_cpu_entry(): /* ACPI spec says that LAPIC entry for non present * CPU may be omitted from MADT or it must be marked * as disabled. However omitting non present CPU from * MADT breaks hotplug on linux. So possible CPUs * should be put in MADT but kept disabled. */ Recent Linux topology changes broke the QEMU use case. A following fix for the QEMU use case broke bare metal topology enumeration. Rework the Linux MADT LAPIC flags check to allow the QEMU use case only for guests and to maintain the ACPI spec behavior for bare metal. Remove an unnecessary check added to fix a bare metal case introduced by the QEMU "fix". [ bp: Change logic as Michal suggested. ] [ mingo: Removed misapplied -stable tag. ] Fixes: fed8d87 ("x86/acpi/boot: Correct acpi_is_processor_usable() check") Fixes: f0551af ("x86/topology: Ignore non-present APIC IDs in a present package") Closes: https://lore.kernel.org/r/20251024204658.3da9bf3f.michal.pecio@gmail.com Reported-by: Michal Pecio <michal.pecio@gmail.com> Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Tested-by: Michal Pecio <michal.pecio@gmail.com> Tested-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com> Link: https://lore.kernel.org/20251111145357.4031846-1-yazen.ghannam@amd.com Cc: stable@vger.kernel.org
1 parent 8f0b4cc commit adbf61c

2 files changed

Lines changed: 8 additions & 19 deletions

File tree

arch/x86/kernel/acpi/boot.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <asm/smp.h>
3636
#include <asm/i8259.h>
3737
#include <asm/setup.h>
38+
#include <asm/hypervisor.h>
3839

3940
#include "sleep.h" /* To include x86_acpi_suspend_lowlevel */
4041
static int __initdata acpi_force = 0;
@@ -164,11 +165,14 @@ static bool __init acpi_is_processor_usable(u32 lapic_flags)
164165
if (lapic_flags & ACPI_MADT_ENABLED)
165166
return true;
166167

167-
if (!acpi_support_online_capable ||
168-
(lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
169-
return true;
168+
if (acpi_support_online_capable)
169+
return lapic_flags & ACPI_MADT_ONLINE_CAPABLE;
170170

171-
return false;
171+
/*
172+
* QEMU expects legacy "Enabled=0" LAPIC entries to be counted as usable
173+
* in order to support CPU hotplug in guests.
174+
*/
175+
return !hypervisor_is_type(X86_HYPER_NATIVE);
172176
}
173177

174178
static int __init

arch/x86/kernel/cpu/topology.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <xen/xen.h>
2828

2929
#include <asm/apic.h>
30-
#include <asm/hypervisor.h>
3130
#include <asm/io_apic.h>
3231
#include <asm/mpspec.h>
3332
#include <asm/msr.h>
@@ -236,20 +235,6 @@ static __init void topo_register_apic(u32 apic_id, u32 acpi_id, bool present)
236235
cpuid_to_apicid[cpu] = apic_id;
237236
topo_set_cpuids(cpu, apic_id, acpi_id);
238237
} else {
239-
u32 pkgid = topo_apicid(apic_id, TOPO_PKG_DOMAIN);
240-
241-
/*
242-
* Check for present APICs in the same package when running
243-
* on bare metal. Allow the bogosity in a guest.
244-
*/
245-
if (hypervisor_is_type(X86_HYPER_NATIVE) &&
246-
topo_unit_count(pkgid, TOPO_PKG_DOMAIN, phys_cpu_present_map)) {
247-
pr_info_once("Ignoring hot-pluggable APIC ID %x in present package.\n",
248-
apic_id);
249-
topo_info.nr_rejected_cpus++;
250-
return;
251-
}
252-
253238
topo_info.nr_disabled_cpus++;
254239
}
255240

0 commit comments

Comments
 (0)