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

Tian, Kevin
2024-08-01T08:11:20Z

> From: Nicolin Chen <nicolinc@nvidia.com>
> 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.

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.