You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
riscv: pmp: Add support for custom user-defined PMP entry
This commit introduces configuration and infrastructure to reserve a
dedicated Physical Memory Protection (PMP) slot for a custom memory
region.
This feature is designed for applications requiring **runtime control of
memory permissions** for critical areas, such as firmware rollback
segments or sensitive configuration data. This control is established
early in the boot process and allows the system to **temporarily modify
the privileges granted to the ROM flash** or other protected regions as
necessary during execution.
The new Kconfig options allow the user to define:
- **CONFIG_CUSTOM_PMP_ENTRY_START**: Base address of the protected
region.
- **CONFIG_CUSTOM_PMP_ENTRY_SIZE**: Size of the protected region.
- **CONFIG_CUSTOM_PMP_ENTRY_PERMISSIONS**: R/W/X access permissions for
the slot.
The custom PMP entry is configured in `z_riscv_pmp_init()` and
purposefully placed before the locked read-only ROM protection entry to
ensure early enforcement.
The necessary context switch logic (`z_riscv_custom_pmp_entry_enable`)
is added to `switch.S` and `pmp.c` to handle the required MPRV/MPP
register configuration when the custom entry is enabled and the PMP
stack guard is disabled.
Signed-off-by: Firas Sammoura <[email protected]>
0 commit comments