Re: [RFC PATCH v3 16/21] KVM: x86: Factor out kvm_use_master_clock()

From: Paul Durrant
Date: Fri May 24 2024 - 10:13:18 EST


On 22/05/2024 01:17, David Woodhouse wrote:
From: David Woodhouse <dwmw@xxxxxxxxxxxx>

Both kvm_track_tsc_matching() and pvclock_update_vm_gtod_copy() make a
decision about whether the KVM clock should be in master clock mode.

They use *different* criteria for the decision though. This isn't really
a problem; it only has the potential to cause unnecessary invocations of
KVM_REQ_MASTERCLOCK_UPDATE if the masterclock was disabled due to TSC
going backwards, or the guest using the old MSR. But it isn't pretty.

Factor the decision out to a single function. And document the historical
reason why it's disabled for guests that use the old MSR_KVM_SYSTEM_TIME.

Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
---
arch/x86/kvm/x86.c | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)


Reviewed-by: Paul Durrant <paul@xxxxxxx>