Re: [PATCH v3 08/11] iommufd/selftest: Add IOMMU_VIOMMU_TYPE_SELFTEST

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 17, 2024 at 02:15:00PM -0300, Jason Gunthorpe wrote:
> On Wed, Oct 09, 2024 at 09:38:08AM -0700, Nicolin Chen wrote:
> 
> > +static struct iommufd_viommu *
> > +mock_viommu_alloc(struct iommu_device *iommu_dev, struct iommu_domain *domain,
> > +		  struct iommufd_ctx *ictx, unsigned int viommu_type)
> > +{
> > +	struct mock_iommu_device *mock_iommu =
> > +		container_of(iommu_dev, struct mock_iommu_device, iommu_dev);
> > +	struct mock_viommu *mock_viommu;
> > +
> > +	if (viommu_type != IOMMU_VIOMMU_TYPE_SELFTEST)
> > +		return ERR_PTR(-EOPNOTSUPP);
> 
> What about the default viommu? What happens then?

IOMMU_VIOMMU_TYPE_DEFAULT is allocated by the core, it won't go
down to iommu_ops->viommu_alloc (this function).

> > +	mock_viommu = iommufd_viommu_alloc(ictx, mock_viommu, core,
> > +					   &mock_viommu_ops);
> > +	if (IS_ERR(mock_viommu))
> > +		return ERR_CAST(mock_viommu);
> > +
> > +	if (!refcount_inc_not_zero(&mock_iommu->users)) {
> 
> It would be a bug if the iommu_dev being passed in was somehow
> released while iommufd had hold of it through vfio. So just use
> refcount_inc()

OK.

Thanks
Nicolin




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux