From owner-svn-src-user@FreeBSD.ORG Thu Jun 11 05:48:49 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DB5C6106566C; Thu, 11 Jun 2009 05:48:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AFC328FC1B; Thu, 11 Jun 2009 05:48:49 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n5B5mnsJ037052; Thu, 11 Jun 2009 05:48:49 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n5B5mntQ037051; Thu, 11 Jun 2009 05:48:49 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200906110548.n5B5mntQ037051@svn.freebsd.org> From: Kip Macy Date: Thu, 11 Jun 2009 05:48:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r193973 - user/kmacy/releng_7_2_xen/sys/i386/xen X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jun 2009 05:48:50 -0000 Author: kmacy Date: Thu Jun 11 05:48:49 2009 New Revision: 193973 URL: http://svn.freebsd.org/changeset/base/193973 Log: Merge 193033 Fix the Xen TOD update when the hypervisor wall clock is nudged. The "wall clock" in the current code is actually the hypervisor start time. The time of day is the "start time" plus the hypervisor "uptime". Large enough bumps in the dom0 clock lead to a hypervisor "bump" which is implemented as a bump in the start time, not the uptime. The clock.c routines were reading in the hypervisor start time and then using this as the TOD. This meant that any hypervisor time bump would cause the FreeBSD DomU to set its TOD to the hypervisor start time, rather than the actual TOD. This fix is a bit hacky and some reshuffling should be done later on to clarify what is going on. I've left the wall clock code alone. (The code which updates shadow_tv and shadow_tv_version.) A new routine adds the uptime to the shadow_tv, which is then used to update the TOD. I've included some debugging so it is obvious when the clock is nudged. Modified: user/kmacy/releng_7_2_xen/sys/i386/xen/clock.c Modified: user/kmacy/releng_7_2_xen/sys/i386/xen/clock.c ============================================================================== --- user/kmacy/releng_7_2_xen/sys/i386/xen/clock.c Thu Jun 11 05:47:13 2009 (r193972) +++ user/kmacy/releng_7_2_xen/sys/i386/xen/clock.c Thu Jun 11 05:48:49 2009 (r193973) @@ -87,6 +87,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* * 32-bit time_t's can't reach leap years before 1904 or after 2036, so we @@ -237,6 +238,15 @@ static void update_wallclock(void) } +static void +add_uptime_to_wallclock(void) +{ + struct timespec ut; + + xen_fetch_uptime(&ut); + timespecadd(&shadow_tv, &ut); +} + /* * Reads a consistent set of time-base values from Xen, into a shadow data * area. Must be called with the xtime_lock held for writing. @@ -332,7 +342,9 @@ clkintr(void *arg) */ if (shadow_tv_version != HYPERVISOR_shared_info->wc_version) { + printf("[XEN] hypervisor wallclock nudged; nudging TOD.\n"); update_wallclock(); + add_uptime_to_wallclock(); tc_setclock(&shadow_tv); } @@ -543,6 +555,7 @@ domu_inittodr(time_t base) struct timespec ts; update_wallclock(); + add_uptime_to_wallclock(); RTC_LOCK; @@ -592,6 +605,7 @@ domu_resettodr(void) op.u.settime.system_time = shadow->system_timestamp; HYPERVISOR_dom0_op(&op); update_wallclock(); + add_uptime_to_wallclock(); } else if (independent_wallclock) { /* notyet */ ;