aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-09-19 00:50:42 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-10-14 03:53:56 -0400
commitc44fc770845163f8d9e573f37f92a7b7a7ade14e (patch)
treedac4327b1454b73cefe7ffb2ef28cc67ea878f2b /arch/x86
parent4d8289494a37e19cd7f3beacea9c957ad3debad6 (diff)
tracing: Move syscalls metadata handling from arch to core
Most of the syscalls metadata processing is done from arch. But these operations are mostly generic accross archs. Especially now that we have a common variable name that expresses the number of syscalls supported by an arch: NR_syscalls, the only remaining bits that need to reside in arch is the syscall nr to addr translation. v2: Compare syscalls symbols only after the "sys" prefix so that we avoid spurious mismatches with archs that have syscalls wrappers, in which case syscalls symbols have "SyS" prefixed aliases. (Reported by: Heiko Carstens) Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Li Zefan <lizf@cn.fujitsu.com> Cc: Masami Hiramatsu <mhiramat@redhat.com> Cc: Jason Baron <jbaron@redhat.com> Cc: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/ftrace.c76
1 files changed, 2 insertions, 74 deletions
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
473extern unsigned long __start_syscalls_metadata[];
474extern unsigned long __stop_syscalls_metadata[];
475extern unsigned long *sys_call_table; 473extern unsigned long *sys_call_table;
476 474
477static struct syscall_metadata **syscalls_metadata; 475unsigned long __init arch_syscall_addr(int nr)
478
479static 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
497struct 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
505int 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
521void set_syscall_enter_id(int num, int id)
522{
523 syscalls_metadata[num]->enter_id = id;
524}
525
526void 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
531static 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}
550arch_initcall(arch_init_ftrace_syscalls);
551#endif 479#endif