Skip to contentSkip to conversation

lmb: Reserve U-Boot separately if relocation is disabled

PATCH Superseded [email protected] 3 participants 3 messages Oct 15, 2021 – Oct 25, 2021 Library code

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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

---
 lib/lmb.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/lmb.c +5 -0
index 676b3a0bda..d868633899 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)_start, gd->mon_len);
+
 		break;
 	}
 }
Signature · 1 line
2.33.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 8 lines · On Fri, 15 Oct 2021 at 09:49, <[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.

Quoted 8 lines

---
V2: Make this fully generic

---
 lib/lmb.c | 5 +++++
 1 file changed, 5 insertions(+)
#2 lore raw
In reply to [email protected]
Quoted 30 lines · On Fri, Oct 15, 2021 at 05:48:56PM +0200, [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.

---
V2: Make this fully generic

---
 lib/lmb.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/lmb.c +1 -0
index 676b3a0bda..d868633899 100644
@@ -13,6 +13,7 @@
 #include <malloc.h>
 
 #include <asm/global_data.h>
+#include <asm/sections.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 

lib/lmb.c void arch_lmb_reserve_generic(struct lmb *lmb, ulong sp, ulong end, ulong align) · line 154

Quoted 10 lines
lib/lmb.c +4 -0
@@ -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)_start, gd->mon_len);
+
 		break;
 	}
 }

I now see:
sandbox: w+ sandbox
+ 150 | lmb_reserve(lmb, (phys_addr_t)_start, gd->mon_len);
+ | ^
w+lib/lmb.c: In function 'arch_lmb_reserve_generic':
w+lib/lmb.c:150:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

Signature · 1 line
Tom