mirror of https://github.com/xqemu/xqemu.git
sPAPR/IOMMU: Fix TCE entry permission
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>
This commit is contained in:
parent
f92f5da108
commit
27e27782f7
|
@ -2489,7 +2489,7 @@ static void vfio_iommu_map_notify(Notifier *n, void *data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iotlb->perm != IOMMU_NONE) {
|
if ((iotlb->perm & IOMMU_RW) != IOMMU_NONE) {
|
||||||
vaddr = memory_region_get_ram_ptr(mr) + xlat;
|
vaddr = memory_region_get_ram_ptr(mr) + xlat;
|
||||||
|
|
||||||
ret = vfio_dma_map(container, iotlb->iova,
|
ret = vfio_dma_map(container, iotlb->iova,
|
||||||
|
|
|
@ -81,7 +81,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr)
|
||||||
ret.iova = addr & page_mask;
|
ret.iova = addr & page_mask;
|
||||||
ret.translated_addr = tce & page_mask;
|
ret.translated_addr = tce & page_mask;
|
||||||
ret.addr_mask = ~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,
|
trace_spapr_iommu_xlate(tcet->liobn, addr, ret.iova, ret.perm,
|
||||||
ret.addr_mask);
|
ret.addr_mask);
|
||||||
|
@ -223,7 +223,7 @@ static target_ulong put_tce_emu(sPAPRTCETable *tcet, target_ulong ioba,
|
||||||
entry.iova = ioba & page_mask;
|
entry.iova = ioba & page_mask;
|
||||||
entry.translated_addr = tce & page_mask;
|
entry.translated_addr = tce & page_mask;
|
||||||
entry.addr_mask = ~page_mask;
|
entry.addr_mask = ~page_mask;
|
||||||
entry.perm = tce;
|
entry.perm = tce & IOMMU_RW;
|
||||||
memory_region_notify_iommu(&tcet->iommu, entry);
|
memory_region_notify_iommu(&tcet->iommu, entry);
|
||||||
|
|
||||||
return H_SUCCESS;
|
return H_SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue