Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932447AbbHGQEn (ORCPT ); Fri, 7 Aug 2015 12:04:43 -0400 Received: from e19.ny.us.ibm.com ([129.33.205.209]:34798 "EHLO e19.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932143AbbHGQEm (ORCPT ); Fri, 7 Aug 2015 12:04:42 -0400 X-Helo: d01dlp01.pok.ibm.com X-MailFrom: jkenisto@linux.vnet.ibm.com X-RcptTo: linux-kernel@vger.kernel.org Subject: [PATCH] sh/kprobes: respect gdb breakpoints From: Jim Keniston To: linux-kernel@vger.kernel.org Cc: Ananth Narayan , Masami Hiramatsu , abab@linux.vnet.ibm.com, vkumar14@lenovo.com Content-Type: text/plain; charset="UTF-8" Date: Fri, 07 Aug 2015 09:04:35 -0700 Message-ID: <1438963475.4896.7.camel@oc1026406570.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.32.3 (2.32.3-34.el6) Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15080716-0057-0000-0000-000000FDBB5E Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2013 Lines: 50 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 Signed-off-by: Reza Arbab Reported-by: Vijay Kumar Tested-by: Vijay Kumar --- arch/sh/include/asm/kprobes.h | 2 ++ arch/sh/kernel/kprobes.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletions(-) diff --git a/arch/sh/include/asm/kprobes.h b/arch/sh/include/asm/kprobes.h index 134f398..f22a3cb 100644 --- a/arch/sh/include/asm/kprobes.h +++ b/arch/sh/include/asm/kprobes.h @@ -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 diff --git a/arch/sh/kernel/kprobes.c b/arch/sh/kernel/kprobes.c index 83acbf3..bcaa072 100644 --- a/arch/sh/kernel/kprobes.c +++ b/arch/sh/kernel/kprobes.c @@ -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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/