Skip to contentSkip to conversation

Kprobes: wrapper to define jprobe.entry

PATCH In review Ananth N Mavinakayanahalli 3 participants 6 messages Nov 18, 2004 – Nov 19, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Kprobes: wrapper to define jprobe.entry

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

include/asm-i386/kprobes.h renamed from linux-2.6.10-rc2/include/asm-i386/kprobes.h +2 -0
diff -Naurp temp/linux-2.6.10-rc2/include/asm-i386/kprobes.h linux-2.6.10-rc2/include/asm-i386/kprobes.h
@@ -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 */
include/asm-ppc64/kprobes.h renamed from linux-2.6.10-rc2/include/asm-ppc64/kprobes.h +2 -0
diff -Naurp temp/linux-2.6.10-rc2/include/asm-ppc64/kprobes.h linux-2.6.10-rc2/include/asm-ppc64/kprobes.h
@@ -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 */
include/asm-x86_64/kprobes.h renamed from linux-2.6.10-rc2/include/asm-x86_64/kprobes.h +2 -0
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
@@ -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 */
#1 lore raw
Quoted 6 lines · Ananth N Mavinakayanahalli

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.

I don't have the kprobes-for-ppc64 patch here.

Quoted 3 lines

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.

So what should I do with this? I'm inclined to drop it until the x86_64 part has been tested and Dave has had a go at the sparc64 version.

#2 lore raw
Quoted 7 lines · On Thu, 18 Nov 2004 14:47:46 -0800 Andrew Morton <[email protected]> wrote:
Quoted 3 lines · Ananth N Mavinakayanahalli

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.

So what should I do with this? I'm inclined to drop it until the x86_64 part has been tested and Dave has had a go at the sparc64 version.

Yes, now that we have kprobe support on 4 platforms, it is important that anyone who changes public parts of this interface do the necessary per-platform fixups necessary to coincide with such changes.

I think the person changing the data type should be the one fixing up sparc64 :-)

#3 lore raw
In reply to Andrew Morton
Quoted 1 line · Andrew Morton

Ananth N Mavinakayanahalli <[email protected]> wrote:

Hi Andrew,

Quoted 7 lines
Quoted 6 lines

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.

Quoted 8 lines

I don't have the kprobes-for-ppc64 patch here.

Quoted 3 lines

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.

So what should I do with this? I'm inclined to drop it until the x86_64 part has been tested and Dave has had a go at the sparc64 version.

I have now tested the patch succesfully on x86_64 and updated it for sparc64 too (Dave says the change looks good).

Please apply.

Thanks,
Ananth

include/asm-i386/kprobes.h renamed from linux-2.6.10-rc2/include/asm-i386/kprobes.h +2 -0
diff -Naurp temp/linux-2.6.10-rc2/include/asm-i386/kprobes.h linux-2.6.10-rc2/include/asm-i386/kprobes.h
@@ -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 */
include/asm-ppc64/kprobes.h renamed from linux-2.6.10-rc2/include/asm-ppc64/kprobes.h +2 -0
diff -Naurp temp/linux-2.6.10-rc2/include/asm-ppc64/kprobes.h linux-2.6.10-rc2/include/asm-ppc64/kprobes.h
@@ -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 */
include/asm-sparc64/kprobes.h renamed from linux-2.6.10-rc2/include/asm-sparc64/kprobes.h +2 -0
diff -Naurp temp/linux-2.6.10-rc2/include/asm-sparc64/kprobes.h linux-2.6.10-rc2/include/asm-sparc64/kprobes.h
@@ -10,6 +10,8 @@ typedef u32 kprobe_opcode_t;
 #define BREAKPOINT_INSTRUCTION_2 0x91d02071 /* ta 0x71 */
 #define MAX_INSN_SIZE 2
 
+#define JPROBE_ENTRY(pentry)	(kprobe_opcode_t *)pentry
+
 /* Architecture specific copy of original instruction*/
 struct arch_specific_insn {
 	/* copy of the original instruction */
include/asm-x86_64/kprobes.h renamed from linux-2.6.10-rc2/include/asm-x86_64/kprobes.h +2 -0
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
@@ -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 */
#4 lore raw
Quoted 14 lines · Ananth N Mavinakayanahalli
Quoted 14 lines
Quoted 7 lines

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.

I don't have the kprobes-for-ppc64 patch here.

Quoted 3 lines

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.

Quoted 5 lines
Quoted 2 lines

So what should I do with this? I'm inclined to drop it until the x86_64 part has been tested and Dave has had a go at the sparc64 version.

I have now tested the patch succesfully on x86_64 and updated it for sparc64 too (Dave says the change looks good).

What is the review and testing status of the kprobes-for-ppc64 patch which you sent?

#5 lore raw
Quoted 15 lines · Andrew Morton
Quoted 14 lines · Ananth N Mavinakayanahalli
Quoted 14 lines
Quoted 7 lines

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.

I don't have the kprobes-for-ppc64 patch here.

Quoted 3 lines

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.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

So what should I do with this? I'm inclined to drop it until the x86_64 part has been tested and Dave has had a go at the sparc64 version.

I have now tested the patch succesfully on x86_64 and updated it for sparc64 too (Dave says the change looks good).

What is the review and testing status of the kprobes-for-ppc64 patch which you sent?

The patch was earlier posted on the PPC64 mailing list for comments and Paul had reviewed it. I had to update the patch to take care of the base kprobe changes that were made to accomodate the x86_64 port.

The patch is tested on POWER3 (uni) and POWER4 (lpar).

Thanks,
Ananth