sh/kprobes: respect gdb breakpoints
PATCH 1/1 sh/kprobes: respect gdb breakpoints
On the sh architecture, kprobes and gdb/gdbserver use different breakpoint opcodes. Without this fix, kprobes doesn't recognize the gdb traps, and the resulting NOTIFY_STOP prevents ptrace and gdb from being notified. The result is that if kprobes is configured, a gdb-traced process hangs when its gdb breakpoint is hit.
Signed-off-by Jim Keniston <[email protected]>
Signed-off-by Reza Arbab <[email protected]>
Reported-by Vijay Kumar <[email protected]>
Tested-by Vijay Kumar <[email protected]>
--- arch/sh/include/asm/kprobes.h | 2 ++ arch/sh/kernel/kprobes.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletions(-)
arch/sh/include/asm/kprobes.h +2 -0
@@ -8,6 +8,8 @@typedef insn_size_t kprobe_opcode_t ;#define BREAKPOINT_INSTRUCTION 0xc33a +#define GDB_BREAKPOINT_INSTRUCTION 0xc3c3 +#define GDBSERVER_BREAKPOINT_INSTRUCTION 0xc320#define MAX_INSN_SIZE 16#define MAX_STACK_SIZE 64
arch/sh/kernel/kprobes.c +4 -1
@@ -260,7 +260,10 @@ static int __kprobes kprobe_handler(struct pt_regs *regs) p =get_kprobe (addr);if (!p) {/* Not one of ours: let kernel handle it */ -if (*(kprobe_opcode_t *)addr !=BREAKPOINT_INSTRUCTION ) { +kprobe_opcode_t opcode = *(kprobe_opcode_t *)addr; +if (opcode !=BREAKPOINT_INSTRUCTION && + opcode !=GDB_BREAKPOINT_INSTRUCTION && + opcode !=GDBSERVER_BREAKPOINT_INSTRUCTION ) {/* * The breakpoint instruction was removed right * after we hit it. Another cpu has removed