Hi,

On 1/14/26 1:14 PM, Sascha Hauer wrote:
> Move complete MMU setup into PBL by leveraging ELF segment information
> to apply correct memory permissions before jumping to barebox proper.
> 
> After ELF relocation, parse PT_LOAD segments and map each with
> permissions derived from p_flags:
> - Text segments (PF_R|PF_X): Read-only + executable (MAP_CODE)
> - Data segments (PF_R|PF_W): Read-write (MAP_CACHED)
> - RO data segments (PF_R): Read-only (MAP_CACHED_RO)
> 
> This ensures barebox proper starts with full W^X protection already
> in place, eliminating the need for complex remapping in barebox proper.
> 
> The framework is portable - common ELF parsing in pbl/mmu.c uses
> architecture-specific early_remap_range() exported from mmu_*.c.
> 
> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
> 
> Co-Authored-By: Claude Sonnet 4.5 <[email protected]>

I think the Co-authored-by: is important information, but the generated
line with its markdown looks a bit off IMO. Can we drop the first line?

> Signed-off-by: Sascha Hauer <[email protected]>

With above and below nitpicks fixed:

Reviewed-by: Ahmad Fatoum <[email protected]>

> -     if (region_overlap_end_exclusive(start, end, text_start, text_end)) {
> -             remap_range_end(start, text_start, MAP_CACHED);
> +     if (region_overlap_end_exclusive(start, end, image_start, image_end)) {
> +             remap_range_end(start, image_start, MAP_CACHED);
>               /* skip barebox segments here, will be mapped later */

skip barebox segments here, as PBL already mapped them

> +             /*
> +              * Remap this segment with proper permissions.
> +              * Use page-wise mapping to allow different permissions for
> +              * different segments even if they're nearby.

There's no page-wise mapping happening, but this is ok.

Cheers,
Ahmad

> +              */
> +             remap_range((void *)addr, size, mmu_flags);
> +     }
> +
> +     pr_debug("MMU setup from ELF complete\n");
> +     return 0;
> +}
> 

-- 
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 via email to