diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-18 13:42:22 +0400 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-15 21:45:59 +0400 |
commit | 547f112571904da03589beb8434185294c77896a (patch) | |
tree | 0cf125fec3110091a208c0243173cfd150e332cd /arch/arc/kernel/entry.S | |
parent | 080c37473eb671a037b3e9a315303851f0675be5 (diff) | |
download | linux-547f112571904da03589beb8434185294c77896a.tar.xz |
ARC: ptrace support
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arc/kernel/entry.S')
-rw-r--r-- | arch/arc/kernel/entry.S | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 69d0d376e28b..76697aecd165 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -7,6 +7,13 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * + * vineetg: Feb 2011 (ptrace low level code fixes) + * -traced syscall return code (r0) was not saved into pt_regs for restoring + * into user reg-file when traded task rets to user space. + * -syscalls needing arch-wrappers (mainly for passing sp as pt_regs) + * were not invoking post-syscall trace hook (jumping directly into + * ret_from_system_call) + * * vineetg: Nov 2010: * -Vector table jumps (@8 bytes) converted into branches (@4 bytes) * -To maintain the slot size of 8 bytes/vector, added nop, which is @@ -347,6 +354,50 @@ ARC_ENTRY EV_Extension b ret_from_exception ARC_EXIT EV_Extension +;######################### System Call Tracing ######################### + +tracesys: + ; save EFA in case tracer wants the PC of traced task + ; using ERET won't work since next-PC has already committed + lr r12, [efa] + GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11 + st r12, [r11, THREAD_FAULT_ADDR] + + ; PRE Sys Call Ptrace hook + mov r0, sp ; pt_regs needed + bl @syscall_trace_entry + + ; Tracing code now returns the syscall num (orig or modif) + mov r8, r0 + + ; Do the Sys Call as we normally would. + ; Validate the Sys Call number + cmp r8, NR_syscalls + mov.hi r0, -ENOSYS + bhi tracesys_exit + + ; Restore the sys-call args. Mere invocation of the hook abv could have + ; clobbered them (since they are in scratch regs). The tracer could also + ; have deliberately changed the syscall args: r0-r7 + ld r0, [sp, PT_r0] + ld r1, [sp, PT_r1] + ld r2, [sp, PT_r2] + ld r3, [sp, PT_r3] + ld r4, [sp, PT_r4] + ld r5, [sp, PT_r5] + ld r6, [sp, PT_r6] + ld r7, [sp, PT_r7] + ld.as r9, [sys_call_table, r8] + jl [r9] ; Entry into Sys Call Handler + +tracesys_exit: + st r0, [sp, PT_r0] ; sys call return value in pt_regs + + ;POST Sys Call Ptrace Hook + bl @syscall_trace_exit + b ret_from_exception ; NOT ret_from_system_call at is saves r0 which + ; we'd done before calling post hook above + ;################### Break Point TRAP ########################## ; ======= (5b) Trap is due to Break-Point ========= @@ -412,6 +463,11 @@ ARC_ENTRY EV_Trap ; Before doing anything, return from CPU Exception Mode FAKE_RET_FROM_EXCPN r11 + ; If syscall tracing ongoing, invoke pre-pos-hooks + GET_CURR_THR_INFO_FLAGS r10 + btst r10, TIF_SYSCALL_TRACE + bnz tracesys ; this never comes back + ;============ This is normal System Call case ========== ; Sys-call num shd not exceed the total system calls avail cmp r8, NR_syscalls @@ -608,6 +664,10 @@ ARC_ENTRY sys_fork_wrapper bl @sys_fork DISCARD_CALLEE_SAVED_USER + GET_CURR_THR_INFO_FLAGS r10 + btst r10, TIF_SYSCALL_TRACE + bnz tracesys_exit + b ret_from_system_call ARC_EXIT sys_fork_wrapper @@ -616,6 +676,10 @@ ARC_ENTRY sys_vfork_wrapper bl @sys_vfork DISCARD_CALLEE_SAVED_USER + GET_CURR_THR_INFO_FLAGS r10 + btst r10, TIF_SYSCALL_TRACE + bnz tracesys_exit + b ret_from_system_call ARC_EXIT sys_vfork_wrapper @@ -624,5 +688,9 @@ ARC_ENTRY sys_clone_wrapper bl @sys_clone DISCARD_CALLEE_SAVED_USER + GET_CURR_THR_INFO_FLAGS r10 + btst r10, TIF_SYSCALL_TRACE + bnz tracesys_exit + b ret_from_system_call ARC_EXIT sys_clone_wrapper |