On Sun, Jun 16, 2024 at 02:11:48PM +0800, Lu Baolu wrote: > Previously, the domain that a page fault targets is stored in an > iopf_group, which represents a minimal set of page faults. With the > introduction of attach handle, replace the domain with the handle > so that the fault handler can obtain more information as needed > when handling the faults. > > iommu_report_device_fault() is currently used for SVA page faults, > which handles the page fault in an internal cycle. The domain is retrieved > with iommu_get_domain_for_dev_pasid() if the pasid in the fault message > is valid. This doesn't work in IOMMUFD case, where if the pasid table of > a device is wholly managed by user space, there is no domain attached to > the PASID of the device, and all page faults are forwarded through a > NESTING domain attaching to RID. > > Add a new IOMMU capability flag, IOMMU_CAP_USER_IOASID_TABLE, which > indicates if the IOMMU driver supports user-managed PASID tables. In the > iopf deliver path, if no attach handle found for the iopf PASID, roll > back to RID domain when the IOMMU driver supports this capability. This remark is out of date since it is now: > @@ -547,6 +547,10 @@ static inline int __iommu_copy_struct_from_user_array( > * @default_domain: If not NULL this will always be set as the default domain. > * This should be an IDENTITY/BLOCKED/PLATFORM domain. > * Do not use in new drivers. > + * @user_pasid_table: IOMMU driver supports user-managed PASID table. There is > + * no user domain for each PASID and the I/O page faults are > + * forwarded through the user domain attached to the device > + * RID. > */ > struct iommu_ops { > bool (*capable)(struct device *dev, enum iommu_cap); > @@ -590,6 +594,7 @@ struct iommu_ops { > struct iommu_domain *blocked_domain; > struct iommu_domain *release_domain; > struct iommu_domain *default_domain; > + u8 user_pasid_table:1; > }; Otherwise looks goot Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx> Jason