According to the Zicfilp specification the bit SPELP in the mstatus register should be 0 (read-only) when s-mode is not present.
changes in v2: - Change to patch series - Now tooling can close the issue in Gitlab properly Link to v1: https://lore.kernel.org/qemu-riscv/[email protected]/ Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4456 Signed-off-by: Christian S. Lima <[email protected]> --- target/riscv/tcg/csr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target/riscv/tcg/csr.c b/target/riscv/tcg/csr.c index 398e312c9a..9d0378bc69 100644 --- a/target/riscv/tcg/csr.c +++ b/target/riscv/tcg/csr.c @@ -2131,7 +2131,10 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, /* If cfi lp extension is available, then apply cfi lp mask */ if (env_archcpu(env)->cfg.ext_zicfilp) { - mask |= (MSTATUS_MPELP | MSTATUS_SPELP); + mask |= MSTATUS_MPELP; + if (riscv_has_ext(env, RVS)) { + mask |= MSTATUS_SPELP; + } } mstatus = (mstatus & ~mask) | (val & mask); -- 2.56.0
