qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target/riscv: Disallow WFI instruction from U-mode
@ 2019-07-03 19:07 Jonathan Behrens
  2019-07-03 22:28 ` Alistair Francis
  2019-07-04  2:37 ` no-reply
  0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Behrens @ 2019-07-03 19:07 UTC (permalink / raw)
  To: qemu-devel
  Cc: open list:RISC-V TCG CPUs, Sagar Karandikar, Jonathan Behrens,
	Palmer Dabbelt, Alistair Francis, Bastian Koppelmann

Signed-off-by: Jonathan Behrens <jonathan@fintelia.io>
---
 target/riscv/op_helper.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c
index 331cc36232..2e5a980192 100644
--- a/target/riscv/op_helper.c
+++ b/target/riscv/op_helper.c
@@ -129,10 +129,10 @@ target_ulong helper_mret(CPURISCVState *env, target_ulong cpu_pc_deb)
 void helper_wfi(CPURISCVState *env)
 {
     CPUState *cs = env_cpu(env);
-
-    if (env->priv == PRV_S &&
-        env->priv_ver >= PRIV_VERSION_1_10_0 &&
-        get_field(env->mstatus, MSTATUS_TW)) {
+    if (!(env->priv >= PRV_S) ||
+        (env->priv == PRV_S &&
+         env->priv_ver >= PRIV_VERSION_1_10_0 &&
+         get_field(env->mstatus, MSTATUS_TW))) {
         riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC());
     } else {
         cs->halted = 1;
-- 
2.22.0


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

end of thread, other threads:[~2020-01-21 22:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-03 19:07 [Qemu-devel] [PATCH] target/riscv: Disallow WFI instruction from U-mode Jonathan Behrens
2019-07-03 22:28 ` Alistair Francis
2019-07-04  2:37 ` no-reply
2020-01-21 13:20   ` Jonathan Behrens
2020-01-21 22:24     ` 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).