Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iommu: Require passing new handles to APIs supporting handle

Add kdoc to highligt the caller of iommu_[attach|replace]_group_handle()
and iommu_attach_device_pasid() should always provide a new handle. This
can avoid race with lockless reference to the handle. e.g. the
find_fault_handler() and iommu_report_device_fault() in the PRI path.

Link: https://patch.msgid.link/r/20250321171940.7213-2-yi.l.liu@intel.com
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Yi Liu and committed by
Jason Gunthorpe
ada14b9f 06d54f00

+9
+9
drivers/iommu/iommu.c
··· 3365 3365 * @pasid: the pasid of the device. 3366 3366 * @handle: the attach handle. 3367 3367 * 3368 + * Caller should always provide a new handle to avoid race with the paths 3369 + * that have lockless reference to handle if it intends to pass a valid handle. 3370 + * 3368 3371 * Return: 0 on success, or an error. 3369 3372 */ 3370 3373 int iommu_attach_device_pasid(struct iommu_domain *domain, ··· 3528 3525 * This is a variant of iommu_attach_group(). It allows the caller to provide 3529 3526 * an attach handle and use it when the domain is attached. This is currently 3530 3527 * used by IOMMUFD to deliver the I/O page faults. 3528 + * 3529 + * Caller should always provide a new handle to avoid race with the paths 3530 + * that have lockless reference to handle. 3531 3531 */ 3532 3532 int iommu_attach_group_handle(struct iommu_domain *domain, 3533 3533 struct iommu_group *group, ··· 3600 3594 * 3601 3595 * If the currently attached domain is a core domain (e.g. a default_domain), 3602 3596 * it will act just like the iommu_attach_group_handle(). 3597 + * 3598 + * Caller should always provide a new handle to avoid race with the paths 3599 + * that have lockless reference to handle. 3603 3600 */ 3604 3601 int iommu_replace_group_handle(struct iommu_group *group, 3605 3602 struct iommu_domain *new_domain,