KVM: Add irqfd to KVM's list via the vfs_poll() callback
authorSean Christopherson <seanjc@google.com>
Thu, 22 May 2025 23:52:14 +0000 (16:52 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 23 Jun 2025 16:50:55 +0000 (09:50 -0700)
commit5f8ca05ea99183ab2b69c7fd9617961211d194e7
treeb4c0974daf6c790d516a8a73f595b560b8a5b08e
parentb5c543518ae9df8e99c63cd08a8b573f0141b31a
KVM: Add irqfd to KVM's list via the vfs_poll() callback

Add the irqfd structure to KVM's list of irqfds in kvm_irqfd_register(),
i.e. via the vfs_poll() callback.  This will allow taking irqfds.lock
across the entire registration sequence (add to waitqueue, add to list),
and more importantly will allow inserting into KVM's list if and only if
adding to the waitqueue succeeds (spoiler alert), without needing to
juggle return codes in weird ways.

Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20250522235223.3178519-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
virt/kvm/eventfd.c