[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH Kernel v21 7/8] vfio iommu: Add migration capability to report su
From: |
Kirti Wankhede |
Subject: |
[PATCH Kernel v21 7/8] vfio iommu: Add migration capability to report supported features |
Date: |
Sat, 16 May 2020 02:43:22 +0530 |
Added migration capability in IOMMU info chain.
User application should check IOMMU info chain for migration capability
to use dirty page tracking feature provided by kernel module.
User application must check page sizes supported and maximum dirty
bitmap size returned by this capability structure for ioctls used to get
dirty bitmap.
Signed-off-by: Kirti Wankhede <address@hidden>
---
drivers/vfio/vfio_iommu_type1.c | 23 ++++++++++++++++++++++-
include/uapi/linux/vfio.h | 22 ++++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index d687794c721c..5c8d20974a2a 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -2390,6 +2390,22 @@ static int vfio_iommu_iova_build_caps(struct vfio_iommu
*iommu,
return ret;
}
+static int vfio_iommu_migration_build_caps(struct vfio_iommu *iommu,
+ struct vfio_info_cap *caps)
+{
+ struct vfio_iommu_type1_info_cap_migration cap_mig;
+
+ cap_mig.header.id = VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION;
+ cap_mig.header.version = 1;
+
+ cap_mig.flags = 0;
+ /* support minimum pgsize */
+ cap_mig.pgsize_bitmap = (size_t)1 << __ffs(iommu->pgsize_bitmap);
+ cap_mig.max_dirty_bitmap_size = DIRTY_BITMAP_SIZE_MAX;
+
+ return vfio_info_add_capability(caps, &cap_mig.header, sizeof(cap_mig));
+}
+
static long vfio_iommu_type1_ioctl(void *iommu_data,
unsigned int cmd, unsigned long arg)
{
@@ -2436,8 +2452,13 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
info.iova_pgsizes = iommu->pgsize_bitmap;
- ret = vfio_iommu_iova_build_caps(iommu, &caps);
+ ret = vfio_iommu_migration_build_caps(iommu, &caps);
+
+ if (!ret)
+ ret = vfio_iommu_iova_build_caps(iommu, &caps);
+
mutex_unlock(&iommu->lock);
+
if (ret)
return ret;
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index a1dd2150971e..aa8aa9dcf02a 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -1013,6 +1013,28 @@ struct vfio_iommu_type1_info_cap_iova_range {
struct vfio_iova_range iova_ranges[];
};
+/*
+ * The migration capability allows to report supported features for migration.
+ *
+ * The structures below define version 1 of this capability.
+ *
+ * The existence of this capability indicates IOMMU kernel driver supports
+ * dirty page tracking.
+ *
+ * pgsize_bitmap: Kernel driver returns supported page sizes bitmap for dirty
+ * page tracking.
+ * max_dirty_bitmap_size: Kernel driver returns maximum supported dirty bitmap
+ * size in bytes to be used by user application for ioctls to get dirty bitmap.
+ */
+#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 1
+
+struct vfio_iommu_type1_info_cap_migration {
+ struct vfio_info_cap_header header;
+ __u32 flags;
+ __u64 pgsize_bitmap;
+ __u64 max_dirty_bitmap_size; /* in bytes */
+};
+
#define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)
/**
--
2.7.0
- [PATCH Kernel v21 0/8] Add UAPIs to support migration for VFIO devices, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 1/8] vfio: UAPI for migration interface for device state, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 2/8] vfio iommu: Remove atomicity of ref_count of pinned pages, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 3/8] vfio iommu: Cache pgsize_bitmap in struct vfio_iommu, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 4/8] vfio iommu: Add ioctl definition for dirty pages tracking, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 5/8] vfio iommu: Implementation of ioctl for dirty pages tracking, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 6/8] vfio iommu: Update UNMAP_DMA ioctl to get dirty bitmap before unmap, Kirti Wankhede, 2020/05/15
- [PATCH Kernel v21 7/8] vfio iommu: Add migration capability to report supported features,
Kirti Wankhede <=
- [PATCH Kernel v21 8/8] vfio: Selective dirty page tracking if IOMMU backed device pins pages, Kirti Wankhede, 2020/05/15
- RE: [PATCH Kernel v21 0/8] Add UAPIs to support migration for VFIO devices, Tian, Kevin, 2020/05/15
- Re: [PATCH Kernel v21 0/8] Add UAPIs to support migration for VFIO devices, Xiang Zheng, 2020/05/17