diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/ftrace.h | 14 | ||||
-rw-r--r-- | include/linux/syscalls.h | 60 |
2 files changed, 69 insertions, 5 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index c146c1021a29..6dc1c652447e 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -506,13 +506,21 @@ static inline void trace_hw_branch_oops(void) {} | |||
506 | /* | 506 | /* |
507 | * A syscall entry in the ftrace syscalls array. | 507 | * A syscall entry in the ftrace syscalls array. |
508 | * | 508 | * |
509 | * @syscall_nr: syscall number | 509 | * @name: name of the syscall |
510 | * @nb_args: number of parameters it takes | ||
511 | * @types: list of types as strings | ||
512 | * @args: list of args as strings (args[i] matches types[i]) | ||
510 | */ | 513 | */ |
511 | struct syscall_trace_entry { | 514 | struct syscall_metadata { |
512 | int syscall_nr; | 515 | const char *name; |
516 | int nb_args; | ||
517 | const char **types; | ||
518 | const char **args; | ||
513 | }; | 519 | }; |
514 | 520 | ||
515 | #ifdef CONFIG_FTRACE_SYSCALLS | 521 | #ifdef CONFIG_FTRACE_SYSCALLS |
522 | extern void arch_init_ftrace_syscalls(void); | ||
523 | extern struct syscall_metadata *syscall_nr_to_meta(int nr); | ||
516 | extern void start_ftrace_syscalls(void); | 524 | extern void start_ftrace_syscalls(void); |
517 | extern void stop_ftrace_syscalls(void); | 525 | extern void stop_ftrace_syscalls(void); |
518 | extern void ftrace_syscall_enter(struct pt_regs *regs); | 526 | extern void ftrace_syscall_enter(struct pt_regs *regs); |
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h index f9f900cfd066..0cff9bb80b02 100644 --- a/include/linux/syscalls.h +++ b/include/linux/syscalls.h | |||
@@ -65,6 +65,7 @@ struct old_linux_dirent; | |||
65 | #include <asm/signal.h> | 65 | #include <asm/signal.h> |
66 | #include <linux/quota.h> | 66 | #include <linux/quota.h> |
67 | #include <linux/key.h> | 67 | #include <linux/key.h> |
68 | #include <linux/ftrace.h> | ||
68 | 69 | ||
69 | #define __SC_DECL1(t1, a1) t1 a1 | 70 | #define __SC_DECL1(t1, a1) t1 a1 |
70 | #define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__) | 71 | #define __SC_DECL2(t2, a2, ...) t2 a2, __SC_DECL1(__VA_ARGS__) |
@@ -95,7 +96,46 @@ struct old_linux_dirent; | |||
95 | #define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__) | 96 | #define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__) |
96 | #define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__) | 97 | #define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__) |
97 | 98 | ||
99 | #ifdef CONFIG_FTRACE_SYSCALLS | ||
100 | #define __SC_STR_ADECL1(t, a) #a | ||
101 | #define __SC_STR_ADECL2(t, a, ...) #a, __SC_STR_ADECL1(__VA_ARGS__) | ||
102 | #define __SC_STR_ADECL3(t, a, ...) #a, __SC_STR_ADECL2(__VA_ARGS__) | ||
103 | #define __SC_STR_ADECL4(t, a, ...) #a, __SC_STR_ADECL3(__VA_ARGS__) | ||
104 | #define __SC_STR_ADECL5(t, a, ...) #a, __SC_STR_ADECL4(__VA_ARGS__) | ||
105 | #define __SC_STR_ADECL6(t, a, ...) #a, __SC_STR_ADECL5(__VA_ARGS__) | ||
106 | |||
107 | #define __SC_STR_TDECL1(t, a) #t | ||
108 | #define __SC_STR_TDECL2(t, a, ...) #t, __SC_STR_TDECL1(__VA_ARGS__) | ||
109 | #define __SC_STR_TDECL3(t, a, ...) #t, __SC_STR_TDECL2(__VA_ARGS__) | ||
110 | #define __SC_STR_TDECL4(t, a, ...) #t, __SC_STR_TDECL3(__VA_ARGS__) | ||
111 | #define __SC_STR_TDECL5(t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__) | ||
112 | #define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__) | ||
113 | |||
114 | #define SYSCALL_METADATA(sname, nb) \ | ||
115 | static const struct syscall_metadata __used \ | ||
116 | __attribute__((__aligned__(4))) \ | ||
117 | __attribute__((section("__syscalls_metadata"))) \ | ||
118 | __syscall_meta_##sname = { \ | ||
119 | .name = "sys"#sname, \ | ||
120 | .nb_args = nb, \ | ||
121 | .types = types_##sname, \ | ||
122 | .args = args_##sname, \ | ||
123 | } | ||
124 | |||
125 | #define SYSCALL_DEFINE0(sname) \ | ||
126 | static const struct syscall_metadata __used \ | ||
127 | __attribute__((__aligned__(4))) \ | ||
128 | __attribute__((section("__syscalls_metadata"))) \ | ||
129 | __syscall_meta_##sname = { \ | ||
130 | .name = "sys_"#sname, \ | ||
131 | .nb_args = 0, \ | ||
132 | }; \ | ||
133 | asmlinkage long sys_##sname(void) | ||
134 | |||
135 | #else | ||
98 | #define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void) | 136 | #define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void) |
137 | #endif | ||
138 | |||
99 | #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) | 139 | #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) |
100 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) | 140 | #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) |
101 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__) | 141 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__) |
@@ -117,10 +157,26 @@ struct old_linux_dirent; | |||
117 | #endif | 157 | #endif |
118 | #endif | 158 | #endif |
119 | 159 | ||
160 | #ifdef CONFIG_FTRACE_SYSCALLS | ||
161 | #define SYSCALL_DEFINEx(x, sname, ...) \ | ||
162 | static const char *types_##sname[] = { \ | ||
163 | __SC_STR_TDECL##x(__VA_ARGS__) \ | ||
164 | }; \ | ||
165 | static const char *args_##sname[] = { \ | ||
166 | __SC_STR_ADECL##x(__VA_ARGS__) \ | ||
167 | }; \ | ||
168 | SYSCALL_METADATA(sname, x); \ | ||
169 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) | ||
170 | #else | ||
171 | #define SYSCALL_DEFINEx(x, sname, ...) \ | ||
172 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__) | ||
173 | #endif | ||
174 | |||
120 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS | 175 | #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS |
121 | 176 | ||
122 | #define SYSCALL_DEFINE(name) static inline long SYSC_##name | 177 | #define SYSCALL_DEFINE(name) static inline long SYSC_##name |
123 | #define SYSCALL_DEFINEx(x, name, ...) \ | 178 | |
179 | #define __SYSCALL_DEFINEx(x, name, ...) \ | ||
124 | asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \ | 180 | asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \ |
125 | static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \ | 181 | static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \ |
126 | asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \ | 182 | asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \ |
@@ -134,7 +190,7 @@ struct old_linux_dirent; | |||
134 | #else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ | 190 | #else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ |
135 | 191 | ||
136 | #define SYSCALL_DEFINE(name) asmlinkage long sys_##name | 192 | #define SYSCALL_DEFINE(name) asmlinkage long sys_##name |
137 | #define SYSCALL_DEFINEx(x, name, ...) \ | 193 | #define __SYSCALL_DEFINEx(x, name, ...) \ |
138 | asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)) | 194 | asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)) |
139 | 195 | ||
140 | #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ | 196 | #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ |