Skip to content

Commit

Permalink
mpfs_mpu: Check that size is valid for MPUCFG
Browse files Browse the repository at this point in the history
The size must be power-of-two for NAPOT according to the the PMP spec.

Signed-off-by: Jani Paalijarvi <[email protected]>
  • Loading branch information
jpaali committed May 24, 2024
1 parent f41fc88 commit 9bee4db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/risc-v/src/mpfs/mpfs_mpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ int mpfs_mpu_set(uintptr_t reg, uintptr_t perm, uintptr_t base,
return -EACCES;
}

/* Base must be word aligned, minimum size is 4K */
/* Base must be word aligned,
* minimum size is 4K and it has to be power-of-two */

Check failure on line 163 in arch/risc-v/src/mpfs/mpfs_mpu.c

View workflow job for this annotation

GitHub Actions / check

Block comment terminator must be on a separate line

if ((base & 0x07) != 0 || size < 0x1000)
if ((base & 0x07) != 0 || size < 0x1000 || (size & (size - 1)) != 0)
{
return -EINVAL;
}
Expand Down

0 comments on commit 9bee4db

Please sign in to comment.