Commit 8209003547c4b1006943eac8dc6c1fb6493cafda

Authored by Kumar Gala
1 parent 8423200553

[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>

Showing 5 changed files with 15 additions and 5 deletions Side-by-side Diff

arch/powerpc/Kconfig
... ... @@ -1206,7 +1206,7 @@
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
arch/powerpc/kernel/kprobes.c
... ... @@ -46,8 +46,8 @@
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  
54 54  
... ... @@ -483,8 +483,12 @@
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 }
arch/powerpc/lib/Makefile
... ... @@ -16,11 +16,11 @@
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
include/asm-powerpc/kprobes.h
... ... @@ -44,6 +44,7 @@
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:
50 51  
... ... @@ -67,9 +68,13 @@
67 68 }
68 69  
69 70 #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)((func_descr_t *)pentry)
70   -
71 71 #define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \
72 72 IS_TWI(instr) || IS_TDI(instr))
  73 +#else
  74 +/* Use stock kprobe_lookup_name since ppc32 doesn't use function descriptors */
  75 +#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)(pentry)
  76 +#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr))
  77 +#endif
73 78  
74 79 #define ARCH_SUPPORTS_KRETPROBES
75 80 #define ARCH_INACTIVE_KPROBE_COUNT 1
include/asm-powerpc/sstep.h
... ... @@ -21,6 +21,7 @@
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);