mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH 4/4] ARM: pbl: MMU: Make it callable multiple times
Date: Mon, 23 Feb 2026 09:41:23 +0100	[thread overview]
Message-ID: <d12e0757-a610-47fe-b99d-bbb8e2aaa4de@pengutronix.de> (raw)
In-Reply-To: <20260223-arm-mmu-v1-4-707d45f6f6e1@pengutronix.de>

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?

Would that break anything?

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 |




  reply	other threads:[~2026-02-23  8:41 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 [this message]
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=d12e0757-a610-47fe-b99d-bbb8e2aaa4de@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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