From: David Vrabel <david.vrabel@citrix.com>
To: <xen-devel@lists.xen.org>
Cc: David Vrabel <david.vrabel@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
<linux-kernel@vger.kernel.org>,
John Stultz <john.stultz@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH 3/4] x86/xen: sync the wallclock when the system time is stepped
Date: Thu, 20 Jun 2013 20:16:31 +0100 [thread overview]
Message-ID: <1371755792-25962-4-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1371755792-25962-1-git-send-email-david.vrabel@citrix.com>
From: David Vrabel <david.vrabel@citrix.com>
The Xen wallclock is a software only clock within the Xen hypervisor
that is used by: a) PV guests as the equivalent of a hardware RTC; and
b) the hypervisor as the clock source for the emulated RTC provided to
HVM guests.
Currently the Xen wallclock is only updated every 11 minutes if NTP is
synchronized to its clock source. If a guest is started before NTP is
synchronized it may see an incorrect wallclock time.
Use the clock_was_set notifier chain to receive a notification when
the system time is stepped and update the wallclock to match the
current system time.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
arch/x86/xen/time.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c
index a1947ac..ad077ca 100644
--- a/arch/x86/xen/time.c
+++ b/arch/x86/xen/time.c
@@ -211,6 +211,25 @@ static int xen_set_wallclock(const struct timespec *now)
return HYPERVISOR_dom0_op(&op);
}
+
+static int xen_clock_was_set_notify(struct notifier_block *nb, unsigned long unused,
+ void *priv)
+{
+ struct timespec now;
+
+ /*
+ * Set the Xen wallclock from Linux system time.
+ */
+ now = current_kernel_time();
+ xen_set_wallclock(&now);
+
+ return NOTIFY_OK;
+}
+
+static struct notifier_block xen_clock_was_set_notifier = {
+ .notifier_call = xen_clock_was_set_notify,
+};
+
static struct clocksource xen_clocksource __read_mostly = {
.name = "xen",
@@ -473,6 +492,9 @@ static void __init xen_time_init(void)
xen_setup_runstate_info(cpu);
xen_setup_timer(cpu);
xen_setup_cpu_clockevents();
+
+ if (xen_initial_domain())
+ register_clock_was_set_notifier(&xen_clock_was_set_notifier);
}
void __init xen_init_time_ops(void)
--
1.7.2.5
next prev parent reply other threads:[~2013-06-20 19:17 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-20 19:16 [PATCHv5 0/4] xen: maintain an accurate persistent clock in more cases David Vrabel
2013-06-20 19:16 ` [PATCH 1/4] hrtimers: provide a hrtimers_late_resume() call David Vrabel
2013-06-21 7:53 ` Thomas Gleixner
2013-06-21 12:32 ` David Vrabel
2013-06-21 14:32 ` Thomas Gleixner
2013-06-21 17:30 ` David Vrabel
2013-06-21 21:24 ` Thomas Gleixner
2013-06-20 19:16 ` [PATCH 2/4] time: add a notifier chain for when the system time is stepped David Vrabel
2013-06-21 7:57 ` Thomas Gleixner
2013-06-21 12:41 ` David Vrabel
2013-06-21 23:06 ` Thomas Gleixner
2013-06-24 10:51 ` David Vrabel
2013-06-24 16:30 ` Thomas Gleixner
2013-06-24 17:00 ` David Vrabel
2013-06-24 17:50 ` John Stultz
2013-06-24 19:55 ` Thomas Gleixner
2013-06-21 16:22 ` John Stultz
2013-06-20 19:16 ` David Vrabel [this message]
2013-06-20 19:16 ` [PATCH 4/4] x86/xen: sync the CMOS RTC as well as the Xen wallclock David Vrabel
2013-06-20 20:03 ` [PATCHv5 0/4] xen: maintain an accurate persistent clock in more cases John Stultz
2013-06-21 18:31 ` Konrad Rzeszutek Wilk
-- strict thread matches above, loose matches on Subject: below --
2013-06-19 15:25 [PATCHv4 " David Vrabel
2013-06-19 15:25 ` [PATCH 3/4] x86/xen: sync the wallclock when the system time is stepped David Vrabel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371755792-25962-4-git-send-email-david.vrabel@citrix.com \
--to=david.vrabel@citrix.com \
--cc=john.stultz@linaro.org \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).