KVM: x86: initialize kvmclock_offset
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 1 Sep 2016 13:44:57 +0000 (15:44 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 20 Sep 2016 07:26:13 +0000 (09:26 +0200)
Make the guest's kvmclock count up from zero, not from the host boot
time.  The guest cannot rely on that anyway because it changes on
migration, the numbers are easier on the eye and finally it matches the
desired semantics of the Hyper-V time reference counter.

Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c

index d1e830715e402e4c9bc09b3a13ce81534163e6dd..00e569c3ca712a755b9465aa0a19ee5f71c396d8 100644 (file)
@@ -7779,6 +7779,7 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
        mutex_init(&kvm->arch.apic_map_lock);
        spin_lock_init(&kvm->arch.pvclock_gtod_sync_lock);
 
+       kvm->arch.kvmclock_offset = -get_kernel_ns();
        pvclock_update_vm_gtod_copy(kvm);
 
        INIT_DELAYED_WORK(&kvm->arch.kvmclock_update_work, kvmclock_update_fn);