target/riscv: mask inactive senvcfg.SSE on read
PATCH 1/1 target/riscv: mask inactive senvcfg.SSE on read
The CFI rules make senvcfg.SSE read as zero when menvcfg.SSE is clear. In VU mode it also reads as zero when henvcfg.SSE is clear. Mask the readback to match those rules.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4224
Signed-off-by wangyang <[email protected]>
--- target/riscv/tcg/csr.c | 8 ++++++++ 1 file changed, 8 insertions(+)
target/riscv/tcg/csr.c +8 -0
@@ -3322,6 +3322,14 @@ static RISCVException read_senvcfg(CPURISCVState *env, int csrno, } *val = env->senvcfg; + +if (env_archcpu (env)->cfg.ext_zicfiss) { +if (!(env->menvcfg &MENVCFG_SSE ) || + (env->virt_enabled && !(env->henvcfg &HENVCFG_SSE ))) { + *val &= ~SENVCFG_SSE ; + } + } +return RISCV_EXCP_NONE ; }
Signature · 1 line
2.43.0
Quoted 6 lines · wangyang
The CFI rules make senvcfg.SSE read as zero when menvcfg.SSE is clear.
In VU mode it also reads as zero when henvcfg.SSE is clear. Mask the readback to match those rules.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4224Signed-off-by wangyang <[email protected]>
Reviewed-by Alistair Francis <[email protected]>
Alistair
Quoted 24 lines
---
target/riscv/tcg/csr.c | 8 ++++++++1 file changed, 8 insertions(+)target/riscv/tcg/csr.c +0
-0@@ -3322,6 +3322,14 @@ static RISCVException read_senvcfg(CPURISCVState *env, int csrno, }
*val =env->senvcfg;target/riscv/tcg/csr.c +8
-0+ + if (env_archcpu(env)->cfg.ext_zicfiss) { + if (!(env->menvcfg & MENVCFG_SSE) || + (env->virt_enabled && !(env->henvcfg & HENVCFG_SSE))) { + *val &= ~SENVCFG_SSE; + } + } +return
RISCV_EXCP_NONE;
}