x86/hvm: Let the guest miss a few ticks before resetting the timer.
authorTim Deegan <tim@xen.org>
Thu, 28 Mar 2013 13:07:06 +0000 (13:07 +0000)
committerTim Deegan <tim@xen.org>
Fri, 29 Mar 2013 09:43:17 +0000 (09:43 +0000)
Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
xen/arch/x86/hvm/rtc.c
xen/include/asm-x86/hvm/vpt.h

index 8d9195fa495558166944ca4a738e9f1d22605562..88cacd1caf27e21c1b7418a39847a56c8482b56e 100644 (file)
@@ -65,17 +65,18 @@ void rtc_periodic_interrupt(void *opaque)
     RTCState *s = opaque;
 
     spin_lock(&s->lock);
-    if ( s->hw.cmos_data[RTC_REG_C] & RTC_PF )
-    {
-        destroy_periodic_time(&s->pt);
-        s->pt_code = 0;
-    }
-    else
+    if ( !(s->hw.cmos_data[RTC_REG_C] & RTC_PF) )
     {
         s->hw.cmos_data[RTC_REG_C] |= RTC_PF;
         if ( s->hw.cmos_data[RTC_REG_B] & RTC_PIE )
             rtc_toggle_irq(s);
     }
+    else if ( ++(s->pt_dead_ticks) >= 10 )
+    {
+        /* VM is ignoring its RTC; no point in running the timer */
+        destroy_periodic_time(&s->pt);
+        s->pt_code = 0;
+    }
     spin_unlock(&s->lock);
 }
 
@@ -88,6 +89,8 @@ static void rtc_timer_update(RTCState *s)
 
     ASSERT(spin_is_locked(&s->lock));
 
+    s->pt_dead_ticks = 0;
+
     period_code = s->hw.cmos_data[RTC_REG_A] & RTC_RATE_SELECT;
     switch ( s->hw.cmos_data[RTC_REG_A] & RTC_DIV_CTL )
     {
index ea9df426d5658da0ca12ee26d8bb96a3c4246673..765fbb7791400a5064dcdf48b5e257228311d4ac 100644 (file)
@@ -114,6 +114,7 @@ typedef struct RTCState {
     struct periodic_time pt;
     s_time_t start_time;
     int pt_code;
+    uint8_t pt_dead_ticks;
     uint32_t use_timer;
     spinlock_t lock;
 } RTCState;