Re: [PATCH v6 08/12] iommu/sva: Use attach/detach_pasid_dev in SVA interfaces

From: Jason Gunthorpe
Date: Thu May 12 2022 - 07:51:46 EST


On Thu, May 12, 2022 at 11:02:39AM +0800, Baolu Lu wrote:
> > > + mutex_lock(&group->mutex);
> > > + domain = xa_load(&group->pasid_array, pasid);
> > > + if (domain && domain->type != type)
> > > + domain = NULL;
> > > + mutex_unlock(&group->mutex);
> > > + iommu_group_put(group);
> > > +
> > > + return domain;
> > This is bad locking, group->pasid_array values cannot be taken outside
> > the lock.
>
> It's not iommu core, but SVA (or other feature components) that manage
> the life cycle of a domain. The iommu core only provides a place to
> store the domain pointer. The feature components are free to fetch their
> domain pointers from iommu core as long as they are sure that the domain
> is alive during use.

I'm not convinced.

Jason