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"
24 #define STACK_FRAME_SIZE (STACK_FRAME_OVERHEAD + __PT_SIZE)
25 #define STACK_PTREGS (STACK_FRAME_OVERHEAD)
26 #define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS)
27 #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW)
32 EXPORT_SYMBOL(_mcount)
35 .globl ftrace_regs_caller
36 .set ftrace_regs_caller,ftrace_caller
38 #ifndef CC_USING_HOTPATCH
39 aghi %r0,MCOUNT_RETURN_FIXUP
41 aghi %r15,-STACK_FRAME_SIZE
42 stg %r1,__SF_BACKCHAIN(%r15)
43 stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15)
44 stg %r0,(STACK_PTREGS_PSW+8)(%r15)
45 stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15)
46 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
47 aghik %r2,%r0,-MCOUNT_INSN_SIZE
48 lgrl %r4,function_trace_op
49 lgrl %r1,ftrace_trace_function
52 aghi %r2,-MCOUNT_INSN_SIZE
53 larl %r4,function_trace_op
55 larl %r1,ftrace_trace_function
59 la %r5,STACK_PTREGS(%r15)
61 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
62 # The j instruction gets runtime patched to a nop instruction.
63 # See ftrace_enable_ftrace_graph_caller.
64 ENTRY(ftrace_graph_caller)
65 j ftrace_graph_caller_end
66 lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
67 lg %r3,(STACK_PTREGS_PSW+8)(%r15)
68 brasl %r14,prepare_ftrace_return
69 stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
70 ftrace_graph_caller_end:
71 .globl ftrace_graph_caller_end
73 lg %r1,(STACK_PTREGS_PSW+8)(%r15)
74 lmg %r2,%r15,(STACK_PTREGS_GPRS+2*8)(%r15)
77 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79 ENTRY(return_to_handler)
82 aghi %r15,-STACK_FRAME_OVERHEAD
83 stg %r1,__SF_BACKCHAIN(%r15)
84 brasl %r14,ftrace_return_to_handler
85 aghi %r15,STACK_FRAME_OVERHEAD