On Fri, 2022-07-29 at 21:14 +0000, Sean Christopherson wrote: > On Thu, Jul 07, 2022, Simon Veith wrote: > > The Time Stamp Counter (TSC) value register can be set to an absolute > > value using the KVM_SET_MSRS ioctl, which calls kvm_synchronize_tsc() > > internally. > > > > Since this is a per-vCPU register, and vCPUs are often managed by > > separate threads, setting a uniform TSC value across all vCPUs is > > challenging: After live migration, for example, the TSC value may need > > to be adjusted to account for the migration downtime. Ideally, we would > > want each vCPU to be adjusted by the same offset; but if we compute the > > offset centrally, the TSC value may become out of date due to scheduling > > delays by the time that each vCPU thread gets around to issuing > > KVM_SET_MSRS. > > > > In preparation for the next patch, this change adds an optional, KVM > > clock based time reference argument to kvm_synchronize_tsc(). This > > argument, if present, is understood to mean "the TSC value being written > > was valid at this corresponding KVM clock time point". > > > Given that commit 828ca89628bf ("KVM: x86: Expose TSC offset controls to userspace") > was merged less than a year ago, it would be helpful to explicitly call out why > KVM_VCPU_TSC_CTRL doesn't work, and why that sub-ioctl can't be extended/modified to > make it work. > > > kvm_synchronize_tsc() will then use this clock reference to adjust the > > TSC value being written for any delays that have been incurred since the > > provided TSC value was valid. > > > > Co-developed-by: David Woodhouse <dwmw@xxxxxxxxxxxx> > > Needs David's SOB. For the record (and for the half-baked "do it like this, except in a way that might stand a chance of compiling..." that I threw at Simon on Slack and didn't necessarily even expect him to credit me for authorship) Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
Attachment:
smime.p7s
Description: S/MIME cryptographic signature