[PATCH 4/4] ARM: pbl: MMU: Make it callable multiple times
Sascha Hauer
s.hauer at pengutronix.de
Mon Feb 23 00:34:09 PST 2026
mmu_early_enable() is called in barebox_pbl_start() after a call to
setup_c(). setup_c() clears the BSS which means alloc_pte() starts at
index zero again when mmu_early_enable() has been called earlier
already.
Some boards might want to do exactly that: Call mmu_early_enable()
earlier to do for example otherwise expensive hashing of xloaded
binaries.
Make mmu_early_enable() safe to be called multiple times by moving the
PTE index out of the BSS.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/arm/cpu/mmu_64.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index 7f38473079..2f451b3c91 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -86,7 +86,10 @@ static void set_pte_range(unsigned level, uint64_t *virt, phys_addr_t phys,
#ifdef __PBL__
static uint64_t *alloc_pte(void)
{
- static unsigned int idx;
+ static int idx = -1;
+
+ if (idx == -1)
+ idx = 0;
idx++;
--
2.47.3
More information about the barebox
mailing list