Skip to content

Commit 892f7c3

Browse files
author
Marc Zyngier
committed
KVM: arm64: Fix WFxT handling of nested virt
The spec for WFxT indicates that the parameter to the WFxT instruction is relative to the reading of CNTVCT_EL0. This means that the implementation needs to take the execution context into account, as CNTVOFF_EL2 does not always affect readings of CNTVCT_EL0 (such as when HCR_EL2.E2H is 1 and that we're in host context). This also rids us of the last instance of KVM_REG_ARM_TIMER_CNT outside of the userspace interaction code. Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent c3be3a4 commit 892f7c3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arch/arm64/kvm/handle_exit.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,12 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu)
147147
if (esr & ESR_ELx_WFx_ISS_RV) {
148148
u64 val, now;
149149

150-
now = kvm_arm_timer_get_reg(vcpu, KVM_REG_ARM_TIMER_CNT);
150+
now = kvm_phys_timer_read();
151+
if (is_hyp_ctxt(vcpu) && vcpu_el2_e2h_is_set(vcpu))
152+
now -= timer_get_offset(vcpu_hvtimer(vcpu));
153+
else
154+
now -= timer_get_offset(vcpu_vtimer(vcpu));
155+
151156
val = vcpu_get_reg(vcpu, kvm_vcpu_sys_get_rt(vcpu));
152157

153158
if (now >= val)

0 commit comments

Comments
 (0)