This is an automated email from Gerrit. "Jan Matyas <[email protected]>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9723
-- gerrit commit cb1c25363fc68bee15bc92796dd5e0bbd2e080ed Author: Jan Matyas <[email protected]> Date: Fri May 29 13:39:18 2026 +0200 target/riscv: Mark dscratch* registers as non-cacheable Dscratch* CSRs should be marked as non-cacheable because their value is not guaranteed to remain intact between abstract commands. See [1]. [1] https://docs.riscv.org/reference/debug/debug_module.html#dm-hartinfo Change-Id: If051be5e9e3d831d8ec5f1103b644fc904b800a5 Signed-off-by: Jan Matyas <[email protected]> diff --git a/src/target/riscv/gdb_regs.h b/src/target/riscv/gdb_regs.h index 0d0392912e..79c24367f4 100644 --- a/src/target/riscv/gdb_regs.h +++ b/src/target/riscv/gdb_regs.h @@ -99,6 +99,7 @@ enum gdb_regno { GDB_REGNO_DPC = CSR_DPC + GDB_REGNO_CSR0, GDB_REGNO_DCSR = CSR_DCSR + GDB_REGNO_CSR0, GDB_REGNO_DSCRATCH0 = CSR_DSCRATCH0 + GDB_REGNO_CSR0, + GDB_REGNO_DSCRATCH1 = CSR_DSCRATCH1 + GDB_REGNO_CSR0, GDB_REGNO_MSTATUS = CSR_MSTATUS + GDB_REGNO_CSR0, GDB_REGNO_MEPC = CSR_MEPC + GDB_REGNO_CSR0, GDB_REGNO_MCAUSE = CSR_MCAUSE + GDB_REGNO_CSR0, diff --git a/src/target/riscv/riscv_reg_impl.h b/src/target/riscv/riscv_reg_impl.h index 17e66935be..2cf4e6ad59 100644 --- a/src/target/riscv/riscv_reg_impl.h +++ b/src/target/riscv/riscv_reg_impl.h @@ -203,7 +203,6 @@ static inline bool riscv_reg_impl_gdb_regno_cacheable(enum gdb_regno regno, case GDB_REGNO_VTYPE: case GDB_REGNO_MISA: case GDB_REGNO_DCSR: - case GDB_REGNO_DSCRATCH0: case GDB_REGNO_MEPC: case GDB_REGNO_SATP: /* @@ -215,6 +214,8 @@ static inline bool riscv_reg_impl_gdb_regno_cacheable(enum gdb_regno regno, case GDB_REGNO_TSELECT: /* I think this should be above, but then it doesn't work. */ case GDB_REGNO_TDATA1: /* Changes value when tselect is changed. */ case GDB_REGNO_TDATA2: /* Changes value when tselect is changed. */ + case GDB_REGNO_DSCRATCH0: /* Dscratch* need not retain value between abstract commands. */ + case GDB_REGNO_DSCRATCH1: default: return false; } --
