KVM: unmap pages from the iommu when slots are removed
[linux-flexiantxendom0-3.2.10.git] / virt / kvm / kvm_main.c
index 42b7393..9739b53 100644 (file)
@@ -808,12 +808,13 @@ int __kvm_set_memory_region(struct kvm *kvm,
        if (r)
                goto out_free;
 
-       /* map the pages in iommu page table */
+       /* map/unmap the pages in iommu page table */
        if (npages) {
                r = kvm_iommu_map_pages(kvm, &new);
                if (r)
                        goto out_free;
-       }
+       } else
+               kvm_iommu_unmap_pages(kvm, &old);
 
        r = -ENOMEM;
        slots = kmemdup(kvm->memslots, sizeof(struct kvm_memslots),