diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-05-24 09:27:03 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-05-24 09:27:03 +0100 |
commit | e1845bbe732b5ad5755f0f3a93fb6ea85919e8a2 (patch) | |
tree | fbdbe843c34d11b19ffc3fef6c6304103a1e7bc3 /xen/include/asm-x86 | |
parent | d0f28d825eafe00591d7b80b8de26e4fd783d924 (diff) | |
download | xen-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/include/asm-x86')
-rw-r--r-- | xen/include/asm-x86/hvm/hvm.h | 6 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/vcpu.h | 3 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/vmx/vmx.h | 1 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/vpt.h | 7 |
4 files changed, 13 insertions, 4 deletions
diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 815a5c2b02..e871bf8be7 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -147,8 +147,10 @@ void hvm_send_assist_req(struct vcpu *v); void hvm_set_guest_tsc(struct vcpu *v, u64 guest_tsc); u64 hvm_get_guest_tsc(struct vcpu *v); -#define hvm_set_guest_time(vcpu, gtime) hvm_set_guest_tsc(vcpu, gtime) -#define hvm_get_guest_time(vcpu) hvm_get_guest_tsc(vcpu) + +void hvm_init_guest_time(struct domain *d); +void hvm_set_guest_time(struct vcpu *v, u64 guest_time); +u64 hvm_get_guest_time(struct vcpu *v); #define hvm_paging_enabled(v) \ (!!((v)->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PG)) diff --git a/xen/include/asm-x86/hvm/vcpu.h b/xen/include/asm-x86/hvm/vcpu.h index fc43d5d20d..6eb9d67b73 100644 --- a/xen/include/asm-x86/hvm/vcpu.h +++ b/xen/include/asm-x86/hvm/vcpu.h @@ -68,6 +68,9 @@ struct hvm_vcpu { struct mtrr_state mtrr; u64 pat_cr; + /* In mode delay_for_missed_ticks, VCPUs have differing guest times. */ + int64_t stime_offset; + /* Which cache mode is this VCPU in (CR0:CD/NW)? */ u8 cache_mode; diff --git a/xen/include/asm-x86/hvm/vmx/vmx.h b/xen/include/asm-x86/hvm/vmx/vmx.h index b7681f0e29..0e381f7e1d 100644 --- a/xen/include/asm-x86/hvm/vmx/vmx.h +++ b/xen/include/asm-x86/hvm/vmx/vmx.h @@ -49,7 +49,6 @@ void vmx_asm_vmexit_handler(struct cpu_user_regs); void vmx_asm_do_vmentry(void); void vmx_intr_assist(void); void vmx_do_resume(struct vcpu *); -void set_guest_time(struct vcpu *v, u64 gtime); void vmx_vlapic_msr_changed(struct vcpu *v); void vmx_realmode(struct cpu_user_regs *regs); diff --git a/xen/include/asm-x86/hvm/vpt.h b/xen/include/asm-x86/hvm/vpt.h index ddc099975d..24026fb118 100644 --- a/xen/include/asm-x86/hvm/vpt.h +++ b/xen/include/asm-x86/hvm/vpt.h @@ -57,7 +57,7 @@ struct hpet_registers { typedef struct HPETState { struct hpet_registers hpet; struct vcpu *vcpu; - uint64_t tsc_freq; + uint64_t stime_freq; uint64_t hpet_to_ns_scale; /* hpet ticks to ns (multiplied by 2^10) */ uint64_t hpet_to_ns_limit; /* max hpet ticks convertable to ns */ uint64_t mc_offset; @@ -137,6 +137,11 @@ struct pl_time { /* platform time */ struct RTCState vrtc; struct HPETState vhpet; struct PMTState vpmt; + /* guest_time = Xen sys time + stime_offset */ + int64_t stime_offset; + /* Ensures monotonicity in appropriate timer modes. */ + uint64_t last_guest_time; + spinlock_t pl_time_lock; }; #define ticks_per_sec(v) (v->domain->arch.hvm_domain.tsc_frequency) |