Skip to content

Commit db09368

Browse files
kirylbp3tk0v
authored andcommitted
x86/acpi: Do not attempt to bring up secondary CPUs in the kexec case
ACPI MADT doesn't allow to offline a CPU after it was onlined. This limits kexec: the second kernel won't be able to use more than one CPU. To prevent a kexec kernel from onlining secondary CPUs, invalidate the mailbox address in the ACPI MADT wakeup structure which prevents a kexec kernel to use it. This is safe as the booting kernel has the mailbox address cached already and acpi_wakeup_cpu() uses the cached value to bring up the secondary CPUs. Note: This is a Linux specific convention and not covered by the ACPI specification. Signed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Kai Huang <[email protected]> Reviewed-by: Kuppuswamy Sathyanarayanan <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Tested-by: Tao Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6630cbc commit db09368

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

arch/x86/kernel/acpi/madt_wakeup.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox __ro_afte
1414

1515
static int acpi_wakeup_cpu(u32 apicid, unsigned long start_ip)
1616
{
17+
if (!acpi_mp_wake_mailbox_paddr) {
18+
pr_warn_once("No MADT mailbox: cannot bringup secondary CPUs. Booting with kexec?\n");
19+
return -EOPNOTSUPP;
20+
}
21+
1722
/*
1823
* Remap mailbox memory only for the first call to acpi_wakeup_cpu().
1924
*
@@ -64,6 +69,28 @@ static int acpi_wakeup_cpu(u32 apicid, unsigned long start_ip)
6469
return 0;
6570
}
6671

72+
static void acpi_mp_disable_offlining(struct acpi_madt_multiproc_wakeup *mp_wake)
73+
{
74+
cpu_hotplug_disable_offlining();
75+
76+
/*
77+
* ACPI MADT doesn't allow to offline a CPU after it was onlined. This
78+
* limits kexec: the second kernel won't be able to use more than one CPU.
79+
*
80+
* To prevent a kexec kernel from onlining secondary CPUs invalidate the
81+
* mailbox address in the ACPI MADT wakeup structure which prevents a
82+
* kexec kernel to use it.
83+
*
84+
* This is safe as the booting kernel has the mailbox address cached
85+
* already and acpi_wakeup_cpu() uses the cached value to bring up the
86+
* secondary CPUs.
87+
*
88+
* Note: This is a Linux specific convention and not covered by the
89+
* ACPI specification.
90+
*/
91+
mp_wake->mailbox_address = 0;
92+
}
93+
6794
int __init acpi_parse_mp_wake(union acpi_subtable_headers *header,
6895
const unsigned long end)
6996
{
@@ -77,7 +104,7 @@ int __init acpi_parse_mp_wake(union acpi_subtable_headers *header,
77104

78105
acpi_mp_wake_mailbox_paddr = mp_wake->mailbox_address;
79106

80-
cpu_hotplug_disable_offlining();
107+
acpi_mp_disable_offlining(mp_wake);
81108

82109
apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu);
83110

0 commit comments

Comments
 (0)