aboutsummaryrefslogtreecommitdiff
path: root/target/riscv/cpu_helper.c
diff options
context:
space:
mode:
authorAlistair Francis <alistair.francis@wdc.com>2020-08-12 12:13:33 -0700
committerAlistair Francis <alistair.francis@wdc.com>2020-08-25 09:11:36 -0700
commitf2d5850f71f3e41b240f328c2bc844a4e44e66c9 (patch)
treec49500326419626349b45118db5549324af8f7db /target/riscv/cpu_helper.c
parent84b1c04bbaf48798a535b38410a0bf839f4a1943 (diff)
target/riscv: Update the Hypervisor trap return/entry
Signed-off-by: Alistair Francis <alistair.francis@wdc.com> Message-id: e7e4e801234f2934306e734f65860f601a5745bd.1597259519.git.alistair.francis@wdc.com Message-Id: <e7e4e801234f2934306e734f65860f601a5745bd.1597259519.git.alistair.francis@wdc.com>
Diffstat (limited to 'target/riscv/cpu_helper.c')
-rw-r--r--target/riscv/cpu_helper.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index 661e790fdc..dc7ae3e7b1 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -929,9 +929,7 @@ void riscv_cpu_do_interrupt(CPUState *cs)
} else if (riscv_cpu_virt_enabled(env)) {
/* Trap into HS mode, from virt */
riscv_cpu_swap_hypervisor_regs(env);
- env->hstatus = set_field(env->hstatus, HSTATUS_SP2V,
- get_field(env->hstatus, HSTATUS_SPV));
- env->hstatus = set_field(env->hstatus, HSTATUS_SP2P,
+ env->hstatus = set_field(env->hstatus, HSTATUS_SPVP,
get_field(env->mstatus, SSTATUS_SPP));
env->hstatus = set_field(env->hstatus, HSTATUS_SPV,
riscv_cpu_virt_enabled(env));
@@ -942,13 +940,11 @@ void riscv_cpu_do_interrupt(CPUState *cs)
riscv_cpu_set_force_hs_excep(env, 0);
} else {
/* Trap into HS mode */
- env->hstatus = set_field(env->hstatus, HSTATUS_SP2V,
- get_field(env->hstatus, HSTATUS_SPV));
- env->hstatus = set_field(env->hstatus, HSTATUS_SP2P,
- get_field(env->mstatus, SSTATUS_SPP));
- env->hstatus = set_field(env->hstatus, HSTATUS_SPV,
- riscv_cpu_virt_enabled(env));
-
+ if (!riscv_cpu_two_stage_lookup(env)) {
+ env->hstatus = set_field(env->hstatus, HSTATUS_SPV,
+ riscv_cpu_virt_enabled(env));
+ }
+ riscv_cpu_set_two_stage_lookup(env, false);
htval = env->guest_phys_fault_addr;
}
}