From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 4/4] ARM: pbl: MMU: Make it callable multiple times
Date: Mon, 23 Feb 2026 09:34:09 +0100 [thread overview]
Message-ID: <20260223-arm-mmu-v1-4-707d45f6f6e1@pengutronix.de> (raw)
In-Reply-To: <20260223-arm-mmu-v1-0-707d45f6f6e1@pengutronix.de>
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@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
next prev parent reply other threads:[~2026-02-23 8:35 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 8:34 [PATCH 0/4] ARM: MMU: Some cleanup after recent changes Sascha Hauer
2026-02-23 8:34 ` [PATCH 1/4] mmu: add MAP_CACHED_RWX mapping type Sascha Hauer
2026-02-23 8:34 ` [PATCH 2/4] ARM: MMU: drop forced pagewise mapping Sascha Hauer
2026-02-23 8:34 ` [PATCH 3/4] ARM: pbl: MMU: drop unnecessary barebox mapping Sascha Hauer
2026-02-23 8:34 ` Sascha Hauer [this message]
2026-02-23 8:41 ` [PATCH 4/4] ARM: pbl: MMU: Make it callable multiple times Ahmad Fatoum
2026-02-23 9:10 ` Sascha Hauer
2026-02-23 15:32 ` (subset) [PATCH 0/4] ARM: MMU: Some cleanup after recent changes Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260223-arm-mmu-v1-4-707d45f6f6e1@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox