From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 4/4] ARM: pbl: MMU: Make it callable multiple times
Date: Mon, 23 Feb 2026 10:10:45 +0100 [thread overview]
Message-ID: <aZwZleKy56aDEBRl@pengutronix.de> (raw)
In-Reply-To: <d12e0757-a610-47fe-b99d-bbb8e2aaa4de@pengutronix.de>
On Mon, Feb 23, 2026 at 09:41:23AM +0100, Ahmad Fatoum wrote:
> Hello Sascha,
>
> On 2/23/26 9:34 AM, Sascha Hauer wrote:
> > 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.
>
> How about making setup_c() safe for calling multiple times by having it
> check and modify a variable in the .data section?
Good idea.
>
> Would that break anything?
I don't know. We might have code that relies on exactly the current
behaviour, but I am not aware of any.
Sascha
>
> Cheers,
> Ahmad
>
> >
> > 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++;
> >
> >
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2026-02-23 9:11 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 ` [PATCH 4/4] ARM: pbl: MMU: Make it callable multiple times Sascha Hauer
2026-02-23 8:41 ` Ahmad Fatoum
2026-02-23 9:10 ` Sascha Hauer [this message]
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=aZwZleKy56aDEBRl@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=a.fatoum@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