RE: [PATCH v2] iommufd/device: Enforce reserved IOVA also when attached to hwpt_nested

From: Tian, Kevin
Date: Tue Aug 06 2024 - 04:09:02 EST


> From: Nicolin Chen <nicolinc@xxxxxxxxxx>
> Sent: Tuesday, August 6, 2024 1:02 PM
>
> +iommufd_group_do_replace_reserved_iova(struct iommufd_group *igroup,
> + struct iommufd_hw_pagetable *hwpt)
> {
> - struct iommufd_hw_pagetable *old_hwpt = igroup->hwpt;
> + struct iommufd_hwpt_paging *hwpt_paging =
> to_hwpt_paging(hwpt);
> struct iommufd_device *cur;
> int rc;
>
> lockdep_assert_held(&igroup->lock);
>
> - if (!hwpt_is_paging(old_hwpt) ||
> - hwpt_paging->ioas != to_hwpt_paging(old_hwpt)->ioas) {
> + if (!hwpt_paging)
> + return 0;
> +
> + if (hwpt_to_ioas(hwpt) &&

this check is always true when hwpt_paging is valid.

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>