From: Weiwei Li Date: Wed, 24 May 2023 01:59:33 +0000 (+0800) Subject: target/riscv: Update cur_pmmask/base when xl changes X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=30a0d77622d105908e7d45cf34c73f781263ede5;p=qemu.git target/riscv: Update cur_pmmask/base when xl changes write_mstatus() can only change current xl when in debug mode. And we need update cur_pmmask/base in this case. Signed-off-by: Weiwei Li Signed-off-by: Junqiang Wang Reviewed-by: LIU Zhiwei Message-Id: <20230524015933.17349-3-liweiwei@iscas.ac.cn> Signed-off-by: Alistair Francis --- diff --git a/target/riscv/csr.c b/target/riscv/csr.c index cf7da4f87f..ad73691878 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -1324,8 +1324,15 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, mstatus = set_field(mstatus, MSTATUS64_SXL, xl); } env->mstatus = mstatus; - env->xl = cpu_recompute_xl(env); + /* + * Except in debug mode, UXL/SXL can only be modified by higher + * privilege mode. So xl will not be changed in normal mode. + */ + if (env->debugger) { + env->xl = cpu_recompute_xl(env); + riscv_cpu_update_mask(env); + } return RISCV_EXCP_NONE; }