Skip to content

Commit

Permalink
arm/arm64: KVM: Load the timer state when enabling the timer
Browse files Browse the repository at this point in the history
After being lazy with saving/restoring the timer state, we defer that
work to vcpu_load and vcpu_put, which ensure that the timer state is
loaded on the hardware timers whenever the VCPU runs.

Unfortunately, we are failing to do that the first time vcpu_load()
runs, because the timer has not yet been enabled at that time.  As long
as the initialized timer state matches what happens to be in the
hardware (a disabled timer, because we never leave the timer screaming),
this does not show up as a problem, but is nevertheless incorrect.

The solution is simple; disable preemption while setting the timer to be
enabled, and call the timer load function when first enabling the timer.

Acked-by: Marc Zyngier <[email protected]>
Signed-off-by: Christoffer Dall <[email protected]>
  • Loading branch information
chazy committed Nov 6, 2017
1 parent 1c88ab7 commit 4a2c4da
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions virt/kvm/arm/arch_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,11 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu)
return ret;

no_vgic:
preempt_disable();
timer->enabled = 1;
kvm_timer_vcpu_load_vgic(vcpu);
preempt_enable();

return 0;
}

Expand Down

0 comments on commit 4a2c4da

Please sign in to comment.