aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hvm/i8254.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-05-24 09:27:03 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-05-24 09:27:03 +0100
commite1845bbe732b5ad5755f0f3a93fb6ea85919e8a2 (patch)
treefbdbe843c34d11b19ffc3fef6c6304103a1e7bc3 /xen/arch/x86/hvm/i8254.c
parentd0f28d825eafe00591d7b80b8de26e4fd783d924 (diff)
downloadxen-e1845bbe732b5ad5755f0f3a93fb6ea85919e8a2.tar.gz
xen-e1845bbe732b5ad5755f0f3a93fb6ea85919e8a2.tar.bz2
xen-e1845bbe732b5ad5755f0f3a93fb6ea85919e8a2.zip
hvm: Build guest timers on monotonic system time.
Move hvm platform timers from underlying physical CPU TSC to Xen system time and ensure domain-wide monotonicity. TSC on many systems may skew between processors leading to 'time going backwards' messages from some guests. Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'xen/arch/x86/hvm/i8254.c')
-rw-r--r--xen/arch/x86/hvm/i8254.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/xen/arch/x86/hvm/i8254.c b/xen/arch/x86/hvm/i8254.c
index ea6d1f11fc..090dbf7193 100644
--- a/xen/arch/x86/hvm/i8254.c
+++ b/xen/arch/x86/hvm/i8254.c
@@ -31,6 +31,7 @@
#include <xen/lib.h>
#include <xen/errno.h>
#include <xen/sched.h>
+#include <asm/time.h>
#include <asm/hvm/hvm.h>
#include <asm/hvm/io.h>
#include <asm/hvm/support.h>
@@ -87,7 +88,7 @@ static int pit_get_count(PITState *pit, int channel)
ASSERT(spin_is_locked(&pit->lock));
d = muldiv64(hvm_get_guest_time(v) - pit->count_load_time[channel],
- PIT_FREQ, ticks_per_sec(v));
+ PIT_FREQ, SYSTEM_TIME_HZ);
switch ( c->mode )
{
@@ -118,7 +119,7 @@ static int pit_get_out(PITState *pit, int channel)
ASSERT(spin_is_locked(&pit->lock));
d = muldiv64(hvm_get_guest_time(v) - pit->count_load_time[channel],
- PIT_FREQ, ticks_per_sec(v));
+ PIT_FREQ, SYSTEM_TIME_HZ);
switch ( s->mode )
{
@@ -195,11 +196,11 @@ static void pit_load_count(PITState *pit, int channel, int val)
val = 0x10000;
if ( v == NULL )
- rdtscll(pit->count_load_time[channel]);
+ pit->count_load_time[channel] = 0;
else
pit->count_load_time[channel] = hvm_get_guest_time(v);
s->count = val;
- period = DIV_ROUND((val * 1000000000ULL), PIT_FREQ);
+ period = DIV_ROUND(val * SYSTEM_TIME_HZ, PIT_FREQ);
if ( (v == NULL) || !is_hvm_vcpu(v) || (channel != 0) )
return;