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>
master
Alistair Francis 2020-01-31 17:02:28 -08:00 committed by Palmer Dabbelt
parent eccc5a12c2
commit 9d0d112696
No known key found for this signature in database
GPG Key ID: 2E1319F35FBB1889
1 changed files with 3 additions and 2 deletions

View 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;