diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2016-01-24 08:32:10 +0100 |
---|---|---|
committer | Chris Zankel <chris@zankel.net> | 2016-03-11 09:53:32 +0100 |
commit | c91e02bd9702f2c00c6a6dc82dec1b2d5bb9f039 (patch) | |
tree | 7ffa9530078b594c2ad0ea97259abe15e9dd9619 /arch/xtensa/kernel/process.c | |
parent | xtensa: use context structure for debug exceptions (diff) | |
download | linux-c91e02bd9702f2c00c6a6dc82dec1b2d5bb9f039.tar.xz linux-c91e02bd9702f2c00c6a6dc82dec1b2d5bb9f039.zip |
xtensa: support hardware breakpoints/watchpoints
Use perf framework to manage hardware instruction and data breakpoints.
Add two new ptrace calls: PTRACE_GETHBPREGS and PTRACE_SETHBPREGS to
query and set instruction and data breakpoints.
Address bit 0 choose instruction (0) or data (1) break register, bits
31..1 are the register number.
Both calls transfer two 32-bit words: address (0) and control (1).
Instruction breakpoint contorl word is 0 to clear breakpoint, 1 to set.
Data breakpoint control word bit 31 is 'trigger on store', bit 30 is
'trigger on load, bits 29..0 are length. Length 0 is used to clear a
breakpoint. To set a breakpoint length must be a power of 2 in the range
1..64 and the address must be length-aligned.
Introduce new thread_info flag: TIF_DB_DISABLED. Set it if debug
exception is raised by the kernel code accessing watched userspace
address and disable corresponding data breakpoint. On exit to userspace
check that flag and, if set, restore all data breakpoints.
Handle debug exceptions raised with PS.EXCM set. This may happen when
window overflow/underflow handler or fast exception handler hits data
breakpoint, in which case save and disable all data breakpoints,
single-step faulting instruction and restore data breakpoints.
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'arch/xtensa/kernel/process.c')
-rw-r--r-- | arch/xtensa/kernel/process.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 1c85323f01d7..5bbfed81c97b 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -24,6 +24,7 @@ #include <linux/unistd.h> #include <linux/ptrace.h> #include <linux/elf.h> +#include <linux/hw_breakpoint.h> #include <linux/init.h> #include <linux/prctl.h> #include <linux/init_task.h> @@ -43,6 +44,7 @@ #include <linux/atomic.h> #include <asm/asm-offsets.h> #include <asm/regs.h> +#include <asm/hw_breakpoint.h> extern void ret_from_fork(void); extern void ret_from_kernel_thread(void); @@ -131,6 +133,7 @@ void flush_thread(void) coprocessor_flush_all(ti); coprocessor_release_all(ti); #endif + flush_ptrace_hw_breakpoint(current); } /* @@ -273,6 +276,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn, ti->cpenable = 0; #endif + clear_ptrace_hw_breakpoint(p); + return 0; } |