Re: [PATCH v2 8/8] iommu/arm-smmu-v3: Support IOMMU_DOMAIN_NESTED

Nicolin Chen
2024-08-28T19:28:38Z

On Wed, Aug 28, 2024 at 04:01:00PM -0300, Jason Gunthorpe wrote:

> > > +
> > > + if (!(parent->type & __IOMMU_DOMAIN_PAGING))
> > > + return ERR_PTR(-EINVAL);
> > > +
> > > + smmu_parent = to_smmu_domain(parent);
> > > + if (smmu_parent->stage != ARM_SMMU_DOMAIN_S2 ||
> >
> > Maybe "!smmu_parent->nest_parent" instead.
>
> Hmm, yes.. Actually we can delete it, and the paging test above.
>
> The core code checks it.

Yea, we can rely on the core.

> Though I think we missed owner validation there??
>
> @@ -225,7 +225,8 @@ iommufd_hwpt_nested_alloc(struct iommufd_ctx *ictx,
> if ((flags & ~IOMMU_HWPT_FAULT_ID_VALID) ||
> !user_data->len || !ops->domain_alloc_user)
> return ERR_PTR(-EOPNOTSUPP);
> - if (parent->auto_domain || !parent->nest_parent)
> + if (parent->auto_domain || !parent->nest_parent ||
> + parent->common.domain->owner != ops)
> return ERR_PTR(-EINVAL);
>
> Right??

Yea, this ensures the same driver.

> > [---]
> > > + smmu_parent->smmu != master->smmu)
> > > + return ERR_PTR(-EINVAL);

Then, we only need this one.

Thanks
Nicolin