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.
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -931,29 +931,34 @@ struct vfio_device_bind_iommufd { · 930 unmodified lines | |||
| 931 | * VFIO_DEVICE_ATTACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 19, | 931 | * VFIO_DEVICE_ATTACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 19, |
| 932 | * struct vfio_device_attach_iommufd_pt) | 932 | * struct vfio_device_attach_iommufd_pt) |
| 933 | * @argsz: User filled size of this data. | 933 | * @argsz: User filled size of this data. |
| 934 | * @flags: Must be 0. | 934 | * @flags: Flags for attach. |
| 935 | * @pt_id: Input the target id which can represent an ioas or a hwpt | 935 | * @pt_id: Input the target id which can represent an ioas or a hwpt |
| 936 | * allocated via iommufd subsystem. | 936 | * allocated via iommufd subsystem. |
| 937 | * Output the input ioas id or the attached hwpt id which could | 937 | * Output the input ioas id or the attached hwpt id which could |
| 938 | * be the specified hwpt itself or a hwpt automatically created | 938 | * be the specified hwpt itself or a hwpt automatically created |
| 939 | * for the specified ioas by kernel during the attachment. | 939 | * 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 | ||
| 940 | * | 942 | * |
| 941 | * Associate the device with an address space within the bound iommufd. | 943 | * Associate the device with an address space within the bound iommufd. |
| 942 | * Undo by VFIO_DEVICE_DETACH_IOMMUFD_PT or device fd close. This is only | 944 | * Undo by VFIO_DEVICE_DETACH_IOMMUFD_PT or device fd close. This is only |
| 943 | * allowed on cdev fds. | 945 | * allowed on cdev fds. |
| 944 | * | 946 | * |
| 945 | * If a vfio device is currently attached to a valid hw_pagetable, without doing | 947 | * If a vfio device or a pasid of this device is currently attached to a valid |
| 946 | * a VFIO_DEVICE_DETACH_IOMMUFD_PT, a second VFIO_DEVICE_ATTACH_IOMMUFD_PT ioctl | 948 | * hw_pagetable (hwpt), without doing a VFIO_DEVICE_DETACH_IOMMUFD_PT, a second |
| 947 | * passing in another hw_pagetable (hwpt) id is allowed. This action, also known | 949 | * VFIO_DEVICE_ATTACH_IOMMUFD_PT ioctl passing in another hwpt id is allowed. |
| 948 | * as a hw_pagetable replacement, will replace the device's currently attached | 950 | * This action, also known as a hw_pagetable replacement, will replace the |
| 949 | * hw_pagetable with a new hw_pagetable corresponding to the given pt_id. | 951 | * currently attached hwpt of the device or the pasid of this device with a new |
| 952 | * hwpt corresponding to the given pt_id. | ||
| 950 | * | 953 | * |
| 951 | * Return: 0 on success, -errno on failure. | 954 | * Return: 0 on success, -errno on failure. |
| 952 | */ | 955 | */ |
| 953 | struct vfio_device_attach_iommufd_pt { | 956 | struct vfio_device_attach_iommufd_pt { |
| 954 | __u32 argsz; | 957 | __u32 argsz; |
| 955 | __u32 flags; | 958 | __u32 flags; |
| 959 | #define VFIO_DEVICE_ATTACH_PASID (1 << 0) | ||
| 956 | __u32 pt_id; | 960 | __u32 pt_id; |
| 961 | __u32 pasid; | ||
| 957 | }; | 962 | }; |
| 958 | 963 | ||
| 959 | #define VFIO_DEVICE_ATTACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 19) | 964 | #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 | |||
| 962 | * VFIO_DEVICE_DETACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 20, | 967 | * VFIO_DEVICE_DETACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 20, |
| 963 | * struct vfio_device_detach_iommufd_pt) | 968 | * struct vfio_device_detach_iommufd_pt) |
| 964 | * @argsz: User filled size of this data. | 969 | * @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 | ||
| 966 | * | 973 | * |
| 967 | * Remove the association of the device and its current associated address | 974 | * Remove the association of the device or a pasid of the device and its current |
| 968 | * space. After it, the device should be in a blocking DMA state. This is only | 975 | * associated address space. After it, the device or the pasid should be in a |
| 969 | * allowed on cdev fds. | 976 | * blocking DMA state. This is only allowed on cdev fds. |
| 970 | * | 977 | * |
| 971 | * Return: 0 on success, -errno on failure. | 978 | * Return: 0 on success, -errno on failure. |
| 972 | */ | 979 | */ |
| 973 | struct vfio_device_detach_iommufd_pt { | 980 | struct vfio_device_detach_iommufd_pt { |
| 974 | __u32 argsz; | 981 | __u32 argsz; |
| 975 | __u32 flags; | 982 | __u32 flags; |
| 983 | #define VFIO_DEVICE_DETACH_PASID (1 << 0) | ||
| 984 | __u32 pasid; | ||
| 976 | }; | 985 | }; |
| 977 | 986 | ||
| 978 | #define VFIO_DEVICE_DETACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 20) | 987 | #define VFIO_DEVICE_DETACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 20) |