diff options
author | Roger Pau Monné <roger.pau@citrix.com> | 2013-06-13 11:26:53 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2013-06-13 11:26:53 +0200 |
commit | 3990446a39c17222729437e606f8d10641e3bdda (patch) | |
tree | 9e11c9b035334086798f15f42523d708c88e3132 | |
parent | 0bda88abe18029c2bbe9dc5d07cc706bd775c9b7 (diff) | |
download | xen-3990446a39c17222729437e606f8d10641e3bdda.tar.gz xen-3990446a39c17222729437e606f8d10641e3bdda.tar.bz2 xen-3990446a39c17222729437e606f8d10641e3bdda.zip |
x86/vtsc: update vcpu_time in hvm_set_guest_time
When using a vtsc, hvm_set_guest_time changes hvm_vcpu.stime_offset,
which is used in the vcpu time structure to calculate the
tsc_timestamp, so after updating stime_offset we need to propagate the
change to vcpu_time in order for the guest to get the right time if
using the PV clock.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com>
master commit: 32c864a35ece2c24a336d183869a546798a4b241
master date: 2013-06-05 10:03:08 +0200
-rw-r--r-- | xen/arch/x86/hvm/vpt.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/xen/arch/x86/hvm/vpt.c b/xen/arch/x86/hvm/vpt.c index 353eda0343..ec0aba681a 100644 --- a/xen/arch/x86/hvm/vpt.c +++ b/xen/arch/x86/hvm/vpt.c @@ -56,7 +56,19 @@ u64 hvm_get_guest_time(struct vcpu *v) void hvm_set_guest_time(struct vcpu *v, u64 guest_time) { - v->arch.hvm_vcpu.stime_offset += guest_time - hvm_get_guest_time(v); + u64 offset = guest_time - hvm_get_guest_time(v); + + if ( offset ) + { + v->arch.hvm_vcpu.stime_offset += offset; + /* + * If hvm_vcpu.stime_offset is updated make sure to + * also update vcpu time, since this value is used to + * calculate the TSC. + */ + if ( v == current ) + update_vcpu_system_time(v); + } } static int pt_irq_vector(struct periodic_time *pt, enum hvm_intsrc src) |