[PATCH 2/2] arm64: lmb: Reserve U-Boot separately if relocation is disabled

marek.vasut at gmail.com marek.vasut at gmail.com
Sun Oct 10 23:52:09 CEST 2021


From: Marek Vasut <marek.vasut+renesas at gmail.com>

In case U-Boot starts with GD_FLG_SKIP_RELOC, the U-Boot code is
not relocated, however the stack and heap is at the end of DRAM
after relocation. Reserve a LMB area for the non-relocated U-Boot
code so it won't be overwritten.

Signed-off-by: Marek Vasut <marek.vasut+renesas at gmail.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
---
 arch/arm/lib/stack.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/lib/stack.c b/arch/arm/lib/stack.c
index 656084c7e5..d2e2715ecf 100644
--- a/arch/arm/lib/stack.c
+++ b/arch/arm/lib/stack.c
@@ -14,6 +14,7 @@
 #include <init.h>
 #include <lmb.h>
 #include <asm/global_data.h>
+#include <asm/sections.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -46,4 +47,12 @@ static ulong get_sp(void)
 void arch_lmb_reserve(struct lmb *lmb)
 {
 	arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 16384);
+
+#ifdef CONFIG_ARM
+		if (gd->flags & GD_FLG_SKIP_RELOC) {
+			lmb_reserve(lmb, (phys_addr_t)__image_copy_start,
+				    (phys_addr_t)__image_copy_end -
+				    (phys_addr_t)__image_copy_start);
+		}
+#endif
 }
-- 
2.33.0



More information about the U-Boot mailing list