Fix a variety of bugs, flaws, and warts related to KVM's handling of PV clocks and the associated PVCLOCK_GUEST_STOPPED flag. Note, there are still a pile of issues with KVM's PV clock code; hopefully the next version of those changes[*] comes along sooner than later. [*] https://lore.kernel.org/all/20240522001817.619072-1-dwmw2@xxxxxxxxxxxxx The following changes since commit a64dcfb451e254085a7daee5fe51bf22959d52d3: Linux 6.14-rc2 (2025-02-09 12:45:03 -0800) are available in the Git repository at: https://github.com/kvm-x86/linux.git tags/kvm-x86-pvclock-6.15 for you to fetch changes up to 1b3c38050b5cc07f6873f244f845fb6c8549ce85: KVM: x86: Override TSC_STABLE flag for Xen PV clocks in kvm_guest_time_update() (2025-02-12 10:45:55 -0800) ---------------------------------------------------------------- KVM PV clock changes for 6.15: - Don't take kvm->lock when iterating over vCPUs in the suspend notifier to fix a largely theoretical deadlock. - Use the vCPU's actual Xen PV clock information when starting the Xen timer, as the cached state in arch.hv_clock can be stale/bogus. - Fix a bug where KVM could bleed PVCLOCK_GUEST_STOPPED across different PV clocks. - Restrict PVCLOCK_GUEST_STOPPED to kvmclock, as KVM's suspend notifier only accounts for kvmclock, and there's no evidence that the flag is actually supported by Xen guests. - Clean up the per-vCPU "cache" of its reference pvclock, and instead only track the vCPU's TSC scaling (multipler+shift) metadata (which is moderately expensive to compute, and rarely changes for modern setups). ---------------------------------------------------------------- Sean Christopherson (11): KVM: x86: Don't take kvm->lock when iterating over vCPUs in suspend notifier KVM: x86: Eliminate "handling" of impossible errors during SUSPEND KVM: x86: Drop local pvclock_flags variable in kvm_guest_time_update() KVM: x86: Process "guest stopped request" once per guest time update KVM: x86/xen: Use guest's copy of pvclock when starting timer KVM: x86: Don't bleed PVCLOCK_GUEST_STOPPED across PV clocks KVM: x86: Set PVCLOCK_GUEST_STOPPED only for kvmclock, not for Xen PV clock KVM: x86: Pass reference pvclock as a param to kvm_setup_guest_pvclock() KVM: x86: Remove per-vCPU "cache" of its reference pvclock KVM: x86: Setup Hyper-V TSC page before Xen PV clocks (during clock update) KVM: x86: Override TSC_STABLE flag for Xen PV clocks in kvm_guest_time_update() arch/x86/include/asm/kvm_host.h | 3 +- arch/x86/kvm/x86.c | 115 ++++++++++++++++++++-------------------- arch/x86/kvm/xen.c | 69 +++++++++++++++++++++--- 3 files changed, 121 insertions(+), 66 deletions(-)