debuggers.hg

changeset 20676:db8a985693f7

Fix clock for XCP Windows PV drivers on restore

This fixes a timekeeping issue for 32 bit guests running XCP Windows
paravirtual drivers on a 64 bit hypervisor where their clock was set
to the 1970s after live migration or restore. Thanks to Paul Durrant
for helping track this down.

>From the original XCP patch:

Arrange that the wallclock time fields in the shared_info structure
are set correctly in 32 bit HVM guests on a 64 bit hypervisor. HVM
guests on a 64 bit hypervisor always start with a 64 bit shared info,
and then change to a 32 bit one if they're using 32 bit drivers. The
32-bit and 64-bit shared info structures put their wallclock times in
slightly different places, and so the wallclock time needs to be
regenerated when you do the conversion.

It can be argued that we should convert the other fields of shared
info at the same time (e.g. if an event channel is pending beforehand,
it should be pending afterwards), but that's much harder to arrange,
because the 32 bit structure can't represent all the states which the
64 bit one can. Just setting the time seems to be sufficient for
our purposes.

Signed-off-by: Steven Smith <steven.smith@citrix.com>
Signed-off-by: Keith Coleman <keith@scaltro.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Dec 14 07:55:35 2009 +0000 (2009-12-14)
parents 2d9c58c29a94
children 7162eff6d085
files xen/arch/x86/hvm/hvm.c
line diff
     1.1 --- a/xen/arch/x86/hvm/hvm.c	Mon Dec 14 07:54:53 2009 +0000
     1.2 +++ b/xen/arch/x86/hvm/hvm.c	Mon Dec 14 07:55:35 2009 +0000
     1.3 @@ -2331,14 +2331,32 @@ int hvm_do_hypercall(struct cpu_user_reg
     1.4  
     1.5  static void hvm_latch_shinfo_size(struct domain *d)
     1.6  {
     1.7 +    bool_t new_has_32bit;
     1.8 +
     1.9      /*
    1.10       * Called from operations which are among the very first executed by
    1.11       * PV drivers on initialisation or after save/restore. These are sensible
    1.12       * points at which to sample the execution mode of the guest and latch
    1.13       * 32- or 64-bit format for shared state.
    1.14       */
    1.15 -    if ( current->domain == d )
    1.16 -        d->arch.has_32bit_shinfo = (hvm_guest_x86_mode(current) != 8);
    1.17 +    if ( current->domain == d ) {
    1.18 +        new_has_32bit = (hvm_guest_x86_mode(current) != 8);
    1.19 +        if (new_has_32bit != d->arch.has_32bit_shinfo) {
    1.20 +            d->arch.has_32bit_shinfo = new_has_32bit;
    1.21 +            /*
    1.22 +             * Make sure that the timebase in the shared info
    1.23 +             * structure is correct for its new bit-ness.  We should
    1.24 +             * arguably try to convert the other fields as well, but
    1.25 +             * that's much more problematic (e.g. what do you do if
    1.26 +             * you're going from 64 bit to 32 bit and there's an event
    1.27 +             * channel pending which doesn't exist in the 32 bit
    1.28 +             * version?).  Just setting the wallclock time seems to be
    1.29 +             * sufficient for everything we do, even if it is a bit of
    1.30 +             * a hack.
    1.31 +             */
    1.32 +            update_domain_wallclock_time(d);
    1.33 +        }
    1.34 +    }
    1.35  }
    1.36  
    1.37  /* Initialise a hypercall transfer page for a VMX domain using