[PATCH v1 08/12] iommufd/viommu: Replace ops->viommu_alloc with ops->viommu_init

Nicolin Chen nicolinc at nvidia.com
Thu Jun 12 10:24:51 PDT 2025


On Thu, Jun 12, 2025 at 08:27:12AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc at nvidia.com>
> > Sent: Tuesday, June 10, 2025 1:14 AM
> > 
> > +	rc = ops->get_viommu_size(cmd->type, idev->dev, &viommu_size);
> > +	if (rc)
> > +		goto out_put_idev;
> > +
> > +	/*
> > +	 * It is a driver bug for providing a viommu_size smaller than the core
> > +	 * vIOMMU structure size
> > +	 */
> > +	if (WARN_ON_ONCE(viommu_size < sizeof(*viommu))) {
> > +		rc = -EINVAL;
> > +		goto out_put_idev;
> > +	}
> > +
> 
> It's not about user providing an invalid argument. Sounds cleaner
> to return NOSUPPORT in such case.

Yea, I think that's legit. The driver is broken to support vIOMMU
allocations.

Maybe we should change this one too?
226 static struct iommufd_hwpt_nested *
227 iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
228                           struct iommufd_hwpt_paging *parent,
229                           struct iommufd_device *idev, u32 flags,
230                           const struct iommu_user_data *user_data)
231 {
...
266         if (WARN_ON_ONCE(hwpt->domain->type != IOMMU_DOMAIN_NESTED)) {
267                 rc = -EINVAL;
268                 goto out_abort;
269         }

Similarly, the driver is broken to support nested HWPT allocations.

Thanks
Nicolin



More information about the linux-arm-kernel mailing list