Re: [PATCH v1 12/14] iommu/arm-smmu-v3: Support IOMMU_DOMAIN_NESTED type of allocations

Nicolin Chen
2023-03-24T17:58:54Z

On Fri, Mar 24, 2023 at 02:51:45PM -0300, Jason Gunthorpe wrote:
> On Fri, Mar 24, 2023 at 10:50:34AM -0700, Nicolin Chen wrote:
> > On Fri, Mar 24, 2023 at 04:44:58PM +0100, Eric Auger wrote:
> > > > @@ -2923,8 +2949,16 @@ arm_smmu_domain_alloc_user(struct device *dev, struct iommu_domain *parent,
> > > > const struct iommu_hwpt_arm_smmuv3 *user_cfg = user_data;
> > > > struct arm_smmu_master *master = dev_iommu_priv_get(dev);
> > > > unsigned type = IOMMU_DOMAIN_UNMANAGED;
> > > > + struct arm_smmu_domain *s2 = NULL;
> > > > +
> > > > + if (parent) {
> > > > + if (parent->ops != arm_smmu_ops.default_domain_ops)
> > > > + return NULL;
> > > > + type = IOMMU_DOMAIN_NESTED;
> > > > + s2 = to_smmu_domain(parent);
> > > > + }
> > > Please can you explain the (use) case where !parent. This creates an
> > > unmanaged S1?
> >
> > It creates an unmanaged type of a domain. The decision to mark
> > it as an unmanaged S1 or an unmanaged S2 domain, is done in the
> > finalise() function that it checks the S2 flag and set a stage
> > accordingly.
>
> This also needs to be fixed up, the alloc_user should not return
> incompletely initialized domains.

The finalise() is called at the end of __arm_smmu_domain_alloc()
so alloc_user passing a dev pointer completes the initialization
actually.

Thanks
Nicolin