The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: linuxppc64-dev@ozlabs.org, akpm@osdl.org, davem@davemloft.net,
	prasanna@in.ibm.com, suparna@in.ibm.com
Subject: [PATCH] Kprobes: wrapper to define jprobe.entry
Date: Thu, 18 Nov 2004 15:56:41 +0530	[thread overview]
Message-ID: <20041118102641.GB8830@in.ibm.com> (raw)

Hi,

Here is a patch that adds a wrapper for defining jprobe.entry to make
it easy to handle the three dword function descriptors defined by the
PowerPC ELF ABI.

Current patch against 2.6.10-rc2-mm1 + kprobes patch for ppc64.

Changes for adding this wrapper for x86, ppc64 (tested) and x86_64 
(untested) below. The earlier method of defining jprobe.entry will
continue to work.

Here is a pseudocode snippet to use jprobes with this patch.

............
struct jprobe jp;
                                                                                
jtcp_v4_rcv(struct skbuff *skb)
{
        /* decode and log skb related details as required */
                                                                                
        jprobe_return();
        return 0;
}
                                                                                
init_module
{
        jp.kp.addr = (kprobe_opcode_t *)<addr of tcp_v4_rcv>;
        jp.entry = JPROBE_ENTRY(jtcp_v4_rcv);
        register_jprobe(&jp);
        return 0;
}
                                                                                
cleanup_module
{
        unregister_jprobe(&jp);
}
............

Dave,

I am not aware of the semantics for sparc64 for making this change.

Thanks,
Ananth

Signed-off-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>

diff -Naurp temp/linux-2.6.10-rc2/include/asm-i386/kprobes.h linux-2.6.10-rc2/include/asm-i386/kprobes.h
--- temp/linux-2.6.10-rc2/include/asm-i386/kprobes.h	2004-11-15 06:57:53.000000000 +0530
+++ linux-2.6.10-rc2/include/asm-i386/kprobes.h	2004-11-18 12:28:03.873952360 +0530
@@ -38,6 +38,8 @@ typedef u8 kprobe_opcode_t;
 	? (MAX_STACK_SIZE) \
 	: (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
 
+#define JPROBE_ENTRY(pentry)	(kprobe_opcode_t *)pentry
+
 /* Architecture specific copy of original instruction*/
 struct arch_specific_insn {
 	/* copy of the original instruction */
diff -Naurp temp/linux-2.6.10-rc2/include/asm-ppc64/kprobes.h linux-2.6.10-rc2/include/asm-ppc64/kprobes.h
--- temp/linux-2.6.10-rc2/include/asm-ppc64/kprobes.h	2004-11-18 12:26:43.236962848 +0530
+++ linux-2.6.10-rc2/include/asm-ppc64/kprobes.h	2004-11-18 12:28:03.875952056 +0530
@@ -35,6 +35,8 @@ typedef unsigned int kprobe_opcode_t;
 #define BREAKPOINT_INSTRUCTION	0x7fe00008	/* trap */
 #define MAX_INSN_SIZE 1
 
+#define JPROBE_ENTRY(pentry)	(kprobe_opcode_t *)((func_descr_t *)pentry)
+
 /* Architecture specific copy of original instruction */
 struct arch_specific_insn {
 	/* copy of original instruction */
diff -Naurp temp/linux-2.6.10-rc2/include/asm-x86_64/kprobes.h linux-2.6.10-rc2/include/asm-x86_64/kprobes.h
--- temp/linux-2.6.10-rc2/include/asm-x86_64/kprobes.h	2004-11-15 06:56:41.000000000 +0530
+++ linux-2.6.10-rc2/include/asm-x86_64/kprobes.h	2004-11-18 12:28:03.877951752 +0530
@@ -37,6 +37,8 @@ typedef u8 kprobe_opcode_t;
 	? (MAX_STACK_SIZE) \
 	: (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
 
+#define JPROBE_ENTRY(pentry)	(kprobe_opcode_t *)pentry
+
 /* Architecture specific copy of original instruction*/
 struct arch_specific_insn {
 	/* copy of the original instruction */

             reply	other threads:[~2004-11-18 10:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-18 10:26 Ananth N Mavinakayanahalli [this message]
2004-11-18 22:47 ` [PATCH] Kprobes: wrapper to define jprobe.entry Andrew Morton
2004-11-18 22:43   ` David S. Miller
2004-11-19  6:52   ` Ananth N Mavinakayanahalli
2004-11-19  7:05     ` Andrew Morton
2004-11-19  9:03       ` Ananth N Mavinakayanahalli

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=20041118102641.GB8830@in.ibm.com \
    --to=ananth@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc64-dev@ozlabs.org \
    --cc=prasanna@in.ibm.com \
    --cc=suparna@in.ibm.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