[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 04/19] vfio/iommufd: Introduce HostIOMMUDeviceIOMMUFDVFIO devi
From: |
Zhenzhong Duan |
Subject: |
[PATCH v3 04/19] vfio/iommufd: Introduce HostIOMMUDeviceIOMMUFDVFIO device |
Date: |
Mon, 29 Apr 2024 14:50:31 +0800 |
HostIOMMUDeviceIOMMUFDVFIO represents a host IOMMU device under VFIO
iommufd backend. It will be created during VFIO device attaching and
passed to vIOMMU.
It includes a link to VFIODevice so that we can do VFIO device
specific operations, i.e., [at/de]taching hwpt, etc.
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
include/hw/vfio/vfio-common.h | 13 +++++++++++++
hw/vfio/iommufd.c | 6 +++++-
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index aa3abe0a18..0943add3bc 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -32,6 +32,7 @@
#include "sysemu/sysemu.h"
#include "hw/vfio/vfio-container-base.h"
#include "sysemu/host_iommu_device.h"
+#include "sysemu/iommufd.h"
#define VFIO_MSG_PREFIX "vfio %s: "
@@ -159,6 +160,18 @@ struct HostIOMMUDeviceLegacyVFIO {
VFIODevice *vdev;
};
+#define TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO \
+ TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio"
+OBJECT_DECLARE_SIMPLE_TYPE(HostIOMMUDeviceIOMMUFDVFIO,
+ HOST_IOMMU_DEVICE_IOMMUFD_VFIO)
+
+/* Abstraction of host IOMMU device with VFIO IOMMUFD backend */
+struct HostIOMMUDeviceIOMMUFDVFIO {
+ HostIOMMUDeviceIOMMUFD parent;
+
+ VFIODevice *vdev;
+};
+
typedef struct VFIODMABuf {
QemuDmaBuf buf;
uint32_t pos_x, pos_y, pos_updates;
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 8827ffe636..997f4ac43e 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -639,7 +639,11 @@ static const TypeInfo types[] = {
.name = TYPE_VFIO_IOMMU_IOMMUFD,
.parent = TYPE_VFIO_IOMMU,
.class_init = vfio_iommu_iommufd_class_init,
- },
+ }, {
+ .name = TYPE_HOST_IOMMU_DEVICE_IOMMUFD_VFIO,
+ .parent = TYPE_HOST_IOMMU_DEVICE_IOMMUFD,
+ .instance_size = sizeof(HostIOMMUDeviceIOMMUFDVFIO),
+ }
};
DEFINE_TYPES(types)
--
2.34.1
- [PATCH v3 00/19] Add a host IOMMU device abstraction to check with vIOMMU, Zhenzhong Duan, 2024/04/29
- [PATCH v3 01/19] backends: Introduce HostIOMMUDevice abstract, Zhenzhong Duan, 2024/04/29
- [PATCH v3 02/19] vfio/container: Introduce HostIOMMUDeviceLegacyVFIO device, Zhenzhong Duan, 2024/04/29
- [PATCH v3 03/19] backends/iommufd: Introduce abstract HostIOMMUDeviceIOMMUFD device, Zhenzhong Duan, 2024/04/29
- [PATCH v3 04/19] vfio/iommufd: Introduce HostIOMMUDeviceIOMMUFDVFIO device,
Zhenzhong Duan <=
- [PATCH v3 05/19] backends/host_iommu_device: Introduce HostIOMMUDeviceCaps, Zhenzhong Duan, 2024/04/29
- [PATCH v3 06/19] range: Introduce range_get_last_bit(), Zhenzhong Duan, 2024/04/29
- [PATCH v3 07/19] vfio/container: Implement HostIOMMUDeviceClass::realize() handler, Zhenzhong Duan, 2024/04/29