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

Configure Feed

Select the types of activity you want to include in your feed.

x86/acpi: Add acpi_get_cpu_uid() for unified ACPI CPU UID retrieval

As a step towards unifying the interface for retrieving ACPI CPU UID
across architectures, introduce a new function acpi_get_cpu_uid() for
x86. While at it, add input validation to make the code more robust.

Update Xen-related code to use acpi_get_cpu_uid() instead of the legacy
cpu_acpi_id() function, and remove the now-unused cpu_acpi_id() to clean
up redundant code.

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://patch.msgid.link/20260401081640.26875-5-fengchengwen@huawei.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Chengwen Feng and committed by
Rafael J. Wysocki
3cfe889f 0c823199

+25 -4
+2
arch/x86/include/asm/acpi.h
··· 157 157 return !!acpi_lapic; 158 158 } 159 159 160 + int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); 161 + 160 162 #define ACPI_HAVE_ARCH_SET_ROOT_POINTER 161 163 static __always_inline void acpi_arch_set_root_pointer(u64 addr) 162 164 {
-1
arch/x86/include/asm/cpu.h
··· 11 11 12 12 #ifndef CONFIG_SMP 13 13 #define cpu_physical_id(cpu) boot_cpu_physical_apicid 14 - #define cpu_acpi_id(cpu) 0 15 14 #endif /* CONFIG_SMP */ 16 15 17 16 #ifdef CONFIG_HOTPLUG_CPU
-1
arch/x86/include/asm/smp.h
··· 130 130 __visible void smp_call_function_single_interrupt(struct pt_regs *r); 131 131 132 132 #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) 133 - #define cpu_acpi_id(cpu) per_cpu(x86_cpu_to_acpiid, cpu) 134 133 135 134 /* 136 135 * This function is needed by all SMP systems. It must _always_ be valid
+20
arch/x86/kernel/acpi/boot.c
··· 1848 1848 x86_acpi_os_ioremap; 1849 1849 EXPORT_SYMBOL_GPL(acpi_os_ioremap); 1850 1850 #endif 1851 + 1852 + int acpi_get_cpu_uid(unsigned int cpu, u32 *uid) 1853 + { 1854 + u32 acpi_id; 1855 + 1856 + if (cpu >= nr_cpu_ids) 1857 + return -EINVAL; 1858 + 1859 + #ifdef CONFIG_SMP 1860 + acpi_id = per_cpu(x86_cpu_to_acpiid, cpu); 1861 + if (acpi_id == CPU_ACPIID_INVALID) 1862 + return -ENODEV; 1863 + #else 1864 + acpi_id = 0; 1865 + #endif 1866 + 1867 + *uid = acpi_id; 1868 + return 0; 1869 + } 1870 + EXPORT_SYMBOL_GPL(acpi_get_cpu_uid);
+3 -2
arch/x86/xen/enlighten_hvm.c
··· 151 151 152 152 static int xen_cpu_up_prepare_hvm(unsigned int cpu) 153 153 { 154 + u32 cpu_uid; 154 155 int rc = 0; 155 156 156 157 /* ··· 162 161 */ 163 162 xen_uninit_lock_cpu(cpu); 164 163 165 - if (cpu_acpi_id(cpu) != CPU_ACPIID_INVALID) 166 - per_cpu(xen_vcpu_id, cpu) = cpu_acpi_id(cpu); 164 + if (acpi_get_cpu_uid(cpu, &cpu_uid) == 0) 165 + per_cpu(xen_vcpu_id, cpu) = cpu_uid; 167 166 else 168 167 per_cpu(xen_vcpu_id, cpu) = cpu; 169 168 xen_vcpu_setup(cpu);