Re: [PATCH 1/2] iommu: Prevent RESV_DIRECT devices from blocking domains

From: Jason Gunthorpe
Date: Tue Jun 27 2023 - 11:47:56 EST


On Tue, Jun 27, 2023 at 04:01:01PM +0800, Baolu Lu wrote:

> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index e59de7852067..3be88b5f36bb 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -962,6 +962,9 @@ static int iommu_create_device_direct_mappings(struct
> iommu_domain *domain,
> pg_size = domain->pgsize_bitmap ? 1UL <<
> __ffs(domain->pgsize_bitmap) : 0;
> INIT_LIST_HEAD(&mappings);
>
> + if (WARN_ON_ONCE((domain->type & __IOMMU_DOMAIN_PAGING) &&
> !pg_size))
> + return -EINVAL;

Calling this function with an identity domain is expected, it must
return 0.

Jason