Re: [PATCH v2] KVM: x86: Refine calculation of guest wall clock to use a single TSC read
From: Sean Christopherson
Date: Thu Oct 05 2023 - 23:49:45 EST
On Thu, 05 Oct 2023 10:16:10 +0100, David Woodhouse wrote:
> When populating the guest's PV wall clock information, KVM currently does
> a simple 'kvm_get_real_ns() - get_kvmclock_ns(kvm)'. This is an antipattern
> which should be avoided; when working with the relationship between two
> clocks, it's never correct to obtain one of them "now" and then the other
> at a slightly different "now" after an unspecified period of preemption
> (which might not even be under the control of the kernel, if this is an
> L1 hosting an L2 guest under nested virtualization).
>
> [...]
Applied to kvm-x86 misc, thanks! And double thanks for the function comment,
it's awesome!
Note, I moved the declaration in x86.h just below get_kvmclock_ns() to bundle
the two kvmclock helpers together.
[1/1] KVM: x86: Refine calculation of guest wall clock to use a single TSC read
https://github.com/kvm-x86/linux/commit/5d6d6a7d7e66
--
https://github.com/kvm-x86/linux/tree/next