diff mbox series

fdt: lmb: add reserved regions as no-overwrite

Message ID 20241021172433.637950-1-sughosh.ganu@linaro.org
State Accepted
Commit 827dee587b75f5dfe109672f2de91bc7ac8bdc0d
Headers show
Series fdt: lmb: add reserved regions as no-overwrite | expand

Commit Message

Sughosh Ganu Oct. 21, 2024, 5:24 p.m. UTC
The boot_fdt_add_mem_rsv_regions() function reserves the memreserve and
reserved-memory regions. These regions are being set with the LMB_NONE
flag which allows overwriting and re-using the regions. This was fine
earlier when the LMB memory map was local and not enforced
globally. But that is no longer the case. Mark these regions as
LMB_NOOVERWRITE so that they cannot be used.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
---
 boot/image-fdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Tom Rini Oct. 29, 2024, 10:28 p.m. UTC | #1
On Mon, 21 Oct 2024 22:54:33 +0530, Sughosh Ganu wrote:

> The boot_fdt_add_mem_rsv_regions() function reserves the memreserve and
> reserved-memory regions. These regions are being set with the LMB_NONE
> flag which allows overwriting and re-using the regions. This was fine
> earlier when the LMB memory map was local and not enforced
> globally. But that is no longer the case. Mark these regions as
> LMB_NOOVERWRITE so that they cannot be used.
> 
> [...]

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index 8eda521693d..9a1fa8840d7 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -110,7 +110,7 @@  void boot_fdt_add_mem_rsv_regions(void *fdt_blob)
 	for (i = 0; i < total; i++) {
 		if (fdt_get_mem_rsv(fdt_blob, i, &addr, &size) != 0)
 			continue;
-		boot_fdt_reserve_region(addr, size, LMB_NONE);
+		boot_fdt_reserve_region(addr, size, LMB_NOOVERWRITE);
 	}
 
 	/* process reserved-memory */
@@ -122,7 +122,7 @@  void boot_fdt_add_mem_rsv_regions(void *fdt_blob)
 			ret = fdt_get_resource(fdt_blob, subnode, "reg", 0,
 					       &res);
 			if (!ret && fdtdec_get_is_enabled(fdt_blob, subnode)) {
-				flags = LMB_NONE;
+				flags = LMB_NOOVERWRITE;
 				if (fdtdec_get_bool(fdt_blob, subnode,
 						    "no-map"))
 					flags = LMB_NOMAP;