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/nospec-insn.h>
13 #include <asm/ptrace.h>
14 #include <asm/export.h>
19 .section .kprobes.text, "ax"
25 #define STACK_FRAME_SIZE (STACK_FRAME_OVERHEAD + __PT_SIZE)
26 #define STACK_PTREGS (STACK_FRAME_OVERHEAD)
27 #define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS)
28 #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW)
33 EXPORT_SYMBOL(_mcount)
36 .globl ftrace_regs_caller
37 .set ftrace_regs_caller,ftrace_caller
39 #if !(defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT))
40 aghi %r0,MCOUNT_RETURN_FIXUP
42 aghi %r15,-STACK_FRAME_SIZE
43 stg %r1,__SF_BACKCHAIN(%r15)
44 stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15)
45 stg %r0,(STACK_PTREGS_PSW+8)(%r15)
46 stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15)
47 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
48 aghik %r2,%r0,-MCOUNT_INSN_SIZE
49 lgrl %r4,function_trace_op
50 lgrl %r1,ftrace_trace_function
53 aghi %r2,-MCOUNT_INSN_SIZE
54 larl %r4,function_trace_op
56 larl %r1,ftrace_trace_function
60 la %r5,STACK_PTREGS(%r15)
62 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
63 # The j instruction gets runtime patched to a nop instruction.
64 # See ftrace_enable_ftrace_graph_caller.
65 .globl ftrace_graph_caller
67 j ftrace_graph_caller_end
68 lmg %r2,%r3,(STACK_PTREGS_GPRS+14*8)(%r15)
69 lg %r4,(STACK_PTREGS_PSW+8)(%r15)
70 brasl %r14,prepare_ftrace_return
71 stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
72 ftrace_graph_caller_end:
73 .globl ftrace_graph_caller_end
75 lg %r1,(STACK_PTREGS_PSW+8)(%r15)
76 lmg %r2,%r15,(STACK_PTREGS_GPRS+2*8)(%r15)
78 ENDPROC(ftrace_caller)
80 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
82 ENTRY(return_to_handler)
85 aghi %r15,-STACK_FRAME_OVERHEAD
86 stg %r1,__SF_BACKCHAIN(%r15)
87 brasl %r14,ftrace_return_to_handler
88 aghi %r15,STACK_FRAME_OVERHEAD
92 ENDPROC(return_to_handler)