• Paul Mackerras's avatar
    KVM: PPC: Book3S HV: Don't take kvm->lock around kvm_for_each_vcpu · 5a3f4936
    Paul Mackerras authored
    Currently the HV KVM code takes the kvm->lock around calls to
    kvm_for_each_vcpu() and kvm_get_vcpu_by_id() (which can call
    kvm_for_each_vcpu() internally).  However, that leads to a lock
    order inversion problem, because these are called in contexts where
    the vcpu mutex is held, but the vcpu mutexes nest within kvm->lock
    according to Documentation/virtual/kvm/locking.txt.  Hence there
    is a possibility of deadlock.
    
    To fix this, we simply don't take the kvm->lock mutex around these
    calls.  This is safe because the implementations of kvm_for_each_vcpu()
    and kvm_get_vcpu_by_id() have been designed to be able to be called
    locklessly.
    Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
    Reviewed-by: default avatarCédric Le Goater <clg@kaod.org>
    Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
    5a3f4936
book3s_hv.c 143 KB