aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Shubin <n.shubin@yadro.com>2021-12-14 12:26:59 +0300
committerAlistair Francis <alistair.francis@wdc.com>2022-01-08 15:46:09 +1000
commit0fbb5d2d3c9ded9fbd3f6f993974cc5e88e28912 (patch)
tree62eab2af9a09fa7c68666bf586c2f95b4babd0e8
parentd70075373af51b6aa1d637962c962120e201fc98 (diff)
downloadqemu-0fbb5d2d3c9ded9fbd3f6f993974cc5e88e28912.zip
qemu-0fbb5d2d3c9ded9fbd3f6f993974cc5e88e28912.tar.gz
qemu-0fbb5d2d3c9ded9fbd3f6f993974cc5e88e28912.tar.bz2
target/riscv/pmp: fix no pmp illegal intrs
As per the privilege specification, any access from S/U mode should fail if no pmp region is configured and pmp is present, othwerwise access should succeed. Fixes: d102f19a208 (target/riscv/pmp: Raise exception if no PMP entry is configured) Signed-off-by: Nikita Shubin <n.shubin@yadro.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-id: 20211214092659.15709-1-nikita.shubin@maquefel.me Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
-rw-r--r--target/riscv/op_helper.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
index ee7c24e..58d992e 100644
--- a/target/riscv/op_helper.c
+++ b/target/riscv/op_helper.c
@@ -146,7 +146,8 @@ target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb)
uint64_t mstatus = env->mstatus;
target_ulong prev_priv = get_field(mstatus, MSTATUS_MPP);
- if (!pmp_get_num_rules(env) && (prev_priv != PRV_M)) {
+ if (riscv_feature(env, RISCV_FEATURE_PMP) &&
+ !pmp_get_num_rules(env) && (prev_priv != PRV_M)) {
riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC());
}