[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH rfcv1 04/23] vfio: implement IOMMUFDDevice interface callbacks
|
From: |
Zhenzhong Duan |
|
Subject: |
[PATCH rfcv1 04/23] vfio: implement IOMMUFDDevice interface callbacks |
|
Date: |
Mon, 15 Jan 2024 18:37:16 +0800 |
Implement IOMMUFDDevice interface callbacks attach_hwpt/detach_hwpt
for vIOMMU usage. vIOMMU utilizes them to attach to or detach from
hwpt on host side.
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
hw/vfio/iommufd.c | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 1b174b71ee..c8c669c59a 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -26,6 +26,8 @@
#include "qemu/chardev_open.h"
#include "pci.h"
+static IOMMUFDDeviceOps vfio_iommufd_device_ops;
+
static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova,
ram_addr_t size, void *vaddr, bool readonly)
{
@@ -430,7 +432,7 @@ found_container:
QLIST_INSERT_HEAD(&vfio_device_list, vbasedev, global_next);
iommufd_device_init(idev, sizeof(*idev), container->be, vbasedev->devid,
- NULL);
+ &vfio_iommufd_device_ops);
trace_iommufd_cdev_device_info(vbasedev->name, devfd, vbasedev->num_irqs,
vbasedev->num_regions, vbasedev->flags);
return 0;
@@ -642,3 +644,35 @@ static const TypeInfo types[] = {
};
DEFINE_TYPES(types)
+
+static int vfio_iommufd_device_attach_hwpt(IOMMUFDDevice *idev,
+ uint32_t hwpt_id)
+{
+ VFIODevice *vbasedev = container_of(idev, VFIODevice, idev);
+ Error *err = NULL;
+ int ret;
+
+ ret = iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt_id, &err);
+ if (err) {
+ error_report_err(err);
+ }
+ return ret;
+}
+
+static int vfio_iommufd_device_detach_hwpt(IOMMUFDDevice *idev)
+{
+ VFIODevice *vbasedev = container_of(idev, VFIODevice, idev);
+ Error *err = NULL;
+ int ret;
+
+ ret = iommufd_cdev_detach_ioas_hwpt(vbasedev, &err);
+ if (err) {
+ error_report_err(err);
+ }
+ return ret;
+}
+
+static IOMMUFDDeviceOps vfio_iommufd_device_ops = {
+ .attach_hwpt = vfio_iommufd_device_attach_hwpt,
+ .detach_hwpt = vfio_iommufd_device_detach_hwpt,
+};
--
2.34.1
- [PATCH rfcv1 00/23] intel_iommu: Enable stage-1 translation, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 02/23] backends/iommufd: add helpers for allocating user-managed HWPT, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 01/23] Update linux header to support nested hwpt alloc, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 03/23] backends/iommufd_device: introduce IOMMUFDDevice targeted interface, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 04/23] vfio: implement IOMMUFDDevice interface callbacks,
Zhenzhong Duan <=
- [PATCH rfcv1 05/23] intel_iommu: add a placeholder variable for scalable modern mode, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 06/23] intel_iommu: check and sync host IOMMU cap/ecap in scalable modern mode, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 07/23] intel_iommu: process PASID cache invalidation, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 08/23] intel_iommu: add PASID cache management infrastructure, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 09/23] vfio/iommufd_device: Add ioas_id in IOMMUFDDevice and pass to vIOMMU, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 10/23] intel_iommu: bind/unbind guest page table to host, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 11/23] intel_iommu: ERRATA_772415 workaround, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 12/23] intel_iommu: replay pasid binds after context cache invalidation, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 13/23] intel_iommu: process PASID-based iotlb invalidation, Zhenzhong Duan, 2024/01/15
- [PATCH rfcv1 14/23] intel_iommu: propagate PASID-based iotlb invalidation to host, Zhenzhong Duan, 2024/01/15