Skip to content

Commit

Permalink
target/riscv/pmp.c: respect mseccfg.RLB for pmpaddrX changes
Browse files Browse the repository at this point in the history
When the rule-lock bypass (RLB) bit is set in the mseccfg CSR, the PMP
configuration lock bits must not apply. While this behavior is
implemented for the pmpcfgX CSRs, this bit is not respected for
changes to the pmpaddrX CSRs. This patch ensures that pmpaddrX CSR
writes work even on locked regions when the global rule-lock bypass is
enabled.

Signed-off-by: Leon Schuermann <leons@opentitan.org>
Reviewed-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20230829215046.1430463-1-leon@is.currently.online>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
  • Loading branch information
Leon Schuermann authored and alistair23 committed Sep 11, 2023
1 parent a7c272d commit 4e3adce
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions target/riscv/pmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ static inline uint8_t pmp_get_a_field(uint8_t cfg)
*/
static inline int pmp_is_locked(CPURISCVState *env, uint32_t pmp_index)
{
/* mseccfg.RLB is set */
if (MSECCFG_RLB_ISSET(env)) {
return 0;
}

if (env->pmp_state.pmp[pmp_index].cfg_reg & PMP_LOCK) {
return 1;
Expand Down

0 comments on commit 4e3adce

Please sign in to comment.