KVM: use proper hrtimer function to retrieve expiration time
authorMarcelo Tosatti <mtosatti@redhat.com>
Thu, 8 Oct 2009 13:55:03 +0000 (10:55 -0300)
committerMarcelo Tosatti <mtosatti@redhat.com>
Fri, 16 Oct 2009 15:30:25 +0000 (12:30 -0300)
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: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/i8254.c
arch/x86/kvm/lapic.c

index 82ad523b490187c4d2f9cea90228293f868c8496..144e7f60b5e2c50f14edde7e3732761fbc22d8d9 100644 (file)
@@ -116,7 +116,7 @@ static s64 __kpit_elapsed(struct kvm *kvm)
         * itself with the initial count and continues counting
         * 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 = mod_64(elapsed, ps->pit_timer.period);
 
index 7024224f0fc8037cf913dbbde9d2cb9d8f2cc640..23c217692ea9ac958295a1c1a64190a45bf07f92 100644 (file)
@@ -521,7 +521,7 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)
        if (apic_get_reg(apic, APIC_TMICT) == 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)
                remaining = ktime_set(0, 0);