* [PATCH master 1/2] ARM: document PBL barebox memory layout
@ 2024-05-17 6:10 Ahmad Fatoum
2024-05-17 6:10 ` [PATCH master 2/2] ARM: fix overlap between ramoops area and early malloc area Ahmad Fatoum
2024-05-21 7:13 ` [PATCH master 1/2] ARM: document PBL barebox memory layout Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-05-17 6:10 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
Apparently, we have an overlap between ramoops/barebox proper
and the early malloc area. Before fixing that, let's add a diagram
explaining the current state of affairs.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/include/asm/barebox-arm.h | 36 ++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 4d70360b9121..30834233fb96 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -52,6 +52,42 @@ static inline void arm_fixup_vectors(void)
void *barebox_arm_boot_dtb(void);
+/*
+ * ----------------------------- endmem ------------------------------
+ * ↑
+ * OPTEE_SIZE (depends on CONFIG_OPTEE_SIZE)
+ * ↓
+ * ------------------------- arm_mem_optee() -------------------------
+ * ↑
+ * SZ_32K
+ * ↓
+ * ------------------------ arm_mem_scratch() ------------------------
+ * ↑
+ * STACK_SIZE
+ * ↓
+ * ------------------------- arm_mem_stack() -------------------------
+ * ↑
+ * PAGE_SIZE (depends on CONFIG_STACK_GUARD_PAGE)
+ * ↓
+ * ----------------------- arm_mem_guard_page() ----------------------
+ * ↑
+ * ARM_EARLY_PAGETABLE_SIZE
+ * ↓
+ * ------------ arm_mem_ttb() / arm_mem_early_malloc_end() ------------
+ * ↑ ↑
+ * CONFIG_FS_PSTORE_RAMOOPS_SIZE SZ_128K
+ * (depends on FS_PSTORE_RAMOOPS) |
+ * | ↓
+ * | ------ arm_mem_early_malloc() ---
+ * ↓
+ * ------------------------- arm_mem_ramoops() ------------------------
+ * ↑
+ * (barebox uncompressed image size
+ * + BSS) rounded to SZ_1M
+ * ↓
+ * ---------------------- arm_mem_barebox_image() ---------------------
+ */
+
static inline unsigned long arm_mem_optee(unsigned long endmem)
{
return endmem - OPTEE_SIZE;
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH master 2/2] ARM: fix overlap between ramoops area and early malloc area
2024-05-17 6:10 [PATCH master 1/2] ARM: document PBL barebox memory layout Ahmad Fatoum
@ 2024-05-17 6:10 ` Ahmad Fatoum
2024-05-21 7:13 ` [PATCH master 1/2] ARM: document PBL barebox memory layout Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-05-17 6:10 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
ramoops is usually a few megabytes and the early malloc area is just
128K, so the effect of this overlap was likely limited, but depending on
size of the data stored to pstore, this could still lead to problems.
Avoid this by locating the early malloc area before the barebox binary.
That way that space is reclaimed in barebox proper for the non-early
malloc region.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
arch/arm/cpu/uncompress.c | 4 ++--
arch/arm/include/asm/barebox-arm.h | 24 +++++++++---------------
2 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index aa1a49bfc96a..612a5b65ff4c 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -66,8 +66,8 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
if (IS_ENABLED(CONFIG_MMU))
mmu_early_enable(membase, memsize);
- free_mem_ptr = arm_mem_early_malloc(endmem);
- free_mem_end_ptr = arm_mem_early_malloc_end(endmem);
+ free_mem_ptr = barebox_base - ARM_MEM_EARLY_MALLOC_SIZE;
+ free_mem_end_ptr = barebox_base;
pr_debug("uncompressing barebox binary at 0x%p (size 0x%08x) to 0x%08lx (uncompressed size: 0x%08x)\n",
pg_start, pg_len, barebox_base, uncompressed_len);
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 30834233fb96..c64e74f8f03a 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -73,12 +73,10 @@ void *barebox_arm_boot_dtb(void);
* ↑
* ARM_EARLY_PAGETABLE_SIZE
* ↓
- * ------------ arm_mem_ttb() / arm_mem_early_malloc_end() ------------
- * ↑ ↑
- * CONFIG_FS_PSTORE_RAMOOPS_SIZE SZ_128K
- * (depends on FS_PSTORE_RAMOOPS) |
- * | ↓
- * | ------ arm_mem_early_malloc() ---
+ * --------------------------- arm_mem_ttb() -------------------------
+ * ↑
+ * CONFIG_FS_PSTORE_RAMOOPS_SIZE
+ * (depends on FS_PSTORE_RAMOOPS)
* ↓
* ------------------------- arm_mem_ramoops() ------------------------
* ↑
@@ -86,6 +84,10 @@ void *barebox_arm_boot_dtb(void);
* + BSS) rounded to SZ_1M
* ↓
* ---------------------- arm_mem_barebox_image() ---------------------
+ * ↑
+ * SZ_128K
+ * ↓
+ * ------------------------ arm_mem_early_malloc ----------------------
*/
static inline unsigned long arm_mem_optee(unsigned long endmem)
@@ -121,15 +123,7 @@ static inline unsigned long arm_mem_ttb(unsigned long endmem)
return endmem;
}
-static inline unsigned long arm_mem_early_malloc(unsigned long endmem)
-{
- return arm_mem_ttb(endmem) - SZ_128K;
-}
-
-static inline unsigned long arm_mem_early_malloc_end(unsigned long endmem)
-{
- return arm_mem_ttb(endmem);
-}
+#define ARM_MEM_EARLY_MALLOC_SIZE SZ_128K
static inline unsigned long arm_mem_ramoops(unsigned long endmem)
{
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH master 1/2] ARM: document PBL barebox memory layout
2024-05-17 6:10 [PATCH master 1/2] ARM: document PBL barebox memory layout Ahmad Fatoum
2024-05-17 6:10 ` [PATCH master 2/2] ARM: fix overlap between ramoops area and early malloc area Ahmad Fatoum
@ 2024-05-21 7:13 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-05-21 7:13 UTC (permalink / raw)
To: barebox, Ahmad Fatoum
On Fri, 17 May 2024 08:10:56 +0200, Ahmad Fatoum wrote:
> Apparently, we have an overlap between ramoops/barebox proper
> and the early malloc area. Before fixing that, let's add a diagram
> explaining the current state of affairs.
>
>
Applied, thanks!
[1/2] ARM: document PBL barebox memory layout
https://git.pengutronix.de/cgit/barebox/commit/?id=c9af0d2b5e57 (link may not be stable)
[2/2] ARM: fix overlap between ramoops area and early malloc area
https://git.pengutronix.de/cgit/barebox/commit/?id=d1cc8a4045a0 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-21 7:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-17 6:10 [PATCH master 1/2] ARM: document PBL barebox memory layout Ahmad Fatoum
2024-05-17 6:10 ` [PATCH master 2/2] ARM: fix overlap between ramoops area and early malloc area Ahmad Fatoum
2024-05-21 7:13 ` [PATCH master 1/2] ARM: document PBL barebox memory layout Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox