xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Paul Durrant <Paul.Durrant@citrix.com>,
	Keir Fraser <keir@xen.org>, Jan Beulich <JBeulich@suse.com>
Subject: [Patch v2] x86/time: Correctly update the domain wallclock in the shared info page
Date: Tue, 16 Jul 2013 11:26:30 +0100	[thread overview]
Message-ID: <1373970390-6692-1-git-send-email-andrew.cooper3@citrix.com> (raw)

For a normal HVM domain on 64bit Xen, the shared info switches to 32bit for
hvmloader, then to the native size for the HVM guest.  This guarantees at
least one transition during which the wallclock information will be updated.

The wallclock for each domain gets updated when dom0 issues a XENPF_settime
hypercall to updated the wallclock base time.

However, for a 64bit domain on 64bit Xen which is resuming from S4,
(i.e. bypassing hvmloader), there are no transitions in the size of the shared
info page, meaning that before the next XENPF_settime from dom0, the domU PV
drivers will find the Unix Epoch in the wallclock rather than the correct
time.

Therefore, manually set the wallclock when creating the domain, so it is set
right from the start of the domain, and when manually adjusting the domain
time offset, as it depends on the same value which has just been adjusted.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Paul Durrant <Paul.Durrant@citrix.com>
---
This fixes a bug presence since Xen gained 64bit support, which had been
hacked around in a gross way in XenServer.

It should be backported to all stable releases.

Changes since v1:
 * s/watchdog/wallclock/ - Stupid typo.
---
 xen/arch/x86/domain.c |    1 +
 xen/arch/x86/time.c   |    1 +
 2 files changed, 2 insertions(+)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 874742c..664d598 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -546,6 +546,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
         clear_page(d->shared_info);
         share_xen_page_with_guest(
             virt_to_page(d->shared_info), d, XENSHARE_writable);
+        update_domain_wallclock_time(d);
 
         if ( (rc = init_domain_irq_mapping(d)) != 0 )
             goto fail;
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index cf8bc78..f047cb3 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -931,6 +931,7 @@ void domain_set_time_offset(struct domain *d, int32_t time_offset_seconds)
     d->time_offset_seconds = time_offset_seconds;
     if ( is_hvm_domain(d) )
         rtc_update_clock(d);
+    update_domain_wallclock_time(d);
 }
 
 int cpu_frequency_change(u64 freq)
-- 
1.7.10.4

                 reply	other threads:[~2013-07-16 10:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1373970390-6692-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Paul.Durrant@citrix.com \
    --cc=keir@xen.org \
    --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).