Skip to content

Commit b7e5c94

Browse files
committed
KVM: arm64: nv: Save guest's ZCR_EL2 when in hyp context
When running a guest hypervisor, ZCR_EL2 is an alias for the counterpart EL1 state. Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 069da3f commit b7e5c94

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

arch/arm64/kvm/fpsimd.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
178178

179179
if (guest_owns_fp_regs()) {
180180
if (vcpu_has_sve(vcpu)) {
181-
__vcpu_sys_reg(vcpu, ZCR_EL1) = read_sysreg_el1(SYS_ZCR);
181+
u64 zcr = read_sysreg_el1(SYS_ZCR);
182+
183+
/*
184+
* If the vCPU is in the hyp context then ZCR_EL1 is
185+
* loaded with its vEL2 counterpart.
186+
*/
187+
__vcpu_sys_reg(vcpu, vcpu_sve_zcr_elx(vcpu)) = zcr;
182188

183189
/*
184190
* Restore the VL that was saved when bound to the CPU,

0 commit comments

Comments
 (0)