xref: /openbmc/linux/arch/s390/kernel/mcount.S (revision ee89bd6b)
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,2f
250:	.long	ftrace_trace_function
261:	.long	function_trace_stop
272:	l	%r2,1b-0b(%r1)
28	icm	%r2,0xf,0(%r2)
29	jnz	3f
30	st	%r14,56(%r15)
31	lr	%r0,%r15
32	ahi	%r15,-96
33	l	%r3,100(%r15)
34	la	%r2,0(%r14)
35	st	%r0,__SF_BACKCHAIN(%r15)
36	la	%r3,0(%r3)
37	ahi	%r2,-MCOUNT_INSN_SIZE
38	l	%r14,0b-0b(%r1)
39	l	%r14,0(%r14)
40	basr	%r14,%r14
41#ifdef CONFIG_FUNCTION_GRAPH_TRACER
42	l	%r2,100(%r15)
43	l	%r3,152(%r15)
44ENTRY(ftrace_graph_caller)
45# The bras instruction gets runtime patched to call prepare_ftrace_return.
46# See ftrace_enable_ftrace_graph_caller. The patched instruction is:
47#	bras	%r14,prepare_ftrace_return
48	bras	%r14,0f
490:	st	%r2,100(%r15)
50#endif
51	ahi	%r15,96
52	l	%r14,56(%r15)
533:	lm	%r2,%r5,16(%r15)
54	br	%r14
55
56#ifdef CONFIG_FUNCTION_GRAPH_TRACER
57
58ENTRY(return_to_handler)
59	stm	%r2,%r5,16(%r15)
60	st	%r14,56(%r15)
61	lr	%r0,%r15
62	ahi	%r15,-96
63	st	%r0,__SF_BACKCHAIN(%r15)
64	bras	%r1,0f
65	.long	ftrace_return_to_handler
660:	l	%r2,0b-0b(%r1)
67	basr	%r14,%r2
68	lr	%r14,%r2
69	ahi	%r15,96
70	lm	%r2,%r5,16(%r15)
71	br	%r14
72
73#endif
74