mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: akpm@osdl.org, torvalds@osdl.org
Cc: anton@samba.org, linux-kernel@vger.kernel.org,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Subject: [PATCH] ppc64: kprobes: handle trap variants while processing probes
Date: Mon, 7 Mar 2005 20:52:04 +1100	[thread overview]
Message-ID: <16940.9284.79566.526069@cargo.ozlabs.ibm.com> (raw)

This patch is from Ananth N Mavinakayanahalli <ananth@in.ibm.com>.

While processing a kprobe, we were currently not handling all available 
trap variants available on PowerPC. This lead to the breakage of BUG()
handling in ppc64.

Signed-off-by: Paul Mackerras <paulus@samba.org>

diff -Naurp temp/linux-2.6.11-rc3/arch/ppc64/kernel/kprobes.c linux-2.6.11-rc3/arch/ppc64/kernel/kprobes.c
--- temp/linux-2.6.11-rc3/arch/ppc64/kernel/kprobes.c	2005-02-03 07:26:53.000000000 +0530
+++ linux-2.6.11-rc3/arch/ppc64/kernel/kprobes.c	2005-02-10 18:08:25.000000000 +0530
@@ -105,8 +105,16 @@ static inline int kprobe_handler(struct 
 	p = get_kprobe(addr);
 	if (!p) {
 		unlock_kprobes();
-#if 0
 		if (*addr != BREAKPOINT_INSTRUCTION) {
+			/* 
+			 * PowerPC has multiple variants of the "trap"
+			 * instruction. If the current instruction is a
+			 * trap variant, it could belong to someone else
+			 */
+			kprobe_opcode_t cur_insn = *addr;
+			if (IS_TW(cur_insn) || IS_TD(cur_insn) || 
+					IS_TWI(cur_insn) || IS_TDI(cur_insn))
+		       		goto no_kprobe;
 			/*
 			 * The breakpoint instruction was removed right
 			 * after we hit it.  Another cpu has removed
@@ -116,7 +124,6 @@ static inline int kprobe_handler(struct 
 			 */
 			ret = 1;
 		}
-#endif
 		/* Not one of ours: let kernel handle it */
 		goto no_kprobe;
 	}
diff -Naurp temp/linux-2.6.11-rc3/include/asm-ppc64/kprobes.h linux-2.6.11-rc3/include/asm-ppc64/kprobes.h
--- temp/linux-2.6.11-rc3/include/asm-ppc64/kprobes.h	2005-02-03 07:25:50.000000000 +0530
+++ linux-2.6.11-rc3/include/asm-ppc64/kprobes.h	2005-02-10 18:08:58.000000000 +0530
@@ -35,6 +35,11 @@ typedef unsigned int kprobe_opcode_t;
 #define BREAKPOINT_INSTRUCTION	0x7fe00008	/* trap */
 #define MAX_INSN_SIZE 1
 
+#define IS_TW(instr)		(((instr) & 0xfc0007fe) == 0x7c000008)
+#define IS_TD(instr)		(((instr) & 0xfc0007fe) == 0x7c000088)
+#define IS_TDI(instr)		(((instr) & 0xfc000000) == 0x08000000)
+#define IS_TWI(instr)		(((instr) & 0xfc000000) == 0x0c000000)
+
 #define JPROBE_ENTRY(pentry)	(kprobe_opcode_t *)((func_descr_t *)pentry)
 
 /* Architecture specific copy of original instruction */

                 reply	other threads:[~2005-03-07  9:51 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=16940.9284.79566.526069@cargo.ozlabs.ibm.com \
    --to=paulus@samba.org \
    --cc=akpm@osdl.org \
    --cc=ananth@in.ibm.com \
    --cc=anton@samba.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /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®