From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9983C021AA for ; Wed, 19 Feb 2025 16:49:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nTxM4Kzm9kVOWrt/r7V27hJ5G++9kfp5omUyb5LUP7w=; b=QMPIstoLVEO0Viqoi7piyZt7n3 ExFy3fvsGsWINGzvz4jCWrkZGZHTIw0cRJy9e6jghBuLyz3Ge+kwh5eZv6KnoYLPX9R5AAQBOO7eB Oukh/ZzihEDvW4hJzlfSBJCQ5dJL2AmrUAXOrxhonccldeDwO62keEjGacX6dQjNxZzMLjTrorQgB 3RcQe73TzeAvzUvDRETvBuB07vNufUHReGRAEX4hT5sfvP63Vk2cIV1fYu66cGBEWqEOvjRjmC5DJ ZZ05Mwvxu5zR2qH1rC46rBoEVx9jZSHJ/5Oe40fB5hxDFO+C9ZziWHv4OX0sJa1i4Xzi15lLU45jd B2t5BF3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tknFm-0000000DvRa-45k3; Wed, 19 Feb 2025 16:48:54 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tknCV-0000000DuD4-39CV for linux-arm-kernel@lists.infradead.org; Wed, 19 Feb 2025 16:45:32 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 229D6A40101; Wed, 19 Feb 2025 16:43:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86362C4CED1; Wed, 19 Feb 2025 16:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739983530; bh=+JgQZSjlHn43fT0aJrhX77TBzq2ON9qyrE/4WoHeu4U=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=c+6eNfzdSJ4yJPpLz5SUOFA739EkUhL9Df4NxICvfFimB4y2P64upX6qpWCETxDDq TCDV6luFeDum45HXGIFo509sW6lficYtmtY+CHr47WmDIShZIhcEnuiesPEyzIPvW9 0X9W0b3hKwv9hQqByPBjwhSY9qQ7/A9RUtYKT+Sh6SdWT4P6K/WBkrX6SXdeuIx3fP uOmgfaq0OdHvBbMsllxbw4J7VvEZUpcgN6JESbrJsji/S7w2yWX0jAtwIvOnTVJ+He Y5dYLvuPsRkdcPWiTJSBsxw5in09dn3WhmOcNv/wYpee5wDs9sOL2X8QQk0mZNskI7 oBksCAT056+PQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tknCS-005tup-Fp; Wed, 19 Feb 2025 16:45:28 +0000 Date: Wed, 19 Feb 2025 16:45:27 +0000 Message-ID: <865xl5sx20.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, Joey Gouly , Suzuki K Poulose , Zenghui Yu , Mingwei Zhang , Colton Lewis , Raghavendra Rao Ananta , Catalin Marinas , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Janne Grunau Subject: Re: [PATCH v2 06/14] KVM: arm64: Remap PMUv3 events onto hardware In-Reply-To: <20250203183111.191519-7-oliver.upton@linux.dev> References: <20250203183111.191519-1-oliver.upton@linux.dev> <20250203183111.191519-7-oliver.upton@linux.dev> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, mizhang@google.com, coltonlewis@google.com, rananta@google.com, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, j@jannau.net X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250219_084531_930678_9EFA5DF0 X-CRM114-Status: GOOD ( 24.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, 03 Feb 2025 18:31:03 +0000, Oliver Upton wrote: > > Use the provided helper to map PMUv3 event IDs onto hardware, if the > driver exposes such a helper. This is expected to be quite rare, and > only useful for non-PMUv3 hardware. > > Tested-by: Janne Grunau > Signed-off-by: Oliver Upton > --- > arch/arm64/kvm/pmu-emul.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c > index 62349b670cf9..60cf973e2af9 100644 > --- a/arch/arm64/kvm/pmu-emul.c > +++ b/arch/arm64/kvm/pmu-emul.c > @@ -673,6 +673,18 @@ static bool kvm_pmc_counts_at_el2(struct kvm_pmc *pmc) > return kvm_pmc_read_evtreg(pmc) & ARMV8_PMU_INCLUDE_EL2; > } > > +static u64 kvm_map_pmu_event(struct kvm *kvm, u64 eventsel) > +{ > + struct arm_pmu *pmu = kvm->arch.arm_pmu; > + int hw_event; > + > + if (!pmu->map_pmuv3_event) > + return eventsel; > + > + hw_event = pmu->map_pmuv3_event(eventsel); > + return (hw_event < 0) ? eventsel : hw_event; I find this a bit odd. If we can translate events, but failed to do so, we still install the originally requested event, and we have no idea what this maps to on the HW. I'd rather we just don't install that event at all rather than counting something random. Thanks, M. -- Without deviation from the norm, progress is not possible.