blob: e499370fbccb328561e6ef5ab0bfe35afb4a0b51 [file] [log] [blame]
Heiko Carstens5d360a72008-12-25 13:38:56 +01001/*
Heiko Carstensa53c8fa2012-07-20 11:15:04 +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
Jan Glauber144d6342011-07-24 10:48:19 +02008#include <linux/linkage.h>
Heiko Carstenscf087342009-03-18 13:27:34 +01009#include <asm/asm-offsets.h>
Heiko Carstensaca91202013-05-13 14:48:52 +020010#include <asm/ftrace.h>
Heiko Carstens53255c92014-10-07 15:45:10 +020011#include <asm/ptrace.h>
Heiko Carstenscf087342009-03-18 13:27:34 +010012
Martin Schwidefsky860dba42011-01-05 12:47:25 +010013 .section .kprobes.text, "ax"
14
Jan Glauber144d6342011-07-24 10:48:19 +020015ENTRY(ftrace_stub)
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020016 br %r14
17
Heiko Carstens53255c92014-10-07 15:45:10 +020018#define STACK_FRAME_SIZE (STACK_FRAME_OVERHEAD + __PT_SIZE)
19#define STACK_PTREGS (STACK_FRAME_OVERHEAD)
20#define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS)
21#define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW)
22
Jan Glauber144d6342011-07-24 10:48:19 +020023ENTRY(_mcount)
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020024 br %r14
25
Jan Glauber144d6342011-07-24 10:48:19 +020026ENTRY(ftrace_caller)
Heiko Carstens53255c92014-10-07 15:45:10 +020027 .globl ftrace_regs_caller
28 .set ftrace_regs_caller,ftrace_caller
29 lgr %r1,%r15
Heiko Carstense6d60b32015-01-09 13:08:28 +010030#ifndef CC_USING_HOTPATCH
Heiko Carstensc9331462014-10-15 12:17:38 +020031 aghi %r0,MCOUNT_RETURN_FIXUP
Heiko Carstense6d60b32015-01-09 13:08:28 +010032#endif
Heiko Carstens53255c92014-10-07 15:45:10 +020033 aghi %r15,-STACK_FRAME_SIZE
34 stg %r1,__SF_BACKCHAIN(%r15)
35 stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15)
36 stg %r0,(STACK_PTREGS_PSW+8)(%r15)
37 stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15)
38#ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
39 aghik %r2,%r0,-MCOUNT_INSN_SIZE
40 lgrl %r4,function_trace_op
41 lgrl %r1,ftrace_trace_function
42#else
43 lgr %r2,%r0
44 aghi %r2,-MCOUNT_INSN_SIZE
45 larl %r4,function_trace_op
46 lg %r4,0(%r4)
47 larl %r1,ftrace_trace_function
48 lg %r1,0(%r1)
Heiko Carstens88dbd202009-06-12 10:26:46 +020049#endif
Heiko Carstens53255c92014-10-07 15:45:10 +020050 lgr %r3,%r14
51 la %r5,STACK_PTREGS(%r15)
52 basr %r14,%r1
53#ifdef CONFIG_FUNCTION_GRAPH_TRACER
54# The j instruction gets runtime patched to a nop instruction.
Heiko Carstens0cccdda2014-10-08 10:03:08 +020055# See ftrace_enable_ftrace_graph_caller.
Heiko Carstens53255c92014-10-07 15:45:10 +020056ENTRY(ftrace_graph_caller)
57 j ftrace_graph_caller_end
58 lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
59 lg %r3,(STACK_PTREGS_PSW+8)(%r15)
60 brasl %r14,prepare_ftrace_return
61 stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
62ftrace_graph_caller_end:
63 .globl ftrace_graph_caller_end
64#endif
65 lg %r1,(STACK_PTREGS_PSW+8)(%r15)
66 lmg %r2,%r15,(STACK_PTREGS_GPRS+2*8)(%r15)
67 br %r1
Heiko Carstensdfd9f7a2009-06-12 10:26:44 +020068
Heiko Carstens88dbd202009-06-12 10:26:46 +020069#ifdef CONFIG_FUNCTION_GRAPH_TRACER
70
Jan Glauber144d6342011-07-24 10:48:19 +020071ENTRY(return_to_handler)
Heiko Carstens53255c92014-10-07 15:45:10 +020072 stmg %r2,%r5,32(%r15)
73 lgr %r1,%r15
74 aghi %r15,-STACK_FRAME_OVERHEAD
75 stg %r1,__SF_BACKCHAIN(%r15)
76 brasl %r14,ftrace_return_to_handler
77 aghi %r15,STACK_FRAME_OVERHEAD
78 lgr %r14,%r2
79 lmg %r2,%r5,32(%r15)
Heiko Carstens88dbd202009-06-12 10:26:46 +020080 br %r14
81
Martin Schwidefsky6ac2a4d2009-09-11 10:28:33 +020082#endif