static int kvm_iommu_map_memslots(struct kvm *kvm)
{
- int i, r = 0;
+ int i, idx, r = 0;
struct kvm_memslots *slots;
+ idx = srcu_read_lock(&kvm->srcu);
slots = kvm_memslots(kvm);
for (i = 0; i < slots->nmemslots; i++) {
if (r)
break;
}
+ srcu_read_unlock(&kvm->srcu, idx);
return r;
}
static int kvm_iommu_unmap_memslots(struct kvm *kvm)
{
- int i;
+ int i, idx;
struct kvm_memslots *slots;
+ idx = srcu_read_lock(&kvm->srcu);
slots = kvm_memslots(kvm);
for (i = 0; i < slots->nmemslots; i++) {
kvm_iommu_put_pages(kvm, slots->memslots[i].base_gfn,
slots->memslots[i].npages);
}
+ srcu_read_unlock(&kvm->srcu, idx);
return 0;
}