RE: [PATCH v5 03/29] iommu: Apply the new iommufd_object_alloc_ucmd helper

Tian, Kevin
2025-05-28T08:13:32Z

> From: Nicolin Chen <nicolinc@nvidia.com>
> Sent: Saturday, May 24, 2025 5:35 AM
>
> On Fri, May 23, 2025 at 07:49:40AM +0000, Tian, Kevin wrote:
> > > From: Nicolin Chen <nicolinc@nvidia.com>
> > > Sent: Sunday, May 18, 2025 11:21 AM
> > >
> > > Now the new ucmd-based object allocator eases the finalize/abort
> routine,
> > > apply this to all existing allocators that aren't protected by any lock.
> > >
> > > Upgrade the for-driver vIOMMU alloctor too, and pass down to all
> existing
> > > viommu_alloc op accordingly.
> > >
> > > Note that __iommufd_object_alloc_ucmd() builds in some static tests that
> > > cover both static_asserts in the iommufd_viommu_alloc(). Thus drop
> them.
> >
> > I may overlook something, but at a quick glance the following check
> > Is not covered?
> >
> > - static_assert(__same_type(struct iommufd_viommu,
> \
> > - ((drv_struct *)NULL)->member));
> \
>
> The container_of() inside __iommufd_object_alloc_ucmd() covers that:
>
> #define container_of(ptr, type, member) ({ \
> void *__mptr = (void *)(ptr); \
> static_assert(__same_type(*(ptr), ((type *)0)->member) || \
> <<== here
> __same_type(*(ptr), void), \
> "pointer type mismatch in container_of()"); \
> ((type *)(__mptr - offsetof(type, member))); })

Yeah it's there.