KVM: Treat the device list as an rculist
authorOliver Upton <oliver.upton@linux.dev>
Mon, 22 Apr 2024 20:01:40 +0000 (20:01 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 25 Apr 2024 12:19:55 +0000 (13:19 +0100)
commitea54dd374232cc3b6d0ac0a89d715d61ebb04bf6
treeda27fc03564121f8a37927d596f93b4ab0832ea9
parentfec50db7033ea478773b159e0e2efb135270e3b7
KVM: Treat the device list as an rculist

A subsequent change to KVM/arm64 will necessitate walking the device
list outside of the kvm->lock. Prepare by converting to an rculist. This
has zero effect on the VM destruction path, as it is expected every
reader is backed by a reference on the kvm struct.

On the other hand, ensure a given device is completely destroyed before
dropping the kvm->lock in the release() path, as certain devices expect
to be a singleton (e.g. the vfio-kvm device).

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20240422200158.2606761-2-oliver.upton@linux.dev
Signed-off-by: Marc Zyngier <maz@kernel.org>
virt/kvm/kvm_main.c
virt/kvm/vfio.c