[PATCH 08/10] KVM: arm64: Add a nVHE-specific SVE VQ reset hypercall

Marc Zyngier maz at kernel.org
Tue Mar 16 15:00:45 GMT 2021


On Tue, 16 Mar 2021 14:24:38 +0000,
Andrew Scull <ascull at google.com> wrote:
> 
> On Tue, Mar 16, 2021 at 10:13:10AM +0000, Marc Zyngier wrote:
> > ZCR_EL2 controls the upper bound for ZCR_EL1, and is set to
> > a potentially lower limit when the guest uses SVE.
> > 
> > In order to restore the SVE state on the EL1 host, we must first
> > reset ZCR_EL2 to its original value.
> > 
> > Provide a hypervall that perform this reset.
> 
> Is there a good reason to have an explicit hypercall vs trapping the
> host access to SVE and restoring in that event?

Trapping ZCR_EL2 isn't possible, as it would UNDEF at EL1. Trapping
ZCR_EL1 accesses is possible though, but it'd mean leaving the SVE
traps enabled on guest exit, something we currently don't do.

> It's quite easy to do trap handling at EL2 now and it could let things
> be even lazier, if that's any benefit in this case.

We don't really have a good infrastructure for dealing with individual
sysregs (pKVM will eventually change that, but we're not there yet,
and it isn't clear how that'd apply to non-protected), so we'd have to
deal with the whole SVE EC.

What we could do is:

- set CPTR_EL2.TZ set on guest exit

- on SVE trap, reset ZCR_EL2, clear CPTR_EL2.TZ, reexecute the
  faulting instruction.

I can have a look at how badly it looks.

> Trapping seems to have had a bad rep in other conversations but I'm not
> sure the same reasoning applies to this as well, or not.

HVC and traps have the same basic cost. I seriously doubt you can
measure the difference on any real CPU.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list