From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (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 308FA22A81A for ; Wed, 19 Feb 2025 19:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739993127; cv=none; b=T1Dhtf2tR+LiRBjW636zDNz60YiK5BF8MHydS/Et+YgBbHOozerFL2Z6o9RXHdYsFkqtknHfROwn9CMKYEOW324ItuptojoGPmmTvuh+yrG/n8uA8Th1hWNa4g0Ei+TKvW7lX/aRXeWHYBDp1ZmUIpBEsYAcx7eZD+wZ0VYm7n0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739993127; c=relaxed/simple; bh=SykixatIZerodgATAwVcTB8LToqqQLkJFQdVB2OSm9Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EldJIiUj7vJucYLAL65ZyhJU1WbAXNz9SOWvet456kHWEM/ktsZE2jUMcwt/Dhl8eRpqJ+6pAj7YgpqJQNgAQlaVd7Q4LwIqgj2QEUcjmB7aZXAUJd1o1PSKTvEF7mj4LZExbA/i3MkMWHFASv1axnbrYOxyCDjkz+Sg3N2SP80= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=HAo43khA; arc=none smtp.client-ip=95.215.58.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="HAo43khA" Date: Wed, 19 Feb 2025 11:25:06 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1739993112; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YWbTsmkFNVzUKGQASgjUS1od0uhjMSBLNuVdbUo2uHQ=; b=HAo43khA9DU1uLsdSMUg9nTVrQVQR5iWPGhSRHK2Wp8bg/ugmPa8asiQlOuuhyqh54C2El P0Ec3ptzNRyg2MaUQjrQu3nWUclL3MWyd0WopanhROR742V2qiKu4g9fHcKmpvzW/7fYJq QFG4ENuIdGD3oxElJek7m3LHNJSXlG0= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Marc Zyngier 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 Message-ID: References: <20250203183111.191519-1-oliver.upton@linux.dev> <20250203183111.191519-7-oliver.upton@linux.dev> <865xl5sx20.wl-maz@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <865xl5sx20.wl-maz@kernel.org> X-Migadu-Flow: FLOW_OUT On Wed, Feb 19, 2025 at 04:45:27PM +0000, Marc Zyngier wrote: > 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. Heh, this was a leftover party trick that I was using to try "raw" events from inside a VM. Happy to limit things to the PMUv3 event space though. Thanks, Oliver