riscv_pmp.c: Check that size is power of two for NAPOT
The size must be power-of-two according to the the PMP spec. Signed-off-by: Jani Paalijarvi <jani.paalijarvi@unikie.com>
This commit is contained in:
parent
b3513c0811
commit
9d4bd915eb
@ -134,9 +134,9 @@ static bool pmp_check_region_attrs(uintptr_t base, uintptr_t size,
|
||||
|
||||
case PMPCFG_A_NAPOT:
|
||||
{
|
||||
/* For NAPOT, both base and size must be properly aligned */
|
||||
/* For NAPOT, Naturally aligned power-of-two region, >= 8 bytes */
|
||||
|
||||
if ((base & 0x07) != 0 || size < 8)
|
||||
if ((base & 0x07) != 0 || size < 8 || (size & (size - 1)) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user