[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] x86/vtsc: update vcpu_time after 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.

This was not done correctly, since in context_switch
update_vcpu_system_time was called before vmx_do_resume, which caused
the vcpu_info time structure to be updated with the wrong values. This
patch fixes this by calling update_vcpu_system_time after the call to
hvm_set_guest_time has happened.

Signed-off-by: Roger Pau Monnà <roger.pau@xxxxxxxxxx>
Cc: Keir Fraser <keir@xxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
 xen/arch/x86/hvm/hvm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index a962ce2..e257dcf 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -343,6 +343,12 @@ void hvm_do_resume(struct vcpu *v)
     ioreq_t *p;
+    /*
+     * Update vcpu_info, since the call to pt_restore_timer can change
+     * the value in v->arch.hvm_vcpu.stime_offset that is used
+     * to calculate the TSC in vcpu_info->time.
+     */
+    update_vcpu_system_time(v);
-- (Apple Git-26)

Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.