Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S263671AbUJ3KGm (ORCPT ); Sat, 30 Oct 2004 06:06:42 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S263670AbUJ3KGm (ORCPT ); Sat, 30 Oct 2004 06:06:42 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.104]:13545 "EHLO e4.ny.us.ibm.com") by vger.kernel.org with ESMTP id S263671AbUJ3KGR (ORCPT ); Sat, 30 Oct 2004 06:06:17 -0400 Date: Sun, 31 Oct 2004 02:36:37 +0530 From: Prasanna S Panchamukhi To: linux-kernel@vger.kernel.org Cc: torvalds@osdl.org, Andrew Morton , ak@muc.de, suparna@in.ibm.com, dprobes@www-124.southbury.usf.ibm.com Subject: Re: [patch 3/3] kprobes : Minor changes for sparc64 Message-ID: <20041030210637.GC1266@in.ibm.com> Reply-To: prasanna@in.ibm.com References: <20041028113208.GA11182@in.ibm.com> <20041028113444.GA5812@in.ibm.com> <20041028113558.GB5812@in.ibm.com> <20041028113845.GC5812@in.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20041028113845.GC5812@in.ibm.com> User-Agent: Mutt/1.4i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4666 Lines: 130 Minor changes required to port kprobes for x86_64. -arch_prepare_kprobe() returns an integer. -added arch_remove_kprobe(). -changes to access copy of original instruction, since kprobe_opcode_t insn[MAX_INSN_SIZE] is moved from struct kprobe to a struct arch_specific_insn. Signed-off-by: Prasanna S Panchamukhi --- linux-2.6.9-final-prasanna/arch/sparc64/kernel/kprobes.c | 29 ++++++++------- linux-2.6.9-final-prasanna/include/asm-sparc64/kprobes.h | 6 +++ 2 files changed, 23 insertions(+), 12 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-31 02:17:49.000000000 +0530 +++ linux-2.6.9-final-prasanna/arch/sparc64/kernel/kprobes.c 2004-10-31 02:23:04.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 + * In the kprobe->ainsn.insn[] array we store the original * instruction at index zero and a break instruction at * index one. * @@ -24,12 +24,12 @@ * - Remember "regs->tnpc" and interrupt level stored in * "regs->tstate" so we can restore them later * - Disable PIL interrupts - * - Set regs->tpc to point to kprobe->insn[0] - * - Set regs->tnpc to point to kprobe->insn[1] + * - Set regs->tpc to point to kprobe->ainsn.insn[0] + * - Set regs->tnpc to point to kprobe->ainsn.insn[1] * - Mark that we are actively in a kprobe * * At this point we wait for the second breakpoint at - * kprobe->insn[1] to hit. When it does we: + * kprobe->ainsn.insn[1] to hit. When it does we: * - Run the post-handler * - Set regs->tpc to "remembered" regs->tnpc stored above, * restore the PIL interrupt level in "regs->tstate" as well @@ -38,10 +38,15 @@ * - 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[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 +64,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 +204,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-31 02:17:49.000000000 +0530 +++ linux-2.6.9-final-prasanna/include/asm-sparc64/kprobes.h 2004-10-31 02:17:49.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); _ -- Thanks & Regards Prasanna S Panchamukhi Linux Technology Center India Software Labs, IBM Bangalore Ph: 91-80-25044636 - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/