Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Chengwen Feng <fengchengwen@huawei.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	x86@kernel.org, liuyonglong@huawei.com,
	anshuman.khandual@arm.com, linux-doc@vger.kernel.org,
	Kees Cook <kees@kernel.org>,
	linux-pci@vger.kernel.org,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Eric.VanTassell@amd.com, fengchengwen@huawei.com,
	Somnath Kotur <somnath.kotur@broadcom.com>,
	Kai Huang <kai.huang@intel.com>,
	Kevin Loughlin <kevinloughlin@google.com>,
	punit.agrawal@oss.qualcomm.com, "H . Peter Anvin" <hpa@zytor.com>,
	Ilkka Koskinen <ilkka@os.amperecomputing.com>,
	WANG Xuerui <kernel@xen0n.name>,
	Thorsten Blum <thorsten.blum@linux.dev>,
	linux-acpi@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
	masahiroy@kernel.org, Yanteng Si <si.yanteng@linux.dev>,
	linux-riscv@lists.infradead.org,
	Peter Zijlstra <peterz@infradead.org>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	linux-arm-kernel@lists.infradead.org,
	xen-devel@lists.xenproject.org, Zheyun Shen <szy0127@sjtu.edu.cn>,
	Len Brown <lenb@kernel.org>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Thomas Huth <thuth@redhat.com>,
	ryan.roberts@arm.com, "Ahmed S . Darwish" <darwi@linutronix.de>,
	Ma Ke <make24@iscas.ac.cn>,
	suzuki.poulose@arm.com, James Clark <james.clark@linaro.org>,
	Wei Huang <wei.huang2@amd.com>,
	Besar Wicaksono <bwicaksono@nvidia.com>,
	loongarch@lists.linux.dev,
	Jonathan Cameron <jonathan.cameron@huawei.com>,
	Sohil Mehta <sohil.mehta@intel.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Xin Li <xin@zytor.com>,
	Andy Gospodarek <andrew.gospodarek@broadcom.com>,
	wanghuiqiang@huawei.com, Juergen Gross <jgross@suse.com>,
	wangyuquan1236@phytium.com.cn,
	Sean Christopherson <seanjc@google.com>,
	guohanjun@huawei.com, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, linux-perf-users@vger.kernel.org,
	wangzhou1@hisilicon.com, Thomas Gleixner <tglx@kernel.org>,
	heinrich.schuchardt@canonical.com, chenl311@chinatelecom.cn,
	Robin Murphy <robin.murphy@arm.com>
Subject: [PATCH RESEND v10 4/8] x86/acpi: Add acpi_get_cpu_uid() for unified ACPI CPU UID retrieval
Date: Wed, 1 Apr 2026 16:16:36 +0800	[thread overview]
Message-ID: <20260401081640.26875-5-fengchengwen@huawei.com> (raw)
In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com>

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.

Cc: stable@vger.kernel.org
Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
---
 arch/x86/include/asm/acpi.h  |  2 ++
 arch/x86/include/asm/cpu.h   |  1 -
 arch/x86/include/asm/smp.h   |  1 -
 arch/x86/kernel/acpi/boot.c  | 20 ++++++++++++++++++++
 arch/x86/xen/enlighten_hvm.c |  5 +++--
 5 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h
index a03aa6f999d1..92b5c27c4fea 100644
--- a/arch/x86/include/asm/acpi.h
+++ b/arch/x86/include/asm/acpi.h
@@ -157,6 +157,8 @@ static inline bool acpi_has_cpu_in_madt(void)
 	return !!acpi_lapic;
 }
 
