diff options
author | Tim Deegan <tim@xen.org> | 2013-03-28 12:00:46 +0000 |
---|---|---|
committer | Tim Deegan <tim@xen.org> | 2013-03-29 09:43:04 +0000 |
commit | 58afa7ef12ff31c1f11658f35a9fef35ca15d641 (patch) | |
tree | b756fc47704a26c281b39083a9fb7ca435d28a69 /xen/arch/x86/hvm/rtc.c | |
parent | 5082cc19524b6687ef1bc0a717538d75aae7cd00 (diff) | |
download | xen-58afa7ef12ff31c1f11658f35a9fef35ca15d641.tar.gz xen-58afa7ef12ff31c1f11658f35a9fef35ca15d641.tar.bz2 xen-58afa7ef12ff31c1f11658f35a9fef35ca15d641.zip |
x86/hvm: Run the RTC periodic timer on a consistent time series.
When the RTC periodic timer gets restarted, align it to the VM's boot
time, not to whatever time it is now. Otherwise every read of REG_C
will restart the current period
Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Jan Beulich <jbeulich@suse.com>
Diffstat (limited to 'xen/arch/x86/hvm/rtc.c')
-rw-r--r-- | xen/arch/x86/hvm/rtc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/xen/arch/x86/hvm/rtc.c b/xen/arch/x86/hvm/rtc.c index c1e09d8392..e9aa81a390 100644 --- a/xen/arch/x86/hvm/rtc.c +++ b/xen/arch/x86/hvm/rtc.c @@ -80,7 +80,7 @@ void rtc_periodic_interrupt(void *opaque) * RTC_RATE_SELECT settings */ static void rtc_timer_update(RTCState *s) { - int period_code, period; + int period_code, period, delta; struct vcpu *v = vrtc_vcpu(s); ASSERT(spin_is_locked(&s->lock)); @@ -98,7 +98,8 @@ static void rtc_timer_update(RTCState *s) { period = 1 << (period_code - 1); /* period in 32 Khz cycles */ period = DIV_ROUND(period * 1000000000ULL, 32768); /* in ns */ - create_periodic_time(v, &s->pt, period, period, RTC_IRQ, NULL, s); + delta = period - ((NOW() - s->start_time) % period); + create_periodic_time(v, &s->pt, delta, period, RTC_IRQ, NULL, s); break; } /* fall through */ @@ -740,6 +741,7 @@ void rtc_init(struct domain *d) s->hw.cmos_data[RTC_REG_D] = RTC_VRT; s->current_tm = gmtime(get_localtime(d)); + s->start_time = NOW(); rtc_copy_date(s); |