diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/s390/kernel/ftrace.c | 67 | ||||
-rw-r--r-- | arch/x86/kernel/ftrace.c | 76 |
2 files changed, 4 insertions, 139 deletions
diff --git a/arch/s390/kernel/ftrace.c b/arch/s390/kernel/ftrace.c index 57bdcb1e3cdf..7c5752c3423d 100644 --- a/arch/s390/kernel/ftrace.c +++ b/arch/s390/kernel/ftrace.c | |||
@@ -206,73 +206,10 @@ out: | |||
206 | 206 | ||
207 | #ifdef CONFIG_FTRACE_SYSCALLS | 207 | #ifdef CONFIG_FTRACE_SYSCALLS |
208 | 208 | ||
209 | extern unsigned long __start_syscalls_metadata[]; | ||
210 | extern unsigned long __stop_syscalls_metadata[]; | ||
211 | extern unsigned int sys_call_table[]; | 209 | extern unsigned int sys_call_table[]; |
212 | 210 | ||
213 | static struct syscall_metadata **syscalls_metadata; | 211 | unsigned long __init arch_syscall_addr(int nr) |
214 | |||
215 | struct syscall_metadata *syscall_nr_to_meta(int nr) | ||
216 | { | ||
217 | if (!syscalls_metadata || nr >= NR_syscalls || nr < 0) | ||
218 | return NULL; | ||
219 | |||
220 | return syscalls_metadata[nr]; | ||
221 | } | ||
222 | |||
223 | int syscall_name_to_nr(char *name) | ||
224 | { | ||
225 | int i; | ||
226 | |||
227 | if (!syscalls_metadata) | ||
228 | return -1; | ||
229 | for (i = 0; i < NR_syscalls; i++) | ||
230 | if (syscalls_metadata[i]) | ||
231 | if (!strcmp(syscalls_metadata[i]->name, name)) | ||
232 | return i; | ||
233 | return -1; | ||
234 | } | ||
235 | |||
236 | void set_syscall_enter_id(int num, int id) | ||
237 | { | ||
238 | syscalls_metadata[num]->enter_id = id; | ||
239 | } | ||
240 | |||
241 | void set_syscall_exit_id(int num, int id) | ||
242 | { | 212 | { |
243 | syscalls_metadata[num]->exit_id = id; | 213 | return (unsigned long)sys_call_table[nr]; |
244 | } | ||
245 | |||
246 | static struct syscall_metadata *find_syscall_meta(unsigned long syscall) | ||
247 | { | ||
248 | struct syscall_metadata *start; | ||
249 | struct syscall_metadata *stop; | ||
250 | char str[KSYM_SYMBOL_LEN]; | ||
251 | |||
252 | start = (struct syscall_metadata *)__start_syscalls_metadata; | ||
253 | stop = (struct syscall_metadata *)__stop_syscalls_metadata; | ||
254 | kallsyms_lookup(syscall, NULL, NULL, NULL, str); | ||
255 | |||
256 | for ( ; start < stop; start++) { | ||
257 | if (start->name && !strcmp(start->name + 3, str + 3)) | ||
258 | return start; | ||
259 | } | ||
260 | return NULL; | ||
261 | } | ||
262 | |||
263 | static int __init arch_init_ftrace_syscalls(void) | ||
264 | { | ||
265 | struct syscall_metadata *meta; | ||
266 | int i; | ||
267 | syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * NR_syscalls, | ||
268 | GFP_KERNEL); | ||
269 | if (!syscalls_metadata) | ||
270 | return -ENOMEM; | ||
271 | for (i = 0; i < NR_syscalls; i++) { | ||
272 | meta = find_syscall_meta((unsigned long)sys_call_table[i]); | ||
273 | syscalls_metadata[i] = meta; | ||
274 | } | ||
275 | return 0; | ||
276 | } | 214 | } |
277 | arch_initcall(arch_init_ftrace_syscalls); | ||
278 | #endif | 215 | #endif |
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 25e6f5fc4b1e..5a1b9758fd62 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c | |||
@@ -470,82 +470,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, | |||
470 | 470 | ||
471 | #ifdef CONFIG_FTRACE_SYSCALLS | 471 | #ifdef CONFIG_FTRACE_SYSCALLS |
472 | 472 | ||
473 | extern unsigned long __start_syscalls_metadata[]; | ||
474 | extern unsigned long __stop_syscalls_metadata[]; | ||
475 | extern unsigned long *sys_call_table; | 473 | extern unsigned long *sys_call_table; |
476 | 474 | ||
477 | static struct syscall_metadata **syscalls_metadata; | 475 | unsigned long __init arch_syscall_addr(int nr) |
478 | |||
479 | static struct syscall_metadata *find_syscall_meta(unsigned long *syscall) | ||
480 | { | ||
481 | struct syscall_metadata *start; | ||
482 | struct syscall_metadata *stop; | ||
483 | char str[KSYM_SYMBOL_LEN]; | ||
484 | |||
485 | |||
486 | start = (struct syscall_metadata *)__start_syscalls_metadata; | ||
487 | stop = (struct syscall_metadata *)__stop_syscalls_metadata; | ||
488 | kallsyms_lookup((unsigned long) syscall, NULL, NULL, NULL, str); | ||
489 | |||
490 | for ( ; start < stop; start++) { | ||
491 | if (start->name && !strcmp(start->name, str)) | ||
492 | return start; | ||
493 | } | ||
494 | return NULL; | ||
495 | } | ||
496 | |||
497 | struct syscall_metadata *syscall_nr_to_meta(int nr) | ||
498 | { | ||
499 | if (!syscalls_metadata || nr >= NR_syscalls || nr < 0) | ||
500 | return NULL; | ||
501 | |||
502 | return syscalls_metadata[nr]; | ||
503 | } | ||
504 | |||
505 | int syscall_name_to_nr(char *name) | ||
506 | { | ||
507 | int i; | ||
508 | |||
509 | if (!syscalls_metadata) | ||
510 | return -1; | ||
511 | |||
512 | for (i = 0; i < NR_syscalls; i++) { | ||
513 | if (syscalls_metadata[i]) { | ||
514 | if (!strcmp(syscalls_metadata[i]->name, name)) | ||
515 | return i; | ||
516 | } | ||
517 | } | ||
518 | return -1; | ||
519 | } | ||
520 | |||
521 | void set_syscall_enter_id(int num, int id) | ||
522 | { | ||
523 | syscalls_metadata[num]->enter_id = id; | ||
524 | } | ||
525 | |||
526 | void set_syscall_exit_id(int num, int id) | ||
527 | { | 476 | { |
528 | syscalls_metadata[num]->exit_id = id; | 477 | return (unsigned long)(&sys_call_table)[nr]; |
529 | } | ||
530 | |||
531 | static int __init arch_init_ftrace_syscalls(void) | ||
532 | { | ||
533 | int i; | ||
534 | struct syscall_metadata *meta; | ||
535 | unsigned long **psys_syscall_table = &sys_call_table; | ||
536 | |||
537 | syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) * | ||
538 | NR_syscalls, GFP_KERNEL); | ||
539 | if (!syscalls_metadata) { | ||
540 | WARN_ON(1); | ||
541 | return -ENOMEM; | ||
542 | } | ||
543 | |||
544 | for (i = 0; i < NR_syscalls; i++) { | ||
545 | meta = find_syscall_meta(psys_syscall_table[i]); | ||
546 | syscalls_metadata[i] = meta; | ||
547 | } | ||
548 | return 0; | ||
549 | } | 478 | } |
550 | arch_initcall(arch_init_ftrace_syscalls); | ||
551 | #endif | 479 | #endif |