• Cornelia Huck's avatar
    KVM: eventfd: Fix lock order inversion. · 684a0b71
    Cornelia Huck authored
    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: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    684a0b71
eventfd.c 19.7 KB