diff options
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/iommu.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c index 673c88a8efe9..779559552ce7 100644 --- a/virt/kvm/iommu.c +++ b/virt/kvm/iommu.c | |||
@@ -126,9 +126,10 @@ unmap_pages: | |||
126 | 126 | ||
127 | static int kvm_iommu_map_memslots(struct kvm *kvm) | 127 | static int kvm_iommu_map_memslots(struct kvm *kvm) |
128 | { | 128 | { |
129 | int i, r = 0; | 129 | int i, idx, r = 0; |
130 | struct kvm_memslots *slots; | 130 | struct kvm_memslots *slots; |
131 | 131 | ||
132 | idx = srcu_read_lock(&kvm->srcu); | ||
132 | slots = kvm_memslots(kvm); | 133 | slots = kvm_memslots(kvm); |
133 | 134 | ||
134 | for (i = 0; i < slots->nmemslots; i++) { | 135 | for (i = 0; i < slots->nmemslots; i++) { |
@@ -136,6 +137,7 @@ static int kvm_iommu_map_memslots(struct kvm *kvm) | |||
136 | if (r) | 137 | if (r) |
137 | break; | 138 | break; |
138 | } | 139 | } |
140 | srcu_read_unlock(&kvm->srcu, idx); | ||
139 | 141 | ||
140 | return r; | 142 | return r; |
141 | } | 143 | } |
@@ -285,15 +287,17 @@ static void kvm_iommu_put_pages(struct kvm *kvm, | |||
285 | 287 | ||
286 | static int kvm_iommu_unmap_memslots(struct kvm *kvm) | 288 | static int kvm_iommu_unmap_memslots(struct kvm *kvm) |
287 | { | 289 | { |
288 | int i; | 290 | int i, idx; |
289 | struct kvm_memslots *slots; | 291 | struct kvm_memslots *slots; |
290 | 292 | ||
293 | idx = srcu_read_lock(&kvm->srcu); | ||
291 | slots = kvm_memslots(kvm); | 294 | slots = kvm_memslots(kvm); |
292 | 295 | ||
293 | for (i = 0; i < slots->nmemslots; i++) { | 296 | for (i = 0; i < slots->nmemslots; i++) { |
294 | kvm_iommu_put_pages(kvm, slots->memslots[i].base_gfn, | 297 | kvm_iommu_put_pages(kvm, slots->memslots[i].base_gfn, |
295 | slots->memslots[i].npages); | 298 | slots->memslots[i].npages); |
296 | } | 299 | } |
300 | srcu_read_unlock(&kvm->srcu, idx); | ||
297 | 301 | ||
298 | return 0; | 302 | return 0; |
299 | } | 303 | } |