Skip to contentSkip to conversation

lmb: Reserve U-Boot separately if relocation is disabled

PATCH In review [email protected] 2 participants 2 messages Nov 13, 2021 – Nov 18, 2021 Library code

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 lmb: Reserve U-Boot separately if relocation is disabled

From: Marek Vasut <[email protected]>

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.

---
V2: Make this fully generic
V3: Cast _start to uintptr_t first

---
 lib/lmb.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/lmb.c +5 -0
index 676b3a0bda..f72996a424 100644
@@ -13,6 +13,7 @@
 #include <malloc.h>
 
 #include <asm/global_data.h>
+#include <asm/sections.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -144,6 +145,10 @@ void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align)
 			bank_end = end - 1;
 
 		lmb_reserve(lmb, sp, bank_end - sp + 1);
+
+		if (gd->flags & GD_FLG_SKIP_RELOC)
+			lmb_reserve(lmb, (phys_addr_t)(uintptr_t)_start, gd->mon_len);
+
 		break;
 	}
 }
Signature · 1 line
2.33.0
#1 lore raw
Quoted 10 lines · On Sat, Nov 13, 2021 at 06:34:37PM +0100, [email protected] wrote:

From: Marek Vasut <[email protected]>

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.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom