diff options
author | Joao Martins <joao.m.martins@oracle.com> | 2024-07-22 22:13:24 +0100 |
---|---|---|
committer | Cédric Le Goater <clg@redhat.com> | 2024-07-23 17:14:52 +0200 |
commit | 7c30710bd99510b1ce91a1b287118c759c55a495 (patch) | |
tree | b0ce83a3f484c6b1e17bf5d50ac4f6c6bd327951 /hw/vfio | |
parent | 52ce88229c2d63a223f4c822240e84c3daeb7f6e (diff) | |
download | qemu-7c30710bd99510b1ce91a1b287118c759c55a495.zip qemu-7c30710bd99510b1ce91a1b287118c759c55a495.tar.gz qemu-7c30710bd99510b1ce91a1b287118c759c55a495.tar.bz2 |
vfio/iommufd: Implement VFIOIOMMUClass::query_dirty_bitmap support
ioctl(iommufd, IOMMU_HWPT_GET_DIRTY_BITMAP, arg) is the UAPI
that fetches the bitmap that tells what was dirty in an IOVA
range.
A single bitmap is allocated and used across all the hwpts
sharing an IOAS which is then used in log_sync() to set Qemu
global bitmaps.
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Diffstat (limited to 'hw/vfio')
-rw-r--r-- | hw/vfio/iommufd.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c index e39fbf4..e7bece4 100644 --- a/hw/vfio/iommufd.c +++ b/hw/vfio/iommufd.c @@ -25,6 +25,7 @@ #include "qemu/cutils.h" #include "qemu/chardev_open.h" #include "pci.h" +#include "exec/ram_addr.h" static int iommufd_cdev_map(const VFIOContainerBase *bcontainer, hwaddr iova, ram_addr_t size, void *vaddr, bool readonly) @@ -146,6 +147,32 @@ err: return -EINVAL; } +static int iommufd_query_dirty_bitmap(const VFIOContainerBase *bcontainer, + VFIOBitmap *vbmap, hwaddr iova, + hwaddr size, Error **errp) +{ + VFIOIOMMUFDContainer *container = container_of(bcontainer, + VFIOIOMMUFDContainer, + bcontainer); + unsigned long page_size = qemu_real_host_page_size(); + VFIOIOASHwpt *hwpt; + + QLIST_FOREACH(hwpt, &container->hwpt_list, next) { + if (!iommufd_hwpt_dirty_tracking(hwpt)) { + continue; + } + + if (!iommufd_backend_get_dirty_bitmap(container->be, hwpt->hwpt_id, + iova, size, page_size, + (uint64_t *)vbmap->bitmap, + errp)) { + return -EINVAL; + } + } + + return 0; +} + static int iommufd_cdev_getfd(const char *sysfs_path, Error **errp) { ERRP_GUARD(); @@ -771,6 +798,7 @@ static void vfio_iommu_iommufd_class_init(ObjectClass *klass, void *data) vioc->detach_device = iommufd_cdev_detach; vioc->pci_hot_reset = iommufd_cdev_pci_hot_reset; vioc->set_dirty_page_tracking = iommufd_set_dirty_page_tracking; + vioc->query_dirty_bitmap = iommufd_query_dirty_bitmap; }; static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque, |