Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp376352lqp; Mon, 10 Jun 2024 06:57:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUUBuYsgZ7Cbb5RZ0Aj+f+FykkDBaAA7/aDuztRFdbJhD/fV3QWrm9ZExUYnZqoVVv0+lDyyEJ1MHMk/KqP7Y3WSp0LeIIm1Rn0dnQamQ== X-Google-Smtp-Source: AGHT+IE1a21N92A7YLyNnqWObOCWsoABsyUwKEq2nlnDXh9LTUOtidE2NG/oQnjliLBpFS592XSx X-Received: by 2002:a05:6a00:1747:b0:704:3678:3ef3 with SMTP id d2e1a72fcca58-70436784fbcmr4671782b3a.18.1718027828641; Mon, 10 Jun 2024 06:57:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718027828; cv=pass; d=google.com; s=arc-20160816; b=Kvdtx8R++wemI4zKvX8kg1E6kXqTzZ5exhyxC6VQYi1aY6B32Xef3UoW2VJohKs2vy QUEf5x8zpnQhBnc3XxbS8qctiGRPiLH+WFdMnAokWRlH4WK2y9LCHWltu9MSu4LJ1ycS I55sUGY/pcT9TaqGKC9gOVCQkuDQKv4av/cbODVDdvXMtheYJhLfB3EYB5m2Ycl/ledk cWHF5531Jm9x7ZRdypCG9AUndKWy3Gix6Xd3QTTBgGG/K7wJEOMkx+wSdNA8gov+d/L2 0P/UB3rQ8H/WmgGWcjgHYJ1ywpbtSfr9teOs9ddu4+ADhBDucRR7O4vbNyPSWmg9yUqU B8Eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=gzEcwiXpSSaDOgri8GBeuwRPwYk9ZaICTJSIkgDLM8g=; fh=NDCPdPn2hiqHaiIRDYQAzsW9PK20CTia4nECGof6enU=; b=JhXvDVk0fgOh+Y68gYt2kIYC5KznI5qDA2pUhJI5rN709jhuA1aNcJf47oBZg2VcaL J2nTpB/CkvwGsW8h4v+9pvji8/yP1C95AnPq/y0tt2emmtAHdTbu1vsVBE7nuEKRdPK0 a793KZgP/ku49lchdckLA7w19QMJt66mtyLbE1FqRXHLUQV3/yj+w6PR3exhQhliR58R wOM/+EpnZtmDoMbPWnwgzByhkoCih9TuETVIYX1flPjnzQeYPkSRt7JemouNvdIzWEsR WHXanjH4Wr3HNW3gDLfXAB/kYHdgmDMsp6NWQKG1P/E4Vxa6KAcSwdvaPJb7HKetr8A3 U+ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208279-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208279-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de275ff40dsi5626014a12.529.2024.06.10.06.57.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 06:57:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208279-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-208279-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208279-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C5E3B287241 for ; Mon, 10 Jun 2024 13:52:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7E3C156C4B; Mon, 10 Jun 2024 13:44:05 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34EC9156885; Mon, 10 Jun 2024 13:44:03 +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=1718027045; cv=none; b=oqoxsL2WJgNi/sxmnSUzsvd1UH13QucO+9jyt31MVUvphcBMCAW7iUUC5BNb16TaXvWOG9cAC74Qd8Id548ZmsFomy/I7JNIvnhhAzkL7LT4ZTCHTwjZFTO+lKtIXH7xHQ56DwAQtzrTsWgXom2cSkDFJYjXyLKq0HaC3mqpOSg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718027045; c=relaxed/simple; bh=q8zrjufdqG2e65l2pDcruZuD7djK4hiuptKw5Qkylyw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EvVD0Bwb3qsNH9PEqgSOJBBr6H6v9skTNzi2Zo4QNZH7wVh7AM1e7hrRPatUj2oFHkHk+a3P/BmBB4lyopAZKp8F3hsOuOskcKEkDVJy95coiP7xb5pON+On11+l2ibuWQ8prVfDtrmvP7RWwe1G6D1CPdX7v6lw7WNFYU4EIoU= 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 64FF91688; Mon, 10 Jun 2024 06:44:27 -0700 (PDT) Received: from e122027.cambridge.arm.com (e122027.cambridge.arm.com [10.1.35.41]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2E643F58B; Mon, 10 Jun 2024 06:44:00 -0700 (PDT) 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 Subject: [PATCH v3 32/43] arm_pmu: Provide a mechanism for disabling the physical IRQ Date: Mon, 10 Jun 2024 14:41:51 +0100 Message-Id: <20240610134202.54893-33-steven.price@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610134202.54893-1-steven.price@arm.com> References: <20240610134202.54893-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: 8bit 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 --- 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 8458fe2cebb4..1e024acc98bb 100644 --- a/drivers/perf/arm_pmu.c +++ b/drivers/perf/arm_pmu.c @@ -735,6 +735,21 @@ static int arm_perf_teardown_cpu(unsigned int cpu, struct hlist_node *node) return 0; } +void arm_pmu_set_phys_irq(bool enable) +{ + int cpu = get_cpu(); + struct arm_pmu *pmu = per_cpu(cpu_armpmu, cpu); + int irq; + + irq = 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 b3b34f6670cf..f9fa628ae2ae 100644 --- a/include/linux/perf/arm_pmu.h +++ b/include/linux/perf/arm_pmu.h @@ -168,6 +168,7 @@ void kvm_host_pmu_init(struct arm_pmu *pmu); #endif bool arm_pmu_irq_is_nmi(void); +void arm_pmu_set_phys_irq(bool enable); /* Internal functions only for core arm_pmu code */ struct arm_pmu *armpmu_alloc(void); @@ -178,6 +179,10 @@ void armpmu_free_irq(int irq, int cpu); #define ARMV8_PMU_PDEV_NAME "armv8-pmu" +#else /* CONFIG_ARM_PMU */ + +static inline void arm_pmu_set_phys_irq(bool enable) {} + #endif /* CONFIG_ARM_PMU */ #define ARMV8_SPE_PDEV_NAME "arm,spe-v1" -- 2.34.1