[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3.1 08/22] vfio/common: add pasid_alloc/free support
From: |
Liu Yi L |
Subject: |
[RFC v3.1 08/22] vfio/common: add pasid_alloc/free support |
Date: |
Sat, 22 Feb 2020 00:07:09 -0800 |
This patch adds VFIO pasid alloc/free support to allow host intercept
in PASID allocation for VM by adding VFIO implementation of HostIOMMUOps.
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 | 47 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index f9be68d..8f30a52 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1179,8 +1179,53 @@ static int vfio_get_iommu_type(VFIOContainer *container,
return -EINVAL;
}
+static int vfio_host_icx_pasid_alloc(HostIOMMUContext *host_icx,
+ uint32_t min, uint32_t max, uint32_t *pasid)
+{
+ VFIOContainer *container = container_of(host_icx, VFIOContainer, host_icx);
+ struct vfio_iommu_type1_pasid_request req;
+ unsigned long argsz;
+ int ret;
+
+ 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)) {
+ ret = -errno;
+ error_report("%s: %d, alloc failed", __func__, ret);
+ return ret;
+ }
+ *pasid = req.alloc_pasid.result;
+ return 0;
+}
+
+static int vfio_host_icx_pasid_free(HostIOMMUContext *host_icx,
+ uint32_t pasid)
+{
+ VFIOContainer *container = container_of(host_icx, VFIOContainer, host_icx);
+ struct vfio_iommu_type1_pasid_request req;
+ unsigned long argsz;
+ int ret;
+
+ 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)) {
+ ret = -errno;
+ error_report("%s: %d, free failed", __func__, ret);
+ return ret;
+ }
+ return 0;
+}
+
static struct HostIOMMUOps vfio_host_icx_ops = {
-/* To be added later */
+ .pasid_alloc = vfio_host_icx_pasid_alloc,
+ .pasid_free = vfio_host_icx_pasid_free,
};
/**
--
2.7.4
- [RFC v3.1 00/22] intel_iommu: expose Shared Virtual Addressing to VMs, Liu Yi L, 2020/02/22
- [RFC v3.1 03/22] vfio: check VFIO_TYPE1_NESTING_IOMMU support, Liu Yi L, 2020/02/22
- [RFC v3.1 09/22] hw/pci: add pci_device_host_iommu_context(), Liu Yi L, 2020/02/22
- [RFC v3.1 13/22] vfio: add bind stage-1 page table support, Liu Yi L, 2020/02/22
- [RFC v3.1 06/22] vfio/pci: init HostIOMMUContext per-container, Liu Yi L, 2020/02/22
- [RFC v3.1 01/22] scripts/update-linux-headers: Import iommu.h, Liu Yi L, 2020/02/22
- [RFC v3.1 05/22] hw/pci: add pci_device_setup_iommu, Liu Yi L, 2020/02/22
- [RFC v3.1 08/22] vfio/common: add pasid_alloc/free support,
Liu Yi L <=
- [RFC v3.1 11/22] intel_iommu: process pasid cache invalidation, Liu Yi L, 2020/02/22
- [RFC v3.1 19/22] intel_iommu: process PASID-based iotlb invalidation, Liu Yi L, 2020/02/22
- [RFC v3.1 04/22] hw/iommu: introduce HostIOMMUContext, Liu Yi L, 2020/02/22
- [RFC v3.1 07/22] vfio: get nesting iommu cap info from Kernel, Liu Yi L, 2020/02/22
- [RFC v3.1 10/22] intel_iommu: add virtual command capability support, Liu Yi L, 2020/02/22
- [RFC v3.1 17/22] intel_iommu: do not pass down pasid bind for PASID #0, Liu Yi L, 2020/02/22
- [RFC v3.1 21/22] intel_iommu: process PASID-based Device-TLB invalidation, Liu Yi L, 2020/02/22
- [RFC v3.1 15/22] intel_iommu: replay guest pasid bindings to host, Liu Yi L, 2020/02/22
- [RFC v3.1 02/22] header file update VFIO/IOMMU vSVA APIs, Liu Yi L, 2020/02/22
- [RFC v3.1 12/22] intel_iommu: add PASID cache management infrastructure, Liu Yi L, 2020/02/22