File tree Expand file tree Collapse file tree 6 files changed +123
-0
lines changed Expand file tree Collapse file tree 6 files changed +123
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ config CSKY
38
38
select HAVE_ARCH_AUDITSYSCALL
39
39
select HAVE_COPY_THREAD_TLS
40
40
select HAVE_DYNAMIC_FTRACE
41
+ select HAVE_DYNAMIC_FTRACE_WITH_REGS
41
42
select HAVE_FUNCTION_TRACER
42
43
select HAVE_FUNCTION_GRAPH_TRACER
43
44
select HAVE_FTRACE_MCOUNT_RECORD
Original file line number Diff line number Diff line change 100
100
rte
101
101
.endm
102
102
103
+ .macro SAVE_REGS_FTRACE
104
+ subi sp , 152
105
+ stw tls , (sp , 0 )
106
+ stw lr , (sp , 4 )
107
+
108
+ mfcr lr , psr
109
+ stw lr , (sp , 12 )
110
+
111
+ addi lr , sp , 152
112
+ stw lr , (sp , 16 )
113
+
114
+ stw a0 , (sp , 20 )
115
+ stw a0 , (sp , 24 )
116
+ stw a1 , (sp , 28 )
117
+ stw a2 , (sp , 32 )
118
+ stw a3 , (sp , 36 )
119
+
120
+ addi sp , 40
121
+ stm r4 - r13 , (sp )
122
+
123
+ addi sp , 40
124
+ stm r16 - r30 , (sp )
125
+ #ifdef CONFIG_CPU_HAS_HILO
126
+ mfhi lr
127
+ stw lr , (sp , 60 )
128
+ mflo lr
129
+ stw lr , (sp , 64 )
130
+ mfcr lr , cr14
131
+ stw lr , (sp , 68 )
132
+ #endif
133
+ subi sp , 80
134
+ .endm
135
+
136
+ .macro RESTORE_REGS_FTRACE
137
+ ldw tls , (sp , 0 )
138
+ ldw a0 , (sp , 16 )
139
+ mtcr a0 , ss0
140
+
141
+ #ifdef CONFIG_CPU_HAS_HILO
142
+ ldw a0 , (sp , 140 )
143
+ mthi a0
144
+ ldw a0 , (sp , 144 )
145
+ mtlo a0
146
+ ldw a0 , (sp , 148 )
147
+ mtcr a0 , cr14
148
+ #endif
149
+
150
+ ldw a0 , (sp , 24 )
151
+ ldw a1 , (sp , 28 )
152
+ ldw a2 , (sp , 32 )
153
+ ldw a3 , (sp , 36 )
154
+
155
+ addi sp , 40
156
+ ldm r4 - r13 , (sp )
157
+ addi sp , 40
158
+ ldm r16 - r30 , (sp )
159
+ addi sp , 72
160
+ mfcr sp , ss0
161
+ .endm
162
+
103
163
.macro SAVE_SWITCH_STACK
104
164
subi sp , 64
105
165
stm r4 - r11 , (sp )
Original file line number Diff line number Diff line change 3
3
4
4
#include <linux/linkage.h>
5
5
#include <asm/ftrace.h>
6
+ #include <abi/entry.h>
7
+ #include <asm/asm - offsets.h>
6
8
7
9
/ *
8
10
* csky - gcc with - pg will put the following asm after prologue:
44
46
jmp t1
45
47
.endm
46
48
49
+ .macro mcount_enter_regs
50
+ subi sp , 8
51
+ stw lr , ( sp , 0 )
52
+ stw r8 , ( sp , 4 )
53
+ SAVE_REGS_FTRACE
54
+ .endm
55
+
56
+ .macro mcount_exit_regs
57
+ RESTORE_REGS_FTRACE
58
+ ldw t1 , ( sp , 0 )
59
+ ldw r8 , ( sp , 4 )
60
+ ldw lr , ( sp , 8 )
61
+ addi sp , 12
62
+ jmp t1
63
+ .endm
64
+
47
65
.macro save_return_regs
48
66
subi sp , 16
49
67
stw a0 , ( sp , 0 )
@@ -122,6 +140,8 @@ ENTRY(ftrace_caller)
122
140
ldw a0 , ( sp , 16 )
123
141
subi a0 , 4
124
142
ldw a1 , ( sp , 24 )
143
+ lrw a2 , function_trace_op
144
+ ldw a2 , (a2 , 0 )
125
145
126
146
nop
127
147
GLOBAL (ftrace_call)
@@ -157,3 +177,31 @@ ENTRY(return_to_handler)
157
177
jmp lr
158
178
END(return_to_handler)
159
179
#endif
180
+
181
+ #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
182
+ ENTRY(ftrace_regs_caller)
183
+ mcount_enter_regs
184
+
185
+ lrw t1 , PT_FRAME_SIZE
186
+ add t1 , sp
187
+
188
+ ldw a0 , (t1 , 0 )
189
+ subi a0 , 4
190
+ ldw a1 , (t1 , 8 )
191
+ lrw a2 , function_trace_op
192
+ ldw a2 , (a2 , 0 )
193
+ mov a3 , sp
194
+
195
+ nop
196
+ GLOBAL (ftrace_regs_call)
197
+ nop32_stub
198
+
199
+ #ifdef CONFIG_FUNCTION_GRAPH_TRACER
200
+ nop
201
+ GLOBAL (ftrace_graph_regs_call)
202
+ nop32_stub
203
+ #endif
204
+
205
+ mcount_exit_regs
206
+ ENDPROC(ftrace_regs_caller)
207
+ #endif / * CONFIG_DYNAMIC_FTRACE * /
Original file line number Diff line number Diff line change 10
10
11
11
#define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
12
12
13
+ #define ARCH_SUPPORTS_FTRACE_OPS 1
14
+
13
15
#define MCOUNT_ADDR ((unsigned long)_mcount)
14
16
15
17
#ifndef __ASSEMBLY__
Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ int main(void)
72
72
DEFINE (PT_RLO , offsetof(struct pt_regs , rlo ));
73
73
#endif
74
74
DEFINE (PT_USP , offsetof(struct pt_regs , usp ));
75
+ DEFINE (PT_FRAME_SIZE , sizeof (struct pt_regs ));
75
76
76
77
/* offsets into the irq_cpustat_t struct */
77
78
DEFINE (CPUSTAT_SOFTIRQ_PENDING , offsetof(irq_cpustat_t ,
Original file line number Diff line number Diff line change @@ -126,6 +126,9 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
126
126
{
127
127
int ret = ftrace_modify_code ((unsigned long )& ftrace_call ,
128
128
(unsigned long )func , true, true);
129
+ if (!ret )
130
+ ret = ftrace_modify_code ((unsigned long )& ftrace_regs_call ,
131
+ (unsigned long )func , true, true);
129
132
return ret ;
130
133
}
131
134
@@ -135,6 +138,14 @@ int __init ftrace_dyn_arch_init(void)
135
138
}
136
139
#endif /* CONFIG_DYNAMIC_FTRACE */
137
140
141
+ #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
142
+ int ftrace_modify_call (struct dyn_ftrace * rec , unsigned long old_addr ,
143
+ unsigned long addr )
144
+ {
145
+ return ftrace_modify_code (rec -> ip , addr , true, true);
146
+ }
147
+ #endif
148
+
138
149
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
139
150
void prepare_ftrace_return (unsigned long * parent , unsigned long self_addr ,
140
151
unsigned long frame_pointer )
You can’t perform that action at this time.
0 commit comments