Re: [PATCH] iommufd: Enforce IOMMU_RESV_SW_MSI upon hwpt_paging allocation

From: Nicolin Chen
Date: Thu Aug 01 2024 - 13:41:19 EST


On Thu, Aug 01, 2024 at 08:10:57AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc@xxxxxxxxxx>
> > Sent: Thursday, August 1, 2024 5:22 AM
> >
> > @@ -316,7 +316,9 @@ static inline bool hwpt_is_paging(struct
> > iommufd_hw_pagetable *hwpt)
> > static inline struct iommufd_hwpt_paging *
> > to_hwpt_paging(struct iommufd_hw_pagetable *hwpt)
> > {
> > - return container_of(hwpt, struct iommufd_hwpt_paging, common);
> > + if (hwpt_is_paging(hwpt))
> > + return container_of(hwpt, struct iommufd_hwpt_paging,
> > common);
> > + return container_of(hwpt, struct iommufd_hwpt_nested, common)-
> > >parent;
> > }
> >
>
> hmm this doesn't work with future new hwpt types.

Was trying to make it a smaller change, but short-sighted.

> It's clearer to pass hwpt into earlier helpers and then do the type check
> insided and make it a nop for types other than paging/nesting.

Ack.

Thanks
Nicolin