Implement hw-breakpoint interfaces for BookE processors
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
RFC PATCH 1/1 Implement hw-breakpoint interfaces for BookE processors
Implement hardware breakpoint interfaces for PowerPC BookE processors
Signed-off-by K.Prasad <[email protected]>
--- arch/powerpc/Kconfig | 2 arch/powerpc/include/asm/cputable.h | 4 arch/powerpc/include/asm/hw_breakpoint_booke.h | 42 +++ arch/powerpc/kernel/Makefile | 4 arch/powerpc/kernel/hw_breakpoint_booke.c | 326 +++++++++++++++++++++++++ arch/powerpc/kernel/ptrace.c | 8 arch/powerpc/kernel/traps.c | 11 include/linux/perf_event.h | 4 8 files changed, 398 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/hw_breakpoint_booke.h new file +42 -0
@@ -0,0 +1,42 @@ +#ifndef _I386_HW_BREAKPOINT_H +#define _I386_HW_BREAKPOINT_H + +#ifdef __KERNEL__ +#define __ARCH_HW_BREAKPOINT_H + +struct arch_hw_breakpoint { +u8 len; +unsigned long address; +unsigned long type; +}; + +#include <linux/kdebug.h> +#include <linux/percpu.h> +#include <linux/list.h> + +/* Breakpoint length beyond which we should use 'range' breakpoints */ +#define DAC_LEN 8 + +static inline int hw_breakpoint_slots (int type) +{ +return HBP_NUM ; +} + +struct perf_event ; +struct pmu ; + +extern int arch_check_bp_in_kernelspace (struct perf_event *bp); +extern int arch_validate_hwbkpt_settings (struct perf_event *bp); +extern int hw_breakpoint_exceptions_notify (struct notifier_block *unused, +unsigned long val,void *data); +extern void hw_breakpoint_handler (struct pt_regs *regs, +unsigned long debug_status); +int arch_install_hw_breakpoint (struct perf_event *bp); +void arch_uninstall_hw_breakpoint (struct perf_event *bp); +void hw_breakpoint_pmu_read (struct perf_event *bp); + +extern struct pmu perf_ops_bp; + +#endif /* __KERNEL__ */ +#endif /* _I386_HW_BREAKPOINT_H */ +
arch/powerpc/kernel/hw_breakpoint_booke.c new file +326 -0
326 lines not on this page · raw message
arch/powerpc/kernel/traps.c +9 -2
@@ -57,6 +57,9 @@#ifdef CONFIG_FSL_BOOKE #include <asm/dbell.h> #endif +#ifdef CONFIG_BOOKE +#include <asm/hw_breakpoint_booke.h> +#endif #if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC )int (*__debugger)(struct pt_regs *regs)__read_mostly ;
@@ -1151,8 +1154,12 @@ void __kprobes DebugException(struct pt_ }_exception (SIGTRAP , regs,TRAP_TRACE , regs->nip); - }else -handle_debug (regs, debug_status); + }else { +if (is_kernel_addr (regs->dar)) +hw_breakpoint_handler (regs, debug_status); +else +handle_debug (regs, debug_status); + } }#endif /* CONFIG_PPC_ADV_DEBUG_REGS */
arch/powerpc/Kconfig +1 -1
@@ -140,7 +140,7 @@ config PPC select HAVE_SYSCALL_WRAPPERS if PPC64 select GENERIC_ATOMIC64 if PPC32 select HAVE_PERF_EVENTS - select HAVE_HW_BREAKPOINT if PERF_EVENTS && PPC_BOOK3S_64 + select HAVE_HW_BREAKPOINT if (PERF_EVENTS && PPC_BOOK3S_64) || BOOKE config EARLY_PRINTK bool
arch/powerpc/kernel/Makefile +4 -0
@@ -34,7 +34,11 @@ obj-y += vdso32/ obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \ signal_64.o ptrace32.o \ paca.o nvram_64.o firmware.o +ifeq ($(CONFIG_BOOKE),y) +obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint_booke.o +else obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o +endif obj-$(CONFIG_PPC_BOOK3S_64) += cpu_setup_ppc970.o cpu_setup_pa6t.o obj64-$(CONFIG_RELOCATABLE) += reloc_64.o obj-$(CONFIG_PPC_BOOK3E_64) += exceptions-64e.o
arch/powerpc/kernel/ptrace.c +8 -0
@@ -787,10 +787,12 @@ int ptrace_set_debugreg(struct task_stru unsigned long data) {#ifdef CONFIG_HAVE_HW_BREAKPOINT +#ifndef CONFIG_BOOKE int ret;struct thread_struct *thread = &(task->thread);struct perf_event *bp;struct perf_event_attr attr; +#endif /* CONFIG_BOOKE */ #endif /* CONFIG_HAVE_HW_BREAKPOINT */ /* For ppc64 we support one DABR and no IABR's at the moment (ppc64).
@@ -821,6 +823,11 @@ int ptrace_set_debugreg(struct task_struif (data && !(data &DABR_TRANSLATION ))return -EIO ; #ifdef CONFIG_HAVE_HW_BREAKPOINT +/* + * Temporarily disable use of breakpoint interfaces through ptrace until + * user-space breakpoint support is enabled. + */ +#ifndef CONFIG_BOOKE bp = thread->ptrace_bps[0]; if (data == 0) { if (bp) {
@@ -873,6 +880,7 @@ int ptrace_set_debugreg(struct task_strureturn PTR_ERR (bp); } +#endif /* CONFIG_BOOKE */ #endif /* CONFIG_HAVE_HW_BREAKPOINT */ /* Move contents to the DABR register */
arch/powerpc/include/asm/cputable.h +4 -0
@@ -512,7 +512,11 @@ static inline int cpu_has_feature(unsign }#ifdef CONFIG_HAVE_HW_BREAKPOINT +#ifdef CONFIG_BOOKE +#define HBP_NUM 2 +#else #define HBP_NUM 1 +#endif /* CONFIG_BOOKE */ #endif /* CONFIG_HAVE_HW_BREAKPOINT */ #endif /* !__ASSEMBLY__ */
include/linux/perf_event.h +4 -0
@@ -440,7 +440,11 @@ enum perf_callchain_context {#endif #ifdef CONFIG_HAVE_HW_BREAKPOINT +#ifdef CONFIG_BOOKE +#include <asm/hw_breakpoint_booke.h> +#else #include <asm/hw_breakpoint.h> +#endif /* CONFIG_BOOKE */ #endif #include <linux/list.h>