diff options
author | Mark McLoughlin <markmc@redhat.com> | 2009-02-05 19:23:46 +0100 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2009-02-15 01:47:39 +0100 |
commit | 682edb4c01e690c7c7cd772dbd6f4e0fd74dc572 (patch) | |
tree | 21e41d8f67f3fc81df9744e91350e76b1787ec3b /virt/kvm/kvm_main.c | |
parent | KVM: x86: fix LAPIC pending count calculation (diff) | |
download | linux-682edb4c01e690c7c7cd772dbd6f4e0fd74dc572.tar.xz linux-682edb4c01e690c7c7cd772dbd6f4e0fd74dc572.zip |
KVM: Fix assigned devices circular locking dependency
kvm->slots_lock is outer to kvm->lock, so take slots_lock
in kvm_vm_ioctl_assign_device() before taking kvm->lock,
rather than taking it in kvm_iommu_map_memslots().
Cc: stable@kernel.org
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index d9bbb20f230f..29a667ce35b0 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -466,6 +466,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm, struct kvm_assigned_dev_kernel *match; struct pci_dev *dev; + down_read(&kvm->slots_lock); mutex_lock(&kvm->lock); match = kvm_find_assigned_dev(&kvm->arch.assigned_dev_head, @@ -527,6 +528,7 @@ static int kvm_vm_ioctl_assign_device(struct kvm *kvm, out: mutex_unlock(&kvm->lock); + up_read(&kvm->slots_lock); return r; out_list_del: list_del(&match->list); @@ -538,6 +540,7 @@ out_put: out_free: kfree(match); mutex_unlock(&kvm->lock); + up_read(&kvm->slots_lock); return r; } #endif |