Messages in this thread | ![/](/images/icornerl.gif) | | From | "Allister, Jack" <> | Subject | Re: [PATCH 1/2] KVM: x86: Add KVM_[GS]ET_CLOCK_GUEST for KVM clock drift fixup | Date | Wed, 10 Apr 2024 10:08:29 +0000 |
| |
> Would the above rely not only on TSC clocksource, but also > ka->use_master_clock==true?
Yes this should only be in the case of master clock. Extra verification to check this for both GET/SET should be present.
> What will happen if the vCPU=0 (e.g., BSP) thread is racing with here > to update the vcpu->arch.hv_clock?
> In addition to live migration, can the user call this API any time > during the VM is running (to fix the clock drift)? Therefore, any > requirement to protect the update of kvmclock_offset from racing?
This should occur when none of the vCPUs are running, in the context of a live-migration/update this would be after deserialization before the resume. I may have been unintentionally misleading here describing some of the problem space. There isn't a "drift" per say when a VM is running and the PVTI stays constant. It's more the relationship between the TSC & PV clock changes due to inaccuracy when KVM decides to generate that information, e.g on a live-update/migration KVM will perform the update. The KVM_REQ_MASTERCLOCK_UPDATE is just an example as to how to simulate/trigger this.
I've posted a V2 which hopefully addresses some of above and makes it clearer overall the aim behind the patches.
| ![\](/images/icornerr.gif) |