[PATCH v3 21/23] riscv: add ELF segment-based memory protection with MMU
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jan 12 05:43:27 PST 2026
On 1/8/26 4:50 PM, Sascha Hauer wrote:
> ret = elf_open_binary_into(&elf, (void *)barebox_base);
> - if (ret) {
> - pr_err("Failed to open ELF binary: %d\n", ret);
> - hang();
> - }
> + if (ret)
> + panic("Failed to open ELF binary: %d\n", ret);
>
> ret = elf_load_inplace(&elf);
> - if (ret) {
> - pr_err("Failed to relocate ELF: %d\n", ret);
> - hang();
> - }
> + if (ret)
> + panic("Failed to relocate ELF: %d\n", ret);
> +
> + pr_debug("ELF entry point: 0x%llx\n", elf.entry);
Squashed into the wrong commit.
>
> /*
> - * TODO: Add pbl_mmu_setup_from_elf() call when RISC-V PBL
> - * MMU support is implemented, similar to ARM
> + * Now that the ELF image is relocated, we know the exact addresses
> + * of all segments. Set up MMU with proper permissions based on
> + * ELF segment flags (PF_R/W/X).
> */
> + if (IS_ENABLED(CONFIG_MMU)) {
When we have stubs in the header, the IS_ENABLED can be omitted and
pbl_mmu_setup_from_elf() can be called unconditionally.
Cheers,
Ahmad
--
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