xref: /openbmc/linux/arch/s390/kernel/mcount.S (revision 62e7ca52)
1/*
2 * Copyright IBM Corp. 2008, 2009
3 *
4 *   Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
5 *
6 */
7
8#include <linux/linkage.h>
9#include <asm/asm-offsets.h>
10#include <asm/ftrace.h>
11
12	.section .kprobes.text, "ax"
13
14ENTRY(ftrace_stub)
15	br	%r14
16
17ENTRY(_mcount)
18#ifdef CONFIG_DYNAMIC_FTRACE
19	br	%r14
20
21ENTRY(ftrace_caller)
22#endif
23	stm	%r2,%r5,16(%r15)
24	bras	%r1,1f
250:	.long	ftrace_trace_function
261:	st	%r14,56(%r15)
27	lr	%r0,%r15
28	ahi	%r15,-96
29	l	%r3,100(%r15)
30	la	%r2,0(%r14)
31	st	%r0,__SF_BACKCHAIN(%r15)
32	la	%r3,0(%r3)
33	ahi	%r2,-MCOUNT_INSN_SIZE
34	l	%r14,0b-0b(%r1)
35	l	%r14,0(%r14)
36	basr	%r14,%r14
37#ifdef CONFIG_FUNCTION_GRAPH_TRACER
38	l	%r2,100(%r15)
39	l	%r3,152(%r15)
40ENTRY(ftrace_graph_caller)
41# The bras instruction gets runtime patched to call prepare_ftrace_return.
42# See ftrace_enable_ftrace_graph_caller. The patched instruction is:
43#	bras	%r14,prepare_ftrace_return
44	bras	%r14,0f
450:	st	%r2,100(%r15)
46#endif
47	ahi	%r15,96
48	l	%r14,56(%r15)
49	lm	%r2,%r5,16(%r15)
50	br	%r14
51
52#ifdef CONFIG_FUNCTION_GRAPH_TRACER
53
54ENTRY(return_to_handler)
55	stm	%r2,%r5,16(%r15)
56	st	%r14,56(%r15)
57	lr	%r0,%r15
58	ahi	%r15,-96
59	st	%r0,__SF_BACKCHAIN(%r15)
60	bras	%r1,0f
61	.long	ftrace_return_to_handler
620:	l	%r2,0b-0b(%r1)
63	basr	%r14,%r2
64	lr	%r14,%r2
65	ahi	%r15,96
66	lm	%r2,%r5,16(%r15)
67	br	%r14
68
69#endif
70