From nobody Mon Mar 23 21:28:58 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=1773903503; cv=none; d=zohomail.com; s=zohoarc; b=WlKBXt9H9Ptm3jJcv92GUYFFGQJNwQ2GgoQHhx7eZJ1v6ro1tjqiPtQNz9nGKR7ByJd7WoA4jwS+p9/hi559JkVn2FAy0gjiX33m6PHGFENKElRrj2ia24JFmGe+rfyV8VN1WrCXrNO0Qg4Q6jUHmmDQIlFiSu1/p2PtaUlSlkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773903503; 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=exD33k43BuQzAEL6nsjKEJKqL7EfNu0IQKwl4k+YbJg=; b=TAaCczEXI5fPlEb2FRkkOh52VWViL95Hbq4e/C5sKSH5AndPM4WeD6jVuvV8kBpOFpPXvfE+7P4Q6JbbwnThjdFqiRVVpeCBUu+bazfInLn0n0Sda0ehu/CuNXdcLn56wSBpmElFn9O6Zx/FcZULXmYA21XUfbJxld907qLrZqg= 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 1773903503922895.3681084450833; Wed, 18 Mar 2026 23:58:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1256665.1551203 (Exim 4.92) (envelope-from ) id 1w37KT-0004mc-WD; Thu, 19 Mar 2026 06:58:02 +0000 Received: by outflank-mailman (output) from mailman id 1256665.1551203; Thu, 19 Mar 2026 06:58:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w37KT-0004lL-Rh; Thu, 19 Mar 2026 06:58:01 +0000 Received: by outflank-mailman (input) for mailman id 1256665; Thu, 19 Mar 2026 06:58:00 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w37KS-0003zM-Pd for xen-devel@lists.xenproject.org; Thu, 19 Mar 2026 06:58:00 +0000 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id f2fc021e-2360-11f1-b164-2bf370ae4941; Thu, 19 Mar 2026 07:57:54 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4fbxFK6m2wz1K9Bp; Thu, 19 Mar 2026 14:51:49 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 7856240561; Thu, 19 Mar 2026 14:57:49 +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:47 +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: f2fc021e-2360-11f1-b164-2bf370ae4941 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=exD33k43BuQzAEL6nsjKEJKqL7EfNu0IQKwl4k+YbJg=; b=TpkbNgrXuFHMaoSxLqV9Sehh2jyBNhzuFTjk04digWx+iZ4u7r0ZO97pTwpdiOPz3O6n3lNJ/ 4V3t97Mi4HDOAvKqXG7pd8g0EWINQftSU1qn9BC94Y+G026NOS1ZPVoH/xNOselntlRacsW/mDN uHBm/USFU8RvNhGQhD/mcZg= 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 3/7] riscv/acpi: Add acpi_get_cpu_uid() implementation and update users Date: Thu, 19 Mar 2026 14:57:31 +0800 Message-ID: <20260319065735.45954-4-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: 1773903505039154100 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add arch-specific acpi_get_cpu_uid() for riscv: - Declare acpi_get_cpu_uid() in arch/riscv/include/asm/acpi.h - Implement acpi_get_cpu_uid() with input parameter validation - Switch rhct.c and arch/riscv/kernel/acpi_numa.c to use acpi_get_cpu_uid() instead of get_acpi_id_for_cpu() This aligns riscv with the unified ACPI CPU UID interface, improving input validation and consistency across ACPI-enabled platforms. Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron --- arch/riscv/include/asm/acpi.h | 1 + arch/riscv/kernel/acpi.c | 16 ++++++++++++++++ arch/riscv/kernel/acpi_numa.c | 9 ++++++--- drivers/acpi/riscv/rhct.c | 7 ++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index 6e13695120bc..f3520cc85af3 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -65,6 +65,7 @@ static inline u32 get_acpi_id_for_cpu(int cpu) { return acpi_cpu_get_madt_rintc(cpu)->uid; } +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); =20 int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const char **isa); diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c index 71698ee11621..322ea92aa39f 100644 --- a/arch/riscv/kernel/acpi.c +++ b/arch/riscv/kernel/acpi.c @@ -337,3 +337,19 @@ int raw_pci_write(unsigned int domain, unsigned int bu= s, } =20 #endif /* CONFIG_PCI */ + +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid) +{ + struct acpi_madt_rintc *rintc; + + if (cpu >=3D nr_cpu_ids) + return -EINVAL; + + rintc =3D acpi_cpu_get_madt_rintc(cpu); + if (!rintc) + return -ENODEV; + + *uid =3D rintc->uid; + return 0; +} +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid); diff --git a/arch/riscv/kernel/acpi_numa.c b/arch/riscv/kernel/acpi_numa.c index 130769e3a99c..6a2d4289f806 100644 --- a/arch/riscv/kernel/acpi_numa.c +++ b/arch/riscv/kernel/acpi_numa.c @@ -37,11 +37,14 @@ static int __init acpi_numa_get_nid(unsigned int cpu) =20 static inline int get_cpu_for_acpi_id(u32 uid) { - int cpu; + u32 cpu_uid; + int ret; =20 - for (cpu =3D 0; cpu < nr_cpu_ids; cpu++) - if (uid =3D=3D get_acpi_id_for_cpu(cpu)) + for (int cpu =3D 0; cpu < nr_cpu_ids; cpu++) { + ret =3D acpi_get_cpu_uid(cpu, &cpu_uid); + if (ret =3D=3D 0 && uid =3D=3D cpu_uid) return cpu; + } =20 return -EINVAL; } diff --git a/drivers/acpi/riscv/rhct.c b/drivers/acpi/riscv/rhct.c index caa2c16e1697..8f3f38c64a88 100644 --- a/drivers/acpi/riscv/rhct.c +++ b/drivers/acpi/riscv/rhct.c @@ -44,10 +44,15 @@ int acpi_get_riscv_isa(struct acpi_table_header *table,= unsigned int cpu, const struct acpi_rhct_isa_string *isa_node; struct acpi_table_rhct *rhct; u32 *hart_info_node_offset; - u32 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); + u32 acpi_cpu_id; + int ret; =20 BUG_ON(acpi_disabled); =20 + ret =3D acpi_get_cpu_uid(cpu, &acpi_cpu_id); + if (ret !=3D 0) + return ret; + if (!table) { rhct =3D acpi_get_rhct(); if (!rhct) --=20 2.17.1