]> git.proxmox.com Git - mirror_qemu.git/commitdiff
target/riscv: Generate illegal instruction on WFI when V=1
authorAlistair Francis <alistair.francis@wdc.com>
Sat, 1 Feb 2020 01:02:28 +0000 (17:02 -0800)
committerPalmer Dabbelt <palmerdabbelt@google.com>
Thu, 27 Feb 2020 21:45:41 +0000 (13:45 -0800)
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Palmer Dabbelt <palmer@sifive.com>
Signed-off-by: Palmer Dabbelt <palmerdabbelt@google.com>
target/riscv/op_helper.c

index e87c9115bc2c2a016ea9430a691858858c11e201..455eb289072616b791b0267d045d46fd7030cd34 100644 (file)
@@ -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;