Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[POWERPC] Added kprobes support to ppc32

Added kprobes to ppc32 platforms that have use single_step_exception. This
excludes 4xx and anything Book-E since their debug mechanisms for single stepping
are completely different.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

+15 -5
+1 -1
arch/powerpc/Kconfig
··· 1206 1206 1207 1207 config KPROBES 1208 1208 bool "Kprobes (EXPERIMENTAL)" 1209 - depends on PPC64 && KALLSYMS && EXPERIMENTAL && MODULES 1209 + depends on !BOOKE && !4xx && KALLSYMS && EXPERIMENTAL && MODULES 1210 1210 help 1211 1211 Kprobes allows you to trap at almost any kernel address and 1212 1212 execute a callback function. register_kprobe() establishes
+6 -2
arch/powerpc/kernel/kprobes.c
··· 46 46 if ((unsigned long)p->addr & 0x03) { 47 47 printk("Attempt to register kprobe at an unaligned address\n"); 48 48 ret = -EINVAL; 49 - } else if (IS_MTMSRD(insn) || IS_RFID(insn)) { 50 - printk("Cannot register a kprobe on rfid or mtmsrd\n"); 49 + } else if (IS_MTMSRD(insn) || IS_RFID(insn) || IS_RFI(insn)) { 50 + printk("Cannot register a kprobe on rfi/rfid or mtmsr[d]\n"); 51 51 ret = -EINVAL; 52 52 } 53 53 ··· 483 483 memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs)); 484 484 485 485 /* setup return addr to the jprobe handler routine */ 486 + #ifdef CONFIG_PPC64 486 487 regs->nip = (unsigned long)(((func_descr_t *)jp->entry)->entry); 487 488 regs->gpr[2] = (unsigned long)(((func_descr_t *)jp->entry)->toc); 489 + #else 490 + regs->nip = (unsigned long)jp->entry; 491 + #endif 488 492 489 493 return 1; 490 494 }
+1 -1
arch/powerpc/lib/Makefile
··· 16 16 strcase.o 17 17 obj-$(CONFIG_QUICC_ENGINE) += rheap.o 18 18 obj-$(CONFIG_XMON) += sstep.o 19 + obj-$(CONFIG_KPROBES) += sstep.o 19 20 obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o 20 21 21 22 ifeq ($(CONFIG_PPC64),y) 22 23 obj-$(CONFIG_SMP) += locks.o 23 - obj-$(CONFIG_DEBUG_KERNEL) += sstep.o 24 24 endif 25 25 26 26 # Temporary hack until we have migrated to asm-powerpc
+6 -1
include/asm-powerpc/kprobes.h
··· 44 44 #define IS_TDI(instr) (((instr) & 0xfc000000) == 0x08000000) 45 45 #define IS_TWI(instr) (((instr) & 0xfc000000) == 0x0c000000) 46 46 47 + #ifdef CONFIG_PPC64 47 48 /* 48 49 * 64bit powerpc uses function descriptors. 49 50 * Handle cases where: ··· 68 67 } 69 68 70 69 #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)((func_descr_t *)pentry) 71 - 72 70 #define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \ 73 71 IS_TWI(instr) || IS_TDI(instr)) 72 + #else 73 + /* Use stock kprobe_lookup_name since ppc32 doesn't use function descriptors */ 74 + #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)(pentry) 75 + #define is_trap(instr) (IS_TW(instr) || IS_TWI(instr)) 76 + #endif 74 77 75 78 #define ARCH_SUPPORTS_KRETPROBES 76 79 #define ARCH_INACTIVE_KPROBE_COUNT 1
+1
include/asm-powerpc/sstep.h
··· 21 21 */ 22 22 #define IS_MTMSRD(instr) (((instr) & 0xfc0007be) == 0x7c000124) 23 23 #define IS_RFID(instr) (((instr) & 0xfc0007fe) == 0x4c000024) 24 + #define IS_RFI(instr) (((instr) & 0xfc0007fe) == 0x4c000064) 24 25 25 26 /* Emulate instructions that cause a transfer of control. */ 26 27 extern int emulate_step(struct pt_regs *regs, unsigned int instr);