67 lines
2.4 KiB
Diff
67 lines
2.4 KiB
Diff
|
|
From aea706f6a71ddbcc9bd342ece14991f8f8261224 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Date: Thu, 11 Jan 2024 17:26:50 +0800
|
||
|
|
Subject: [PATCH] vfio/iommufd: Implement [at|de]tach_hwpt handlers
|
||
|
|
|
||
|
|
Implement [at|de]tach_hwpt handlers in VFIO subsystem. vIOMMU
|
||
|
|
utilizes them to attach to or detach from hwpt on host side.
|
||
|
|
|
||
|
|
To achieve that, a new property vdev is add to
|
||
|
|
TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO which is initialized in
|
||
|
|
.realize() handler.
|
||
|
|
|
||
|
|
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
|
||
|
|
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
[Shameer: Changed ret for host_iommu_device_iommufd_vfio_detach_hwpt()]
|
||
|
|
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
|
||
|
|
---
|
||
|
|
hw/vfio/iommufd.c | 22 ++++++++++++++++++++++
|
||
|
|
1 file changed, 22 insertions(+)
|
||
|
|
|
||
|
|
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
|
||
|
|
index 47a8823146..528023b95b 100644
|
||
|
|
--- a/hw/vfio/iommufd.c
|
||
|
|
+++ b/hw/vfio/iommufd.c
|
||
|
|
@@ -827,6 +827,24 @@ static void vfio_iommu_iommufd_class_init(ObjectClass *klass, void *data)
|
||
|
|
vioc->query_dirty_bitmap = iommufd_query_dirty_bitmap;
|
||
|
|
};
|
||
|
|
|
||
|
|
+static bool
|
||
|
|
+host_iommu_device_iommufd_vfio_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
|
||
|
|
+ uint32_t hwpt_id, Error **errp)
|
||
|
|
+{
|
||
|
|
+ VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;
|
||
|
|
+
|
||
|
|
+ return !iommufd_cdev_attach_ioas_hwpt(vbasedev, hwpt_id, errp);
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
+static bool
|
||
|
|
+host_iommu_device_iommufd_vfio_detach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
|
||
|
|
+ Error **errp)
|
||
|
|
+{
|
||
|
|
+ VFIODevice *vbasedev = HOST_IOMMU_DEVICE(idev)->agent;
|
||
|
|
+
|
||
|
|
+ return !iommufd_cdev_detach_ioas_hwpt(vbasedev, errp);
|
||
|
|
+}
|
||
|
|
+
|
||
|
|
static bool hiod_iommufd_vfio_realize_late(HostIOMMUDevice *hiod, void *opaque,
|
||
|
|
Error **errp)
|
||
|
|
{
|
||
|
|
@@ -872,9 +890,13 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
|
||
|
|
static void hiod_iommufd_vfio_class_init(ObjectClass *oc, void *data)
|
||
|
|
{
|
||
|
|
HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc);
|
||
|
|
+ HostIOMMUDeviceIOMMUFDClass *idevc = HOST_IOMMU_DEVICE_IOMMUFD_CLASS(oc);
|
||
|
|
|
||
|
|
hiodc->realize = hiod_iommufd_vfio_realize;
|
||
|
|
hiodc->realize_late = hiod_iommufd_vfio_realize_late;
|
||
|
|
+
|
||
|
|
+ idevc->attach_hwpt = host_iommu_device_iommufd_vfio_attach_hwpt;
|
||
|
|
+ idevc->detach_hwpt = host_iommu_device_iommufd_vfio_detach_hwpt;
|
||
|
|
};
|
||
|
|
|
||
|
|
static const TypeInfo types[] = {
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|