From: Alex Williamson Date: Thu, 24 Jan 2013 22:04:09 +0000 (-0700) Subject: kvm: Obey read-only mappings in iommu X-Git-Tag: v5.15~20187^2~151^2~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d47510e295c0f82699192a61d715351cf00f65de;p=platform%2Fkernel%2Flinux-starfive.git kvm: Obey read-only mappings in iommu 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 Signed-off-by: Gleb Natapov --- diff --git a/virt/kvm/iommu.c b/virt/kvm/iommu.c index 4a340cb..72a130b 100644 --- a/virt/kvm/iommu.c +++ b/virt/kvm/iommu.c @@ -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;