diff mbox

[v2] use guest value of version field in kvmclock

Message ID 1296653276-31931-1-git-send-email-glommer@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Glauber Costa Feb. 2, 2011, 1:27 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c39ab4a..5707405 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1151,15 +1151,18 @@  static int kvm_guest_time_update(struct kvm_vcpu *v)
 	vcpu->last_guest_tsc = tsc_timestamp;
 	vcpu->hv_clock.flags = 0;
 
+	shared_kaddr = kmap_atomic(vcpu->time_page, KM_USER0);
+
 	/*
 	 * The interface expects us to write an even number signaling that the
 	 * update is finished. Since the guest won't see the intermediate
-	 * state, we just increase by 2 at the end.
+	 * state, we just increase by 2 at the end. We use the guest's value as
+	 * a basis to make it migration-safe.
 	 */
+	memcpy(&vcpu->hv_clock.version, shared_kaddr + vcpu->time_offset,
+	       sizeof(vcpu->hv_clock.version));
 	vcpu->hv_clock.version += 2;
 
-	shared_kaddr = kmap_atomic(vcpu->time_page, KM_USER0);
-
 	memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
 	       sizeof(vcpu->hv_clock));