[PATCH v8 25/38] KVM: arm64: Trap SME usage in guest
Mark Brown
broonie at kernel.org
Tue Jan 25 04:25:47 PST 2022
On Tue, Jan 25, 2022 at 11:27:55AM +0000, Marc Zyngier wrote:
> Mark Brown <broonie at kernel.org> wrote:
> > + if (IS_ENABLED(CONFIG_ARM64_SME) && cpus_have_final_cap(ARM64_SME))
> Please drop the IS_ENABLED(). We purposely avoid conditional
> compilation in KVM in order to avoid bitrot, and the amount of code
> you save isn't significant. Having a static key is more than enough to
> avoid runtime costs.
Sure, I wanted to be extra careful here as this is all in hot paths and
going to get moved elsewhere when we have real guest support.
> > + if (IS_ENABLED(CONFIG_ARM64_SME) && cpus_have_final_cap(ARM64_SME) &&
> > + cpus_have_final_cap(ARM64_HAS_FGT)) {
> > + val = read_sysreg_s(SYS_HFGRTR_EL2);
> > + val &= ~(HFGxTR_EL2_nTPIDR_EL0_MASK |
> > + HFGxTR_EL2_nSMPRI_EL1_MASK);
> > + write_sysreg_s(val, SYS_HFGRTR_EL2);
> > +
> > + val = read_sysreg_s(SYS_HFGWTR_EL2);
> > + val &= ~(HFGxTR_EL2_nTPIDR_EL0_MASK |
> > + HFGxTR_EL2_nSMPRI_EL1_MASK);
> > + write_sysreg_s(val, SYS_HFGWTR_EL2);
> > + }
> If the CPUs do not have FGT, what provides the equivalent trapping?
Nothing for nVHE mode.
> If FGT is mandatory when SME exists, then you should simplify the
> condition.
OK, I'll remove the defensiveness here. FGT is mandatory from v8.6 and
SME is a v9 feature so people shouldn't build a SME implementation that
lacks FGT.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20220125/6f709741/attachment.sig>
More information about the linux-arm-kernel
mailing list