History

vfio iommu: Add ioctl definition for dirty pages tracking

IOMMU container maintains a list of all pages pinned by vfio_pin_pages API. All pages pinned by vendor driver through this API should be considered as dirty during migration. When container consists of IOMMU capable device and all pages are pinned and mapped, then all pages are marked dirty. Added support to start/stop dirtied pages tracking and to get bitmap of all dirtied pages for requested IO virtual address range.

Kirti Wankhede committed 6 years ago

Commit b704fd11 parent cade0751 file · +57 −0Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/vfio.h+57−0
@@ -1033,6 +1033,12 @@ struct vfio_iommu_type1_dma_map { · 1032 unmodified lines
1033 1033
1034#define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13)1034#define VFIO_IOMMU_MAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 13)
1035 1035
1036struct vfio_bitmap {
1037 __u64 pgsize; /* page size for bitmap in bytes */
1038 __u64 size; /* in bytes */
1039 __u64 __user *data; /* one bit per page */
1040};
1041
1036/**1042/**
1037 * VFIO_IOMMU_UNMAP_DMA - _IOWR(VFIO_TYPE, VFIO_BASE + 14,1043 * VFIO_IOMMU_UNMAP_DMA - _IOWR(VFIO_TYPE, VFIO_BASE + 14,
1038 * struct vfio_dma_unmap)1044 * struct vfio_dma_unmap)
@@ -1059,6 +1065,57 @@ struct vfio_iommu_type1_dma_unmap { · 20 unmodified lines
1059#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15)1065#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15)
1060#define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16)1066#define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16)
1061 1067
1068/**
1069 * VFIO_IOMMU_DIRTY_PAGES - _IOWR(VFIO_TYPE, VFIO_BASE + 17,
1070 * struct vfio_iommu_type1_dirty_bitmap)
1071 * IOCTL is used for dirty pages logging.
1072 * Caller should set flag depending on which operation to perform, details as
1073 * below:
1074 *
1075 * Calling the IOCTL with VFIO_IOMMU_DIRTY_PAGES_FLAG_START flag set, instructs
1076 * the IOMMU driver to log pages that are dirtied or potentially dirtied by
1077 * the device; designed to be used when a migration is in progress. Dirty pages
1078 * are logged until logging is disabled by user application by calling the IOCTL
1079 * with VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP flag.
1080 *
1081 * Calling the IOCTL with VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP flag set, instructs
1082 * the IOMMU driver to stop logging dirtied pages.
1083 *
1084 * Calling the IOCTL with VFIO_IOMMU_DIRTY_PAGES_FLAG_GET_BITMAP flag set
1085 * returns the dirty pages bitmap for IOMMU container for a given IOVA range.
1086 * The user must specify the IOVA range and the pgsize through the structure
1087 * vfio_iommu_type1_dirty_bitmap_get in the data[] portion. This interface
1088 * supports getting a bitmap of the smallest supported pgsize only and can be
1089 * modified in future to get a bitmap of any specified supported pgsize. The
1090 * user must provide a zeroed memory area for the bitmap memory and specify its
1091 * size in bitmap.size. One bit is used to represent one page consecutively
1092 * starting from iova offset. The user should provide page size in bitmap.pgsize
1093 * field. A bit set in the bitmap indicates that the page at that offset from
1094 * iova is dirty. The caller must set argsz to a value including the size of
1095 * structure vfio_iommu_type1_dirty_bitmap_get, but excluding the size of the
1096 * actual bitmap. If dirty pages logging is not enabled, an error will be
1097 * returned.
1098 *
1099 * Only one of the flags _START, _STOP and _GET may be specified at a time.
1100 *
1101 */
1102struct vfio_iommu_type1_dirty_bitmap {
1103 __u32 argsz;
1104 __u32 flags;
1105#define VFIO_IOMMU_DIRTY_PAGES_FLAG_START (1 << 0)
1106#define VFIO_IOMMU_DIRTY_PAGES_FLAG_STOP (1 << 1)
1107#define VFIO_IOMMU_DIRTY_PAGES_FLAG_GET_BITMAP (1 << 2)
1108 __u8 data[];
1109};
1110
1111struct vfio_iommu_type1_dirty_bitmap_get {
1112 __u64 iova; /* IO virtual address */
1113 __u64 size; /* Size of iova range */
1114 struct vfio_bitmap bitmap;
1115};
1116
1117#define VFIO_IOMMU_DIRTY_PAGES _IO(VFIO_TYPE, VFIO_BASE + 17)
1118
1062/* -------- Additional API for SPAPR TCE (Server POWERPC) IOMMU -------- */1119/* -------- Additional API for SPAPR TCE (Server POWERPC) IOMMU -------- */
1063 1120
1064/*1121/*