qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/riscv/pmp: fix no pmp illegal intrs
@ 2021-12-14  9:26 Nikita Shubin
  2021-12-14 21:12 ` Richard Henderson
  2021-12-21  6:34 ` Alistair Francis
  0 siblings, 2 replies; 7+ messages in thread
From: Nikita Shubin @ 2021-12-14  9:26 UTC (permalink / raw)
  Cc: qemu-riscv, Nikita Shubin, Bin Meng, qemu-devel, Alistair Francis,
	atishp, Palmer Dabbelt

From: Nikita Shubin <n.shubin@yadro.com>

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>
---
 target/riscv/op_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
index ee7c24efe7..58d992e98a 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());
     }
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-22 22:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-14  9:26 [PATCH] target/riscv/pmp: fix no pmp illegal intrs Nikita Shubin
2021-12-14 21:12 ` Richard Henderson
2021-12-14 21:13   ` Richard Henderson
2021-12-15  7:57     ` Nikita Shubin
2021-12-21  6:34 ` Alistair Francis
2021-12-21  7:13   ` Nikita Shubin
2021-12-22 22:15     ` Alistair Francis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).