]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: eventfd: Fix lock order inversion.
authorCornelia Huck <cornelia.huck@de.ibm.com>
Mon, 17 Mar 2014 18:11:35 +0000 (19:11 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 18 Mar 2014 16:06:04 +0000 (17:06 +0100)
commit9f3ffc5a8455a6d0af0360fcc0396a112ed5fa74
treeeb83541090766873f36f9916e720ff0a85e1eeb2
parentdf52c05f1c8a8c5a05e5ae7d726cf1bb574a623a
KVM: eventfd: Fix lock order inversion.

When registering a new irqfd, we call its ->poll method to collect any
event that might have previously been pending so that we can trigger it.
This is done under the kvm->irqfds.lock, which means the eventfd's ctx
lock is taken under it.

However, if we get a POLLHUP in irqfd_wakeup, we will be called with the
ctx lock held before getting the irqfds.lock to deactivate the irqfd,
causing lockdep to complain.

Calling the ->poll method does not really need the irqfds.lock, so let's
just move it after we've given up the irqfds.lock in kvm_irqfd_assign().

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/eventfd.c