[GIT PULL] KVM: vcpu_array fixes and cleanups for 6.14

From: Sean Christopherson
Date: Thu Jan 16 2025 - 20:09:37 EST


The wonderful vcpu_array changes that you already know and love :-D

The following changes since commit 3522c419758ee8dca5a0e8753ee0070a22157bc1:

Merge tag 'kvm-riscv-fixes-6.13-1' of https://github.com/kvm-riscv/linux into HEAD (2024-12-13 13:59:20 -0500)

are available in the Git repository at:

https://github.com/kvm-x86/linux.git tags/kvm-x86-vcpu_array-6.14

for you to fetch changes up to 01528db67f28d5919f7b0a68900dc212165218e2:

KVM: Drop hack that "manually" informs lockdep of kvm->lock vs. vcpu->mutex (2024-12-16 14:37:30 -0800)

----------------------------------------------------------------
KVM vcpu_array fixes and cleanups for 6.14:

- Explicitly verify the target vCPU is online in kvm_get_vcpu() to fix a bug
where KVM would return a pointer to a vCPU prior to it being fully online,
and give kvm_for_each_vcpu() similar treatment to fix a similar flaw.

- Wait for a vCPU to come online prior to executing a vCPU ioctl to fix a
bug where userspace could coerce KVM into handling the ioctl on a vCPU that
isn't yet onlined.

- Gracefully handle xa_insert() failures even though such failuires should be
impossible in practice.

----------------------------------------------------------------
Sean Christopherson (6):
KVM: Explicitly verify target vCPU is online in kvm_get_vcpu()
KVM: Verify there's at least one online vCPU when iterating over all vCPUs
KVM: Grab vcpu->mutex across installing the vCPU's fd and bumping online_vcpus
Revert "KVM: Fix vcpu_array[0] races"
KVM: Don't BUG() the kernel if xa_insert() fails with -EBUSY
KVM: Drop hack that "manually" informs lockdep of kvm->lock vs. vcpu->mutex

include/linux/kvm_host.h | 16 +++++++++---
virt/kvm/kvm_main.c | 68 ++++++++++++++++++++++++++++++++++++------------
2 files changed, 65 insertions(+), 19 deletions(-)