mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 18:44:58 -06:00
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>
This commit is contained in:
parent
52ce88229c
commit
7c30710bd9
4 changed files with 62 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue