Hi,

On 18/5/26 09:07, Jay Chang wrote:
When configuring pmpcfg (TOR, NA4, or NAPOT) and pmpaddr, if the
value is smaller than the PMP granularity, it needs to be aligned
to the PMP granularity.

Signed-off-by: Jay Chang <[email protected]>
Reviewed-by: Frank Chang <[email protected]>
Reviewed-by: Daniel Henrique Barboza <[email protected]>
---
  target/riscv/pmp.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)


@@ -263,6 +264,11 @@ void pmp_update_rule_addr(CPURISCVState *env, uint32_t 
pmp_index)
          break;
case PMP_AMATCH_NAPOT:
+        /* Bits [g-2:0] need to be all one to align pmp granularity */
+        if (g >= 2) {
+            this_addr |= ((1ULL << (g - 1ULL)) - 1ULL);

deposit64() could be easier to read here.

+        }
+
          pmp_decode_napot(this_addr, &sa, &ea);
          break;


Reply via email to