diff mbox

[v2,3/3] KVM: x86: zero kvmclock_offset when vcpu0 initializes kvmclock system MSR

Message ID 20150528232219.769743096@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti May 28, 2015, 11:20 p.m. UTC
Initialize kvmclock base, on kvmclock system MSR write time,
so that the guest sees kvmclock counting from zero.

This matches baremetal behaviour when kvmclock in guest
sets sched clock stable.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

---
 arch/x86/kvm/x86.c |    4 ++++
 1 file changed, 4 insertions(+)



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: kvm/arch/x86/kvm/x86.c
===================================================================
--- kvm.orig/arch/x86/kvm/x86.c	2015-05-28 19:18:12.621372286 -0300
+++ kvm/arch/x86/kvm/x86.c	2015-05-28 19:19:17.738268690 -0300
@@ -1700,6 +1700,8 @@ 
 		vcpu->pvclock_set_guest_stopped_request = false;
 	}
 
+	/* pvclock counts from zero */
+	pvclock_flags |= PVCLOCK_COUNTS_FROM_ZERO;
 	/* If the host uses TSC clocksource, then it is stable */
 	if (use_master_clock)
 		pvclock_flags |= PVCLOCK_TSC_STABLE_BIT;
@@ -2282,6 +2284,8 @@ 
 					&vcpu->requests);
 
 			ka->boot_vcpu_runs_old_kvmclock = tmp;
+
+			ka->kvmclock_offset = -get_kernel_ns();
 		}
 
 		vcpu->arch.time = data;