From: Zephyr Li <[email protected]> The Sstc predicate currently checks both ext_sstc and rdtime_fn. This causes the gdbstub CSR XML generation to skip Sstc CSRs when rdtime_fn has not been initialized yet, even if the CPU supports Sstc.
As a result, GDB reports $stimecmp as void with a CPU that exposes the sstc extension. Only use ext_sstc for the early existence check, and keep the rdtime_fn check for non-debugger accesses. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3496 Signed-off-by: Zephyr Li <[email protected]> Reviewed-by: Alistair Francis <[email protected]> Reviewed-by: Chao Liu <[email protected]> Message-ID: <[email protected]> Signed-off-by: Alistair Francis <[email protected]> --- target/riscv/csr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d004a4bfb4..2e81221b1d 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -590,7 +590,7 @@ static RISCVException sstc(CPURISCVState *env, int csrno) { bool hmode_check = false; - if (!riscv_cpu_cfg(env)->ext_sstc || !env->rdtime_fn) { + if (!riscv_cpu_cfg(env)->ext_sstc) { return RISCV_EXCP_ILLEGAL_INST; } @@ -607,6 +607,10 @@ static RISCVException sstc(CPURISCVState *env, int csrno) return RISCV_EXCP_NONE; } + if (!env->rdtime_fn) { + return RISCV_EXCP_ILLEGAL_INST; + } + if (env->priv == PRV_M) { return RISCV_EXCP_NONE; } -- 2.54.0