+int acpi_get_cpu_uid(unsigned int cpu, u32 *uid);
+
 #define ACPI_HAVE_ARCH_SET_ROOT_POINTER
 static __always_inline void acpi_arch_set_root_pointer(u64 addr)
 {
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/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index a3f2fb1fea1b..ceba24f65ae3 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1848,3 +1848,23 @@ void __iomem * (*acpi_os_ioremap)(acpi_physical_address phys, acpi_size size) =
 	x86_acpi_os_ioremap;
 EXPORT_SYMBOL_GPL(acpi_os_ioremap);
 #endif
+
+int acpi_get_cpu_uid(unsigned int cpu, u32 *uid)
+{
+	u32 acpi_id;
+
+	if (cpu >= nr_cpu_ids)
+		return -EINVAL;
+
+#ifdef CONFIG_SMP
+	acpi_id = per_cpu(x86_cpu_to_acpiid, cpu);
+	if (acpi_id == CPU_ACPIID_INVALID)
+		return -ENODEV;
+#else
+	acpi_id = 0;
+#endif
+
+	*uid = acpi_id;
+	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);
-- 
2.17.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2026-04-01  8:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01  8:16 [PATCH RESEND v10 0/8] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Chengwen Feng
2026-04-01  8:16 ` [PATCH RESEND v10 1/8] arm64: acpi: Add acpi_get_cpu_uid() for unified ACPI CPU UID retrieval Chengwen Feng
2026-04-01  8:16 ` [PATCH RESEND v10 2/8] LoongArch: " Chengwen Feng
2026-04-01  8:16 ` [PATCH RESEND v10 3/8] RISC-V: ACPI: " Chengwen Feng
2026-04-01  8:16 ` Chengwen Feng [this message]
2026-04-01  8:16 ` [PATCH RESEND v10 5/8] ACPI: Centralize acpi_get_cpu_uid() declaration in include/linux/acpi.h Chengwen Feng
2026-04-01  8:16 ` [PATCH RESEND v10 6/8] perf: arm_cspmu: Switch to acpi_get_cpu_uid() from get_acpi_id_for_cpu() Chengwen Feng
2026-04-01  8:16 ` [PATCH RESEND v10 7/8] ACPI: PPTT: Use acpi_get_cpu_uid() and remove get_acpi_id_for_cpu() Chengwen Feng
2026-04-01  8:16 ` [PATCH RESEND v10 8/8] PCI/TPH: Pass ACPI Processor UID to Cache Locality _DSM Chengwen Feng
2026-04-06 14:58 ` [PATCH RESEND v10 0/8] ACPI: Unify CPU UID interface and fix ARM64 TPH steer-tag issue Rafael J. Wysocki
2026-04-30  3:25 ` patchwork-bot+linux-riscv

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260401081640.26875-5-fengchengwen@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=Eric.VanTassell@amd.com \
    --cc=andrew.gospodarek@broadcom.com \
    --cc=anshuman.khandual@arm.com \
    --cc=bhelgaas@google.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bwicaksono@nvidia.com \
    --cc=catalin.marinas@arm.com \
    --cc=chenl311@chinatelecom.cn \
    --cc=corbet@lwn.net \
    --cc=darwi@linutronix.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=guohanjun@huawei.com \
    --cc=heinrich.schuchardt@canonical.com \
    --cc=hpa@zytor.com \
    --cc=ilkka@os.amperecomputing.com \
    --cc=james.clark@linaro.org \
    --cc=jgross@suse.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=kai.huang@intel.com \
    --cc=kees@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=kevinloughlin@google.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=liuyonglong@huawei.com \
    --cc=loongarch@lists.linux.dev \
    --cc=make24@iscas.ac.cn \
    --cc=mark.rutland@arm.com \
    --cc=masahiroy@kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=punit.agrawal@oss.qualcomm.com \
    --cc=rafael@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=ryan.roberts@arm.com \
    --cc=seanjc@google.com \
    --cc=si.yanteng@linux.dev \
    --cc=sohil.mehta@intel.com \
    --cc=somnath.kotur@broadcom.com \
    --cc=stable@vger.kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=szy0127@sjtu.edu.cn \
    --cc=tglx@kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=thorsten.blum@linux.dev \
    --cc=thuth@redhat.com \
    --cc=wanghuiqiang@huawei.com \
    --cc=wangyuquan1236@phytium.com.cn \
    --cc=wangzhou1@hisilicon.com \
    --cc=wei.huang2@amd.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=xin@zytor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox