From: Jim Keniston <jkenisto@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: Ananth Narayan <ananth@in.ibm.com>,
Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
abab@linux.vnet.ibm.com, vkumar14@lenovo.com
Subject: [PATCH] sh/kprobes: respect gdb breakpoints
Date: Fri, 07 Aug 2015 09:04:35 -0700 [thread overview]
Message-ID: <1438963475.4896.7.camel@oc1026406570.ibm.com> (raw)
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 <jkenisto@linux.vnet.ibm.com>
Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com>
Reported-by: Vijay Kumar <vkumar14@lenovo.com>
Tested-by: Vijay Kumar <vkumar14@lenovo.com>
---
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
reply other threads:[~2015-08-07 16:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438963475.4896.7.camel@oc1026406570.ibm.com \
--to=jkenisto@linux.vnet.ibm.com \
--cc=abab@linux.vnet.ibm.com \
--cc=ananth@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masami.hiramatsu.pt@hitachi.com \
--cc=vkumar14@lenovo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®