All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prasanna S Panchamukhi <prasanna@in.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: torvalds@osdl.org, Andrew Morton <akpm@osdl.org>,
	ak@muc.de, suparna@in.ibm.com,
	dprobes@www-124.southbury.usf.ibm.com
Subject: Re: [3/3] PATCH Kprobes for x86_64- 2.6.9-final
Date: Thu, 28 Oct 2004 17:08:45 +0530	[thread overview]
Message-ID: <20041028113845.GC5812@in.ibm.com> (raw)
In-Reply-To: <20041028113558.GB5812@in.ibm.com>

[3/3] kprobes-arch-sparc64-changes.patch


Minor changes required to port kprobes for x86_64.

Signed-off-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>



---

 linux-2.6.9-final-prasanna/arch/sparc64/kernel/kprobes.c |   28 ++++++++++-----
 linux-2.6.9-final-prasanna/include/asm-sparc64/kprobes.h |    6 +++
 2 files changed, 25 insertions(+), 9 deletions(-)

diff -puN arch/sparc64/kernel/kprobes.c~kprobes-arch-sparc64-changes arch/sparc64/kernel/kprobes.c
--- linux-2.6.9-final/arch/sparc64/kernel/kprobes.c~kprobes-arch-sparc64-changes	2004-10-28 16:47:08.000000000 +0530
+++ linux-2.6.9-final-prasanna/arch/sparc64/kernel/kprobes.c	2004-10-28 16:47:08.000000000 +0530
@@ -15,7 +15,7 @@
  * traps.  The top-level scheme is similar to that used
  * in the x86 kprobes implementation.
  *
- * In the kprobe->insn[] array we store the original
+ * At kprobe->insn we allocate enough bytes and then store the original
  * instruction at index zero and a break instruction at
  * index one.
  *
@@ -38,10 +38,20 @@
  * - Mark that we are no longer actively in a kprobe.
  */
 
-void arch_prepare_kprobe(struct kprobe *p)
+int arch_prepare_kprobe(struct kprobe *p)
+{
+	p->ainsn.insn = (kprobe_opcode_t *) kmalloc(MAX_INSN_SIZE, GFP_ATOMIC);
+	if (!p->ainsn.insn) {
+		return -ENOMEM;
+	}
+
+	p->ainsn.insn[0] = *p->addr;
+	p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2;
+	return 0;
+}
+
+void arch_remove_kprobe(struct kprobe *p)
 {
-	p->insn[0] = *p->addr;
-	p->insn[1] = BREAKPOINT_INSTRUCTION_2;
 }
 
 /* kprobe_status settings */
@@ -59,8 +69,8 @@ static inline void prepare_singlestep(st
 	current_kprobe_orig_tstate_pil = (regs->tstate & TSTATE_PIL);
 	regs->tstate |= TSTATE_PIL;
 
-	regs->tpc = (unsigned long) &p->insn[0];
-	regs->tnpc = (unsigned long) &p->insn[1];
+	regs->tpc = (unsigned long) &p->ainsn.insn[0];
+	regs->tnpc = (unsigned long) &p->ainsn.insn[1];
 }
 
 static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
@@ -199,19 +209,19 @@ static void retpc_fixup(struct pt_regs *
  * instruction.  To avoid the SMP problems that can occur when we
  * temporarily put back the original opcode to single-step, we
  * single-stepped a copy of the instruction.  The address of this
- * copy is p->insn.
+ * copy is p->ainsn.insn.
  *
  * This function prepares to return from the post-single-step
  * breakpoint trap.
  */
 static void resume_execution(struct kprobe *p, struct pt_regs *regs)
 {
-	u32 insn = p->insn[0];
+	u32 insn = p->ainsn.insn[0];
 
 	regs->tpc = current_kprobe_orig_tnpc;
 	regs->tnpc = relbranch_fixup(insn,
 				     (unsigned long) p->addr,
-				     (unsigned long) &p->insn[0],
+				     (unsigned long) &p->ainsn.insn[0],
 				     regs->tnpc);
 	retpc_fixup(regs, insn, (unsigned long) p->addr);
 
diff -puN include/asm-sparc64/kprobes.h~kprobes-arch-sparc64-changes include/asm-sparc64/kprobes.h
--- linux-2.6.9-final/include/asm-sparc64/kprobes.h~kprobes-arch-sparc64-changes	2004-10-28 16:47:08.000000000 +0530
+++ linux-2.6.9-final-prasanna/include/asm-sparc64/kprobes.h	2004-10-28 16:47:08.000000000 +0530
@@ -10,6 +10,12 @@ typedef u32 kprobe_opcode_t;
 #define BREAKPOINT_INSTRUCTION_2 0x91d02071 /* ta 0x71 */
 #define MAX_INSN_SIZE 2
 
+/* Architecture specific copy of original instruction*/
+struct arch_specific_insn {
+	/* copy of the original instruction */
+	kprobe_opcode_t insn[MAX_INSN_SIZE];
+};
+
 #ifdef CONFIG_KPROBES
 extern int kprobe_exceptions_notify(struct notifier_block *self,
 				    unsigned long val, void *data);

_
-- 

Prasanna S Panchamukhi
Linux Technology Center
India Software Labs, IBM Bangalore
Ph: 91-80-25044636
<prasanna@in.ibm.com>

  reply	other threads:[~2004-10-28 11:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-28 11:32 [0/3] PATCH Kprobes for x86_64- 2.6.9-final Prasanna S Panchamukhi
2004-10-28 11:34 ` [1/3] " Prasanna S Panchamukhi
2004-10-28 11:35   ` [2/3] " Prasanna S Panchamukhi
2004-10-28 11:38     ` Prasanna S Panchamukhi [this message]
2004-10-30 21:06       ` [patch 3/3] kprobes : Minor changes for sparc64 Prasanna S Panchamukhi
2004-10-30 21:03     ` [patch 2/3] kprobes : kprobes ported to x86_64 Prasanna S Panchamukhi
2004-10-30 20:59   ` [patch 1/3] kprobes: Minor i386 changes required for porting kprobes " Prasanna S Panchamukhi
2004-10-28 11:37 ` [0/3] PATCH Kprobes for x86_64- 2.6.9-final Andi Kleen
2004-10-28 15:53   ` Prasanna S Panchamukhi
2004-10-28 23:42     ` Andi Kleen
2004-10-28 18:15   ` David S. Miller
2004-10-28 23:41     ` Andi Kleen

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=20041028113845.GC5812@in.ibm.com \
    --to=prasanna@in.ibm.com \
    --cc=ak@muc.de \
    --cc=akpm@osdl.org \
    --cc=dprobes@www-124.southbury.usf.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suparna@in.ibm.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.