WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] x86: rdtsc emulation (PV and HVM) must be

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86: rdtsc emulation (PV and HVM) must be monotonically increasing
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 02 Sep 2009 03:45:14 -0700
Delivery-date: Wed, 02 Sep 2009 03:46:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1251887942 -3600
# Node ID a787b0053395caf00a28621386852e45451aeacb
# Parent  e513d565c8f1298d26bc614eabd1b7111693a940
x86: rdtsc emulation (PV and HVM) must be monotonically increasing

The Intel SDM (section 18.10) clearly states that rdtsc
returns a "monotonically increasing unique value".
Current emulation code for rdtsc (both PV and HVM) returns
only a monotonically-non-decreasing (non-unique) value,
so ensure stale value is always incremented.

Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
---
 xen/arch/x86/hvm/vpt.c |    4 ++--
 xen/arch/x86/time.c    |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff -r e513d565c8f1 -r a787b0053395 xen/arch/x86/hvm/vpt.c
--- a/xen/arch/x86/hvm/vpt.c    Wed Sep 02 11:38:24 2009 +0100
+++ b/xen/arch/x86/hvm/vpt.c    Wed Sep 02 11:39:02 2009 +0100
@@ -47,10 +47,10 @@ u64 hvm_get_guest_time(struct vcpu *v)
 
     spin_lock(&pl->pl_time_lock);
     now = get_s_time() + pl->stime_offset;
-    if ( (int64_t)(now - pl->last_guest_time) >= 0 )
+    if ( (int64_t)(now - pl->last_guest_time) > 0 )
         pl->last_guest_time = now;
     else
-        now = pl->last_guest_time;
+        now = ++pl->last_guest_time;
     spin_unlock(&pl->pl_time_lock);
 
     return now + v->arch.hvm_vcpu.stime_offset;
diff -r e513d565c8f1 -r a787b0053395 xen/arch/x86/time.c
--- a/xen/arch/x86/time.c       Wed Sep 02 11:38:24 2009 +0100
+++ b/xen/arch/x86/time.c       Wed Sep 02 11:39:02 2009 +0100
@@ -1454,10 +1454,10 @@ void pv_soft_rdtsc(struct vcpu *v, struc
         rdtsc_usercount++;
         spin_lock(&v->domain->arch.vtsc_lock);
         now = get_s_time() + v->domain->arch.vtsc_stime_offset;
-        if ( (int64_t)(now - v->domain->arch.vtsc_last) >= 0 )
+        if ( (int64_t)(now - v->domain->arch.vtsc_last) > 0 )
             v->domain->arch.vtsc_last = now;
         else
-            now = v->domain->arch.vtsc_last;
+            now = ++v->domain->arch.vtsc_last;
         spin_unlock(&v->domain->arch.vtsc_lock);
         regs->eax = (uint32_t)now;
         regs->edx = (uint32_t)(now >> 32);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86: rdtsc emulation (PV and HVM) must be monotonically increasing, Xen patchbot-unstable <=