blob: 1e6a557956283bfdae25afb7247e54b0c2ea91e5 [file] [log] [blame]
Heiko Carstens5d360a72008-12-25 13:38:56 +01001/*
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +02002 * Copyright IBM Corp. 2008,2009
Heiko Carstens5d360a72008-12-25 13:38:56 +01003 *
4 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
5 *
6 */
7
Heiko Carstenscf087342009-03-18 13:27:34 +01008#include <asm/asm-offsets.h>
9
Martin Schwidefsky860dba42011-01-05 12:47:25 +010010 .section .kprobes.text, "ax"
11
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020012 .globl ftrace_stub
13ftrace_stub:
14 br %r14
15
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020016 .globl _mcount
Heiko Carstens5d360a72008-12-25 13:38:56 +010017_mcount:
Martin Schwidefsky6ac2a4d2009-09-11 10:28:33 +020018#ifdef CONFIG_DYNAMIC_FTRACE
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020019 br %r14
20
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020021 .globl ftrace_caller
22ftrace_caller:
Martin Schwidefsky6ac2a4d2009-09-11 10:28:33 +020023#endif
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020024 stm %r2,%r5,16(%r15)
Heiko Carstens8b4488f2009-06-12 10:26:45 +020025 bras %r1,2f
260: .long ftrace_trace_function
271: .long function_trace_stop
282: l %r2,1b-0b(%r1)
29 icm %r2,0xf,0(%r2)
30 jnz 3f
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020031 st %r14,56(%r15)
Heiko Carstens8b4488f2009-06-12 10:26:45 +020032 lr %r0,%r15
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020033 ahi %r15,-96
34 l %r3,100(%r15)
35 la %r2,0(%r14)
Heiko Carstens8b4488f2009-06-12 10:26:45 +020036 st %r0,__SF_BACKCHAIN(%r15)
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020037 la %r3,0(%r3)
Heiko Carstens8b4488f2009-06-12 10:26:45 +020038 l %r14,0b-0b(%r1)
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020039 l %r14,0(%r14)
40 basr %r14,%r14
Heiko Carstens88dbd202009-06-12 10:26:46 +020041#ifdef CONFIG_FUNCTION_GRAPH_TRACER
Martin Schwidefsky4cc9bed2011-01-05 12:48:11 +010042 l %r2,100(%r15)
43 l %r3,152(%r15)
Heiko Carstens88dbd202009-06-12 10:26:46 +020044 .globl ftrace_graph_caller
45ftrace_graph_caller:
Martin Schwidefsky4cc9bed2011-01-05 12:48:11 +010046# The bras instruction gets runtime patched to call prepare_ftrace_return.
47# See ftrace_enable_ftrace_graph_caller. The patched instruction is:
48# bras %r14,prepare_ftrace_return
49 bras %r14,0f
500: st %r2,100(%r15)
Heiko Carstens88dbd202009-06-12 10:26:46 +020051#endif
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020052 ahi %r15,96
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020053 l %r14,56(%r15)
Heiko Carstens8b4488f2009-06-12 10:26:45 +0200543: lm %r2,%r5,16(%r15)
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020055 br %r14
56
Heiko Carstens88dbd202009-06-12 10:26:46 +020057#ifdef CONFIG_FUNCTION_GRAPH_TRACER
58
59 .globl return_to_handler
60return_to_handler:
61 stm %r2,%r5,16(%r15)
62 st %r14,56(%r15)
63 lr %r0,%r15
64 ahi %r15,-96
65 st %r0,__SF_BACKCHAIN(%r15)
66 bras %r1,0f
67 .long ftrace_return_to_handler
680: l %r2,0b-0b(%r1)
69 basr %r14,%r2
70 lr %r14,%r2
71 ahi %r15,96
72 lm %r2,%r5,16(%r15)
73 br %r14
74
Martin Schwidefsky6ac2a4d2009-09-11 10:28:33 +020075#endif