Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions arch/riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ config PMP_STACK_GUARD_MIN_SIZE
wiggle room to accommodate the eventual overflow exception
stack usage.

config ENABLE_DEFAULT_ROM_PMP
bool "Set static PMP entry for ROM region"
depends on RISCV_PMP
default n if MEM_ATTR
default y
help
Controls the static PMP entry for the ROM region. It is enabled by
default but automatically disabled when CONFIG_MEM_ATTR is set,
to allow the memory attributes subsystem to manage the PMP region.

# Implement the null pointer detection using the Physical Memory Protection
# (PMP) Unit.
config NULL_POINTER_EXCEPTION_DETECTION_PMP
Expand Down
2 changes: 2 additions & 0 deletions arch/riscv/core/pmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,13 @@ void z_riscv_pmp_init(void)
unsigned long pmp_cfg[CONFIG_PMP_SLOTS / PMPCFG_STRIDE];
unsigned int index = 0;

#ifdef CONFIG_ENABLE_DEFAULT_ROM_PMP
/* The read-only area is always there for every mode */
set_pmp_entry(&index, PMP_R | PMP_X | PMP_L,
(uintptr_t)__rom_region_start,
(size_t)__rom_region_size,
pmp_addr, pmp_cfg, ARRAY_SIZE(pmp_addr));
#endif /* CONFIG_ENABLE_DEFAULT_ROM_PMP */

#ifdef CONFIG_NULL_POINTER_EXCEPTION_DETECTION_PMP
/*
Expand Down