[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/9] HostIOMMUDevice: Introduce get_page_size_mask() callback
From: |
Cédric Le Goater |
Subject: |
[PULL 4/9] HostIOMMUDevice: Introduce get_page_size_mask() callback |
Date: |
Tue, 9 Jul 2024 13:50:12 +0200 |
From: Eric Auger <eric.auger@redhat.com>
This callback will be used to retrieve the page size mask supported
along a given Host IOMMU device.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/vfio/vfio-container-base.h | 7 +++++++
include/sysemu/host_iommu_device.h | 8 ++++++++
hw/vfio/container.c | 10 ++++++++++
hw/vfio/iommufd.c | 11 +++++++++++
4 files changed, 36 insertions(+)
diff --git a/include/hw/vfio/vfio-container-base.h
b/include/hw/vfio/vfio-container-base.h
index
45d7c40fce8f4f3508cbc08b436b2db1dfaa01e4..62a8b60d87db263225147a21eff2ef6e21cb22df
100644
--- a/include/hw/vfio/vfio-container-base.h
+++ b/include/hw/vfio/vfio-container-base.h
@@ -88,6 +88,13 @@ int vfio_container_query_dirty_bitmap(const
VFIOContainerBase *bcontainer,
GList *vfio_container_get_iova_ranges(const VFIOContainerBase *bcontainer);
+static inline uint64_t
+vfio_container_get_page_size_mask(const VFIOContainerBase *bcontainer)
+{
+ assert(bcontainer);
+ return bcontainer->pgsizes;
+}
+
#define TYPE_VFIO_IOMMU "vfio-iommu"
#define TYPE_VFIO_IOMMU_LEGACY TYPE_VFIO_IOMMU "-legacy"
#define TYPE_VFIO_IOMMU_SPAPR TYPE_VFIO_IOMMU "-spapr"
diff --git a/include/sysemu/host_iommu_device.h
b/include/sysemu/host_iommu_device.h
index
05c7324a0d1ccd2e30bc42ca1f0353e55361500a..c1bf74ae2c7a729b22d6512f3ca37ce65fa6bcec
100644
--- a/include/sysemu/host_iommu_device.h
+++ b/include/sysemu/host_iommu_device.h
@@ -89,6 +89,14 @@ struct HostIOMMUDeviceClass {
* @hiod: handle to the host IOMMU device
*/
GList* (*get_iova_ranges)(HostIOMMUDevice *hiod);
+ /**
+ *
+ * @get_page_size_mask: Return the page size mask supported along this
+ * @hiod Host IOMMU device
+ *
+ * @hiod: handle to the host IOMMU device
+ */
+ uint64_t (*get_page_size_mask)(HostIOMMUDevice *hiod);
};
/*
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index
ddd835996cfae13dcab01e53fd381ace1cdae668..425db1a14c076fd6eaca0d25e06237e4e21fb798
100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -1173,6 +1173,15 @@ hiod_legacy_vfio_get_iova_ranges(HostIOMMUDevice *hiod)
return vfio_container_get_iova_ranges(vdev->bcontainer);
}
+static uint64_t
+hiod_legacy_vfio_get_page_size_mask(HostIOMMUDevice *hiod)
+{
+ VFIODevice *vdev = hiod->agent;
+
+ g_assert(vdev);
+ return vfio_container_get_page_size_mask(vdev->bcontainer);
+}
+
static void vfio_iommu_legacy_instance_init(Object *obj)
{
VFIOContainer *container = VFIO_IOMMU_LEGACY(obj);
@@ -1187,6 +1196,7 @@ static void hiod_legacy_vfio_class_init(ObjectClass *oc,
void *data)
hioc->realize = hiod_legacy_vfio_realize;
hioc->get_cap = hiod_legacy_vfio_get_cap;
hioc->get_iova_ranges = hiod_legacy_vfio_get_iova_ranges;
+ hioc->get_page_size_mask = hiod_legacy_vfio_get_page_size_mask;
};
static const TypeInfo types[] = {
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index
211e7223f150ee3c8447a9c454c5a3528860682f..7b5f87a1488111f7b88ce7588db4f5e5bd976978
100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -652,12 +652,23 @@ hiod_iommufd_vfio_get_iova_ranges(HostIOMMUDevice *hiod)
return vfio_container_get_iova_ranges(vdev->bcontainer);
}
+static uint64_t
+hiod_iommufd_vfio_get_page_size_mask(HostIOMMUDevice *hiod)
+{
+ VFIODevice *vdev = hiod->agent;
+
+ g_assert(vdev);
+ return vfio_container_get_page_size_mask(vdev->bcontainer);
+}
+
+
static void hiod_iommufd_vfio_class_init(ObjectClass *oc, void *data)
{
HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc);
hiodc->realize = hiod_iommufd_vfio_realize;
hiodc->get_iova_ranges = hiod_iommufd_vfio_get_iova_ranges;
+ hiodc->get_page_size_mask = hiod_iommufd_vfio_get_page_size_mask;
};
static const TypeInfo types[] = {
--
2.45.2
- [PULL 0/9] vfio queue, Cédric Le Goater, 2024/07/09
- [PULL 2/9] vfio-container-base: Introduce vfio_container_get_iova_ranges() helper, Cédric Le Goater, 2024/07/09
- [PULL 1/9] virtio-iommu: Fix error handling in virtio_iommu_set_host_iova_ranges(), Cédric Le Goater, 2024/07/09
- [PULL 6/9] memory: remove IOMMU MR iommu_set_page_size_mask() callback, Cédric Le Goater, 2024/07/09
- [PULL 5/9] virtio-iommu : Retrieve page size mask on virtio_iommu_set_iommu_device(), Cédric Le Goater, 2024/07/09
- [PULL 3/9] HostIOMMUDevice : remove Error handle from get_iova_ranges callback, Cédric Le Goater, 2024/07/09
- [PULL 4/9] HostIOMMUDevice: Introduce get_page_size_mask() callback,
Cédric Le Goater <=
- [PULL 7/9] virtio-iommu: Revert transient enablement of IOMMU MR in bypass mode, Cédric Le Goater, 2024/07/09
- [PULL 8/9] vfio/display: Fix potential memleak of edid info, Cédric Le Goater, 2024/07/09
- [PULL 9/9] vfio/display: Fix vfio_display_edid_init() error path, Cédric Le Goater, 2024/07/09
- Re: [PULL 0/9] vfio queue, Richard Henderson, 2024/07/09