@@ -2932,6 +2932,16 @@ static int vfio_iommu_type1_dirty_pages(struct vfio_iommu *iommu,
return -EINVAL;
}
+static void vfio_iommu_type1_close_dma_owner(void *iommu_data)
+{
+ struct vfio_iommu *iommu = iommu_data;
+
+ mutex_lock(&iommu->lock);
+ if (iommu->task == current->group_leader)
+ vfio_iommu_unmap_unpin_all(iommu);
+ mutex_unlock(&iommu->lock);
+}
+
static long vfio_iommu_type1_ioctl(void *iommu_data,
unsigned int cmd, unsigned long arg)
{
@@ -3114,6 +3124,7 @@ static int vfio_iommu_type1_dma_rw(void *iommu_data, dma_addr_t user_iova,
.unregister_device = vfio_iommu_type1_unregister_device,
.dma_rw = vfio_iommu_type1_dma_rw,
.group_iommu_domain = vfio_iommu_type1_group_iommu_domain,
+ .close_dma_owner = vfio_iommu_type1_close_dma_owner,
};
static int __init vfio_iommu_type1_init(void)
If a task exits or exec, unmap and unpin all dma mappings owned by the task. Signed-off-by: Steve Sistare <steven.sistare@oracle.com> --- drivers/vfio/vfio_iommu_type1.c | 11 +++++++++++ 1 file changed, 11 insertions(+)