Skip to content

Commit 069da3f

Browse files
committed
KVM: arm64: nv: Load guest hyp's ZCR into EL1 state
Load the guest hypervisor's ZCR_EL2 into the corresponding EL1 register when restoring SVE state, as ZCR_EL2 affects the VL in the hypervisor context. Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent b3d29a8 commit 069da3f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,9 @@ struct kvm_vcpu_arch {
868868

869869
#define vcpu_sve_max_vq(vcpu) sve_vq_from_vl((vcpu)->arch.sve_max_vl)
870870

871+
#define vcpu_sve_zcr_elx(vcpu) \
872+
(unlikely(is_hyp_ctxt(vcpu)) ? ZCR_EL2 : ZCR_EL1)
873+
871874
#define vcpu_sve_state_size(vcpu) ({ \
872875
size_t __size_ret; \
873876
unsigned int __vcpu_vq; \

arch/arm64/kvm/hyp/include/hyp/switch.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,8 @@ static inline void __hyp_sve_restore_guest(struct kvm_vcpu *vcpu)
318318
__sve_restore_state(vcpu_sve_pffr(vcpu),
319319
&vcpu->arch.ctxt.fp_regs.fpsr,
320320
true);
321-
write_sysreg_el1(__vcpu_sys_reg(vcpu, ZCR_EL1), SYS_ZCR);
321+
322+
write_sysreg_el1(__vcpu_sys_reg(vcpu, vcpu_sve_zcr_elx(vcpu)), SYS_ZCR);
322323
}
323324

324325
static inline void __hyp_sve_save_host(void)

0 commit comments

Comments
 (0)