Skip to content

Commit 5a2ae23

Browse files
LIU Zhiweialistair23
authored andcommitted
target/riscv: Set default XLEN for hypervisor
When swap regs for hypervisor, the value of vsstatus or mstatus_hs should have the right XLEN. Otherwise, it will propagate to mstatus. Signed-off-by: LIU Zhiwei <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Message-id: [email protected] Signed-off-by: Alistair Francis <[email protected]>
1 parent d8c40c2 commit 5a2ae23

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

target/riscv/cpu.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,16 @@ static void riscv_cpu_reset(DeviceState *dev)
422422
*/
423423
env->mstatus = set_field(env->mstatus, MSTATUS64_SXL, env->misa_mxl);
424424
env->mstatus = set_field(env->mstatus, MSTATUS64_UXL, env->misa_mxl);
425+
if (riscv_has_ext(env, RVH)) {
426+
env->vsstatus = set_field(env->vsstatus,
427+
MSTATUS64_SXL, env->misa_mxl);
428+
env->vsstatus = set_field(env->vsstatus,
429+
MSTATUS64_UXL, env->misa_mxl);
430+
env->mstatus_hs = set_field(env->mstatus_hs,
431+
MSTATUS64_SXL, env->misa_mxl);
432+
env->mstatus_hs = set_field(env->mstatus_hs,
433+
MSTATUS64_UXL, env->misa_mxl);
434+
}
425435
}
426436
env->mcause = 0;
427437
env->pc = env->resetvec;

0 commit comments

Comments
 (0)