diff options
author | Kumar Gala <galak@kernel.crashing.org> | 2007-02-06 23:55:19 -0500 |
---|---|---|
committer | Kumar Gala <galak@kernel.crashing.org> | 2007-02-06 23:55:19 -0500 |
commit | 8209003547c4b1006943eac8dc6c1fb6493cafda (patch) | |
tree | 37ed5742527d448f211c575fe714fe68846e0c40 | |
parent | 8423200553113cc031caa9b147f6150a8e26545c (diff) |
[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>
-rw-r--r-- | arch/powerpc/Kconfig | 2 | ||||
-rw-r--r-- | arch/powerpc/kernel/kprobes.c | 8 | ||||
-rw-r--r-- | arch/powerpc/lib/Makefile | 2 | ||||
-rw-r--r-- | include/asm-powerpc/kprobes.h | 7 | ||||
-rw-r--r-- | include/asm-powerpc/sstep.h | 1 |
5 files changed, 15 insertions, 5 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index aeb53096acf7..0b6325a77c75 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
@@ -1206,7 +1206,7 @@ source "arch/powerpc/oprofile/Kconfig" | |||
1206 | 1206 | ||
1207 | config KPROBES | 1207 | config KPROBES |
1208 | bool "Kprobes (EXPERIMENTAL)" | 1208 | bool "Kprobes (EXPERIMENTAL)" |
1209 | depends on PPC64 && KALLSYMS && EXPERIMENTAL && MODULES | 1209 | depends on !BOOKE && !4xx && KALLSYMS && EXPERIMENTAL && MODULES |
1210 | help | 1210 | help |
1211 | Kprobes allows you to trap at almost any kernel address and | 1211 | Kprobes allows you to trap at almost any kernel address and |
1212 | execute a callback function. register_kprobe() establishes | 1212 | execute a callback function. register_kprobe() establishes |
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 4657563f8813..dd2886f97e98 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c | |||
@@ -46,8 +46,8 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) | |||
46 | if ((unsigned long)p->addr & 0x03) { | 46 | if ((unsigned long)p->addr & 0x03) { |
47 | printk("Attempt to register kprobe at an unaligned address\n"); | 47 | printk("Attempt to register kprobe at an unaligned address\n"); |
48 | ret = -EINVAL; | 48 | ret = -EINVAL; |
49 | } else if (IS_MTMSRD(insn) || IS_RFID(insn)) { | 49 | } else if (IS_MTMSRD(insn) || IS_RFID(insn) || IS_RFI(insn)) { |
50 | printk("Cannot register a kprobe on rfid or mtmsrd\n"); | 50 | printk("Cannot register a kprobe on rfi/rfid or mtmsr[d]\n"); |
51 | ret = -EINVAL; | 51 | ret = -EINVAL; |
52 | } | 52 | } |
53 | 53 | ||
@@ -483,8 +483,12 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) | |||
483 | memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs)); | 483 | memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs)); |
484 | 484 | ||
485 | /* setup return addr to the jprobe handler routine */ | 485 | /* setup return addr to the jprobe handler routine */ |
486 | #ifdef CONFIG_PPC64 | ||
486 | regs->nip = (unsigned long)(((func_descr_t *)jp->entry)->entry); | 487 | regs->nip = (unsigned long)(((func_descr_t *)jp->entry)->entry); |
487 | regs->gpr[2] = (unsigned long)(((func_descr_t *)jp->entry)->toc); | 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 | return 1; | 493 | return 1; |
490 | } | 494 | } |
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile index e2d414160c83..4b1ba49fbd9e 100644 --- a/arch/powerpc/lib/Makefile +++ b/arch/powerpc/lib/Makefile | |||
@@ -16,11 +16,11 @@ obj-$(CONFIG_PPC64) += checksum_64.o copypage_64.o copyuser_64.o \ | |||
16 | strcase.o | 16 | strcase.o |
17 | obj-$(CONFIG_QUICC_ENGINE) += rheap.o | 17 | obj-$(CONFIG_QUICC_ENGINE) += rheap.o |
18 | obj-$(CONFIG_XMON) += sstep.o | 18 | obj-$(CONFIG_XMON) += sstep.o |
19 | obj-$(CONFIG_KPROBES) += sstep.o | ||
19 | obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o | 20 | obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o |
20 | 21 | ||
21 | ifeq ($(CONFIG_PPC64),y) | 22 | ifeq ($(CONFIG_PPC64),y) |
22 | obj-$(CONFIG_SMP) += locks.o | 23 | obj-$(CONFIG_SMP) += locks.o |
23 | obj-$(CONFIG_DEBUG_KERNEL) += sstep.o | ||
24 | endif | 24 | endif |
25 | 25 | ||
26 | # Temporary hack until we have migrated to asm-powerpc | 26 | # Temporary hack until we have migrated to asm-powerpc |
diff --git a/include/asm-powerpc/kprobes.h b/include/asm-powerpc/kprobes.h index 2dafa376a63f..3a5dd492588f 100644 --- a/include/asm-powerpc/kprobes.h +++ b/include/asm-powerpc/kprobes.h | |||
@@ -44,6 +44,7 @@ typedef unsigned int kprobe_opcode_t; | |||
44 | #define IS_TDI(instr) (((instr) & 0xfc000000) == 0x08000000) | 44 | #define IS_TDI(instr) (((instr) & 0xfc000000) == 0x08000000) |
45 | #define IS_TWI(instr) (((instr) & 0xfc000000) == 0x0c000000) | 45 | #define IS_TWI(instr) (((instr) & 0xfc000000) == 0x0c000000) |
46 | 46 | ||
47 | #ifdef CONFIG_PPC64 | ||
47 | /* | 48 | /* |
48 | * 64bit powerpc uses function descriptors. | 49 | * 64bit powerpc uses function descriptors. |
49 | * Handle cases where: | 50 | * Handle cases where: |
@@ -67,9 +68,13 @@ typedef unsigned int kprobe_opcode_t; | |||
67 | } | 68 | } |
68 | 69 | ||
69 | #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)((func_descr_t *)pentry) | 70 | #define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)((func_descr_t *)pentry) |
70 | |||
71 | #define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \ | 71 | #define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \ |
72 | IS_TWI(instr) || IS_TDI(instr)) | 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 | #define ARCH_SUPPORTS_KRETPROBES | 79 | #define ARCH_SUPPORTS_KRETPROBES |
75 | #define ARCH_INACTIVE_KPROBE_COUNT 1 | 80 | #define ARCH_INACTIVE_KPROBE_COUNT 1 |
diff --git a/include/asm-powerpc/sstep.h b/include/asm-powerpc/sstep.h index 630a9889c07c..f593b0f9b627 100644 --- a/include/asm-powerpc/sstep.h +++ b/include/asm-powerpc/sstep.h | |||
@@ -21,6 +21,7 @@ struct pt_regs; | |||
21 | */ | 21 | */ |
22 | #define IS_MTMSRD(instr) (((instr) & 0xfc0007be) == 0x7c000124) | 22 | #define IS_MTMSRD(instr) (((instr) & 0xfc0007be) == 0x7c000124) |
23 | #define IS_RFID(instr) (((instr) & 0xfc0007fe) == 0x4c000024) | 23 | #define IS_RFID(instr) (((instr) & 0xfc0007fe) == 0x4c000024) |
24 | #define IS_RFI(instr) (((instr) & 0xfc0007fe) == 0x4c000064) | ||
24 | 25 | ||
25 | /* Emulate instructions that cause a transfer of control. */ | 26 | /* Emulate instructions that cause a transfer of control. */ |
26 | extern int emulate_step(struct pt_regs *regs, unsigned int instr); | 27 | extern int emulate_step(struct pt_regs *regs, unsigned int instr); |