target/riscv: Do not hide Sstc CSRs from gdbstub
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 <fritchleybohrer@gmail.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Reviewed-by: Chao Liu <chao.liu.zevorn@gmail.com> Message-ID: <20260525024220.39027-1-fritchleybohrer@gmail.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Zephyr Li committed
May 25, 2026 at 10:42 UTC
0f0426551db20de5ea72ba70c216ccfafe056df8
1 file changed
+5
-1
target/riscv/csr.c
+5
-1
@@ -590,7 +590,7 @@ static RISCVException sstc(CPURISCVState *env, int csrno)
590
{
591
bool hmode_check = false;
592
593
- if (!riscv_cpu_cfg(env)->ext_sstc || !env->rdtime_fn) {
593
+ if (!riscv_cpu_cfg(env)->ext_sstc) {
594
return RISCV_EXCP_ILLEGAL_INST;
595
}
596
@@ -607,6 +607,10 @@ static RISCVException sstc(CPURISCVState *env, int csrno)
607
return RISCV_EXCP_NONE;
608
}
609
610
+ if (!env->rdtime_fn) {
611
+ return RISCV_EXCP_ILLEGAL_INST;
612
+ }
613
+
614
if (env->priv == PRV_M) {
615
return RISCV_EXCP_NONE;
616
}