vfio iommu: Update UNMAP_DMA ioctl to get dirty bitmap before unmap
authorKirti Wankhede <kwankhede@nvidia.com>
Thu, 28 May 2020 20:30:52 +0000 (02:00 +0530)
committerAlex Williamson <alex.williamson@redhat.com>
Thu, 28 May 2020 21:53:26 +0000 (15:53 -0600)
commit331e33d2960c8292bad8b02578fcfac18f721517
tree39d18c0231b574fd90de6626a4aebf65bdb0c250
parentd6a4c185660cb978f76e46e3f5f6b08dc00ecc8f
vfio iommu: Update UNMAP_DMA ioctl to get dirty bitmap before unmap

DMA mapped pages, including those pinned by mdev vendor drivers, might
get unpinned and unmapped while migration is active and device is still
running. For example, in pre-copy phase while guest driver could access
those pages, host device or vendor driver can dirty these mapped pages.
Such pages should be marked dirty so as to maintain memory consistency
for a user making use of dirty page tracking.

To get bitmap during unmap, user should allocate memory for bitmap, set
it all zeros, set size of allocated memory, set page size to be
considered for bitmap and set flag VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP.

Signed-off-by: Kirti Wankhede <kwankhede@nvidia.com>
Reviewed-by: Neo Jia <cjia@nvidia.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Yan Zhao <yan.y.zhao@intel.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_iommu_type1.c
include/uapi/linux/vfio.h