From: Binglei Wang <l3b2w1@gmail.com>
To: hch@lst.de
Cc: m.szyprowski@samsung.com, robin.murphy@arm.com,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
l3b2w1@gmail.com
Subject: [PATCH v2] cma: check for memory region overlapping
Date: Tue, 25 Jul 2023 22:16:02 +0800 [thread overview]
Message-ID: <20230725141602.7759-1-l3b2w1@gmail.com> (raw)
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
next reply other threads:[~2023-07-25 14:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-25 14:16 Binglei Wang [this message]
2023-07-25 16:19 ` [PATCH v2] cma: check for memory region overlapping kernel test robot
2023-07-25 17:21 ` kernel test robot
2023-07-25 21:30 ` kernel test robot
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=20230725141602.7759-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;
as well as URLs for NNTP newsgroup(s).