RE: [PATCH] iommufd: Enforce IOMMU_RESV_SW_MSI upon hwpt_paging allocation
From: Tian, Kevin
Date: Thu Aug 01 2024 - 04:11:34 EST
> 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.
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.