From nobody Wed Dec 17 16:12:17 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5A603563C7; Wed, 17 Dec 2025 10:14:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765966481; cv=none; b=RLKbJsDrQE5VaWSq6iiErduKJ0Zk72xDqySD4nYDqBPIfuD/hOLzxul2Hw2+vdOlJJbHO/dszcUWZYqPIbEmZJLW6N/Ldlse4dEypFunGNdfA292WKQ1rTUPWW24fElBCkB9Zmfe4OfpsD40BuL6ZTVF7VSG2F2hW9yWFDSh8Xs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765966481; c=relaxed/simple; bh=14B43xqkiXjYLxPwYqDTXgUuhPj7aGBC4iZ+41eMxdA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fv0SUxIihtUAsPA4IjHhdQo44p5wmGaAWnGU57oMZzC1anp8a8yPiD7uncTNqD/v8X0X3/lYwNprElg7CsON3WB89Rth8v6SbvyGrLMgtHVodijSaIn6Vkx/mLTUWD6v9r4elYAyea48/Y10X8wzy98RcnwU6CDriPGcgBB1oF4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 509F71517; Wed, 17 Dec 2025 02:14:32 -0800 (PST) Received: from e122027.arm.com (unknown [10.57.45.201]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9680F3F73B; Wed, 17 Dec 2025 02:14:35 -0800 (PST) From: Steven Price To: kvm@vger.kernel.org, kvmarm@lists.linux.dev Cc: Steven Price , Catalin Marinas , Marc Zyngier , Will Deacon , James Morse , Oliver Upton , Suzuki K Poulose , Zenghui Yu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Joey Gouly , Alexandru Elisei , Christoffer Dall , Fuad Tabba , linux-coco@lists.linux.dev, Ganapatrao Kulkarni , Gavin Shan , Shanker Donthineni , Alper Gun , "Aneesh Kumar K . V" , Emi Kisanuki , Vishal Annapurve Subject: [PATCH v12 36/46] arm_pmu: Provide a mechanism for disabling the physical IRQ Date: Wed, 17 Dec 2025 10:11:13 +0000 Message-ID: <20251217101125.91098-37-steven.price@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251217101125.91098-1-steven.price@arm.com> References: <20251217101125.91098-1-steven.price@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Arm CCA assigns the physical PMU device to the guest running in realm world, however the IRQs are routed via the host. To enter a realm guest while a PMU IRQ is pending it is necessary to block the physical IRQ to prevent an immediate exit. Provide a mechanism in the PMU driver for KVM to control the physical IRQ. Signed-off-by: Steven Price Reviewed-by: Gavin Shan --- v3: Add a dummy function for the !CONFIG_ARM_PMU case. --- drivers/perf/arm_pmu.c | 15 +++++++++++++++ include/linux/perf/arm_pmu.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c index c94494db06f5..6705c61c73c2 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -751,6 +751,21 @@ static int arm_perf_teardown_cpu(unsigned int cpu, str= uct hlist_node *node) return 0; } =20 +void arm_pmu_set_phys_irq(bool enable) +{ + int cpu =3D get_cpu(); + struct arm_pmu *pmu =3D per_cpu(cpu_armpmu, cpu); + int irq; + + irq =3D armpmu_get_cpu_irq(pmu, cpu); + if (irq && !enable) + per_cpu(cpu_irq_ops, cpu)->disable_pmuirq(irq); + else if (irq && enable) + per_cpu(cpu_irq_ops, cpu)->enable_pmuirq(irq); + + put_cpu(); +} + #ifdef CONFIG_CPU_PM static void cpu_pm_pmu_setup(struct arm_pmu *armpmu, unsigned long cmd) { diff --git a/include/linux/perf/arm_pmu.h b/include/linux/perf/arm_pmu.h index e1be4a6c8b43..de49f92f6ebf 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -186,6 +186,7 @@ void kvm_host_pmu_init(struct arm_pmu *pmu); #endif =20 bool arm_pmu_irq_is_nmi(void); +void arm_pmu_set_phys_irq(bool enable); =20 /* Internal functions only for core arm_pmu code */ struct arm_pmu *armpmu_alloc(void); @@ -196,6 +197,10 @@ void armpmu_free_irq(struct arm_pmu * __percpu *armpmu= , int irq, int cpu); =20 #define ARMV8_PMU_PDEV_NAME "armv8-pmu" =20 +#else /* CONFIG_ARM_PMU */ + +static inline void arm_pmu_set_phys_irq(bool enable) {} + #endif /* CONFIG_ARM_PMU */ =20 #define ARMV8_SPE_PDEV_NAME "arm,spe-v1" --=20 2.43.0