KVM: arm64: Trap host SVE accesses when the FPSIMD state is dirty
authorMarc Zyngier <maz@kernel.org>
Wed, 17 Mar 2021 16:50:39 +0000 (16:50 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 18 Mar 2021 14:22:31 +0000 (14:22 +0000)
commitbeed09067b428a7e84a53b05c1de1f93c8460e91
treeb1191fec23fd574d4eb8d17ffc22453bc66217a5
parentb145a8437aab2799969f6ad8e384b557872333c2
KVM: arm64: Trap host SVE accesses when the FPSIMD state is dirty

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.

To make it as lazy as possible on the EL1 host side, set
the SVE trapping in place when exiting from the guest.
On the first EL1 access to SVE, ZCR_EL2 will be restored
to its full glory.

Suggested-by: Andrew Scull <ascull@google.com>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hyp/nvhe/hyp-main.c
arch/arm64/kvm/hyp/nvhe/switch.c