Add acpi_get_cpu_uid() implementation for x86, replacing the existing
cpu_acpi_id() function. This completes the unified ACPI Processor UID
retrieval interface across all ACPI-enabled architectures.
Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
---
arch/x86/include/asm/cpu.h | 1 -
arch/x86/include/asm/smp.h | 1 -
arch/x86/kernel/cpu/common.c | 15 +++++++++++++++
arch/x86/xen/enlighten_hvm.c | 5 +++--
include/linux/acpi.h | 2 --
5 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index ad235dda1ded..57a0786dfd75 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -11,7 +11,6 @@
#ifndef CONFIG_SMP
#define cpu_physical_id(cpu) boot_cpu_physical_apicid
-#define cpu_acpi_id(cpu) 0
#endif /* CONFIG_SMP */
#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 84951572ab81..05d1d479b4cf 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -130,7 +130,6 @@ __visible void smp_call_function_interrupt(struct pt_regs *regs);
__visible void smp_call_function_single_interrupt(struct pt_regs *r);
#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
-#define cpu_acpi_id(cpu) per_cpu(x86_cpu_to_acpiid, cpu)
/*
* This function is needed by all SMP systems. It must _always_ be valid
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 1c3261cae40c..3081557542c7 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -28,6 +28,7 @@
#include <linux/stackprotector.h>
#include <linux/utsname.h>
#include <linux/efi.h>
+#include <linux/acpi.h>
#include <asm/alternative.h>
#include <asm/cmdline.h>
@@ -57,6 +58,7 @@
#include <asm/asm.h>
#include <asm/bugs.h>
#include <asm/cpu.h>
+#include <asm/smp.h>
#include <asm/mce.h>
#include <asm/msr.h>
#include <asm/cacheinfo.h>
@@ -2643,3 +2645,16 @@ void __init arch_cpu_finalize_init(void)
*/
mem_encrypt_init();
}
+
+int acpi_get_cpu_uid(unsigned int cpu, u32 *uid)
+{
+ if (cpu >= nr_cpu_ids)
+ return -EINVAL;
+#ifndef CONFIG_SMP
+ *uid = 0;
+#else
+ *uid = per_cpu(x86_cpu_to_acpiid, cpu);
+#endif
+ return 0;
+}
+EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
index fe57ff85d004..2f9fa27e5a3c 100644
--- a/arch/x86/xen/enlighten_hvm.c
+++ b/arch/x86/xen/enlighten_hvm.c
@@ -151,6 +151,7 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs)
static int xen_cpu_up_prepare_hvm(unsigned int cpu)
{
+ u32 cpu_uid;
int rc = 0;
/*
@@ -161,8 +162,8 @@ static int xen_cpu_up_prepare_hvm(unsigned int cpu)
*/
xen_uninit_lock_cpu(cpu);
- if (cpu_acpi_id(cpu) != CPU_ACPIID_INVALID)
- per_cpu(xen_vcpu_id, cpu) = cpu_acpi_id(cpu);
+ if (acpi_get_cpu_uid(cpu, &cpu_uid) == 0)
+ per_cpu(xen_vcpu_id, cpu) = cpu_uid;
else
per_cpu(xen_vcpu_id, cpu) = cpu;
xen_vcpu_setup(cpu);
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 035094a55f18..90a1fdcb7eb9 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -324,7 +324,6 @@ int acpi_unmap_cpu(int cpu);
acpi_handle acpi_get_processor_handle(int cpu);
-#ifndef CONFIG_X86
/*
* acpi_get_cpu_uid() - Get ACPI Processor UID of a specified CPU from MADT table
* @cpu: Logical CPU number (0-based)
@@ -335,7 +334,6 @@ acpi_handle acpi_get_processor_handle(int cpu);
* -ENODEV if the ACPI Processor UID for the specified CPU is not found.
*/
int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
-#endif
#ifdef CONFIG_ACPI_HOTPLUG_IOAPIC
int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
--
2.17.1
On Thu, Mar 12, 2026 at 03:23:15PM +0800, Chengwen Feng wrote:
> Add acpi_get_cpu_uid() implementation for x86, replacing the existing
> cpu_acpi_id() function. This completes the unified ACPI Processor UID
> retrieval interface across all ACPI-enabled architectures.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> arch/x86/include/asm/cpu.h | 1 -
> arch/x86/include/asm/smp.h | 1 -
> arch/x86/kernel/cpu/common.c | 15 +++++++++++++++
> arch/x86/xen/enlighten_hvm.c | 5 +++--
> include/linux/acpi.h | 2 --
> 5 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
> index ad235dda1ded..57a0786dfd75 100644
> --- a/arch/x86/include/asm/cpu.h
> +++ b/arch/x86/include/asm/cpu.h
> @@ -11,7 +11,6 @@
>
> #ifndef CONFIG_SMP
> #define cpu_physical_id(cpu) boot_cpu_physical_apicid
> -#define cpu_acpi_id(cpu) 0
> #endif /* CONFIG_SMP */
>
> #ifdef CONFIG_HOTPLUG_CPU
> diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
> index 84951572ab81..05d1d479b4cf 100644
> --- a/arch/x86/include/asm/smp.h
> +++ b/arch/x86/include/asm/smp.h
> @@ -130,7 +130,6 @@ __visible void smp_call_function_interrupt(struct pt_regs *regs);
> __visible void smp_call_function_single_interrupt(struct pt_regs *r);
>
> #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
> -#define cpu_acpi_id(cpu) per_cpu(x86_cpu_to_acpiid, cpu)
>
> /*
> * This function is needed by all SMP systems. It must _always_ be valid
> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
> index 1c3261cae40c..3081557542c7 100644
> --- a/arch/x86/kernel/cpu/common.c
> +++ b/arch/x86/kernel/cpu/common.c
> @@ -28,6 +28,7 @@
> #include <linux/stackprotector.h>
> #include <linux/utsname.h>
> #include <linux/efi.h>
> +#include <linux/acpi.h>
>
> #include <asm/alternative.h>
> #include <asm/cmdline.h>
> @@ -57,6 +58,7 @@
> #include <asm/asm.h>
> #include <asm/bugs.h>
> #include <asm/cpu.h>
> +#include <asm/smp.h>
> #include <asm/mce.h>
> #include <asm/msr.h>
> #include <asm/cacheinfo.h>
> @@ -2643,3 +2645,16 @@ void __init arch_cpu_finalize_init(void)
> */
> mem_encrypt_init();
> }
> +
> +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid)
> +{
> + if (cpu >= nr_cpu_ids)
> + return -EINVAL;
> +#ifndef CONFIG_SMP
> + *uid = 0;
> +#else
> + *uid = per_cpu(x86_cpu_to_acpiid, cpu);
> +#endif
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
> diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
> index fe57ff85d004..2f9fa27e5a3c 100644
> --- a/arch/x86/xen/enlighten_hvm.c
> +++ b/arch/x86/xen/enlighten_hvm.c
> @@ -151,6 +151,7 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs)
>
> static int xen_cpu_up_prepare_hvm(unsigned int cpu)
> {
> + u32 cpu_uid;
> int rc = 0;
>
> /*
> @@ -161,8 +162,8 @@ static int xen_cpu_up_prepare_hvm(unsigned int cpu)
> */
> xen_uninit_lock_cpu(cpu);
>
> - if (cpu_acpi_id(cpu) != CPU_ACPIID_INVALID)
> - per_cpu(xen_vcpu_id, cpu) = cpu_acpi_id(cpu);
> + if (acpi_get_cpu_uid(cpu, &cpu_uid) == 0)
> + per_cpu(xen_vcpu_id, cpu) = cpu_uid;
> else
> per_cpu(xen_vcpu_id, cpu) = cpu;
> xen_vcpu_setup(cpu);
This doesn't look right, it will now set CPU_ACPIID_INVALID, while
previously it would not.
On 3/12/2026 7:02 PM, Peter Zijlstra wrote:
> On Thu, Mar 12, 2026 at 03:23:15PM +0800, Chengwen Feng wrote:
>> Add acpi_get_cpu_uid() implementation for x86, replacing the existing
>> cpu_acpi_id() function. This completes the unified ACPI Processor UID
>> retrieval interface across all ACPI-enabled architectures.
>>
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> ---
>> arch/x86/include/asm/cpu.h | 1 -
>> arch/x86/include/asm/smp.h | 1 -
>> arch/x86/kernel/cpu/common.c | 15 +++++++++++++++
>> arch/x86/xen/enlighten_hvm.c | 5 +++--
>> include/linux/acpi.h | 2 --
>> 5 files changed, 18 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
>> index ad235dda1ded..57a0786dfd75 100644
>> --- a/arch/x86/include/asm/cpu.h
>> +++ b/arch/x86/include/asm/cpu.h
>> @@ -11,7 +11,6 @@
>>
>> #ifndef CONFIG_SMP
>> #define cpu_physical_id(cpu) boot_cpu_physical_apicid
>> -#define cpu_acpi_id(cpu) 0
>> #endif /* CONFIG_SMP */
>>
>> #ifdef CONFIG_HOTPLUG_CPU
>> diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
>> index 84951572ab81..05d1d479b4cf 100644
>> --- a/arch/x86/include/asm/smp.h
>> +++ b/arch/x86/include/asm/smp.h
>> @@ -130,7 +130,6 @@ __visible void smp_call_function_interrupt(struct pt_regs *regs);
>> __visible void smp_call_function_single_interrupt(struct pt_regs *r);
>>
>> #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
>> -#define cpu_acpi_id(cpu) per_cpu(x86_cpu_to_acpiid, cpu)
>>
>> /*
>> * This function is needed by all SMP systems. It must _always_ be valid
>> diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
>> index 1c3261cae40c..3081557542c7 100644
>> --- a/arch/x86/kernel/cpu/common.c
>> +++ b/arch/x86/kernel/cpu/common.c
>> @@ -28,6 +28,7 @@
>> #include <linux/stackprotector.h>
>> #include <linux/utsname.h>
>> #include <linux/efi.h>
>> +#include <linux/acpi.h>
>>
>> #include <asm/alternative.h>
>> #include <asm/cmdline.h>
>> @@ -57,6 +58,7 @@
>> #include <asm/asm.h>
>> #include <asm/bugs.h>
>> #include <asm/cpu.h>
>> +#include <asm/smp.h>
>> #include <asm/mce.h>
>> #include <asm/msr.h>
>> #include <asm/cacheinfo.h>
>> @@ -2643,3 +2645,16 @@ void __init arch_cpu_finalize_init(void)
>> */
>> mem_encrypt_init();
>> }
>> +
>> +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid)
>> +{
>> + if (cpu >= nr_cpu_ids)
>> + return -EINVAL;
>> +#ifndef CONFIG_SMP
>> + *uid = 0;
>> +#else
>> + *uid = per_cpu(x86_cpu_to_acpiid, cpu);
>> +#endif
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
>> diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c
>> index fe57ff85d004..2f9fa27e5a3c 100644
>> --- a/arch/x86/xen/enlighten_hvm.c
>> +++ b/arch/x86/xen/enlighten_hvm.c
>> @@ -151,6 +151,7 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs)
>>
>> static int xen_cpu_up_prepare_hvm(unsigned int cpu)
>> {
>> + u32 cpu_uid;
>> int rc = 0;
>>
>> /*
>> @@ -161,8 +162,8 @@ static int xen_cpu_up_prepare_hvm(unsigned int cpu)
>> */
>> xen_uninit_lock_cpu(cpu);
>>
>> - if (cpu_acpi_id(cpu) != CPU_ACPIID_INVALID)
>> - per_cpu(xen_vcpu_id, cpu) = cpu_acpi_id(cpu);
>> + if (acpi_get_cpu_uid(cpu, &cpu_uid) == 0)
>> + per_cpu(xen_vcpu_id, cpu) = cpu_uid;
>> else
>> per_cpu(xen_vcpu_id, cpu) = cpu;
>> xen_vcpu_setup(cpu);
>
> This doesn't look right, it will now set CPU_ACPIID_INVALID, while
> previously it would not.
This is indeed an issue, it has been fixed in v7 (by treating CPU_ACPIID_INVALID as an error).
Thanks
>
>
On Thu, 12 Mar 2026 15:23:15 +0800 Chengwen Feng <fengchengwen@huawei.com> wrote: > Add acpi_get_cpu_uid() implementation for x86, replacing the existing > cpu_acpi_id() function. This completes the unified ACPI Processor UID > retrieval interface across all ACPI-enabled architectures. > > Cc: stable@vger.kernel.org > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
© 2016 - 2026 Red Hat, Inc.