Skip to content

Commit ed25dcf

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: nv: Don't treat ZCR_EL2 as a 'mapped' register
Unlike the other mapped EL2 sysregs ZCR_EL2 isn't guaranteed to be resident when a vCPU is loaded as it actually follows the SVE context. As such, the contents of ZCR_EL1 may belong to another guest if the vCPU has been preempted before reaching sysreg emulation. Unconditionally use the in-memory value of ZCR_EL2 and switch to the memory-only accessors. The in-memory value is guaranteed to be valid as fpsimd_lazy_switch_to_{guest,host}() will restore/save the register appropriately. Signed-off-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent 3a86608 commit ed25dcf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ static void locate_register(const struct kvm_vcpu *vcpu, enum vcpu_sysreg reg,
203203
MAPPED_EL2_SYSREG(AMAIR_EL2, AMAIR_EL1, NULL );
204204
MAPPED_EL2_SYSREG(ELR_EL2, ELR_EL1, NULL );
205205
MAPPED_EL2_SYSREG(SPSR_EL2, SPSR_EL1, NULL );
206-
MAPPED_EL2_SYSREG(ZCR_EL2, ZCR_EL1, NULL );
207206
MAPPED_EL2_SYSREG(CONTEXTIDR_EL2, CONTEXTIDR_EL1, NULL );
208207
MAPPED_EL2_SYSREG(SCTLR2_EL2, SCTLR2_EL1, NULL );
209208
case CNTHCTL_EL2:
@@ -2709,14 +2708,13 @@ static bool access_zcr_el2(struct kvm_vcpu *vcpu,
27092708
}
27102709

27112710
if (!p->is_write) {
2712-
p->regval = vcpu_read_sys_reg(vcpu, ZCR_EL2);
2711+
p->regval = __vcpu_sys_reg(vcpu, ZCR_EL2);
27132712
return true;
27142713
}
27152714

27162715
vq = SYS_FIELD_GET(ZCR_ELx, LEN, p->regval) + 1;
27172716
vq = min(vq, vcpu_sve_max_vq(vcpu));
2718-
vcpu_write_sys_reg(vcpu, vq - 1, ZCR_EL2);
2719-
2717+
__vcpu_assign_sys_reg(vcpu, ZCR_EL2, vq - 1);
27202718
return true;
27212719
}
27222720

0 commit comments

Comments
 (0)