S390-HWBKPT v4: Modify ptrace to use Hardware
Subsystems (2)
PATCH 3/3 S390-HWBKPT v4: Modify ptrace to use Hardware
Modify the ptrace code to use the hardware breakpoint interfaces for user-space
Signed-off-by Mahesh Salgaonkar <[email protected]>
---
arch/s390/include/asm/ptrace.h | 3 - arch/s390/kernel/process.c | 3 + arch/s390/kernel/ptrace.c | 221 ++++++++++++++++++++++++++++------------ 3 files changed, 158 insertions(+), 69 deletions(-)
arch/s390/include/asm/ptrace.h +2 -1
@@ -406,7 +406,8 @@ typedef struct*/ unsigned single_step : 1; unsigned instruction_fetch : 1; - unsigned : 30; + unsigned storage_alteration: 1; + unsigned : 29;/* * These addresses are copied into cr10 & cr11 if single * stepping is switched off
arch/s390/kernel/process.c +3 -0
@@ -32,6 +32,7 @@#include <linux/kernel_stat.h> #include <linux/syscalls.h> #include <linux/compat.h> +#include <linux/hw_breakpoint.h> #include <asm/compat.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
@@ -153,6 +154,7 @@ void exit_thread(void)void flush_thread (void ) { +flush_ptrace_hw_breakpoint (current); }void release_thread (struct task_struct *dead_task)
@@ -215,6 +217,7 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp, p->thread.mm_segment =get_fs ();/* Don't copy debug registers */ memset (&p->thread.per_info,0 ,sizeof (p->thread.per_info)); +memset (p->thread.ptrace_bps,0 ,sizeof (p->thread.ptrace_bps));clear_tsk_thread_flag (p,TIF_SINGLE_STEP );/* Initialize per thread user and system timer values */ ti =task_thread_info (p);
arch/s390/kernel/ptrace.c +153 -68
317 lines not on this page · raw message
arch/s390/kernel/ptrace.c line 109
Quoted 8 lines · Mahesh Salgaonkar
arch/s390/kernel/ptrace.c +8
-0+static void ptrace_triggered (struct perf_event *bp,int nmi, +struct perf_sample_data *data, +struct pt_regs *regs) +{ +struct thread_struct *thread = &(current->thread); + + thread->ptrace_bps[0 ] = bp; +}
Hmm, I don't understand what happens here. You only set up the thread->ptrace_bps here?
So if it never triggers it will never be freed? Also how do you handle the signal?
Quoted 18 lines
arch/s390/kernel/ptrace.c +18
-0+ +static void ptrace_set_breakpoint (struct task_struct *task,int disabled) +{ +per_struct *per_info; +struct perf_event *bp; +struct thread_struct *t = &task->thread; +struct perf_event_attr attr; + +hw_breakpoint_init (&attr); + per_info = (per_struct *) &task->thread.per_info; + +if (per_info->single_step | per_info->instruction_fetch) + attr.bp_type =HW_BREAKPOINT_X ; +else if (per_info->storage_alteration) + attr.bp_type =HW_BREAKPOINT_W ; +else { +ptrace_remove_breakpoint (task); +return ;
arch/s390/kernel/ptrace.c line 137
Quoted 10 lines
arch/s390/kernel/ptrace.c +10
-0+ } + + attr.disabled = disabled; + attr.bp_addr =get_per_addr (per_info); + attr.bp_len =get_per_len (per_info); + +if (!t->ptrace_bps[0 ]) { + bp =register_user_hw_breakpoint (&attr, ptrace_triggered, task); +if (!IS_ERR (bp)) + t->ptrace_bps[0 ] = bp;
Hmm, and you actually set it up here before.
I'm not sure what's the point of doing the same in ptrace_triggered()