From: Binglei Wang <l3b2w1@gmail.com>
To: hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, l3b2w1@gmail.com
Subject: [PATCH v3] cma: check for memory region overlapping
Date: Wed, 26 Jul 2023 22:28:23 +0800 [thread overview]
Message-ID: <20230726142823.6356-1-l3b2w1@gmail.com> (raw)
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
next reply other threads:[~2023-07-26 14:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 14:28 Binglei Wang [this message]
2023-07-31 16:02 ` [PATCH v3] cma: check for memory region overlapping Christoph Hellwig
2023-09-07 12:57 ` Robin Murphy
2023-09-11 3:43 ` binglei wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230726142823.6356-1-l3b2w1@gmail.com \
--to=l3b2w1@gmail.com \
--cc=hch@lst.de \
--cc=iommu@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=robin.murphy@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox