kvm: Obey read-only mappings in iommu
authorAlex Williamson <alex.williamson@redhat.com>
Thu, 24 Jan 2013 22:04:09 +0000 (15:04 -0700)
committerGleb Natapov <gleb@redhat.com>
Sun, 27 Jan 2013 10:41:41 +0000 (12:41 +0200)
We've been ignoring read-only mappings and programming everything
into the iommu as read-write.  Fix this to only include the write
access flag when read-only is not set.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
virt/kvm/iommu.c

index 4a340cb230134bd7fb15b62545ff8b5245ecbfa2..72a130bc448aa97adb1ca35a2dfff09a102b717d 100644 (file)
@@ -76,7 +76,9 @@ int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot)
        gfn     = slot->base_gfn;
        end_gfn = gfn + slot->npages;
 
-       flags = IOMMU_READ | IOMMU_WRITE;
+       flags = IOMMU_READ;
+       if (!(slot->flags & KVM_MEM_READONLY))
+               flags |= IOMMU_WRITE;
        if (kvm->arch.iommu_flags & KVM_IOMMU_CACHE_COHERENCY)
                flags |= IOMMU_CACHE;