vmm: Use relative alarms for periodic LAPIC timers
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 14 Aug 2017 16:06:28 +0000 (12:06 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 14 Aug 2017 21:02:20 +0000 (17:02 -0400)
With relative alarms, we'll try to inject another IPI in X ticks from now,
instead of X ticks from when we wanted the previous alarm to go off.

If the VMM is descheduled for a long time, perhaps due to being an SCP or
otherwise low-priority, the "incremental" alarms will build up, since we
don't run our alarm handler immediately.

If the guest clocks off the ticks, it'll have problems.  If that happens,
we can come up with something else.  I tested tinycore by giving it the
period it wanted * 2, and it thought time passed correctly (date).

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tests/vmm/vmrunkernel.c

index 584c95d..023dfe4 100644 (file)
@@ -341,7 +341,7 @@ void timer_alarm_handler(struct alarm_waiter *waiter)
 
        if (vector && initial_count && timer_mode == 0x01) {
                /* This is periodic, we reset the alarm */
-               set_awaiter_inc(waiter, initial_count << multiplier);
+               set_awaiter_rel(waiter, initial_count << multiplier);
                __set_alarm(waiter);
        }