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-devel

[Xen-devel] [PATCH 1/5] vtdt: Define a new function gtsc_to_gtime()

To: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 1/5] vtdt: Define a new function gtsc_to_gtime()
From: "Wei, Gang" <gang.wei@xxxxxxxxx>
Date: Tue, 14 Dec 2010 11:26:11 +0800
Accept-language: zh-CN, en-US
Acceptlanguage: zh-CN, en-US
Cc: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, "Wei, Gang" <gang.wei@xxxxxxxxx>
Delivery-date: Mon, 13 Dec 2010 19:27:56 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcubPqe7vraTqCKpTCanz6bNFLQx6Q==
Thread-topic: [PATCH 1/5] vtdt: Define a new function gtsc_to_gtime()
vtdt: Define a new function gtsc_to_gtime()

Define it to do the transform from guest tsc to guest time.

Fix the typo in gtime_to_gtsc() definition.

Signed-off-by: Wei Gang <gang.wei@xxxxxxxxx>

diff -r 373b7357d977 xen/arch/x86/time.c
--- a/xen/arch/x86/time.c       Thu Dec 09 22:32:43 2010 +0800
+++ b/xen/arch/x86/time.c       Thu Dec 09 22:32:51 2010 +0800
@@ -1634,11 +1634,20 @@ static void __init tsc_parse(const char 
 }
 custom_param("tsc", tsc_parse);
 
-u64 gtime_to_gtsc(struct domain *d, u64 tsc)
+u64 gtime_to_gtsc(struct domain *d, u64 time)
 {
     if ( !is_hvm_domain(d) )
-        tsc = max_t(s64, tsc - d->arch.vtsc_offset, 0);
-    return scale_delta(tsc, &d->arch.ns_to_vtsc);
+        time = max_t(s64, time - d->arch.vtsc_offset, 0);
+    return scale_delta(time, &d->arch.ns_to_vtsc);
+}
+
+u64 gtsc_to_gtime(struct domain *d, u64 tsc)
+{
+    u64 time = scale_delta(tsc, &d->arch.vtsc_to_ns);
+
+    if ( !is_hvm_domain(d) )
+        time += d->arch.vtsc_offset;
+    return time;
 }
 
 void pv_soft_rdtsc(struct vcpu *v, struct cpu_user_regs *regs, int rdtscp)
diff -r 373b7357d977 xen/include/asm-x86/time.h
--- a/xen/include/asm-x86/time.h        Thu Dec 09 22:32:43 2010 +0800
+++ b/xen/include/asm-x86/time.h        Thu Dec 09 22:32:51 2010 +0800
@@ -59,7 +59,8 @@ uint64_t tsc_ticks2ns(uint64_t ticks);
 uint64_t tsc_ticks2ns(uint64_t ticks);
 
 void pv_soft_rdtsc(struct vcpu *v, struct cpu_user_regs *regs, int rdtscp);
-u64 gtime_to_gtsc(struct domain *d, u64 tsc);
+u64 gtime_to_gtsc(struct domain *d, u64 time);
+u64 gtsc_to_gtime(struct domain *d, u64 tsc);
 
 void tsc_set_info(struct domain *d, uint32_t tsc_mode, uint64_t elapsed_nsec,
                   uint32_t gtsc_khz, uint32_t incarnation);

Attachment: 2-gtsc_to_gtime.patch
Description: 2-gtsc_to_gtime.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 1/5] vtdt: Define a new function gtsc_to_gtime(), Wei, Gang <=