Kprobes for PPC64 - updated
PATCH 1/1 Kprobes for PPC64 - updated
Hi,
Here is the updated kprobes patch for ppc64. Paul's "move emulate_step to arch/ppc64/lib" patch is a prereq.
Current patch is against 2.6.9-rc2-mm1.
Kprobes (Kernel dynamic probes) is a lightweight mechanism for kernel modules to insert probes into a running kernel, without the need to modify the underlying source. The probe handlers can then be coded to log relevent data at the probe point. More information on kprobes can be found at:
http://www-124.ibm.com/developerworks/oss/linux/projects/kprobes/
Jprobes (or jumper probes) is a small infrastructure to access function arguments. It can be used by defining a small stub with the same template as the routine in kernel, within which the required parameters can be logged.
Thanks,
Ananth
arch/ppc64/Kconfig.debug renamed from linux-2.6.10-rc2/arch/ppc64/Kconfig.debug +10 -0
@@ -6,6 +6,16 @@ config DEBUG_STACKOVERFLOW bool "Check for stack overflows" depends on DEBUG_KERNEL +config KPROBES + bool "Kprobes" + depends on DEBUG_KERNEL + help + Kprobes allows you to trap at almost any kernel address and + execute a callback function. register_kprobe() establishes + a probepoint and specifies the callback. Kprobes is useful + for kernel debugging, non-intrusive instrumentation and testing. + If in doubt, say "N". + config DEBUG_STACK_USAGE bool "Stack utilization instrumentation" depends on DEBUG_KERNEL
arch/ppc64/kernel/kprobes.c renamed from linux-2.6.10-rc2/arch/ppc64/kernel/kprobes.c +258 -0
258 lines not on this page · raw message
arch/ppc64/kernel/Makefile renamed from linux-2.6.10-rc2/arch/ppc64/kernel/Makefile +1 -0
@@ -61,5 +61,6 @@ obj-$(CONFIG_PPC_MAPLE) += smp-tbsync.o endif obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o +obj-$(CONFIG_KPROBES) += kprobes.o CFLAGS_ioctl32.o += -Ifs/
arch/ppc64/kernel/traps.c renamed from linux-2.6.10-rc2/arch/ppc64/kernel/traps.c +24 -0
@@ -29,6 +29,7 @@#include <linux/interrupt.h> #include <linux/init.h> #include <linux/module.h> +#include <asm/kdebug.h> #include <asm/pgtable.h> #include <asm/uaccess.h>
@@ -61,6 +62,20 @@ EXPORT_SYMBOL(__debugger_dabr_match);EXPORT_SYMBOL (__debugger_fault_handler);#endif +struct notifier_block *ppc64_die_chain; +static spinlock_t die_notifier_lock =SPIN_LOCK_UNLOCKED ; + +int register_die_notifier (struct notifier_block *nb) +{ +int err =0 ; +unsigned long flags; + +spin_lock_irqsave (&die_notifier_lock, flags); + err =notifier_chain_register (&ppc64_die_chain, nb); +spin_unlock_irqrestore (&die_notifier_lock, flags); +return err; +} +/* * Trap & Exception support */
@@ -287,6 +302,9 @@ UnknownException(struct pt_regs *regs)void InstructionBreakpointException (struct pt_regs *regs) { +if (notify_die (DIE_IABR_MATCH ,"iabr_match" , regs,5 , +5 ,SIGTRAP ) ==NOTIFY_STOP ) +return ;if (debugger_iabr_match (regs))return ;_exception (SIGTRAP , regs,TRAP_BRKPT , regs->nip);
@@ -297,6 +315,9 @@ SingleStepException(struct pt_regs *regs { regs->msr &= ~MSR_SE ;/* Turn off 'trace' bit */ +if (notify_die (DIE_SSTEP ,"single_step" , regs,5 , +5 ,SIGTRAP ) ==NOTIFY_STOP ) +return ;if (debugger_sstep (regs))return ;
@@ -470,6 +491,9 @@ ProgramCheckException(struct pt_regs *re }else if (regs->msr &0x20000 ) {/* trap exception */ +if (notify_die (DIE_BPT ,"breakpoint" , regs,5 , +5 ,SIGTRAP ) ==NOTIFY_STOP ) +return ;if (debugger_bpt (regs))return ;
arch/ppc64/lib/Makefile renamed from linux-2.6.10-rc2/arch/ppc64/lib/Makefile +1 -1
@@ -15,4 +15,4 @@ ifdef CONFIG_PPC_ISERIES obj-$(CONFIG_PCI) += e2a.o endif -lib-$(CONFIG_XMON) += sstep.o +lib-$(CONFIG_DEBUG_KERNEL) += sstep.o
arch/ppc64/mm/fault.c renamed from linux-2.6.10-rc2/arch/ppc64/mm/fault.c +8 -0
@@ -36,6 +36,7 @@#include <asm/mmu_context.h> #include <asm/system.h> #include <asm/uaccess.h> +#include <asm/kdebug.h> /* * Check whether the instruction at regs->nip is a store using
@@ -95,6 +96,10 @@ int do_page_fault(struct pt_regs *regs,BUG_ON ((trap ==0x380 ) || (trap ==0x480 )); +if (notify_die (DIE_PAGE_FAULT ,"page_fault" , regs, error_code, +11 ,SIGSEGV ) ==NOTIFY_STOP ) +return 0 ; +if (trap ==0x300 ) {if (debugger_fault_handler (regs))return 0 ;
@@ -105,6 +110,9 @@ int do_page_fault(struct pt_regs *regs,return SIGSEGV ;if (error_code &0x00400000 ) { +if (notify_die (DIE_DABR_MATCH ,"dabr_match" , regs, error_code, +11 ,SIGSEGV ) ==NOTIFY_STOP ) +return 0 ;if (debugger_dabr_match (regs))return 0 ; }
arch/ppc64/xmon/xmon.c renamed from linux-2.6.10-rc2/arch/ppc64/xmon/xmon.c +0 -11
@@ -229,17 +229,6 @@ extern inline void sync(void)*/ /* -* We don't allow single-stepping an mtmsrd that would clear -* MSR_RI, since that would make the exception unrecoverable. -* Since we need to single-step to proceed from a breakpoint, -* we don't allow putting a breakpoint on an mtmsrd instruction. -* Similarly we don't allow breakpoints on rfid instructions. -* These macros tell us if an instruction is a mtmsrd or rfid. -*/ -#define IS_MTMSRD (instr) (((instr) & 0xfc0007fe) == 0x7c000164) -#define IS_RFID (instr) (((instr) & 0xfc0007fe) == 0x4c000024) - -/* * Disable surveillance (the service processor watchdog function) * while we are in xmon. * XXX we should re-enable it when we leave. :)
include/asm-ppc64/kdebug.h renamed from linux-2.6.10-rc2/include/asm-ppc64/kdebug.h +43 -0
43 lines not on this page · raw message
include/asm-ppc64/kprobes.h renamed from linux-2.6.10-rc2/include/asm-ppc64/kprobes.h +54 -0
54 lines not on this page · raw message
include/asm-ppc64/sstep.h renamed from linux-2.6.10-rc2/include/asm-ppc64/sstep.h +11 -0
@@ -9,5 +9,16 @@struct pt_regs ; +/* +* We don't allow single-stepping an mtmsrd that would clear +* MSR_RI, since that would make the exception unrecoverable. +* Since we need to single-step to proceed from a breakpoint, +* we don't allow putting a breakpoint on an mtmsrd instruction. +* Similarly we don't allow breakpoints on rfid instructions. +* These macros tell us if an instruction is a mtmsrd or rfid. +*/ +#define IS_MTMSRD (instr) (((instr) & 0xfc0007fe) == 0x7c000164) +#define IS_RFID (instr) (((instr) & 0xfc0007fe) == 0x4c000024) +/* Emulate instructions that cause a transfer of control. */ extern int emulate_step (struct pt_regs *regs,unsigned int instr);