Skip to content

Conversation

fsammoura1980
Copy link
Contributor

@fsammoura1980 fsammoura1980 commented Oct 6, 2025

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.

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]>
Copy link

sonarqubecloud bot commented Oct 6, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Architectures area: RISCV RISCV Architecture (32-bit & 64-bit)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants