From nobody Mon Mar 23 21:28:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1773903511; cv=none; d=zohomail.com; s=zohoarc; b=M54YZ/myXTb5wPtB5BSxgRXGdqBLUALmr6KpwLOPr78LbxJr3mCsqakip0/n2tvkGQskiq/fjofPofbwBmp0ZuKljMkH+kZrtHgOPmcOK6ynu2n3pc0pSjI2J6m4QqJ/qaeyKxMSj9ACQaaphvWZF12U0CIeEWOTgwuWvam1E1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773903511; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PORbZUhpQhzjbuApsvH0fxa/MWQvKgK1Jvyh1G8ZdcY=; b=cUbg85ke8vSsOgc+uA2USZubbKKDnYH2OhY6ldLnDtKVry/9k3d5p2E9jNP3fOuSEyGvoREf4OmJucoB3hgu7nG1We+54ZYzQYqeL4uINsOTDS1WYAd0le4ddsstjuNl8Q+luzGpWFyUDRvWFJBOlgHsGV64X4F0Bqrk0iPf9BM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1773903511377117.2686682179226; Wed, 18 Mar 2026 23:58:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1256662.1551176 (Exim 4.92) (envelope-from ) id 1w37KQ-00043L-0Y; Thu, 19 Mar 2026 06:57:58 +0000 Received: by outflank-mailman (output) from mailman id 1256662.1551176; Thu, 19 Mar 2026 06:57:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w37KP-00042n-T6; Thu, 19 Mar 2026 06:57:57 +0000 Received: by outflank-mailman (input) for mailman id 1256662; Thu, 19 Mar 2026 06:57:57 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w37KP-0003m8-0D for xen-devel@lists.xenproject.org; Thu, 19 Mar 2026 06:57:57 +0000 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f2e26a63-2360-11f1-9ccf-f158ae23cfc8; Thu, 19 Mar 2026 07:57:54 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4fbxFw3N4cznTbj; Thu, 19 Mar 2026 14:52:20 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 9F1D140565; Thu, 19 Mar 2026 14:57:51 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 19 Mar 2026 14:57:49 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f2e26a63-2360-11f1-9ccf-f158ae23cfc8 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=PORbZUhpQhzjbuApsvH0fxa/MWQvKgK1Jvyh1G8ZdcY=; b=2/eFya07ZKYvHLC9suiHJtQiDz3ed6rQPINqksGFpjqlzmici8rg+USCdp4afGx6mnnjV7/8N sC1maDZx1p8D5i3n/VAxK7AGG3b5eYoCzJL0jLiVMNEZAWBMkdKSiKTNjyHPSvDA5R0kMbOaF3J gz4K2Ly5bUWgt/t5oBO27bI= From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , Shuah Khan , Huacai Chen , WANG Xuerui , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , Kees Cook , Yanteng Si , Sean Christopherson , Kai Huang , Tom Lendacky , Thomas Huth , Thorsten Blum , Kevin Loughlin , Zheyun Shen , Peter Zijlstra , Pawan Gupta , Xin Li , "Ahmed S . Darwish" , Sohil Mehta , Ilkka Koskinen , Robin Murphy , James Clark , Besar Wicaksono , Ma Ke , Wei Huang , Andy Gospodarek , Somnath Kotur , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v9 4/7] x86/acpi: Add acpi_get_cpu_uid() implementation and update Xen users Date: Thu, 19 Mar 2026 14:57:32 +0800 Message-ID: <20260319065735.45954-5-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260319065735.45954-1-fengchengwen@huawei.com> References: <20260319065735.45954-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemk500009.china.huawei.com (7.202.194.94) X-ZohoMail-DKIM: pass (identity @huawei.com) X-ZM-MESSAGEID: 1773903513336158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add arch-specific acpi_get_cpu_uid() for x86: - Declare acpi_get_cpu_uid() in arch/x86/include/asm/acpi.h - Implement acpi_get_cpu_uid() with input parameter validation - Replace cpu_acpi_id() with acpi_get_cpu_uid() in Xen-related code - Remove the now-unused cpu_acpi_id() function Extend the unified ACPI CPU UID interface to x86, ensuring consistent error handling and input validation across all ACPI-enabled architectures. Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron Reviewed-by: Juergen Gross --- 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; } =20 +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 @@ =20 #ifndef CONFIG_SMP #define cpu_physical_id(cpu) boot_cpu_physical_apicid -#define cpu_acpi_id(cpu) 0 #endif /* CONFIG_SMP */ =20 #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_re= gs *regs); __visible void smp_call_function_single_interrupt(struct pt_regs *r); =20 #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) -#define cpu_acpi_id(cpu) per_cpu(x86_cpu_to_acpiid, cpu) =20 /* * 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_addr= ess phys, acpi_size size) =3D 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 >=3D nr_cpu_ids) + return -EINVAL; + +#ifdef CONFIG_SMP + acpi_id =3D per_cpu(x86_cpu_to_acpiid, cpu); + if (acpi_id =3D=3D CPU_ACPIID_INVALID) + return -ENODEV; +#else + acpi_id =3D 0; +#endif + + *uid =3D 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) =20 static int xen_cpu_up_prepare_hvm(unsigned int cpu) { + u32 cpu_uid; int rc =3D 0; =20 /* @@ -161,8 +162,8 @@ static int xen_cpu_up_prepare_hvm(unsigned int cpu) */ xen_uninit_lock_cpu(cpu); =20 - if (cpu_acpi_id(cpu) !=3D CPU_ACPIID_INVALID) - per_cpu(xen_vcpu_id, cpu) =3D cpu_acpi_id(cpu); + if (acpi_get_cpu_uid(cpu, &cpu_uid) =3D=3D 0) + per_cpu(xen_vcpu_id, cpu) =3D cpu_uid; else per_cpu(xen_vcpu_id, cpu) =3D cpu; xen_vcpu_setup(cpu); --=20 2.17.1