From nobody Mon Mar 23 21:30:47 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=1773903509; cv=none; d=zohomail.com; s=zohoarc; b=h0hlvx8CEXYWx3CPcpEc7eMmVxRURT4aXoHWGpeO4SFvS5MvKlGO0nujPMt4ohHPkB8jv9ah794l71/oT3YsZ8a82u1vuDqu3eTV62+lhk2MSkx2Uf+iaonZ7OKGvQN9CJ+nHNOmIOQy5xCkVHwV71UkGW1D7NDn7Fe3jcqo0Is= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773903509; 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=1LtXSgcAkmn0PF4spa6njy7dooXhT6HaBBUxjinTlGk=; b=PimxXoy72hzzkVBCh70jvf0ONBX5wmOCCWwZPwOfBA+LaeqYJsEQX8BptpsA5Snll6Ocow4fY9PkmV/vVseSRSpkmRVBaGX3n194beeabEX9UbSppme7Kj0uJ9nU8l2lj8yxRz+PFNa98fLZnH1exfKKYHISewjrv0M3p+vfwgQ= 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 1773903509786831.1760927888001; Wed, 18 Mar 2026 23:58:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1256664.1551199 (Exim 4.92) (envelope-from ) id 1w37KT-0004fv-FZ; Thu, 19 Mar 2026 06:58:01 +0000 Received: by outflank-mailman (output) from mailman id 1256664.1551199; 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-0004fn-Bi; Thu, 19 Mar 2026 06:58:01 +0000 Received: by outflank-mailman (input) for mailman id 1256664; Thu, 19 Mar 2026 06:58:00 +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 1w37KS-0003m8-33 for xen-devel@lists.xenproject.org; Thu, 19 Mar 2026 06:58:00 +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 ef43a9bb-2360-11f1-9ccf-f158ae23cfc8; Thu, 19 Mar 2026 07:57:48 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4fbxFp1D5kznTZF; Thu, 19 Mar 2026 14:52:14 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 5103F40561; Thu, 19 Mar 2026 14:57:45 +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:43 +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: ef43a9bb-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=1LtXSgcAkmn0PF4spa6njy7dooXhT6HaBBUxjinTlGk=; b=Oa0avR/fuCpQTzS1Xgh5wf4j++7qZ/jAEVW8ijiRm8p6S+AYfiPzzTmjoGLIC6Sib+sqhvf4Z cMqAKYfN+c1Au0EeuJL4A3/AYuS/IaW/W2vsRf9IUiBmP7LGEt5BPPDsMSBx4yzrH8AlmATlZ5/ RyDrj0/5gHMF4tFkUTFTf0M= 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 1/7] arm64/acpi: Add acpi_get_cpu_uid() and switch arm_cspmu to use it Date: Thu, 19 Mar 2026 14:57:29 +0800 Message-ID: <20260319065735.45954-2-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: 1773903511285158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add arch-specific acpi_get_cpu_uid() for arm64, and update dependent code: - Declare acpi_get_cpu_uid() in arch/arm64/include/asm/acpi.h - Implement acpi_get_cpu_uid() with input parameter validation - Replace get_acpi_id_for_cpu() with acpi_get_cpu_uid() in drivers/perf/arm_cspmu/arm_cspmu.c - Reimplement get_cpu_for_acpi_id() based on acpi_get_cpu_uid() (to align with new interface) and move its implementation next to acpi_get_cpu_uid() This is the first step towards unifying ACPI CPU UID retrieval interface across architectures, while adding input validation for robustness. Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron --- arch/arm64/include/asm/acpi.h | 14 ++------------ arch/arm64/kernel/acpi.c | 30 ++++++++++++++++++++++++++++++ drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++-- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index c07a58b96329..2219a3301e72 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -118,18 +118,8 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu) { return acpi_cpu_get_madt_gicc(cpu)->uid; } - -static inline int get_cpu_for_acpi_id(u32 uid) -{ - int cpu; - - for (cpu =3D 0; cpu < nr_cpu_ids; cpu++) - if (acpi_cpu_get_madt_gicc(cpu) && - uid =3D=3D get_acpi_id_for_cpu(cpu)) - return cpu; - - return -EINVAL; -} +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); +int get_cpu_for_acpi_id(u32 uid); =20 static inline void arch_fix_phys_package_id(int num, u32 slot) { } void __init acpi_init_cpus(void); diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index af90128cfed5..24b9d934be54 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -458,3 +458,33 @@ int acpi_unmap_cpu(int cpu) } EXPORT_SYMBOL(acpi_unmap_cpu); #endif /* CONFIG_ACPI_HOTPLUG_CPU */ + +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid) +{ + struct acpi_madt_generic_interrupt *gicc; + + if (cpu >=3D nr_cpu_ids) + return -EINVAL; + + gicc =3D acpi_cpu_get_madt_gicc(cpu); + if (!gicc) + return -ENODEV; + + *uid =3D gicc->uid; + return 0; +} +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid); + +int get_cpu_for_acpi_id(u32 uid) +{ + u32 cpu_uid; + int ret; + + 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; + } + + return -EINVAL; +} diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/ar= m_cspmu.c index 34430b68f602..ed72c3d1f796 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -1107,15 +1107,17 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu= *cspmu) { struct acpi_apmt_node *apmt_node; int affinity_flag; + u32 cpu_uid; int cpu; + int ret; =20 apmt_node =3D arm_cspmu_apmt_node(cspmu->dev); affinity_flag =3D apmt_node->flags & ACPI_APMT_FLAGS_AFFINITY; =20 if (affinity_flag =3D=3D ACPI_APMT_FLAGS_AFFINITY_PROC) { for_each_possible_cpu(cpu) { - if (apmt_node->proc_affinity =3D=3D - get_acpi_id_for_cpu(cpu)) { + ret =3D acpi_get_cpu_uid(cpu, &cpu_uid); + if (ret =3D=3D 0 && apmt_node->proc_affinity =3D=3D cpu_uid) { cpumask_set_cpu(cpu, &cspmu->associated_cpus); break; } --=20 2.17.1