Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 299348
b: refs/heads/master
c: 21a1416
h: refs/heads/master
v: v3
  • Loading branch information
Alex Williamson authored and Marcelo Tosatti committed Apr 19, 2012
1 parent f88ee40 commit 689f870
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2225fd56049643c1a7d645c0ce9d499d43c7974e
refs/heads/master: 21a1416a1c945c5aeaeaf791b63c64926018eb77
23 changes: 15 additions & 8 deletions trunk/virt/kvm/iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,13 @@ int kvm_iommu_map_guest(struct kvm *kvm)
return -ENODEV;
}

mutex_lock(&kvm->slots_lock);

kvm->arch.iommu_domain = iommu_domain_alloc(&pci_bus_type);
if (!kvm->arch.iommu_domain)
return -ENOMEM;
if (!kvm->arch.iommu_domain) {
r = -ENOMEM;
goto out_unlock;
}

if (!allow_unsafe_assigned_interrupts &&
!iommu_domain_has_cap(kvm->arch.iommu_domain,
Expand All @@ -253,17 +257,16 @@ int kvm_iommu_map_guest(struct kvm *kvm)
" module option.\n", __func__);
iommu_domain_free(kvm->arch.iommu_domain);
kvm->arch.iommu_domain = NULL;
return -EPERM;
r = -EPERM;
goto out_unlock;
}

r = kvm_iommu_map_memslots(kvm);
if (r)
goto out_unmap;

return 0;
kvm_iommu_unmap_memslots(kvm);

out_unmap:
kvm_iommu_unmap_memslots(kvm);
out_unlock:
mutex_unlock(&kvm->slots_lock);
return r;
}

Expand Down Expand Up @@ -340,7 +343,11 @@ int kvm_iommu_unmap_guest(struct kvm *kvm)
if (!domain)
return 0;

mutex_lock(&kvm->slots_lock);
kvm_iommu_unmap_memslots(kvm);
kvm->arch.iommu_domain = NULL;
mutex_unlock(&kvm->slots_lock);

iommu_domain_free(domain);
return 0;
}

0 comments on commit 689f870

Please sign in to comment.