File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -146,9 +146,9 @@ int vfio_iommufd_physical_attach_ioas(struct vfio_device *vdev, u32 *pt_id)
146
146
return - EINVAL ;
147
147
148
148
if (vdev -> iommufd_attached )
149
- return - EBUSY ;
150
-
151
- rc = iommufd_device_attach (vdev -> iommufd_device , pt_id );
149
+ rc = iommufd_device_replace ( vdev -> iommufd_device , pt_id ) ;
150
+ else
151
+ rc = iommufd_device_attach (vdev -> iommufd_device , pt_id );
152
152
if (rc )
153
153
return rc ;
154
154
vdev -> iommufd_attached = true;
@@ -223,8 +223,9 @@ int vfio_iommufd_emulated_attach_ioas(struct vfio_device *vdev, u32 *pt_id)
223
223
lockdep_assert_held (& vdev -> dev_set -> lock );
224
224
225
225
if (vdev -> iommufd_attached )
226
- return - EBUSY ;
227
- rc = iommufd_access_attach (vdev -> iommufd_access , * pt_id );
226
+ rc = iommufd_access_replace (vdev -> iommufd_access , * pt_id );
227
+ else
228
+ rc = iommufd_access_attach (vdev -> iommufd_access , * pt_id );
228
229
if (rc )
229
230
return rc ;
230
231
vdev -> iommufd_attached = true;
Original file line number Diff line number Diff line change @@ -939,6 +939,12 @@ struct vfio_device_bind_iommufd {
939
939
* Undo by VFIO_DEVICE_DETACH_IOMMUFD_PT or device fd close. This is only
940
940
* allowed on cdev fds.
941
941
*
942
+ * If a vfio device is currently attached to a valid hw_pagetable, without doing
943
+ * a VFIO_DEVICE_DETACH_IOMMUFD_PT, a second VFIO_DEVICE_ATTACH_IOMMUFD_PT ioctl
944
+ * passing in another hw_pagetable (hwpt) id is allowed. This action, also known
945
+ * as a hw_pagetable replacement, will replace the device's currently attached
946
+ * hw_pagetable with a new hw_pagetable corresponding to the given pt_id.
947
+ *
942
948
* Return: 0 on success, -errno on failure.
943
949
*/
944
950
struct vfio_device_attach_iommufd_pt {
You can’t perform that action at this time.
0 commit comments