Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH v2] cma: check for memory region overlapping
@ 2023-07-25 14:16 Binglei Wang
  2023-07-25 16:19 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Binglei Wang @ 2023-07-25 14:16 UTC (permalink / raw)
  To: hch; +Cc: m.szyprowski, robin.murphy, iommu, linux-kernel, l3b2w1

From: l3b2w1 <l3b2w1@gmail.com>

Add a overlapping check in the program flow of paring dts.
Check if cma area overlaps with memblock-reserved areas
(kenrel code area for example)before calling 
early_init_fdt_scan_reserved_mem.

Signed-off-by: l3b2w1 <l3b2w1@gmail.com>
---

Notes:
    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..20ebbcefd 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.39.0


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

end of thread, other threads:[~2023-07-25 21:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-25 14:16 [PATCH v2] cma: check for memory region overlapping Binglei Wang
2023-07-25 16:19 ` kernel test robot
2023-07-25 17:21 ` kernel test robot
2023-07-25 21:30 ` kernel test robot

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