Skip to content

Commit 08a89c2

Browse files
author
Christoph Hellwig
committed
dma-direct check for highmem pages in dma_direct_alloc_pages
Check for highmem pages from CMA, just like in the dma_direct_alloc path. Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 9f4df96 commit 08a89c2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

kernel/dma/direct.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,17 @@ struct page *dma_direct_alloc_pages(struct device *dev, size_t size,
309309
page = __dma_direct_alloc_pages(dev, size, gfp);
310310
if (!page)
311311
return NULL;
312+
if (PageHighMem(page)) {
313+
/*
314+
* Depending on the cma= arguments and per-arch setup
315+
* dma_alloc_contiguous could return highmem pages.
316+
* Without remapping there is no way to return them here,
317+
* so log an error and fail.
318+
*/
319+
dev_info(dev, "Rejecting highmem page from CMA.\n");
320+
goto out_free_pages;
321+
}
322+
312323
ret = page_address(page);
313324
if (force_dma_unencrypted(dev)) {
314325
if (set_memory_decrypted((unsigned long)ret,

0 commit comments

Comments
 (0)