diff mbox series

[v3,08/10] vfio/iommufd: Parse hw_caps and store dirty tracking support

Message ID 20240708143420.16953-9-joao.m.martins@oracle.com (mailing list archive)
State New, archived
Headers show
Series hw/vfio: IOMMUFD Dirty Tracking | expand

Commit Message

Joao Martins July 8, 2024, 2:34 p.m. UTC
Fetch capabilities from IOMMU device and add a capability to
host-iommu-device to reflect whether backing IOMMU has dirty tracking.

This is in preparation to relax the migration eligibility when device
doesn't have dirty tracking.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
 include/sysemu/host_iommu_device.h | 2 ++
 backends/iommufd.c                 | 2 ++
 hw/vfio/iommufd.c                  | 1 +
 3 files changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/include/sysemu/host_iommu_device.h b/include/sysemu/host_iommu_device.h
index ee6c813c8b22..d38a31693482 100644
--- a/include/sysemu/host_iommu_device.h
+++ b/include/sysemu/host_iommu_device.h
@@ -25,6 +25,7 @@ 
 typedef struct HostIOMMUDeviceCaps {
     uint32_t type;
     uint8_t aw_bits;
+    bool dirty_tracking;
 } HostIOMMUDeviceCaps;
 
 #define TYPE_HOST_IOMMU_DEVICE "host-iommu-device"
@@ -97,6 +98,7 @@  struct HostIOMMUDeviceClass {
  */
 #define HOST_IOMMU_DEVICE_CAP_IOMMU_TYPE        0
 #define HOST_IOMMU_DEVICE_CAP_AW_BITS           1
+#define HOST_IOMMU_DEVICE_CAP_DIRTY_TRACKING    2
 
 #define HOST_IOMMU_DEVICE_CAP_AW_BITS_MAX       64
 #endif
diff --git a/backends/iommufd.c b/backends/iommufd.c
index b2d3bbd7c31b..9400d51004f0 100644
--- a/backends/iommufd.c
+++ b/backends/iommufd.c
@@ -314,6 +314,8 @@  static int hiod_iommufd_get_cap(HostIOMMUDevice *hiod, int cap, Error **errp)
     switch (cap) {
     case HOST_IOMMU_DEVICE_CAP_IOMMU_TYPE:
         return caps->type;
+    case HOST_IOMMU_DEVICE_CAP_DIRTY_TRACKING:
+        return caps->dirty_tracking;
     case HOST_IOMMU_DEVICE_CAP_AW_BITS:
         return caps->aw_bits;
     default:
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index 9fad47baed9e..2678801f1cad 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -832,6 +832,7 @@  static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
         hiod->name = g_strdup(vdev->name);
         caps->type = type;
         caps->aw_bits = vfio_device_get_aw_bits(vdev);
+        caps->dirty_tracking = (hw_caps & IOMMU_HW_CAP_DIRTY_TRACKING);
     }
 
     return true;