Re: [PATCH v5 09/29] iommufd: Do not unmap an owned iopt_area

Nicolin Chen
2025-06-05T04:33:28Z

On Wed, May 28, 2025 at 02:08:45PM -0300, Jason Gunthorpe wrote:
> @@ -740,11 +740,16 @@ static int iopt_unmap_iova_range(struct io_pagetable *iopt, unsigned long start,
> up_write(&iopt->iova_rwsem);
> up_read(&iopt->domains_rwsem);
>
> - iommufd_access_notify_unmap(iopt, area_first, length);
> + rc = iommufd_access_notify_unmap(iopt, area_first, length);
> + if (rc)
> + goto out_unmapped;
> +

I found that we have to re-take those rwsems to unset a flag:

rc = iommufd_access_notify_unmap(iopt, area_first, length);
if (rc) {
down_read(&iopt->domains_rwsem);
down_write(&iopt->iova_rwsem);
area->prevent_access = false;
goto out_unlock_iova;
}

Will include this in the patch.

Thanks
Nicolin