]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: x86: Avoid global clock update on setting KVM clock MSR
authorDavid Woodhouse <dwmw@amazon.co.uk>
Sun, 28 Apr 2024 12:27:17 +0000 (13:27 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 22 May 2024 00:05:41 +0000 (17:05 -0700)
Commit 0061d53daf26 ("KVM: x86: limit difference between kvmclock updates")
introduced a KVM_REQ_GLOBAL_CLOCK_UPDATE when one vCPU set up its clock.

This was a workaround for the ever-drifting clocks which were based on the
host's CLOCK_MONOTONIC and thus subject to NTP skew. On booting or resuming
a guest, it just leads to running kvm_guest_time_update() twice for each
vCPU for now good reason.

Just use KVM_REQ_CLOCK_UPDATE on the vCPU itself, and only in the case
where the KVM clock is being set up, not turned off.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
arch/x86/kvm/x86.c

index 437412b36caeab50ca453e8df39c6b4a292fabbb..32a873d5ed00686128c3ffbe84a949edc03ffb0a 100644 (file)
@@ -2361,13 +2361,13 @@ static void kvm_write_system_time(struct kvm_vcpu *vcpu, gpa_t system_time,
        }
 
        vcpu->arch.time = system_time;
-       kvm_make_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu);
 
        /* we verify if the enable bit is set... */
-       if (system_time & 1)
+       if (system_time & 1) {
                kvm_gpc_activate(&vcpu->arch.pv_time, system_time & ~1ULL,
                                 sizeof(struct pvclock_vcpu_time_info));
-       else
+               kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
+       } else
                kvm_gpc_deactivate(&vcpu->arch.pv_time);
 
        return;