From e18ccd8fcfae88190c7f3dba8ef02042666b56b3 Mon Sep 17 00:00:00 2001 From: Tim Deegan Date: Fri, 18 Jan 2013 12:31:57 +0100 Subject: [PATCH] x86/hvm: fix RTC setting. When the guest writes one field of the RTC time, we must bring all the other fields up to date for the current second before calculating the new RTC time. Signed-off-by: Tim Deegan Tested-by: Phil Evans Committed-by: Jan Beulich --- xen/arch/x86/hvm/rtc.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/rtc.c b/xen/arch/x86/hvm/rtc.c index ea5179a4b4..b994e99ad9 100644 --- a/xen/arch/x86/hvm/rtc.c +++ b/xen/arch/x86/hvm/rtc.c @@ -399,10 +399,17 @@ static int rtc_ioport_write(void *opaque, uint32_t addr, uint32_t data) case RTC_DAY_OF_MONTH: case RTC_MONTH: case RTC_YEAR: - s->hw.cmos_data[s->hw.cmos_index] = data; - /* if in set mode, do not update the time */ - if ( !(s->hw.cmos_data[RTC_REG_B] & RTC_SET) ) + /* if in set mode, just write the register */ + if ( (s->hw.cmos_data[RTC_REG_B] & RTC_SET) ) + s->hw.cmos_data[s->hw.cmos_index] = data; + else + { + /* Fetch the current time and update just this field. */ + s->current_tm = gmtime(get_localtime(d)); + rtc_copy_date(s); + s->hw.cmos_data[s->hw.cmos_index] = data; rtc_set_time(s); + } alarm_timer_update(s); break; case RTC_REG_A: -- 2.30.2