diff options
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 @@ | |||
7 | * it under the terms of the GNU General Public License version 2 as | 7 | * it under the terms of the GNU General Public License version 2 as |
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | * | 9 | * |
10 | * vineetg: Feb 2011 (ptrace low level code fixes) | ||
11 | * -traced syscall return code (r0) was not saved into pt_regs for restoring | ||
12 | * into user reg-file when traded task rets to user space. | ||
13 | * -syscalls needing arch-wrappers (mainly for passing sp as pt_regs) | ||
14 | * were not invoking post-syscall trace hook (jumping directly into | ||
15 | * ret_from_system_call) | ||
16 | * | ||
10 | * vineetg: Nov 2010: | 17 | * vineetg: Nov 2010: |
11 | * -Vector table jumps (@8 bytes) converted into branches (@4 bytes) | 18 | * -Vector table jumps (@8 bytes) converted into branches (@4 bytes) |
12 | * -To maintain the slot size of 8 bytes/vector, added nop, which is | 19 | * -To maintain the slot size of 8 bytes/vector, added nop, which is |
@@ -347,6 +354,50 @@ ARC_ENTRY EV_Extension | |||
347 | b ret_from_exception | 354 | b ret_from_exception |
348 | ARC_EXIT EV_Extension | 355 | ARC_EXIT EV_Extension |
349 | 356 | ||
357 | ;######################### System Call Tracing ######################### | ||
358 | |||
359 | tracesys: | ||
360 | ; save EFA in case tracer wants the PC of traced task | ||
361 | ; using ERET won't work since next-PC has already committed | ||
362 | lr r12, [efa] | ||
363 | GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11 | ||
364 | st r12, [r11, THREAD_FAULT_ADDR] | ||
365 | |||
366 | ; PRE Sys Call Ptrace hook | ||
367 | mov r0, sp ; pt_regs needed | ||
368 | bl @syscall_trace_entry | ||
369 | |||
370 | ; Tracing code now returns the syscall num (orig or modif) | ||
371 | mov r8, r0 | ||
372 | |||
373 | ; Do the Sys Call as we normally would. | ||
374 | ; Validate the Sys Call number | ||
375 | cmp r8, NR_syscalls | ||
376 | mov.hi r0, -ENOSYS | ||
377 | bhi tracesys_exit | ||
378 | |||
379 | ; Restore the sys-call args. Mere invocation of the hook abv could have | ||
380 | ; clobbered them (since they are in scratch regs). The tracer could also | ||
381 | ; have deliberately changed the syscall args: r0-r7 | ||
382 | ld r0, [sp, PT_r0] | ||
383 | ld r1, [sp, PT_r1] | ||
384 | ld r2, [sp, PT_r2] | ||
385 | ld r3, [sp, PT_r3] | ||
386 | ld r4, [sp, PT_r4] | ||
387 | ld r5, [sp, PT_r5] | ||
388 | ld r6, [sp, PT_r6] | ||
389 | ld r7, [sp, PT_r7] | ||
390 | ld.as r9, [sys_call_table, r8] | ||
391 | jl [r9] ; Entry into Sys Call Handler | ||
392 | |||
393 | tracesys_exit: | ||
394 | st r0, [sp, PT_r0] ; sys call return value in pt_regs | ||
395 | |||
396 | ;POST Sys Call Ptrace Hook | ||
397 | bl @syscall_trace_exit | ||
398 | b ret_from_exception ; NOT ret_from_system_call at is saves r0 which | ||
399 | ; we'd done before calling post hook above | ||
400 | |||
350 | ;################### Break Point TRAP ########################## | 401 | ;################### Break Point TRAP ########################## |
351 | 402 | ||
352 | ; ======= (5b) Trap is due to Break-Point ========= | 403 | ; ======= (5b) Trap is due to Break-Point ========= |
@@ -412,6 +463,11 @@ ARC_ENTRY EV_Trap | |||
412 | ; Before doing anything, return from CPU Exception Mode | 463 | ; Before doing anything, return from CPU Exception Mode |
413 | FAKE_RET_FROM_EXCPN r11 | 464 | FAKE_RET_FROM_EXCPN r11 |
414 | 465 | ||
466 | ; If syscall tracing ongoing, invoke pre-pos-hooks | ||
467 | GET_CURR_THR_INFO_FLAGS r10 | ||
468 | btst r10, TIF_SYSCALL_TRACE | ||
469 | bnz tracesys ; this never comes back | ||
470 | |||
415 | ;============ This is normal System Call case ========== | 471 | ;============ This is normal System Call case ========== |
416 | ; Sys-call num shd not exceed the total system calls avail | 472 | ; Sys-call num shd not exceed the total system calls avail |
417 | cmp r8, NR_syscalls | 473 | cmp r8, NR_syscalls |
@@ -608,6 +664,10 @@ ARC_ENTRY sys_fork_wrapper | |||
608 | bl @sys_fork | 664 | bl @sys_fork |
609 | DISCARD_CALLEE_SAVED_USER | 665 | DISCARD_CALLEE_SAVED_USER |
610 | 666 | ||
667 | GET_CURR_THR_INFO_FLAGS r10 | ||
668 | btst r10, TIF_SYSCALL_TRACE | ||
669 | bnz tracesys_exit | ||
670 | |||
611 | b ret_from_system_call | 671 | b ret_from_system_call |
612 | ARC_EXIT sys_fork_wrapper | 672 | ARC_EXIT sys_fork_wrapper |
613 | 673 | ||
@@ -616,6 +676,10 @@ ARC_ENTRY sys_vfork_wrapper | |||
616 | bl @sys_vfork | 676 | bl @sys_vfork |
617 | DISCARD_CALLEE_SAVED_USER | 677 | DISCARD_CALLEE_SAVED_USER |
618 | 678 | ||
679 | GET_CURR_THR_INFO_FLAGS r10 | ||
680 | btst r10, TIF_SYSCALL_TRACE | ||
681 | bnz tracesys_exit | ||
682 | |||
619 | b ret_from_system_call | 683 | b ret_from_system_call |
620 | ARC_EXIT sys_vfork_wrapper | 684 | ARC_EXIT sys_vfork_wrapper |
621 | 685 | ||
@@ -624,5 +688,9 @@ ARC_ENTRY sys_clone_wrapper | |||
624 | bl @sys_clone | 688 | bl @sys_clone |
625 | DISCARD_CALLEE_SAVED_USER | 689 | DISCARD_CALLEE_SAVED_USER |
626 | 690 | ||
691 | GET_CURR_THR_INFO_FLAGS r10 | ||
692 | btst r10, TIF_SYSCALL_TRACE | ||
693 | bnz tracesys_exit | ||
694 | |||
627 | b ret_from_system_call | 695 | b ret_from_system_call |
628 | ARC_EXIT sys_clone_wrapper | 696 | ARC_EXIT sys_clone_wrapper |