[PATCH 2/2] KVM: arm64: Move FGT value configuration to vCPU state

Mark Brown broonie at kernel.org
Fri Mar 17 06:49:44 PDT 2023


On Fri, Mar 17, 2023 at 09:02:32AM +0000, Marc Zyngier wrote:
> Mark Brown <broonie at kernel.org> wrote:

> > +	vcpu->arch.hfgrtr_el2 = 0;
> > +	vcpu->arch.hfgwtr_el2 = 0;

> Although this looks completely innocent, this actually have the effect
> of trapping the SMPRI_EL1 and TPIDR2_EL0 registers, something that is
> self documented in the current code, and that completely disappears
> with this patch.

> This needs documenting by enumerating the sysregs that get trapped.

That's an awful lot of registers with the fine grained traps, and when
extended to cover HFHxTR2 there's a bunch of RES0 bits intended for
future traps.  It feels a bit unmanagable.  I'd have expected something
more along the lines of "enable all traps other than...".  The pattern
seemed to be more to have an explicit initialiser for the bits that are
set (eg, with CPACR_EL1) which was why I didn't put anything explicit.

> > +	/* Fine grained traps values for the guest and host */
> > +	u64 hfgrtr_el2;
> > +	u64 hfgwtr_el2;
> > +	u64 hfgrtr_el2_host;
> > +	u64 hfgwtr_el2_host;

> Why do we have both host and guest? This is the vcpu structure, and
> the host state doesn't belong here. If you want to save some host
> state, place the hfgxtr_el2 fields in kvm_cpu_context, and use the
> per-CPU instance of this structure to save the host state.

Ah, I'd not run into the percpu structure - that does look like a better
fit.
-------------- 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/20230317/4ca5cbc6/attachment.sig>


More information about the linux-arm-kernel mailing list