[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230726142823.6356-1-l3b2w1@gmail.com>
Date: Wed, 26 Jul 2023 22:28:23 +0800
From: Binglei Wang <l3b2w1@...il.com>
To: hch@....de, m.szyprowski@...sung.com, robin.murphy@....com
Cc: iommu@...ts.linux.dev, linux-kernel@...r.kernel.org,
l3b2w1@...il.com
Subject: [PATCH v3] cma: check for memory region overlapping
From: Binglei Wang <l3b2w1@...il.com>
In the process of parsing the DTS, checks
whether the memory region specified by the DTS CMA node area
overlaps with the kernel text memory space reserved by memblock
before calling early_init_fdt_scan_reserved_mem.
Maybe it's better to have some warning prompts printed.
Signed-off-by: Binglei Wang <l3b2w1@...il.com>
---
Notes:
v3: fix compile error.
v2: delete the logic code for handling return -EBUSY.
v1: return -EBUSY when detect overlapping and handle the return case.
kernel/dma/contiguous.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 6ea80ae42..dc6d2af1e 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -410,6 +410,11 @@ static int __init rmem_cma_setup(struct reserved_mem *rmem)
return -EBUSY;
}
+ if (memblock_is_region_reserved(rmem->base, rmem->size)) {
+ pr_info("Reserved memory: overlap with other memblock reserved region\n");
+ return -EBUSY;
+ }
+
if (!of_get_flat_dt_prop(node, "reusable", NULL) ||
of_get_flat_dt_prop(node, "no-map", NULL))
return -EINVAL;
--
2.34.1
Powered by blists - more mailing lists