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

powerpc: Move the single step enable code to a generic path

This patch moves the single step enable code used by kprobe to a generic
routine header so that, it can be re-used by other code, in this case,
uprobes. No functional changes.

Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
Cc: Ananth N Mavinakaynahalli <ananth@in.ibm.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org
Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

authored by

Suzuki K. Poulose and committed by
Benjamin Herrenschmidt
35fd219a 85f395c5

+26 -19
+25
arch/powerpc/include/asm/probes.h
··· 38 38 #define is_trap(instr) (IS_TW(instr) || IS_TWI(instr)) 39 39 #endif /* CONFIG_PPC64 */ 40 40 41 + #ifdef CONFIG_PPC_ADV_DEBUG_REGS 42 + #define MSR_SINGLESTEP (MSR_DE) 43 + #else 44 + #define MSR_SINGLESTEP (MSR_SE) 45 + #endif 46 + 47 + /* Enable single stepping for the current task */ 48 + static inline void enable_single_step(struct pt_regs *regs) 49 + { 50 + regs->msr |= MSR_SINGLESTEP; 51 + #ifdef CONFIG_PPC_ADV_DEBUG_REGS 52 + /* 53 + * We turn off Critical Input Exception(CE) to ensure that the single 54 + * step will be for the instruction we have the probe on; if we don't, 55 + * it is possible we'd get the single step reported for CE. 56 + */ 57 + regs->msr &= ~MSR_CE; 58 + mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM); 59 + #ifdef CONFIG_PPC_47x 60 + isync(); 61 + #endif 62 + #endif 63 + } 64 + 65 + 41 66 #endif /* __KERNEL__ */ 42 67 #endif /* _ASM_POWERPC_PROBES_H */
+1 -19
arch/powerpc/kernel/kprobes.c
··· 36 36 #include <asm/sstep.h> 37 37 #include <asm/uaccess.h> 38 38 39 - #ifdef CONFIG_PPC_ADV_DEBUG_REGS 40 - #define MSR_SINGLESTEP (MSR_DE) 41 - #else 42 - #define MSR_SINGLESTEP (MSR_SE) 43 - #endif 44 - 45 39 DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 46 40 DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 47 41 ··· 98 104 99 105 static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 100 106 { 101 - regs->msr |= MSR_SINGLESTEP; 102 - #ifdef CONFIG_PPC_ADV_DEBUG_REGS 103 - /* 104 - * We turn off Critical Input Exception(CE) to ensure that the single 105 - * step will be for the instruction we have the probe on; if we don't, 106 - * it is possible we'd get the single step reported for CE. 107 - */ 108 - regs->msr &= ~MSR_CE; 109 - mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM); 110 - #ifdef CONFIG_PPC_47x 111 - isync(); 112 - #endif 113 - #endif 107 + enable_single_step(regs); 114 108 115 109 /* 116 110 * On powerpc we should single step on the original