xcp-1.6-updates/xen-4.1.hg

changeset 23277:80130491806f

x86: fix delta calculation in TSC deadline timer emulation

In the virtual LAPIC, correct the delta calculation when emulating the
TSC deadline timer.

Without this fix, XenServer (which is based on Xen 4.1) does not work
when running as an HVM guest. dom0 fails to boot because its timer
interrupts are very delayed (by several minutes in some cases).

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Keir Fraser <keir@xen.org>
xen-unstable changeset: 25191:a95fc7decc83
xen-unstable date: Wed Apr 11 16:49:45 2012 +0100
author David Vrabel <david.vrabel@citrix.com>
date Wed Apr 11 19:41:14 2012 +0100 (2012-04-11)
parents 6f224431eca2
children 0aa6bc8f38a9
files xen/arch/x86/hvm/vlapic.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vlapic.c	Wed Apr 04 16:09:25 2012 +0100
     1.2 +++ b/xen/arch/x86/hvm/vlapic.c	Wed Apr 11 19:41:14 2012 +0100
     1.3 @@ -889,7 +889,6 @@ uint64_t  vlapic_tdt_msr_get(struct vlap
     1.4  void vlapic_tdt_msr_set(struct vlapic *vlapic, uint64_t value)
     1.5  {
     1.6      uint64_t guest_tsc;
     1.7 -    uint64_t guest_time;
     1.8      struct vcpu *v = vlapic_vcpu(vlapic);
     1.9  
    1.10      /* may need to exclude some other conditions like vlapic->hw.disabled */
    1.11 @@ -901,12 +900,10 @@ void vlapic_tdt_msr_set(struct vlapic *v
    1.12      
    1.13      /* new_value = 0, >0 && <= now, > now */
    1.14      guest_tsc = hvm_get_guest_tsc(v);
    1.15 -    guest_time = hvm_get_guest_time(v);
    1.16      if ( value > guest_tsc )
    1.17      {
    1.18 -        uint64_t delta = value - v->arch.hvm_vcpu.cache_tsc_offset;
    1.19 -        delta = gtsc_to_gtime(v->domain, delta);
    1.20 -        delta = max_t(s64, delta - guest_time, 0);
    1.21 +        uint64_t delta = gtsc_to_gtime(v->domain, value - guest_tsc);
    1.22 +        delta = max_t(s64, delta, 0);
    1.23  
    1.24          HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER, "delta[0x%016"PRIx64"]", delta);
    1.25  
    1.26 @@ -940,9 +937,8 @@ void vlapic_tdt_msr_set(struct vlapic *v
    1.27  
    1.28      HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER,
    1.29                  "tdt_msr[0x%016"PRIx64"],"
    1.30 -                " gtsc[0x%016"PRIx64"],"
    1.31 -                " gtime[0x%016"PRIx64"]",
    1.32 -                vlapic->hw.tdt_msr, guest_tsc, guest_time);
    1.33 +                " gtsc[0x%016"PRIx64"]",
    1.34 +                vlapic->hw.tdt_msr, guest_tsc);
    1.35  }
    1.36  
    1.37  static int __vlapic_accept_pic_intr(struct vcpu *v)