aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/syscalls.h6
-rw-r--r--include/trace/syscall.h2
-rw-r--r--kernel/trace/trace_syscalls.c36
3 files changed, 16 insertions, 28 deletions
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 2f7c539ab96d..d3c9fd01a110 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -153,6 +153,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused) \
153#define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__) 153#define __SC_STR_TDECL6(t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__)
154 154
155#define SYSCALL_TRACE_ENTER_EVENT(sname) \ 155#define SYSCALL_TRACE_ENTER_EVENT(sname) \
156 static const struct syscall_metadata __syscall_meta_##sname; \
156 static struct ftrace_event_call event_enter_##sname; \ 157 static struct ftrace_event_call event_enter_##sname; \
157 struct trace_event enter_syscall_print_##sname = { \ 158 struct trace_event enter_syscall_print_##sname = { \
158 .trace = print_syscall_enter, \ 159 .trace = print_syscall_enter, \
@@ -184,11 +185,12 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused) \
184 .define_fields = syscall_enter_define_fields, \ 185 .define_fields = syscall_enter_define_fields, \
185 .regfunc = reg_event_syscall_enter, \ 186 .regfunc = reg_event_syscall_enter, \
186 .unregfunc = unreg_event_syscall_enter, \ 187 .unregfunc = unreg_event_syscall_enter, \
187 .data = "sys"#sname, \ 188 .data = (void *)&__syscall_meta_##sname,\
188 TRACE_SYS_ENTER_PROFILE_INIT(sname) \ 189 TRACE_SYS_ENTER_PROFILE_INIT(sname) \
189 } 190 }
190 191
191#define SYSCALL_TRACE_EXIT_EVENT(sname) \ 192#define SYSCALL_TRACE_EXIT_EVENT(sname) \
193 static const struct syscall_metadata __syscall_meta_##sname; \
192 static struct ftrace_event_call event_exit_##sname; \ 194 static struct ftrace_event_call event_exit_##sname; \
193 struct trace_event exit_syscall_print_##sname = { \ 195 struct trace_event exit_syscall_print_##sname = { \
194 .trace = print_syscall_exit, \ 196 .trace = print_syscall_exit, \
@@ -220,7 +222,7 @@ static void prof_sysexit_disable_##sname(struct ftrace_event_call *unused) \
220 .define_fields = syscall_exit_define_fields, \ 222 .define_fields = syscall_exit_define_fields, \
221 .regfunc = reg_event_syscall_exit, \ 223 .regfunc = reg_event_syscall_exit, \
222 .unregfunc = unreg_event_syscall_exit, \ 224 .unregfunc = unreg_event_syscall_exit, \
223 .data = "sys"#sname, \ 225 .data = (void *)&__syscall_meta_##sname,\
224 TRACE_SYS_EXIT_PROFILE_INIT(sname) \ 226 TRACE_SYS_EXIT_PROFILE_INIT(sname) \
225 } 227 }
226 228
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 5f8827c92db7..c5265c81c4e7 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -34,7 +34,7 @@ struct syscall_metadata {
34 34
35#ifdef CONFIG_FTRACE_SYSCALLS 35#ifdef CONFIG_FTRACE_SYSCALLS
36extern unsigned long arch_syscall_addr(int nr); 36extern unsigned long arch_syscall_addr(int nr);
37extern int syscall_name_to_nr(char *name); 37extern int syscall_name_to_nr(const char *name);
38void set_syscall_enter_id(int num, int id); 38void set_syscall_enter_id(int num, int id);
39void set_syscall_exit_id(int num, int id); 39void set_syscall_exit_id(int num, int id);
40 40
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 00d6e176f5b6..39649b1675dd 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -51,7 +51,7 @@ static struct syscall_metadata *syscall_nr_to_meta(int nr)
51 return syscalls_metadata[nr]; 51 return syscalls_metadata[nr];
52} 52}
53 53
54int syscall_name_to_nr(char *name) 54int syscall_name_to_nr(const char *name)
55{ 55{
56 int i; 56 int i;
57 57
@@ -172,18 +172,11 @@ extern char *__bad_type_size(void);
172int syscall_enter_format(struct ftrace_event_call *call, struct trace_seq *s) 172int syscall_enter_format(struct ftrace_event_call *call, struct trace_seq *s)
173{ 173{
174 int i; 174 int i;
175 int nr;
176 int ret; 175 int ret;
177 struct syscall_metadata *entry; 176 struct syscall_metadata *entry = call->data;
178 struct syscall_trace_enter trace; 177 struct syscall_trace_enter trace;
179 int offset = offsetof(struct syscall_trace_enter, args); 178 int offset = offsetof(struct syscall_trace_enter, args);
180 179
181 nr = syscall_name_to_nr(call->data);
182 entry = syscall_nr_to_meta(nr);
183
184 if (!entry)
185 return 0;
186
187 ret = trace_seq_printf(s, "\tfield:%s %s;\toffset:%zu;\tsize:%zu;" 180 ret = trace_seq_printf(s, "\tfield:%s %s;\toffset:%zu;\tsize:%zu;"
188 "\tsigned:%u;\n", 181 "\tsigned:%u;\n",
189 SYSCALL_FIELD(int, nr)); 182 SYSCALL_FIELD(int, nr));
@@ -245,18 +238,11 @@ int syscall_exit_format(struct ftrace_event_call *call, struct trace_seq *s)
245int syscall_enter_define_fields(struct ftrace_event_call *call) 238int syscall_enter_define_fields(struct ftrace_event_call *call)
246{ 239{
247 struct syscall_trace_enter trace; 240 struct syscall_trace_enter trace;
248 struct syscall_metadata *meta; 241 struct syscall_metadata *meta = call->data;
249 int ret; 242 int ret;
250 int nr;
251 int i; 243 int i;
252 int offset = offsetof(typeof(trace), args); 244 int offset = offsetof(typeof(trace), args);
253 245
254 nr = syscall_name_to_nr(call->data);
255 meta = syscall_nr_to_meta(nr);
256
257 if (!meta)
258 return 0;
259
260 ret = trace_define_common_fields(call); 246 ret = trace_define_common_fields(call);
261 if (ret) 247 if (ret)
262 return ret; 248 return ret;
@@ -366,9 +352,9 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
366{ 352{
367 int ret = 0; 353 int ret = 0;
368 int num; 354 int num;
369 char *name; 355 const char *name;
370 356
371 name = (char *)call->data; 357 name = ((struct syscall_metadata *)call->data)->name;
372 num = syscall_name_to_nr(name); 358 num = syscall_name_to_nr(name);
373 if (num < 0 || num >= NR_syscalls) 359 if (num < 0 || num >= NR_syscalls)
374 return -ENOSYS; 360 return -ENOSYS;
@@ -389,9 +375,9 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
389void unreg_event_syscall_enter(struct ftrace_event_call *call) 375void unreg_event_syscall_enter(struct ftrace_event_call *call)
390{ 376{
391 int num; 377 int num;
392 char *name; 378 const char *name;
393 379
394 name = (char *)call->data; 380 name = ((struct syscall_metadata *)call->data)->name;
395 num = syscall_name_to_nr(name); 381 num = syscall_name_to_nr(name);
396 if (num < 0 || num >= NR_syscalls) 382 if (num < 0 || num >= NR_syscalls)
397 return; 383 return;
@@ -407,9 +393,9 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
407{ 393{
408 int ret = 0; 394 int ret = 0;
409 int num; 395 int num;
410 char *name; 396 const char *name;
411 397
412 name = call->data; 398 name = ((struct syscall_metadata *)call->data)->name;
413 num = syscall_name_to_nr(name); 399 num = syscall_name_to_nr(name);
414 if (num < 0 || num >= NR_syscalls) 400 if (num < 0 || num >= NR_syscalls)
415 return -ENOSYS; 401 return -ENOSYS;
@@ -430,9 +416,9 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
430void unreg_event_syscall_exit(struct ftrace_event_call *call) 416void unreg_event_syscall_exit(struct ftrace_event_call *call)
431{ 417{
432 int num; 418 int num;
433 char *name; 419 const char *name;
434 420
435 name = call->data; 421 name = ((struct syscall_metadata *)call->data)->name;
436 num = syscall_name_to_nr(name); 422 num = syscall_name_to_nr(name);
437 if (num < 0 || num >= NR_syscalls) 423 if (num < 0 || num >= NR_syscalls)
438 return; 424 return;