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 A2BB03148D7; Fri, 19 Sep 2025 15:14:53 +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=1758294893; cv=none; b=Ra0MF0e+RA7SYkM+WkYlB9+ngXrDdVCLU4YSbWxsVvZaPLjndl+7NDwogt4mXIfwgdMykKcU8zSu5v0bYsuN8miWA/mzhMRQfgP0JoBcr9T4xMb0+mwAOpLF6Hf9bGoe5fv0vokXh5uvLypqc6g1BlGPHSS6DqzAcMyrjo8sCFs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758294893; c=relaxed/simple; bh=NNpcBJB4jVrgHcageJLDdkxE2rXZt7r2rrDsKSC+D9I=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=heQzel7A5h5fiVP3dufdJDE2HrutfUFYulz+2MU643RUGqoqOW2kDq4LUXUhGsTOJXvqT68fBqu8iDV3b81AnCYpJtXpBCNVGKMA8kdyR7spmcNjmEX2BEm3PM9lQ15ro444SW5/JZp+3iYf68S2yR9VoTwwyaBIfpki1P3PoeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Eg4JKZQO; 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="Eg4JKZQO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D2CAC4CEF0; Fri, 19 Sep 2025 15:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758294893; bh=NNpcBJB4jVrgHcageJLDdkxE2rXZt7r2rrDsKSC+D9I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Eg4JKZQOCeE8iQvdN+xzthu0malVpcqAn0K+LiPgASso6UWuMIahP8/vuL5Db7Emp KPSeSEMTwefKp+sQCDJi0DuCii2L1du0M3dAWHrgaJBt4zPfAXrHYyy67gvjIjERRz tj1rbbnelqbucGoG7/6yVqjB8Rgx8QIdB/xvn2AsXqqgFPKb9kg3+oR9+Yeavhd5V2 pvW8A0RgP4ZeMdERb6nPXfzTdfn0ROHkrp37kn3VWetHLFALyiOLxnVEjQG3XQgldV XYK7lQ+cv/HgUX+q39HLhNdPzpidVAOswo0VJCb2577KR+MbrZ16P1IzVmVt6qJi0E YTmssBMmAHYDw== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uzcp0-00000007oto-3G9H; Fri, 19 Sep 2025 15:14:50 +0000 Date: Fri, 19 Sep 2025 16:14:49 +0100 Message-ID: <87zfaqxymu.wl-maz@kernel.org> From: Marc Zyngier To: Mark Brown Cc: Oliver Upton , Joey Gouly , Catalin Marinas , Suzuki K Poulose , Will Deacon , Paolo Bonzini , Jonathan Corbet , Shuah Khan , Dave Martin , Fuad Tabba , Mark Rutland , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Peter Maydell , Eric Auger Subject: Re: [PATCH v8 06/29] KVM: arm64: Introduce non-UNDEF FGT control In-Reply-To: <20250902-kvm-arm64-sme-v8-6-2cb2199c656c@kernel.org> References: <20250902-kvm-arm64-sme-v8-0-2cb2199c656c@kernel.org> <20250902-kvm-arm64-sme-v8-6-2cb2199c656c@kernel.org> 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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-kselftest@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: broonie@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, catalin.marinas@arm.com, suzuki.poulose@arm.com, will@kernel.org, pbonzini@redhat.com, corbet@lwn.net, shuah@kernel.org, Dave.Martin@arm.com, tabba@google.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, peter.maydell@linaro.org, eric.auger@redhat.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Tue, 02 Sep 2025 12:36:09 +0100, Mark Brown wrote: > > We have support for determining a set of fine grained traps to enable for > the guest which is tied to the support for injecting UNDEFs for undefined > features. This means that we can't use the mechanism for system registers > which should be present but need emulation, such as SMPRI_EL1 which should > be accessible when SME is present but if SME priority support is absent > SMPRI_EL1.Priority should be RAZ. > > Add an additional set of fine grained traps fgt, mirroring the existing fgu > array. We use the same format where we always set the bit for the trap in > the array as for FGU. This makes it clear what is being explicitly managed > and keeps the code consistent. > > We do not convert the handling of ARM_WORKAROUND_AMPERE_ACO3_CPU_38 to this > mechanism since this only enables a write trap and when implementing the > existing UNDEF that we would share the read and write trap enablement (this > being the overwhelmingly common case). > > Signed-off-by: Mark Brown > --- > arch/arm64/include/asm/kvm_host.h | 6 ++++++ > arch/arm64/kvm/hyp/include/hyp/switch.h | 7 ++++--- > 2 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 2f2394cce24e..b501c2880ba2 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -302,6 +302,12 @@ struct kvm_arch { > */ > u64 fgu[__NR_FGT_GROUP_IDS__]; > > + /* > + * Additional FGTs to enable for the guests, eg. for emulated > + * registers, > + */ > + u64 fgt[__NR_FGT_GROUP_IDS__]; > + Conceptually, this serves the same role as the existing control registers (HCR_EL2, HCRX_EL2, MDCR_EL2), which are obviously per-vcpu. So having this on a per-VM basis doesn't really work, because we definitely don't expect this to be uniform (see 20250917203125.283116-3-oliver.upton@linux.dev for an example of why this is not the case). FGUs are uniform, because when something doesn't exist on a vcpu, it doesn't exist on *any* vcpu. Non-FGU use of FGTs, however, has to be more flexible because that's part of the emulation, and is actually pretty rare that we want to trap something at all times, on all vcpus. For the same reason, conflating the R and W registers doesn't work either. For the above example, I want to be able to trap write accesses to MDSCR_EL1, and not reads, just like the Ampere brain-damage. So please make this per-vcpu, decouple R and W FGTs, and convert the Ampere horror to this scheme. Thanks, M. -- Jazz isn't dead. It just smells funny.