xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@citrix.com>
To: xen-devel@lists.xensource.com
Cc: David Vrabel <david.vrabel@citrix.com>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCHv2] x86: fix delta calculation in TSC deadline timer emulation
Date: Wed, 11 Apr 2012 11:31:48 +0100	[thread overview]
Message-ID: <1334140308-9914-1-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <4F855FEE020000780007D2DB@nat28.tlf.novell.com>

From: David Vrabel <david.vrabel@citrix.com>

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>
Cc: Jan Beulich <jbeulich@suse.com>
---
A 4.1.x candidate?

Changes since v1:
- remove unused guest_time variable
---
 xen/arch/x86/hvm/vlapic.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 8401756..abdb556 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -898,7 +898,6 @@ uint64_t  vlapic_tdt_msr_get(struct vlapic *vlapic)
 void vlapic_tdt_msr_set(struct vlapic *vlapic, uint64_t value)
 {
     uint64_t guest_tsc;
-    uint64_t guest_time;
     struct vcpu *v = vlapic_vcpu(vlapic);
 
     /* may need to exclude some other conditions like vlapic->hw.disabled */
@@ -910,12 +909,10 @@ void vlapic_tdt_msr_set(struct vlapic *vlapic, uint64_t value)
     
     /* new_value = 0, >0 && <= now, > now */
     guest_tsc = hvm_get_guest_tsc(v);
-    guest_time = hvm_get_guest_time(v);
     if ( value > guest_tsc )
     {
-        uint64_t delta = value - v->arch.hvm_vcpu.cache_tsc_offset;
-        delta = gtsc_to_gtime(v->domain, delta);
-        delta = max_t(s64, delta - guest_time, 0);
+        uint64_t delta = gtsc_to_gtime(v->domain, value - guest_tsc);
+        delta = max_t(s64, delta, 0);
 
         HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER, "delta[0x%016"PRIx64"]", delta);
 
@@ -949,9 +946,8 @@ void vlapic_tdt_msr_set(struct vlapic *vlapic, uint64_t value)
 
     HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER,
                 "tdt_msr[0x%016"PRIx64"],"
-                " gtsc[0x%016"PRIx64"],"
-                " gtime[0x%016"PRIx64"]",
-                vlapic->hw.tdt_msr, guest_tsc, guest_time);
+                " gtsc[0x%016"PRIx64"]",
+                vlapic->hw.tdt_msr, guest_tsc);
 }
 
 static int __vlapic_accept_pic_intr(struct vcpu *v)
-- 
1.7.2.5

  reply	other threads:[~2012-04-11 10:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-10 17:08 [PATCH] x86: fix delta calculation in TSC deadline timer emulation David Vrabel
2012-04-11  8:41 ` Jan Beulich
2012-04-11 10:31   ` David Vrabel [this message]
2012-04-11 10:37     ` [PATCHv2] " Jan Beulich

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=1334140308-9914-1-git-send-email-david.vrabel@citrix.com \
    --to=david.vrabel@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xensource.com \
    /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).