Skip to content

Commit b0e7362

Browse files
committed
arch: riscv: Use CONFIG_PMP_SLOTS for M-mode stack guard arrays
The arrays `m_mode_pmpaddr_regs` and `m_mode_pmpcfg_regs` within the `_thread_arch` struct, used for the M-mode stack guard (when CONFIG_PMP_STACK_GUARD is enabled), were previously sized using the hardcoded PMP_M_MODE_SLOTS macro (defined as 8). This commit changes the array sizing to use the Kconfig option CONFIG_PMP_SLOTS. This option reflects the total number of Physical Memory Protection (PMP) slots available and configured for the target hardware. Using CONFIG_PMP_SLOTS ensures these arrays are dimensioned according to the system's actual capabilities, providing better flexibility and correctness over a fixed size. Signed-off-by: Firas Sammoura <[email protected]>
1 parent 6bb4cb5 commit b0e7362

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/zephyr/arch/riscv/thread.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ struct _thread_arch {
8181
#endif
8282
#ifdef CONFIG_PMP_STACK_GUARD
8383
unsigned int m_mode_pmp_end_index;
84-
unsigned long m_mode_pmpaddr_regs[PMP_M_MODE_SLOTS];
85-
unsigned long m_mode_pmpcfg_regs[PMP_M_MODE_SLOTS / sizeof(unsigned long)];
84+
unsigned long m_mode_pmpaddr_regs[CONFIG_PMP_SLOTS];
85+
unsigned long m_mode_pmpcfg_regs[CONFIG_PMP_SLOTS / sizeof(unsigned long)];
8686
#endif
8787
};
8888

0 commit comments

Comments
 (0)