Skip to content

Commit dbc5f37

Browse files
yiliu1765jgunthorpe
authored andcommitted
iommufd: Allow allocating PASID-compatible domain
The underlying infrastructure has supported the PASID attach and related enforcement per the requirement of the IOMMU_HWPT_ALLOC_PASID flag. This extends iommufd to support PASID compatible domain requested by userspace. Link: https://patch.msgid.link/r/[email protected] Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Nicolin Chen <[email protected]> Signed-off-by: Yi Liu <[email protected]> Tested-by: Nicolin Chen <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent ce15c13 commit dbc5f37

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

drivers/iommu/iommufd/hw_pagetable.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ iommufd_hwpt_paging_alloc(struct iommufd_ctx *ictx, struct iommufd_ioas *ioas,
112112
{
113113
const u32 valid_flags = IOMMU_HWPT_ALLOC_NEST_PARENT |
114114
IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
115-
IOMMU_HWPT_FAULT_ID_VALID;
115+
IOMMU_HWPT_FAULT_ID_VALID |
116+
IOMMU_HWPT_ALLOC_PASID;
116117
const struct iommu_ops *ops = dev_iommu_ops(idev->dev);
117118
struct iommufd_hwpt_paging *hwpt_paging;
118119
struct iommufd_hw_pagetable *hwpt;
@@ -233,7 +234,7 @@ iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
233234
struct iommufd_hw_pagetable *hwpt;
234235
int rc;
235236

236-
if ((flags & ~IOMMU_HWPT_FAULT_ID_VALID) ||
237+
if ((flags & ~(IOMMU_HWPT_FAULT_ID_VALID | IOMMU_HWPT_ALLOC_PASID)) ||
237238
!user_data->len || !ops->domain_alloc_nested)
238239
return ERR_PTR(-EOPNOTSUPP);
239240
if (parent->auto_domain || !parent->nest_parent ||
@@ -290,7 +291,7 @@ iommufd_viommu_alloc_hwpt_nested(struct iommufd_viommu *viommu, u32 flags,
290291
struct iommufd_hw_pagetable *hwpt;
291292
int rc;
292293

293-
if (flags & ~IOMMU_HWPT_FAULT_ID_VALID)
294+
if (flags & ~(IOMMU_HWPT_FAULT_ID_VALID | IOMMU_HWPT_ALLOC_PASID))
294295
return ERR_PTR(-EOPNOTSUPP);
295296
if (!user_data->len)
296297
return ERR_PTR(-EOPNOTSUPP);

include/uapi/linux/iommufd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,9 @@ struct iommu_vfio_ioas {
393393
* Any domain attached to the non-PASID part of the
394394
* device must also be flagged, otherwise attaching a
395395
* PASID will blocked.
396+
* For the user that wants to attach PASID, ioas is
397+
* not recommended for both the non-PASID part
398+
* and PASID part of the device.
396399
* If IOMMU does not support PASID it will return
397400
* error (-EOPNOTSUPP).
398401
*/

0 commit comments

Comments
 (0)