diff options
author | Alistair Francis <alistair.francis@wdc.com> | 2020-01-31 17:02:28 -0800 |
---|---|---|
committer | Palmer Dabbelt <palmerdabbelt@google.com> | 2020-02-27 13:45:41 -0800 |
commit | 9d0d11269671646be7475cc01142e9d3ed8ae59c (patch) | |
tree | 1698a50f1091168b673149feb4803472967b3a55 | |
parent | eccc5a12c2fd1c646c69a1e7de29183b7a559973 (diff) | |
download | qemu-9d0d11269671646be7475cc01142e9d3ed8ae59c.zip |
target/riscv: Generate illegal instruction on WFI when V=1
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
-rw-r--r-- | target/riscv/op_helper.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/target/riscv/op_helper.c b/target/riscv/op_helper.c index e87c9115bc..455eb28907 100644 --- a/target/riscv/op_helper.c +++ b/target/riscv/op_helper.c @@ -130,9 +130,10 @@ void helper_wfi(CPURISCVState *env) { CPUState *cs = env_cpu(env); - if (env->priv == PRV_S && + if ((env->priv == PRV_S && env->priv_ver >= PRIV_VERSION_1_10_0 && - get_field(env->mstatus, MSTATUS_TW)) { + get_field(env->mstatus, MSTATUS_TW)) || + riscv_cpu_virt_enabled(env)) { riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC()); } else { cs->halted = 1; |