These apply on top of Paul's shared-info series (v14) from https://xenbits.xen.org/gitweb/?p=people/pauldu/linux.git;a=shortlog;h=refs/heads/shared-info14 and https://lore.kernel.org/kvm/20240215152916.1158-1-paul@xxxxxxx/T/#t (less patch 21 of that series, which is reworked to come at the end of *this* series instead, as an optional cleanup for later as discussed.) First, deal with the awful brokenness of the KVM clock, and its systemic drift especially when TSC scaling is used. This is a bit of a workaround for Xen timers where it hurts *most*, but it's actually easier in this case because there is a vCPU (and associated PV clock information) to use for the scaling. A better fix for __get_kvmclock() is in the works, but there's an enormous yak to shave there because there are so many interrelated bugs in the TSC and timekeeping code. Ensure that the guest doesn't miss Xen event channel wakeups which are already pending when the local APIC is enabled. Userspace doesn't get to interpose here, so KVM needs to do the same as Xen and explicitly check for the pending event. While looking at that, Michal spotted a potential false positive from the WARN_ON_ONCE() when delivering the vector, so fix that too. The remainder of the series is about cleaning up locking, simplifying the pfncache locking so that a recursive lock deadlock in the Xen code can be eliminated (by virtue of the inner function not having to take that lock at all any more). The final patch in the series is optional, but probably worth doing anyway. In moving the rwlock cleanup to be an optional patch at the end of the series, I've reworked the commit messages so most of the lamentation about the existing horridness, and the mention of the "bug that should not happen", is in the simpler ->refresh_lock patch. David Woodhouse (6): KVM: x86/xen: improve accuracy of Xen timers KVM: x86/xen: inject vCPU upcall vector when local APIC is enabled KVM: x86/xen: remove WARN_ON_ONCE() with false positives in evtchn delivery KVM: pfncache: simplify locking and make more self-contained KVM: x86/xen: fix recursive deadlock in timer injection KVM: pfncache: clean up rwlock abuse arch/x86/kvm/lapic.c | 5 +- arch/x86/kvm/x86.c | 61 +++++++++++++++++++++-- arch/x86/kvm/x86.h | 1 + arch/x86/kvm/xen.c | 133 ++++++++++++++++++++++++++++++++++++--------------- arch/x86/kvm/xen.h | 18 +++++++ virt/kvm/pfncache.c | 33 ++++++++----- 6 files changed, 195 insertions(+), 56 deletions(-)