Skip events which have been missed by the guest.

Signed-off-by: Marcelo Tosatti <[email protected]>

Index: kvm-new/arch/x86/kvm/timer.c
===================================================================
--- kvm-new.orig/arch/x86/kvm/timer.c
+++ kvm-new/arch/x86/kvm/timer.c
@@ -58,6 +58,21 @@ void kvm_timer_ack(struct kvm_timer *kti
        ktimer->can_inject = true;
 }
 
+static void no_reinject_adjust(struct kvm_timer *ktimer, ktime_t expire)
+{
+       u64 unacked_events, delta;
+       ktime_t now;
+
+       now = ktime_get();
+       delta = ktime_to_ns(ktime_sub(now, expire));
+       unacked_events = 0;
+
+       if (now.tv64 > expire.tv64)
+               unacked_events = div_u64(delta, ktimer->period);
+       if (unacked_events > 1)
+               ktimer->acked_events += unacked_events-1;
+}
+
 static ktime_t periodic_timer_next_event(struct kvm_timer *ktimer)
 {
        ktime_t last_acked_event;
@@ -136,6 +151,8 @@ void kvm_inject_pending_timer_irqs(struc
                ktimer->ops->inject(ktimer);
                if (!ktimer->periodic)
                        list_del_init(&ktimer->vcpu_timer);
+               else if (unlikely(!ktimer->reinject))
+                       no_reinject_adjust(ktimer, expire);
        }
 }
 

-- 

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to