Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpu/hotplug, x86/acpi: Disable CPU offlining for ACPI MADT wakeup

ACPI MADT doesn't allow to offline a CPU after it has been woken up.

Currently, CPU hotplug is prevented based on the confidential computing
attribute which is set for Intel TDX. But TDX is not the only possible user of
the wake up method. Any platform that uses ACPI MADT wakeup method cannot
offline CPU.

Disable CPU offlining on ACPI MADT wakeup enumeration.

This has no visible effects for users: currently, TDX guest is the only platform
that uses the ACPI MADT wakeup method.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Tao Liu <ltao@redhat.com>
Link: https://lore.kernel.org/r/20240614095904.1345461-5-kirill.shutemov@linux.intel.com

authored by

Kirill A. Shutemov and committed by
Borislav Petkov (AMD)
66e48e49 1037e4c5

+4 -13
-1
arch/x86/coco/core.c
··· 29 29 { 30 30 switch (attr) { 31 31 case CC_ATTR_GUEST_UNROLL_STRING_IO: 32 - case CC_ATTR_HOTPLUG_DISABLED: 33 32 case CC_ATTR_GUEST_MEM_ENCRYPT: 34 33 case CC_ATTR_MEM_ENCRYPT: 35 34 return true;
+3
arch/x86/kernel/acpi/madt_wakeup.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 #include <linux/acpi.h> 3 + #include <linux/cpu.h> 3 4 #include <linux/io.h> 4 5 #include <asm/apic.h> 5 6 #include <asm/barrier.h> ··· 76 75 acpi_table_print_madt_entry(&header->common); 77 76 78 77 acpi_mp_wake_mailbox_paddr = mp_wake->base_address; 78 + 79 + cpu_hotplug_disable_offlining(); 79 80 80 81 apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); 81 82
-10
include/linux/cc_platform.h
··· 82 82 CC_ATTR_GUEST_SEV_SNP, 83 83 84 84 /** 85 - * @CC_ATTR_HOTPLUG_DISABLED: Hotplug is not supported or disabled. 86 - * 87 - * The platform/OS is running as a guest/virtual machine does not 88 - * support CPU hotplug feature. 89 - * 90 - * Examples include TDX Guest. 91 - */ 92 - CC_ATTR_HOTPLUG_DISABLED, 93 - 94 - /** 95 85 * @CC_ATTR_HOST_SEV_SNP: AMD SNP enabled on the host. 96 86 * 97 87 * The host kernel is running with the necessary features
+1 -2
kernel/cpu.c
··· 1481 1481 * If the platform does not support hotplug, report it explicitly to 1482 1482 * differentiate it from a transient offlining failure. 1483 1483 */ 1484 - if (cc_platform_has(CC_ATTR_HOTPLUG_DISABLED) || 1485 - cpu_hotplug_offline_disabled) 1484 + if (cpu_hotplug_offline_disabled) 1486 1485 return -EOPNOTSUPP; 1487 1486 if (cpu_hotplug_disabled) 1488 1487 return -EBUSY;