Skip to content

Conversation

fsammoura1980
Copy link
Contributor

Replace sizeof(unsigned long) with PMPCFG_STRIDE (defined as __riscv_xlen / 8) for dimensioning PMP configuration register arrays (pmpcfg_regs).

The size of PMP configuration registers should be derived directly from the target architecture's XLEN. Using sizeof(unsigned long) can cause size mismatches, particularly with static analysis tools like SonarQube. These tools might assume a host-specific size for unsigned long, leading to spurious out-of-bounds access warnings when analyzing code for different RISCV base architectures (e.g., RV32 vs. RV64).

This change ensures the array sizing is correctly and consistently tied to the target's register width (XLEN).

Replace `sizeof(unsigned long)` with `PMPCFG_STRIDE` (defined as
`__riscv_xlen / 8`) for dimensioning PMP configuration register arrays
(`pmpcfg_regs`).

The size of PMP configuration registers should be derived directly from
the target architecture's XLEN. Using `sizeof(unsigned long)` can cause
size mismatches, particularly with static analysis tools like SonarQube.
These tools might assume a host-specific size for `unsigned long`,
leading to spurious out-of-bounds access warnings when analyzing code
for different RISCV base architectures (e.g., RV32 vs. RV64).

This change ensures the array sizing is correctly and consistently tied
to the target's register width (XLEN).

Signed-off-by: Firas Sammoura <[email protected]>
Copy link

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.

6 participants