From: Jason Gunthorpe Date: Tue, 8 Apr 2025 16:54:02 +0000 (-0300) Subject: iommu/pages: Move the __GFP_HIGHMEM checks into the common code X-Git-Tag: v6.16-rc1~110^2^12~35 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=580ccca4ee53d7f2a2c90044220887daec0dcd9a;p=linux-block.git iommu/pages: Move the __GFP_HIGHMEM checks into the common code The entire allocator API is built around using the kernel virtual address, it is illegal to pass GFP_HIGHMEM in as a GFP flag. Block it in the common code. Remove the duplicated checks from drivers. Reviewed-by: Lu Baolu Reviewed-by: Mostafa Saleh Tested-by: Nicolin Chen Tested-by: Alejandro Jimenez Signed-off-by: Jason Gunthorpe Link: https://lore.kernel.org/r/14-v4-c8663abbb606+3f7-iommu_pages_jgg@nvidia.com Signed-off-by: Joerg Roedel --- diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index 62df2528d020..08d0f62abe8a 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -267,8 +267,6 @@ static void *__arm_lpae_alloc_pages(size_t size, gfp_t gfp, dma_addr_t dma; void *pages; - VM_BUG_ON((gfp & __GFP_HIGHMEM)); - if (cfg->alloc) pages = cfg->alloc(cookie, size, gfp); else diff --git a/drivers/iommu/io-pgtable-dart.c b/drivers/iommu/io-pgtable-dart.c index c80ccc753b5e..8b5403aae8c0 100644 --- a/drivers/iommu/io-pgtable-dart.c +++ b/drivers/iommu/io-pgtable-dart.c @@ -111,7 +111,6 @@ static void *__dart_alloc_pages(size_t size, gfp_t gfp) { int order = get_order(size); - VM_BUG_ON((gfp & __GFP_HIGHMEM)); return iommu_alloc_pages(gfp, order); } diff --git a/drivers/iommu/iommu-pages.c b/drivers/iommu/iommu-pages.c index 3077df642adb..a7eed09420a2 100644 --- a/drivers/iommu/iommu-pages.c +++ b/drivers/iommu/iommu-pages.c @@ -37,6 +37,10 @@ void *iommu_alloc_pages_node(int nid, gfp_t gfp, unsigned int order) const unsigned long pgcnt = 1UL << order; struct folio *folio; + /* This uses page_address() on the memory. */ + if (WARN_ON(gfp & __GFP_HIGHMEM)) + return NULL; + /* * __folio_alloc_node() does not handle NUMA_NO_NODE like * alloc_pages_node() did.