History

vfio/type1: Add IOVA range capability support

This allows the user-space to retrieve the supported IOVA range(s), excluding any non-relaxable reserved regions. The implementation is based on capability chains, added to VFIO_IOMMU_GET_INFO ioctl.

Shameer Kolothum committed 7 years ago

Commit a7170721 parent 9b77e5c2 files · +126 −1Browse files

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

Unified · Split

include/uapi/linux/vfio.h+25−1
@@ -714,7 +714,31 @@ struct vfio_iommu_type1_info { · 713 unmodified lines
714714 __u32 argsz;
715715 __u32 flags;
716716 #define VFIO_IOMMU_INFO_PGSIZES (1 << 0) /* supported page sizes info */
717− __u64 iova_pgsizes; /* Bitmap of supported page sizes */
717+#define VFIO_IOMMU_INFO_CAPS (1 << 1) /* Info supports caps */
718+ __u64 iova_pgsizes; /* Bitmap of supported page sizes */
719+ __u32 cap_offset; /* Offset within info struct of first cap */
720+};
721+
722+/*
723+ * The IOVA capability allows to report the valid IOVA range(s)
724+ * excluding any non-relaxable reserved regions exposed by
725+ * devices attached to the container. Any DMA map attempt
726+ * outside the valid iova range will return error.
727+ *
728+ * The structures below define version 1 of this capability.
729+ */
730+#define VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE 1
731+
732+struct vfio_iova_range {
733+ __u64 start;
734+ __u64 end;
735+};
736+
737+struct vfio_iommu_type1_info_cap_iova_range {
738+ struct vfio_info_cap_header header;
739+ __u32 nr_iovas;
740+ __u32 reserved;
741+ struct vfio_iova_range iova_ranges[];
718742 };
719743
720744 #define VFIO_IOMMU_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12)