Skip to content

Commit 53449af

Browse files
committed
arch: riscv: Allow skipping default ROM PMP entry
The `z_riscv_pmp_init` function currently includes a standard PMP entry to mark the ROM region (`__rom_region_start` to `__rom_region_size`) as read-only and executable (PMP_R | PMP_X | PMP_L). This change wraps the setup of this default ROM PMP entry with `#ifndef CONFIG_CUSTOM_PMP_ENTRY`. If `CONFIG_CUSTOM_PMP_ENTRY` is set, this default ROM entry configuration is skipped. This allows projects, SoCs, or board configurations to provide a completely custom PMP layout starting from the first entry from the device tree based on `zephyr,memattr`, which might be necessary for specialized memory protection schemes or to override the default ROM region attributes. Signed-off-by: Firas Sammoura <[email protected]>
1 parent 7219bdd commit 53449af

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/riscv/core/pmp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,16 @@ void z_riscv_pmp_init(void)
373373
}
374374
#endif
375375

376+
#ifndef CONFIG_CUSTOM_PMP_ENTRY
377+
376378
/* The read-only area is always there for every mode */
377379
set_pmp_entry(&index, PMP_R | PMP_X | PMP_L,
378380
(uintptr_t)__rom_region_start,
379381
(size_t)__rom_region_size,
380382
pmp_addr, pmp_cfg, ARRAY_SIZE(pmp_addr));
381383

384+
#endif
385+
382386
#ifdef CONFIG_NULL_POINTER_EXCEPTION_DETECTION_PMP
383387
/*
384388
* Use a PMP slot to make region (starting at address 0x0) inaccessible

0 commit comments

Comments
 (0)