summaryrefslogtreecommitdiff
path: root/kernel/dma/direct.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-09-26 17:39:36 +0300
committerChristoph Hellwig <hch@lst.de>2020-10-07 12:03:21 +0300
commit08a89c28304ae74e4c7422f784359e41a37e3e7c (patch)
treeb72d56991b23def1c1dc7fca97f409aee738f837 /kernel/dma/direct.c
parent9f4df96b8781e40d0cb0e32eb3d1f6d87375adf9 (diff)
downloadlinux-08a89c28304ae74e4c7422f784359e41a37e3e7c.tar.xz
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 <hch@lst.de>
Diffstat (limited to 'kernel/dma/direct.c')
-rw-r--r--kernel/dma/direct.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index bf9f77623022..f5ecadd4e1c1 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -309,6 +309,17 @@ struct page *dma_direct_alloc_pages(struct device *dev, size_t size,
page = __dma_direct_alloc_pages(dev, size, gfp);
if (!page)
return NULL;
+ if (PageHighMem(page)) {
+ /*
+ * Depending on the cma= arguments and per-arch setup
+ * dma_alloc_contiguous could return highmem pages.
+ * Without remapping there is no way to return them here,
+ * so log an error and fail.
+ */
+ dev_info(dev, "Rejecting highmem page from CMA.\n");
+ goto out_free_pages;
+ }
+
ret = page_address(page);
if (force_dma_unencrypted(dev)) {
if (set_memory_decrypted((unsigned long)ret,