Heiko Carstens | 5d360a7 | 2008-12-25 13:38:56 +0100 | [diff] [blame] | 1 | /* |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 2 | * Copyright IBM Corp. 2008, 2009 |
Heiko Carstens | 5d360a7 | 2008-12-25 13:38:56 +0100 | [diff] [blame] | 3 | * |
| 4 | * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>, |
| 5 | * |
| 6 | */ |
| 7 | |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 8 | #include <linux/linkage.h> |
Heiko Carstens | cf08734 | 2009-03-18 13:27:34 +0100 | [diff] [blame] | 9 | #include <asm/asm-offsets.h> |
Heiko Carstens | aca9120 | 2013-05-13 14:48:52 +0200 | [diff] [blame] | 10 | #include <asm/ftrace.h> |
Heiko Carstens | 53255c9 | 2014-10-07 15:45:10 +0200 | [diff] [blame] | 11 | #include <asm/ptrace.h> |
Al Viro | 711f5df | 2016-01-12 13:30:03 -0500 | [diff] [blame] | 12 | #include <asm/export.h> |
Heiko Carstens | cf08734 | 2009-03-18 13:27:34 +0100 | [diff] [blame] | 13 | |
Martin Schwidefsky | 860dba4 | 2011-01-05 12:47:25 +0100 | [diff] [blame] | 14 | .section .kprobes.text, "ax" |
| 15 | |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 16 | ENTRY(ftrace_stub) |
Heiko Carstens | dfd9f7a | 2009-06-12 10:26:44 +0200 | [diff] [blame] | 17 | br %r14 |
| 18 | |
Heiko Carstens | 53255c9 | 2014-10-07 15:45:10 +0200 | [diff] [blame] | 19 | #define STACK_FRAME_SIZE (STACK_FRAME_OVERHEAD + __PT_SIZE) |
| 20 | #define STACK_PTREGS (STACK_FRAME_OVERHEAD) |
| 21 | #define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS) |
| 22 | #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW) |
| 23 | |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 24 | ENTRY(_mcount) |
Heiko Carstens | dfd9f7a | 2009-06-12 10:26:44 +0200 | [diff] [blame] | 25 | br %r14 |
| 26 | |
Al Viro | 711f5df | 2016-01-12 13:30:03 -0500 | [diff] [blame] | 27 | EXPORT_SYMBOL(_mcount) |
| 28 | |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 29 | ENTRY(ftrace_caller) |
Heiko Carstens | 53255c9 | 2014-10-07 15:45:10 +0200 | [diff] [blame] | 30 | .globl ftrace_regs_caller |
| 31 | .set ftrace_regs_caller,ftrace_caller |
| 32 | lgr %r1,%r15 |
Heiko Carstens | e6d60b3 | 2015-01-09 13:08:28 +0100 | [diff] [blame] | 33 | #ifndef CC_USING_HOTPATCH |
Heiko Carstens | c933146 | 2014-10-15 12:17:38 +0200 | [diff] [blame] | 34 | aghi %r0,MCOUNT_RETURN_FIXUP |
Heiko Carstens | e6d60b3 | 2015-01-09 13:08:28 +0100 | [diff] [blame] | 35 | #endif |
Heiko Carstens | 53255c9 | 2014-10-07 15:45:10 +0200 | [diff] [blame] | 36 | aghi %r15,-STACK_FRAME_SIZE |
| 37 | stg %r1,__SF_BACKCHAIN(%r15) |
| 38 | stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15) |
| 39 | stg %r0,(STACK_PTREGS_PSW+8)(%r15) |
| 40 | stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15) |
| 41 | #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES |
| 42 | aghik %r2,%r0,-MCOUNT_INSN_SIZE |
| 43 | lgrl %r4,function_trace_op |
| 44 | lgrl %r1,ftrace_trace_function |
| 45 | #else |
| 46 | lgr %r2,%r0 |
| 47 | aghi %r2,-MCOUNT_INSN_SIZE |
| 48 | larl %r4,function_trace_op |
| 49 | lg %r4,0(%r4) |
| 50 | larl %r1,ftrace_trace_function |
| 51 | lg %r1,0(%r1) |
Heiko Carstens | 88dbd20 | 2009-06-12 10:26:46 +0200 | [diff] [blame] | 52 | #endif |
Heiko Carstens | 53255c9 | 2014-10-07 15:45:10 +0200 | [diff] [blame] | 53 | lgr %r3,%r14 |
| 54 | la %r5,STACK_PTREGS(%r15) |
| 55 | basr %r14,%r1 |
| 56 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 57 | # The j instruction gets runtime patched to a nop instruction. |
Heiko Carstens | 0cccdda | 2014-10-08 10:03:08 +0200 | [diff] [blame] | 58 | # See ftrace_enable_ftrace_graph_caller. |
Heiko Carstens | 53255c9 | 2014-10-07 15:45:10 +0200 | [diff] [blame] | 59 | ENTRY(ftrace_graph_caller) |
| 60 | j ftrace_graph_caller_end |
| 61 | lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15) |
| 62 | lg %r3,(STACK_PTREGS_PSW+8)(%r15) |
| 63 | brasl %r14,prepare_ftrace_return |
| 64 | stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15) |
| 65 | ftrace_graph_caller_end: |
| 66 | .globl ftrace_graph_caller_end |
| 67 | #endif |
| 68 | lg %r1,(STACK_PTREGS_PSW+8)(%r15) |
| 69 | lmg %r2,%r15,(STACK_PTREGS_GPRS+2*8)(%r15) |
| 70 | br %r1 |
Heiko Carstens | dfd9f7a | 2009-06-12 10:26:44 +0200 | [diff] [blame] | 71 | |
Heiko Carstens | 88dbd20 | 2009-06-12 10:26:46 +0200 | [diff] [blame] | 72 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 73 | |
Jan Glauber | 144d634 | 2011-07-24 10:48:19 +0200 | [diff] [blame] | 74 | ENTRY(return_to_handler) |
Heiko Carstens | 53255c9 | 2014-10-07 15:45:10 +0200 | [diff] [blame] | 75 | stmg %r2,%r5,32(%r15) |
| 76 | lgr %r1,%r15 |
| 77 | aghi %r15,-STACK_FRAME_OVERHEAD |
| 78 | stg %r1,__SF_BACKCHAIN(%r15) |
| 79 | brasl %r14,ftrace_return_to_handler |
| 80 | aghi %r15,STACK_FRAME_OVERHEAD |
| 81 | lgr %r14,%r2 |
| 82 | lmg %r2,%r5,32(%r15) |
Heiko Carstens | 88dbd20 | 2009-06-12 10:26:46 +0200 | [diff] [blame] | 83 | br %r14 |
| 84 | |
Martin Schwidefsky | 6ac2a4d | 2009-09-11 10:28:33 +0200 | [diff] [blame] | 85 | #endif |