Commit 1d2b8fc
committed
arch/riscv: Defer locking of interrupt stack guard PMP entry
The PMP entry for the interrupt stack guard is initially configured in
`z_riscv_pmp_init()`. This entry was previously locked immediately using
the `PMP_L` (Lock) flag.
This immediate locking causes issues in complex boot scenarios, such as
systems that jump from a Read-Only (RO) image to a Read-Write (RW) image.
When switching images, the kernel must re-initialize PMP. If the
interrupt stack address, calculated as `(uintptr_t)z_interrupt_stacks[_current_cpu->id]`,
changes between the RO and RW stages, the already-locked PMP entry for the
original address cannot be reconfigured, leading to an incorrect or
inoperable memory protection setup.
This commit removes the premature `PMP_L` flag from the PMP entry setup
in `z_riscv_pmp_init()`.
The essential locking of the interrupt stack guard will now be deferred
and correctly applied within `z_riscv_pmp_stackguard_enable()`, which is
executed only when the system is ready and the conditions
`defined(CONFIG_PMP_STACK_GUARD) && defined(CONFIG_MULTITHREADING)` are met.
Signed-off-by: Firas Sammoura <[email protected]>1 parent b8576db commit 1d2b8fc
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| |||
0 commit comments