]> www.infradead.org Git - nvme.git/commitdiff
KVM: arm64: nv: Save guest's ZCR_EL2 when in hyp context
authorOliver Upton <oliver.upton@linux.dev>
Thu, 20 Jun 2024 16:46:42 +0000 (16:46 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Thu, 20 Jun 2024 19:02:40 +0000 (19:02 +0000)
When running a guest hypervisor, ZCR_EL2 is an alias for the counterpart
EL1 state.

Reviewed-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20240620164653.1130714-6-oliver.upton@linux.dev
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/fpsimd.c

index 521b32868d0d26e7ea802b918aea55cdb407f761..0815ff0347f5e0d7291268018a6821f3a32312b3 100644 (file)
@@ -178,7 +178,13 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
 
        if (guest_owns_fp_regs()) {
                if (vcpu_has_sve(vcpu)) {
-                       __vcpu_sys_reg(vcpu, ZCR_EL1) = read_sysreg_el1(SYS_ZCR);
+                       u64 zcr = read_sysreg_el1(SYS_ZCR);
+
+                       /*
+                        * If the vCPU is in the hyp context then ZCR_EL1 is
+                        * loaded with its vEL2 counterpart.
+                        */
+                       __vcpu_sys_reg(vcpu, vcpu_sve_zcr_elx(vcpu)) = zcr;
 
                        /*
                         * Restore the VL that was saved when bound to the CPU,