History

vfio: VFIO_DEVICE_[AT|DE]TACH_IOMMUFD_PT support pasid

This extends the VFIO_DEVICE_[AT|DE]TACH_IOMMUFD_PT ioctls to attach/detach a given pasid of a vfio device to/from an IOAS/HWPT.

Yi Liu committed 1 year ago

Commit ad744ed1 parent 29064132 files · +71 −18Browse files

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

Unified · Split

include/uapi/linux/vfio.h+19−10
@@ -931,29 +931,34 @@ struct vfio_device_bind_iommufd { · 930 unmodified lines
931931 * VFIO_DEVICE_ATTACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 19,
932932 * struct vfio_device_attach_iommufd_pt)
933933 * @argsz: User filled size of this data.
934− * @flags: Must be 0.
934+ * @flags: Flags for attach.
935935 * @pt_id: Input the target id which can represent an ioas or a hwpt
936936 * allocated via iommufd subsystem.
937937 * Output the input ioas id or the attached hwpt id which could
938938 * be the specified hwpt itself or a hwpt automatically created
939939 * for the specified ioas by kernel during the attachment.
940+ * @pasid: The pasid to be attached, only meaningful when
941+ * VFIO_DEVICE_ATTACH_PASID is set in @flags
940942 *
941943 * Associate the device with an address space within the bound iommufd.
942944 * Undo by VFIO_DEVICE_DETACH_IOMMUFD_PT or device fd close. This is only
943945 * allowed on cdev fds.
944946 *
945− * If a vfio device is currently attached to a valid hw_pagetable, without doing
946− * a VFIO_DEVICE_DETACH_IOMMUFD_PT, a second VFIO_DEVICE_ATTACH_IOMMUFD_PT ioctl
947− * passing in another hw_pagetable (hwpt) id is allowed. This action, also known
948− * as a hw_pagetable replacement, will replace the device's currently attached
949− * hw_pagetable with a new hw_pagetable corresponding to the given pt_id.
947+ * If a vfio device or a pasid of this device is currently attached to a valid
948+ * hw_pagetable (hwpt), without doing a VFIO_DEVICE_DETACH_IOMMUFD_PT, a second
949+ * VFIO_DEVICE_ATTACH_IOMMUFD_PT ioctl passing in another hwpt id is allowed.
950+ * This action, also known as a hw_pagetable replacement, will replace the
951+ * currently attached hwpt of the device or the pasid of this device with a new
952+ * hwpt corresponding to the given pt_id.
950953 *
951954 * Return: 0 on success, -errno on failure.
952955 */
953956 struct vfio_device_attach_iommufd_pt {
954957 __u32 argsz;
955958 __u32 flags;
959+#define VFIO_DEVICE_ATTACH_PASID (1 << 0)
956960 __u32 pt_id;
961+ __u32 pasid;
957962 };
958963
959964 #define VFIO_DEVICE_ATTACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 19)
@@ -962,17 +967,21 @@ struct vfio_device_attach_iommufd_pt { · 2 unmodified lines
962967 * VFIO_DEVICE_DETACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 20,
963968 * struct vfio_device_detach_iommufd_pt)
964969 * @argsz: User filled size of this data.
965− * @flags: Must be 0.
970+ * @flags: Flags for detach.
971+ * @pasid: The pasid to be detached, only meaningful when
972+ * VFIO_DEVICE_DETACH_PASID is set in @flags
966973 *
967− * Remove the association of the device and its current associated address
968− * space. After it, the device should be in a blocking DMA state. This is only
969− * allowed on cdev fds.
974+ * Remove the association of the device or a pasid of the device and its current
975+ * associated address space. After it, the device or the pasid should be in a
976+ * blocking DMA state. This is only allowed on cdev fds.
970977 *
971978 * Return: 0 on success, -errno on failure.
972979 */
973980 struct vfio_device_detach_iommufd_pt {
974981 __u32 argsz;
975982 __u32 flags;
983+#define VFIO_DEVICE_DETACH_PASID (1 << 0)
984+ __u32 pasid;
976985 };
977986
978987 #define VFIO_DEVICE_DETACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 20)