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 --- arch/x86/kvm/x86.c | 4 ++++ 1 file changed, 4 insertions(+) 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;