Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

riscv: kgdb: fix several debug register assignment bugs

Fix several bugs in the RISC-V kgdb implementation:

- The element of dbg_reg_def[] that is supposed to pertain to the S1
register embeds instead the struct pt_regs offset of the A1
register. Fix this to use the S1 register offset in struct pt_regs.

- The sleeping_thread_to_gdb_regs() function copies the value of the
S10 register into the gdb_regs[] array element meant for the S9
register, and copies the value of the S11 register into the array
element meant for the S10 register. It also neglects to copy the
value of the S11 register. Fix all of these issues.

Fixes: fe89bd2be8667 ("riscv: Add KGDB support")
Cc: Vincent Chen <vincent.chen@sifive.com>
Link: https://patch.msgid.link/fde376f8-bcfd-bfe4-e467-07d8f7608d05@kernel.org
Signed-off-by: Paul Walmsley <pjw@kernel.org>

+4 -3
+4 -3
arch/riscv/kernel/kgdb.c
··· 175 175 {DBG_REG_T1, GDB_SIZEOF_REG, offsetof(struct pt_regs, t1)}, 176 176 {DBG_REG_T2, GDB_SIZEOF_REG, offsetof(struct pt_regs, t2)}, 177 177 {DBG_REG_FP, GDB_SIZEOF_REG, offsetof(struct pt_regs, s0)}, 178 - {DBG_REG_S1, GDB_SIZEOF_REG, offsetof(struct pt_regs, a1)}, 178 + {DBG_REG_S1, GDB_SIZEOF_REG, offsetof(struct pt_regs, s1)}, 179 179 {DBG_REG_A0, GDB_SIZEOF_REG, offsetof(struct pt_regs, a0)}, 180 180 {DBG_REG_A1, GDB_SIZEOF_REG, offsetof(struct pt_regs, a1)}, 181 181 {DBG_REG_A2, GDB_SIZEOF_REG, offsetof(struct pt_regs, a2)}, ··· 244 244 gdb_regs[DBG_REG_S6_OFF] = task->thread.s[6]; 245 245 gdb_regs[DBG_REG_S7_OFF] = task->thread.s[7]; 246 246 gdb_regs[DBG_REG_S8_OFF] = task->thread.s[8]; 247 - gdb_regs[DBG_REG_S9_OFF] = task->thread.s[10]; 248 - gdb_regs[DBG_REG_S10_OFF] = task->thread.s[11]; 247 + gdb_regs[DBG_REG_S9_OFF] = task->thread.s[9]; 248 + gdb_regs[DBG_REG_S10_OFF] = task->thread.s[10]; 249 + gdb_regs[DBG_REG_S11_OFF] = task->thread.s[11]; 249 250 gdb_regs[DBG_REG_EPC_OFF] = task->thread.ra; 250 251 } 251 252