[PATCH 4/4] ARM: pbl: MMU: Make it callable multiple times
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Feb 23 00:41:23 PST 2026
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 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++;
>
>
--
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 |
More information about the barebox
mailing list