sPAPR/IOMMU: Fix TCE entry permission
authorGavin Shan <gwshan@linux.vnet.ibm.com>
Mon, 14 Jul 2014 12:09:43 +0000 (22:09 +1000)
committerAlexander Graf <agraf@suse.de>
Tue, 15 Jul 2014 14:11:59 +0000 (16:11 +0200)
The permission of TCE entry should exclude physical base address.
Otherwise, unmapping TCE entry can be interpreted to mapping TCE
entry wrongly for VFIO devices.

Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
hw/misc/vfio.c
hw/ppc/spapr_iommu.c

index aef4c9ce9db14019c024b91d28f8e4079cc42400..0b9eba0c849bf1592120c1a3b58f643d8d37bdbd 100644 (file)
@@ -2489,7 +2489,7 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
         return;
     }
 
-    if (iotlb->perm != IOMMU_NONE) {
+    if ((iotlb->perm & IOMMU_RW) != IOMMU_NONE) {
         vaddr = memory_region_get_ram_ptr(mr) + xlat;
 
         ret = vfio_dma_map(container, iotlb->iova,
index 698ae60953eee85c83cfc5677d7c6330a0e529ee..f6e32a48afb3dc2fc836b2d808061af702a47f2b 100644 (file)
@@ -81,7 +81,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
         ret.iova = addr & page_mask;
         ret.translated_addr = tce & page_mask;
         ret.addr_mask = ~page_mask;
-        ret.perm = tce;
+        ret.perm = tce & IOMMU_RW;
     }
     trace_spapr_iommu_xlate(tcet->liobn, addr, ret.iova, ret.perm,
                             ret.addr_mask);
@@ -223,7 +223,7 @@ static target_ulong put_tce_emu(sPAPRTCETable *tcet, target_ulong ioba,
     entry.iova = ioba & page_mask;
     entry.translated_addr = tce & page_mask;
     entry.addr_mask = ~page_mask;
-    entry.perm = tce;
+    entry.perm = tce & IOMMU_RW;
     memory_region_notify_iommu(&tcet->iommu, entry);
 
     return H_SUCCESS;
This page took 0.03456 seconds and 4 git commands to generate.