mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] cma: check for memory region overlapping
@ 2023-07-26 14:28 Binglei Wang
  2023-07-31 16:02 ` Christoph Hellwig
  2023-09-07 12:57 ` Robin Murphy
  0 siblings, 2 replies; 4+ messages in thread
From: Binglei Wang @ 2023-07-26 14:28 UTC (permalink / raw)
  To: hch, m.szyprowski, robin.murphy; +Cc: iommu, linux-kernel, l3b2w1

From: Binglei Wang <l3b2w1@gmail.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@gmail.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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-09-11  3:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-26 14:28 [PATCH v3] cma: check for memory region overlapping Binglei Wang
2023-07-31 16:02 ` Christoph Hellwig
2023-09-07 12:57 ` Robin Murphy
2023-09-11  3:43   ` binglei wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®