1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright IBM Corp. 2008, 2009
5 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
9 #include <linux/linkage.h>
10 #include <asm/asm-offsets.h>
11 #include <asm/ftrace.h>
12 #include <asm/ptrace.h>
13 #include <asm/export.h>
15 .section .kprobes.text, "ax"
20 #define STACK_FRAME_SIZE (STACK_FRAME_OVERHEAD + __PT_SIZE)
21 #define STACK_PTREGS (STACK_FRAME_OVERHEAD)
22 #define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS)
23 #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW)
28 EXPORT_SYMBOL(_mcount)
31 .globl ftrace_regs_caller
32 .set ftrace_regs_caller,ftrace_caller
34 #ifndef CC_USING_HOTPATCH
35 aghi %r0,MCOUNT_RETURN_FIXUP
37 aghi %r15,-STACK_FRAME_SIZE
38 stg %r1,__SF_BACKCHAIN(%r15)
39 stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15)
40 stg %r0,(STACK_PTREGS_PSW+8)(%r15)
41 stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15)
42 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
43 aghik %r2,%r0,-MCOUNT_INSN_SIZE
44 lgrl %r4,function_trace_op
45 lgrl %r1,ftrace_trace_function
48 aghi %r2,-MCOUNT_INSN_SIZE
49 larl %r4,function_trace_op
51 larl %r1,ftrace_trace_function
55 la %r5,STACK_PTREGS(%r15)
57 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
58 # The j instruction gets runtime patched to a nop instruction.
59 # See ftrace_enable_ftrace_graph_caller.
60 ENTRY(ftrace_graph_caller)
61 j ftrace_graph_caller_end
62 lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
63 lg %r3,(STACK_PTREGS_PSW+8)(%r15)
64 brasl %r14,prepare_ftrace_return
65 stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
66 ftrace_graph_caller_end:
67 .globl ftrace_graph_caller_end
69 lg %r1,(STACK_PTREGS_PSW+8)(%r15)
70 lmg %r2,%r15,(STACK_PTREGS_GPRS+2*8)(%r15)
73 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
75 ENTRY(return_to_handler)
78 aghi %r15,-STACK_FRAME_OVERHEAD
79 stg %r1,__SF_BACKCHAIN(%r15)
80 brasl %r14,ftrace_return_to_handler
81 aghi %r15,STACK_FRAME_OVERHEAD