Commit ace15464 authored by Marcelo Tosatti's avatar Marcelo Tosatti

KVM: use proper hrtimer function to retrieve expiration time

hrtimer->base can be temporarily NULL due to racing hrtimer_start.
See switch_hrtimer_base/lock_hrtimer_base.

Use hrtimer_get_remaining which is robust against it.

CC: stable@kernel.org
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 012abeea
...@@ -116,7 +116,7 @@ static s64 __kpit_elapsed(struct kvm *kvm) ...@@ -116,7 +116,7 @@ static s64 __kpit_elapsed(struct kvm *kvm)
* itself with the initial count and continues counting * itself with the initial count and continues counting
* from there. * from there.
*/ */
remaining = hrtimer_expires_remaining(&ps->pit_timer.timer); remaining = hrtimer_get_remaining(&ps->pit_timer.timer);
elapsed = ps->pit_timer.period - ktime_to_ns(remaining); elapsed = ps->pit_timer.period - ktime_to_ns(remaining);
elapsed = mod_64(elapsed, ps->pit_timer.period); elapsed = mod_64(elapsed, ps->pit_timer.period);
......
...@@ -521,7 +521,7 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic) ...@@ -521,7 +521,7 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
if (apic_get_reg(apic, APIC_TMICT) == 0) if (apic_get_reg(apic, APIC_TMICT) == 0)
return 0; return 0;
remaining = hrtimer_expires_remaining(&apic->lapic_timer.timer); remaining = hrtimer_get_remaining(&apic->lapic_timer.timer);
if (ktime_to_ns(remaining) < 0) if (ktime_to_ns(remaining) < 0)
remaining = ktime_set(0, 0); remaining = ktime_set(0, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment