MIPS: Kprobe support v0.2
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 MIPS: Kprobe support v0.2
This updated version of patch incorporates some of the comments from Daney. The list of changes are as follows:
o Instead of separate handler "do_break", do_bp is used to track and handle kprobe induced breaks. This cleans up ugly ifdef hack.
o Instead of using 0 and 5 code in break, new kprobe specific defines (515, 516) have been added and handled.
The use of notify_die could not be dropped because the kprobes framework installs handlers on notify_die chain.
Himanshu Chauhan (1):
MIPS: Kprobe support v0.2 This incorporates some of the comments
from Daney.
arch/mips/Kconfig | 13 ++ arch/mips/include/asm/break.h | 2 + arch/mips/include/asm/kdebug.h | 5 + arch/mips/include/asm/kprobes.h | 86 +++++++++ arch/mips/kernel/Makefile | 2 + arch/mips/kernel/kprobes.c | 379 +++++++++++++++++++++++++++++++++++++++ arch/mips/kernel/traps.c | 46 +++++- arch/mips/mm/fault.c | 11 +- 8 files changed, 541 insertions(+), 3 deletions(-) create mode 100644 arch/mips/include/asm/kprobes.h create mode 100644 arch/mips/kernel/kprobes.c
PATCH 1/1 MIPS: Kprobe support v0.2 This incorporates some of the comments from Daney.
In reply to a message not in the archive--- arch/mips/Kconfig | 13 ++ arch/mips/include/asm/break.h | 2 + arch/mips/include/asm/kdebug.h | 5 + arch/mips/include/asm/kprobes.h | 86 +++++++++ arch/mips/kernel/Makefile | 2 + arch/mips/kernel/kprobes.c | 379 +++++++++++++++++++++++++++++++++++++++ arch/mips/kernel/traps.c | 46 +++++- arch/mips/mm/fault.c | 11 +- 8 files changed, 541 insertions(+), 3 deletions(-) create mode 100644 arch/mips/include/asm/kprobes.h create mode 100644 arch/mips/kernel/kprobes.c
arch/mips/Kconfig +13 -0
@@ -2243,6 +2243,19 @@ source "kernel/power/Kconfig" endmenu +menu "Instrumentation Support" + +config KPROBES + bool "MIPS Kprobes Support (Experimental)" + depends on EXPERIMENTAL && MODULES + help + Kprobes allow you to trap at almost any kernel address + and execute a callback function. Kprobes is useful for + kernel debugging, non-intrusive instrumetation and testing. + If in doubt, say N. + +endmenu + source "arch/mips/kernel/cpufreq/Kconfig" source "net/Kconfig"
arch/mips/include/asm/break.h +2 -0
@@ -30,6 +30,8 @@#define BRK_BUG 512/* Used by BUG() */ #define BRK_KDB 513/* Used in KDB_ENTER() */ #define BRK_MEMU 514/* Used by FPU emulator */ +#define BRK_KPRB_BP 515/* Used by Kprobes for pre-handling */ +#define BRK_KPRB_SSTP 516/* Used by Kprobes for post-handling */ #define BRK_MULOVF 1023/* Multiply overflow */ #endif /* __ASM_BREAK_H */
arch/mips/include/asm/kdebug.h +5 -0
@@ -8,6 +8,11 @@ enum die_val {DIE_FP ,DIE_TRAP ,DIE_RI , +#ifdef CONFIG_KPROBES +DIE_PAGE_FAULT , +DIE_BREAK , + DIE_SSTEPBP, +#endif };#endif /* _ASM_MIPS_KDEBUG_H */
arch/mips/include/asm/kprobes.h new file +86 -0
86 lines not on this page · raw message
arch/mips/kernel/Makefile +2 -0
@@ -83,6 +83,7 @@ obj-$(CONFIG_MIPS32_N32) += binfmt_elfn32.o scall64-n32.o signal_n32.o obj-$(CONFIG_MIPS32_O32) += binfmt_elfo32.o scall64-o32.o obj-$(CONFIG_KGDB) += kgdb.o +obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_64BIT) += cpu-bugs64.o
@@ -95,6 +96,7 @@ obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_SPINLOCK_TEST) += spinlock_test.o + CFLAGS_cpu-bugs64.o = $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi) obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT) += 8250-platform.o
arch/mips/kernel/kprobes.c new file +379 -0
379 lines not on this page · raw message
arch/mips/kernel/traps.c +45 -1
76 lines not on this page · raw message
arch/mips/mm/fault.c +9 -2
@@ -18,6 +18,8 @@#include <linux/smp.h> #include <linux/vt_kern.h> /* For unblank_screen() */ #include <linux/module.h> +#include <linux/kprobes.h> +#include <linux/kdebug.h> /* notify_die and asm/kdebug.h */ #include <asm/branch.h> #include <asm/mmu_context.h>
@@ -31,8 +33,8 @@* and the problem, and then passes it off to one of the appropriate * routines. */ -asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, -unsigned long address) +asmlinkage void __kprobes do_page_fault(struct pt_regs *regs, unsigned long write, +unsigned long address) {struct vm_area_struct * vma =NULL ;struct task_struct *tsk = current;
@@ -47,6 +49,11 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, field, regs->cp0_epc);#endif +/* Notify kprobes fault handler. */ +if (notify_die (DIE_PAGE_FAULT ,"page fault" , + regs,-1 ,SEGV_MAPERR ,SEGV_MAPERR ) ==NOTIFY_STOP ) +return ; + info.si_code =SEGV_MAPERR ;/*
Signature · 1 line
1.7.0.4