From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28575212FA5; Wed, 19 Feb 2025 16:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739983531; cv=none; b=gAdTVK6JFxCcEejawRSofi1oQeH4ZkX1ByS5msA+BXPBdxV5gk9RHSHCs5YzSsNSQU9jDUGdzwLCWt7De0mieAowxhLH7YqwbtX1V2BVgFAxVbcDYdddiBrmo6njIwETiSFfGrsH4dJ7YEP8CWbKeVoFgM9V36xR8MqoMNyUSbA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739983531; c=relaxed/simple; bh=+JgQZSjlHn43fT0aJrhX77TBzq2ON9qyrE/4WoHeu4U=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=DHfZEVkiu7bUijQUccf7K7guxCGWHzsVF1cfaZk92qa1uV9ouf3i2LJniq5dq/ceoCnMj7QTIoL13WxA4MvQdqHBdKw6NoUCsHdB2PhdHLQD8JdHlVbQ0tBud393g4LJFdQ/cSAhO1AFICSzObrjnGcDbnFQq3iszDzJZHaPmTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c+6eNfzd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c+6eNfzd" 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.