Re: [PATCH v3 2/6] iommufd: Create access in vfio_iommufd_emulated_bind()

Jason Gunthorpe
2023-03-31T16:56:02Z

On Fri, Mar 31, 2023 at 08:16:16AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@nvidia.com>
> > Sent: Thursday, March 30, 2023 4:00 AM
> >
> > On Mon, Mar 27, 2023 at 02:33:47AM -0700, Yi Liu wrote:
> > > @@ -494,6 +479,30 @@ void iommufd_access_destroy(struct
> > iommufd_access *access)
> > > }
> > > EXPORT_SYMBOL_NS_GPL(iommufd_access_destroy, IOMMUFD);
> > >
> > > +int iommufd_access_attach(struct iommufd_access *access, u32 ioas_id)
> > > +{
> > > + struct iommufd_ioas *new_ioas;
> > > + int rc = 0;
> > > +
> > > + if (access->ioas != NULL && access->ioas->obj.id != ioas_id)
> > > + return -EINVAL;
> >
> > This should just be
> >
> > if (access->ioas)
> > return -EINVAL;
>
> the physical path has the same check:
>
> if (idev->igroup->hwpt != NULL && idev->igroup->hwpt != hwpt) {
> rc = -EINVAL;
> goto err_unlock;
> }
>
> If we change here then that one should be changed too.

No, that one is checking if the another device attached to the same
group is a compatible hwpt so we succeed to attach the new device

Jason