[PATCH 09/10] KVM: arm64: Save/restore SVE state for nVHE
Will Deacon
will at kernel.org
Wed Mar 17 17:57:35 GMT 2021
On Tue, Mar 16, 2021 at 10:13:11AM +0000, Marc Zyngier wrote:
> Implement the SVE save/restore for nVHE, following a similar
> logic to that of the VHE implementation:
>
> - the SVE state is switched on trap from EL1 to EL2
>
> - no further changes to ZCR_EL2 occur as long as the guest isn't
> preempted or exit to userspace
>
> - on vcpu_put(), ZCR_EL2 is reset to its default value, and ZCR_EL1
> restored to the default guest value
>
> Signed-off-by: Marc Zyngier <maz at kernel.org>
> ---
> arch/arm64/kvm/fpsimd.c | 15 ++++++++--
> arch/arm64/kvm/hyp/include/hyp/switch.h | 37 +++++++++----------------
> arch/arm64/kvm/hyp/nvhe/switch.c | 4 +--
> 3 files changed, 28 insertions(+), 28 deletions(-)
>
> diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c
> index b5f95abd23f5..cc6cdea69596 100644
> --- a/arch/arm64/kvm/fpsimd.c
> +++ b/arch/arm64/kvm/fpsimd.c
> @@ -121,11 +121,22 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
> local_irq_save(flags);
>
> if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED) {
> - if (guest_has_sve)
> + if (guest_has_sve) {
> __vcpu_sys_reg(vcpu, ZCR_EL1) = read_sysreg_el1(SYS_ZCR);
>
> + /* Restore the VL that was saved when bound to the CPU */
> + if (!has_vhe()) {
> + u64 zcr;
> +
> + kvm_call_hyp(__kvm_reset_sve_vq);
What would go wrong if we did this unconditionally on return to the host, or
is it just a performance thing to move work off the fast path where we
return back to the same vCPU?
Will
More information about the linux-arm-kernel
mailing list