[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 8/8] VFIO: do IOMMU TLB invalidation from guest
From: |
Liu, Yi L |
Subject: |
[Qemu-devel] [RFC PATCH 8/8] VFIO: do IOMMU TLB invalidation from guest |
Date: |
Wed, 26 Apr 2017 18:12:05 +0800 |
From: "Liu, Yi L" <address@hidden>
This patch adds support for VFIO_IOMMU_TLB_INVALIDATE cmd in
vfio_iommu_type1.
For SVM virtualization on VT-d, for VFIO_IOMMU_TLB_INVALIDATE, it
calls iommu_ops->do_invalidate() to submit the guest iommu cache
invalidation to pIOMMU.
Signed-off-by: Liu, Yi L <address@hidden>
---
drivers/vfio/vfio_iommu_type1.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 30b6d48..6cebdfd 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1528,6 +1528,17 @@ static int bind_pasid_tbl_fn(struct device *dev, void
*data)
return ret;
}
+static int do_tlb_inv_fn(struct device *dev, void *data)
+{
+ int ret = 0;
+ struct vfio_svm_task *task = data;
+ struct tlb_invalidate_info *inv_info;
+
+ inv_info = task->payload;
+ ret = iommu_do_invalidate(task->domain, dev, inv_info);
+ return ret;
+}
+
static int vfio_do_svm_task(struct vfio_iommu *iommu, void *data,
int (*fn)(struct device *, void *))
{
@@ -1654,6 +1665,21 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
}
kfree(data);
return ret;
+ } else if (cmd == VFIO_IOMMU_TLB_INVALIDATE) {
+ struct vfio_iommu_tlb_invalidate hdr;
+ u8 *data = NULL;
+ int ret = 0;
+
+ minsz = offsetofend(struct vfio_iommu_tlb_invalidate, length);
+ if (copy_from_user(&hdr, (void __user *)arg, minsz))
+ return -EFAULT;
+ if (hdr.length == 0)
+ return -EINVAL;
+ data = memdup_user((void __user *)(arg + minsz),
+ hdr.length);
+ ret = vfio_do_svm_task(iommu, data, do_tlb_inv_fn);
+ kfree(data);
+ return ret;
}
return -ENOTTY;
--
1.9.1
[Qemu-devel] [RFC PATCH 2/8] iommu/vt-d: add bind_pasid_table function, Liu, Yi L, 2017/04/26
[Qemu-devel] [RFC PATCH 3/8] iommu: Introduce iommu do invalidate API function, Liu, Yi L, 2017/04/26
[Qemu-devel] [RFC PATCH 4/8] iommu/vt-d: Add iommu do invalidate function, Liu, Yi L, 2017/04/26
[Qemu-devel] [RFC PATCH 5/8] VFIO: Add new IOTCL for PASID Table bind propagation, Liu, Yi L, 2017/04/26
[Qemu-devel] [RFC PATCH 6/8] VFIO: do pasid table binding, Liu, Yi L, 2017/04/26
[Qemu-devel] [RFC PATCH 8/8] VFIO: do IOMMU TLB invalidation from guest,
Liu, Yi L <=
[Qemu-devel] [RFC PATCH 7/8] VFIO: Add new IOCTL for IOMMU TLB invalidate propagation, Liu, Yi L, 2017/04/26