[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 12/25] vfio/common: add pasid_alloc/free support
From: |
Liu, Yi L |
Subject: |
[RFC v3 12/25] vfio/common: add pasid_alloc/free support |
Date: |
Wed, 29 Jan 2020 04:16:43 -0800 |
From: Liu Yi L <address@hidden>
This patch adds VFIO pasid alloc/free support to allow host intercept
in PASID allocation for VM by adding VFIO implementation of
DualStageIOMMUOps.pasid_alloc/free callbacks.
Cc: Kevin Tian <address@hidden>
Cc: Jacob Pan <address@hidden>
Cc: Peter Xu <address@hidden>
Cc: Eric Auger <address@hidden>
Cc: Yi Sun <address@hidden>
Cc: David Gibson <address@hidden>
Cc: Alex Williamson <address@hidden>
Signed-off-by: Liu Yi L <address@hidden>
---
hw/vfio/common.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index a07824b..014f4e7 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1179,7 +1179,49 @@ static int vfio_get_iommu_type(VFIOContainer *container,
return -EINVAL;
}
+static int vfio_ds_iommu_pasid_alloc(DualStageIOMMUObject *dsi_obj,
+ uint32_t min, uint32_t max, uint32_t *pasid)
+{
+ VFIOContainer *container = container_of(dsi_obj, VFIOContainer, dsi_obj);
+ struct vfio_iommu_type1_pasid_request req;
+ unsigned long argsz;
+
+ argsz = sizeof(req);
+ req.argsz = argsz;
+ req.flags = VFIO_IOMMU_PASID_ALLOC;
+ req.alloc_pasid.min = min;
+ req.alloc_pasid.max = max;
+
+ if (ioctl(container->fd, VFIO_IOMMU_PASID_REQUEST, &req)) {
+ error_report("%s: %d, alloc failed", __func__, -errno);
+ return -errno;
+ }
+ *pasid = req.alloc_pasid.result;
+ return 0;
+}
+
+static int vfio_ds_iommu_pasid_free(DualStageIOMMUObject *dsi_obj,
+ uint32_t pasid)
+{
+ VFIOContainer *container = container_of(dsi_obj, VFIOContainer, dsi_obj);
+ struct vfio_iommu_type1_pasid_request req;
+ unsigned long argsz;
+
+ argsz = sizeof(req);
+ req.argsz = argsz;
+ req.flags = VFIO_IOMMU_PASID_FREE;
+ req.free_pasid = pasid;
+
+ if (ioctl(container->fd, VFIO_IOMMU_PASID_REQUEST, &req)) {
+ error_report("%s: %d, free failed", __func__, -errno);
+ return -errno;
+ }
+ return 0;
+}
+
static struct DualStageIOMMUOps vfio_ds_iommu_ops = {
+ .pasid_alloc = vfio_ds_iommu_pasid_alloc,
+ .pasid_free = vfio_ds_iommu_pasid_free,
};
static int vfio_get_iommu_info(VFIOContainer *container,
--
2.7.4
- [RFC v3 06/25] scripts/update-linux-headers: Import iommu.h, (continued)
- [RFC v3 06/25] scripts/update-linux-headers: Import iommu.h, Liu, Yi L, 2020/01/29
- [RFC v3 04/25] hw/pci: introduce pci_device_iommu_context(), Liu, Yi L, 2020/01/29
- [RFC v3 09/25] vfio: check VFIO_TYPE1_NESTING_IOMMU support, Liu, Yi L, 2020/01/29
- [RFC v3 08/25] vfio: pass IOMMUContext into vfio_get_group(), Liu, Yi L, 2020/01/29
- [RFC v3 02/25] hw/iommu: introduce DualStageIOMMUObject, Liu, Yi L, 2020/01/29
- [RFC v3 07/25] header file update VFIO/IOMMU vSVA APIs, Liu, Yi L, 2020/01/29
- [RFC v3 05/25] intel_iommu: provide get_iommu_context() callback, Liu, Yi L, 2020/01/29
- [RFC v3 03/25] hw/iommu: introduce IOMMUContext, Liu, Yi L, 2020/01/29
- [RFC v3 10/25] vfio: register DualStageIOMMUObject to vIOMMU, Liu, Yi L, 2020/01/29
- [RFC v3 01/25] hw/pci: modify pci_setup_iommu() to set PCIIOMMUOps, Liu, Yi L, 2020/01/29
- [RFC v3 12/25] vfio/common: add pasid_alloc/free support,
Liu, Yi L <=
- [RFC v3 13/25] intel_iommu: modify x-scalable-mode to be string option, Liu, Yi L, 2020/01/29
- [RFC v3 11/25] vfio: get stage-1 pasid formats from Kernel, Liu, Yi L, 2020/01/29
- [RFC v3 15/25] intel_iommu: process pasid cache invalidation, Liu, Yi L, 2020/01/29
- [RFC v3 14/25] intel_iommu: add virtual command capability support, Liu, Yi L, 2020/01/29
- [RFC v3 16/25] intel_iommu: add PASID cache management infrastructure, Liu, Yi L, 2020/01/29
- [RFC v3 17/25] vfio: add bind stage-1 page table support, Liu, Yi L, 2020/01/29
- [RFC v3 18/25] intel_iommu: bind/unbind guest page table to host, Liu, Yi L, 2020/01/29
- [RFC v3 19/25] intel_iommu: replay guest pasid bindings to host, Liu, Yi L, 2020/01/29
- [RFC v3 20/25] intel_iommu: replay pasid binds after context cache invalidation, Liu, Yi L, 2020/01/29
- [RFC v3 22/25] vfio: add support for flush iommu stage-1 cache, Liu, Yi L, 2020/01/29