From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Vrabel Subject: [PATCH 3/3] x86/xen: sync the CMOS RTC as well as the Xen wallclock Date: Mon, 13 May 2013 18:56:08 +0100 Message-ID: <1368467768-2316-4-git-send-email-david.vrabel__38648.8664932132$1368467920$gmane$org@citrix.com> References: <1368467768-2316-1-git-send-email-david.vrabel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1368467768-2316-1-git-send-email-david.vrabel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , John Stultz , David Vrabel , Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org From: David Vrabel If NTP is used in dom0 and it is synchronized to its clock source, then the kernel will periodically synchronize the Xen wallclock with the system time. Updates to the Xen wallclock do not persist across reboots, so also synchronize the CMOS RTC (as on bare metal). Signed-off-by: David Vrabel --- arch/x86/xen/time.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index a1947ac..4656165 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -199,17 +200,25 @@ static void xen_get_wallclock(struct timespec *now) static int xen_set_wallclock(const struct timespec *now) { struct xen_platform_op op; + int ret; /* do nothing for domU */ if (!xen_initial_domain()) return -1; + /* Set the Xen wallclock. */ op.cmd = XENPF_settime; op.u.settime.secs = now->tv_sec; op.u.settime.nsecs = now->tv_nsec; op.u.settime.system_time = xen_clocksource_read(); - return HYPERVISOR_dom0_op(&op); + ret = HYPERVISOR_dom0_op(&op); + if (ret) + return ret; + + /* Set the hardware RTC. */ + return mach_set_rtc_mmss(now); + } static struct clocksource xen_clocksource __read_mostly = { -- 1.7.2.5