On Thu, Apr 28, 2022 at 10:09:21PM +0100, Joao Martins wrote: > Add the correspondent APIs for performing VFIO dirty tracking, > particularly VFIO_IOMMU_DIRTY_PAGES ioctl subcmds: > * VFIO_IOMMU_DIRTY_PAGES_FLAG_START: Start dirty tracking and allocates > the area @dirty_bitmap > * VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP: Stop dirty tracking and frees > the area @dirty_bitmap > * VFIO_IOMMU_DIRTY_PAGES_FLAG_GET_BITMAP: Fetch dirty bitmap while dirty > tracking is active. > > Advertise the VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION > whereas it gets set the domain configured page size the same as > iopt::iova_alignment and maximum dirty bitmap size same > as VFIO. Compared to VFIO type1 iommu, the perpectual dirtying is > not implemented and userspace gets -EOPNOTSUPP which is handled by > today's userspace. > > Move iommufd_get_pagesizes() definition prior to unmap for > iommufd_vfio_unmap_dma() dirty support to validate the user bitmap page > size against IOPT pagesize. > > Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx> > --- > drivers/iommu/iommufd/vfio_compat.c | 221 ++++++++++++++++++++++++++-- > 1 file changed, 209 insertions(+), 12 deletions(-) I think I would probably not do this patch, it has behavior that is quite different from the current vfio - ie the interaction with the mdevs, and I don't intend to fix that. So, with this patch and a mdev then vfio_compat will return all-not-dirty but current vfio will return all-dirty - and that is significant enough to break qemu. We've made a qemu patch to allow qemu to be happy if dirty tracking is not supported in the vfio container for migration, which is part of the v2 enablement series. That seems like the better direction. I can see why this is useful to test with the current qemu however. Jason