tracing: add compat syscall support v3
PATCH 1/14 x86: add NR_syscalls_compat, make ia32 syscall table visible
In reply to Jason BaronAdd 'NR_syscalls_compat' global for x86. Also, make 'ia32_sys_call_table' into a global.
--- arch/x86/ia32/ia32entry.S | 3 +++ arch/x86/include/asm/compat.h | 2 ++ 2 files changed, 5 insertions(+), 0 deletions(-)
arch/x86/ia32/ia32entry.S +3 -0
@@ -503,6 +503,7 @@ END(ia32_ptregs_common) .section .rodata,"a" .align 8 +.globl ia32_sys_call_table ia32_sys_call_table: .quad sys_restart_syscall .quad sys_exit
@@ -843,3 +844,5 @@ ia32_sys_call_table: .quad sys_perf_event_open .quad compat_sys_recvmmsg ia32_syscall_end: +.globl NR_syscalls_compat +NR_syscalls_compat: .int ((ia32_syscall_end - ia32_sys_call_table)/8)
arch/x86/include/asm/compat.h +2 -0
@@ -215,4 +215,6 @@ static inline int is_compat_task(void) return current_thread_info()->status & TS_COMPAT; } +extern int NR_syscalls_compat; +#endif /* _ASM_X86_COMPAT_H */
Signature · 1 line
1.6.5.1
PATCH 2/14 x86: add arch_compat_syscall_addr()
In reply to Jason BaronAdd arch_compat_syscall_addr(int nr) for x86_64. This is in preparation for adding compat syscall support to the event tracer.
--- arch/x86/include/asm/syscall.h | 5 +++++ arch/x86/kernel/ftrace.c | 8 ++++++++ 2 files changed, 13 insertions(+), 0 deletions(-)
arch/x86/include/asm/syscall.h +5 -0
@@ -16,7 +16,12 @@#include <linux/sched.h> #include <linux/err.h> +#if defined(CONFIG_COMPAT ) && defined(CONFIG_FTRACE_SYSCALLS ) +#define __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS +#endif +extern const unsigned long sys_call_table[]; +extern const unsigned long *ia32_sys_call_table;/* * Only the low 32 bits of orig_ax are meaningful, so we return int.
arch/x86/kernel/ftrace.c +8 -0
@@ -26,6 +26,7 @@#include <asm/ftrace.h> #include <asm/nops.h> #include <asm/nmi.h> +#include <asm/syscall.h> #ifdef CONFIG_DYNAMIC_FTRACE
@@ -510,3 +511,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, } }#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ + +#ifdef __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS +unsigned long __init arch_compat_syscall_addr (int nr) +{ +return (unsigned long )(&ia32_sys_call_table)[nr]; +} +#endif
Signature · 1 line
1.6.5.1
PATCH 6/14 tracing: add tracing support for compat syscalls
In reply to Jason BaronAdd core support to event tracing for compat syscalls. The basic idea is that we check if we have a compat task via 'is_compat_task()'. If so, we lookup in the new compat_syscalls_metadata table, the corresponding struct syscall_metadata, to check syscall arguments and whether or not we are enabled.
--- include/linux/compat.h | 2 + include/trace/syscall.h | 4 ++ kernel/trace/trace.h | 2 + kernel/trace/trace_syscalls.c | 86 +++++++++++++++++++++++++++++++++++++---- 4 files changed, 86 insertions(+), 8 deletions(-)
include/linux/compat.h +2 -0
@@ -355,6 +355,8 @@ asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,#else /* CONFIG_COMPAT */ +#define NR_syscalls_compat 0 +static inline int is_compat_task (void ) {return 0 ;
include/trace/syscall.h +4 -0
@@ -22,6 +22,7 @@struct syscall_metadata {const char *name;int syscall_nr; +int compat_syscall_nr;int nb_args;const char **types;const char **args;
@@ -36,6 +37,9 @@ struct syscall_metadata {#ifdef CONFIG_FTRACE_SYSCALLS extern unsigned long arch_syscall_addr (int nr); +#ifdef CONFIG_COMPAT +extern unsigned long arch_compat_syscall_addr (int nr); +#endif extern int init_syscall_trace (struct ftrace_event_call *call);extern int syscall_enter_define_fields (struct ftrace_event_call *call);
kernel/trace/trace.h +2 -0
@@ -94,12 +94,14 @@ extern struct tracer boot_tracer;struct syscall_trace_enter {struct trace_entry ent;int nr; +int compat;unsigned long args[]; };struct syscall_trace_exit {struct trace_entry ent;int nr; +int compat;long ret; };
kernel/trace/trace_syscalls.c +78 -8
185 lines not on this page · raw message
Signature · 1 line
1.6.5.1
cover tracing: add compat syscall support v3
Hi,
Re-post to add infrastructure for compat syscall event tracing support. This patch series also adds x86_64 arch specific support as an example consumer of the new infrastructure.
Arches can request compat syscall tracing by setting:__HAVE_ARCH_FTRACE_COMPAT_SYSCALLS, if CONFIG_COMPAT and CONFIG_FTRACE_SYSCALLS are set. Arches then need to implement the following interfaces:
1) int is_compat_task(void);
- most arches seem to have this already
2) unsigned long arch_compat_syscall_addr(int nr);
- returns a pointer to the compat syscall entry corresponding to syscall 'nr'
3) int NR_syscalls_compat;
- number of entries in the compat syscall table.
thanks,
-Jason
Changes in v3:
- create a separate "compat_syscalls" event subsystem
- ARCH_COMPAT_SYSCALL_DEFINE#N() tacks "sys32" to start of syscall name
- COMPAT_SYSCALL_DEFINE#N() tacks "compat_sys" to start of syscall name
- both above macros create perf events as: [enter|exit]_compat_sys_blah
- non-compat syscall naming changes to: [enter|exit]_sys_blah
- removes any unreferenced compat syscalls from debugfs
Heiko Carstens (1):
compat: have generic is_compat_task for !CONFIG_COMPAT
Jason Baron (13):
x86: add NR_syscalls_compat, make ia32 syscall table visible
x86: add arch_compat_syscall_addr()
tracing: remove syscall bitmaps in preparation for compat support
tracing: move __start_ftrace_events and __stop_ftrace_events to
header file
tracing: add tracing support for compat syscalls
syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
x86, compat: convert ia32 layer to use
syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro
compat: convert to use COMPAT_SYSCALL_DEFINE#N()
compat: convert fs compat to use COMPAT_SYSCALL_DEFINE#N() macros
tags: recognize compat syscalls
cleanup: remove arg from TRACE_SYS_ENTER_PROFILE_INIT() macro
tracing: make a "compat_syscalls" tracing subsys
arch/s390/include/asm/compat.h | 7 -- arch/s390/kernel/ptrace.c | 2 +- arch/s390/kernel/setup.c | 2 +- arch/s390/mm/mmap.c | 2 +- arch/x86/ia32/ia32entry.S | 3 + arch/x86/ia32/sys_ia32.c | 106 ++++++++++++++-------------- arch/x86/include/asm/compat.h | 2 + arch/x86/include/asm/syscall.h | 5 ++ arch/x86/kernel/ftrace.c | 8 ++ drivers/s390/block/dasd_eckd.c | 2 +- drivers/s390/block/dasd_ioctl.c | 1 + drivers/s390/char/fs3270.c | 1 + drivers/s390/char/vmcp.c | 1 + drivers/s390/cio/chsc_sch.c | 1 + drivers/s390/scsi/zfcp_cfdc.c | 1 + fs/compat.c | 147 +++++++++++++++++++-------------------- include/linux/compat.h | 9 +++ include/linux/ftrace_event.h | 3 + include/linux/syscalls.h | 91 +++++++++++++++++------- include/trace/syscall.h | 8 ++ kernel/compat.c | 106 ++++++++++++++--------------- kernel/trace/trace.h | 2 + kernel/trace/trace_events.c | 3 - kernel/trace/trace_syscalls.c | 124 +++++++++++++++++++++++++-------- scripts/tags.sh | 8 ++- 25 files changed, 392 insertions(+), 253 deletions(-)
PATCH 5/14 tracing: move __start_ftrace_events and __stop_ftrace_events to header file
trace_syscalls.c uses __start_ftrace_events and __stop_ftrace_events in order to prune compat syscall ftrace events that are not referenced by the compat syscall table. So move the 'extern' definitions to a common header file.
--- include/linux/ftrace_event.h | 3 +++ kernel/trace/trace_events.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-)
include/linux/ftrace_event.h +3 -0
@@ -136,6 +136,9 @@ struct ftrace_event_call {void (*profile_disable)(struct ftrace_event_call *); }; +extern struct ftrace_event_call __start_ftrace_events[]; +extern struct ftrace_event_call __stop_ftrace_events[]; +#define FTRACE_MAX_PROFILE_SIZE 2048#define MAX_FILTER_PRED 32
kernel/trace/trace_events.c +0 -3
@@ -1222,9 +1222,6 @@ static struct notifier_block trace_module_nb = { .priority = 0, }; -extern struct ftrace_event_call __start_ftrace_events[]; -extern struct ftrace_event_call __stop_ftrace_events[]; -static char bootup_event_buf[COMMAND_LINE_SIZE ]__initdata ;static __init int setup_trace_event (char *str)
Signature · 1 line
1.6.5.1
PATCH 8/14 x86, compat: convert ia32 layer to use
In reply to Jason BaronMake use of the new ARCH_COMPAT_SYSCALL_DEFINE#N() macros to tie the compat syscalls into the event tracer.
--- arch/x86/ia32/sys_ia32.c | 106 +++++++++++++++++++++++----------------------- 1 files changed, 53 insertions(+), 53 deletions(-)
arch/x86/ia32/sys_ia32.c +53 -53
@@ -50,15 +50,15 @@#define AA (__x) ((unsigned long)(__x)) -asmlinkage long sys32_truncate64 (char __user *filename, -unsigned long offset_low, -unsigned long offset_high) +ARCH_COMPAT_SYSCALL_DEFINE3(truncate64, char __user *, filename, + unsigned long, offset_low, + unsigned long, offset_high) {return sys_truncate (filename, ((loff_t ) offset_high <<32 ) | offset_low); } -asmlinkage long sys32_ftruncate64 (unsigned int fd,unsigned long offset_low, -unsigned long offset_high) +ARCH_COMPAT_SYSCALL_DEFINE3(ftruncate64, unsigned int, fd, unsigned long, offset_low, + unsigned long, offset_high) {return sys_ftruncate (fd, ((loff_t ) offset_high <<32 ) | offset_low); }
@@ -95,8 +95,8 @@ static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)return 0 ; } -asmlinkage long sys32_stat64 (char __user *filename, -struct stat64 __user *statbuf) +ARCH_COMPAT_SYSCALL_DEFINE2(stat64, char __user *, filename, + struct stat64 __user *, statbuf) {struct kstat stat;int ret =vfs_stat (filename, &stat);
@@ -106,8 +106,8 @@ asmlinkage long sys32_stat64(char __user *filename,return ret; } -asmlinkage long sys32_lstat64 (char __user *filename, -struct stat64 __user *statbuf) +ARCH_COMPAT_SYSCALL_DEFINE2(lstat64, char __user *, filename, + struct stat64 __user *, statbuf) {struct kstat stat;int ret =vfs_lstat (filename, &stat);
@@ -116,7 +116,7 @@ asmlinkage long sys32_lstat64(char __user *filename,return ret; } -asmlinkage long sys32_fstat64 (unsigned int fd,struct stat64 __user *statbuf) +ARCH_COMPAT_SYSCALL_DEFINE2(fstat64, unsigned int, fd, struct stat64 __user *, statbuf) {struct kstat stat;int ret =vfs_fstat (fd, &stat);
@@ -125,8 +125,8 @@ asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)return ret; } -asmlinkage long sys32_fstatat (unsigned int dfd,char __user *filename, -struct stat64 __user *statbuf,int flag) +ARCH_COMPAT_SYSCALL_DEFINE4(fstatat, unsigned int, dfd, char __user *, filename, + struct stat64 __user *, statbuf, int, flag) {struct kstat stat;int error;
@@ -152,7 +152,7 @@ struct mmap_arg_struct {unsigned int offset; }; -asmlinkage long sys32_mmap (struct mmap_arg_struct __user *arg) +ARCH_COMPAT_SYSCALL_DEFINE1(mmap, struct mmap_arg_struct __user *, arg) {struct mmap_arg_struct a;
@@ -166,15 +166,15 @@ asmlinkage long sys32_mmap(struct mmap_arg_struct __user *arg) a.offset>>PAGE_SHIFT); } -asmlinkage long sys32_mprotect (unsigned long start,size_t len, -unsigned long prot) +ARCH_COMPAT_SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len, + unsigned long, prot) {return sys_mprotect (start, len, prot); } -asmlinkage long sys32_rt_sigaction (int sig,struct sigaction32 __user *act, -struct sigaction32 __user *oact, -unsigned int sigsetsize) +ARCH_COMPAT_SYSCALL_DEFINE4(rt_sigaction, int, sig, struct sigaction32 __user *, act, + struct sigaction32 __user *, oact, + unsigned int, sigsetsize) {struct k_sigaction new_ka, old_ka;int ret;
@@ -248,8 +248,8 @@ asmlinkage long sys32_rt_sigaction(int sig, struct sigaction32 __user *act,return ret; } -asmlinkage long sys32_sigaction (int sig,struct old_sigaction32 __user *act, -struct old_sigaction32 __user *oact) +ARCH_COMPAT_SYSCALL_DEFINE3(sigaction, int, sig, struct old_sigaction32 __user *, act, + struct old_sigaction32 __user *, oact) {struct k_sigaction new_ka, old_ka;int ret;
@@ -287,9 +287,9 @@ asmlinkage long sys32_sigaction(int sig, struct old_sigaction32 __user *act,return ret; } -asmlinkage long sys32_rt_sigprocmask (int how,compat_sigset_t __user *set, -compat_sigset_t __user *oset, -unsigned int sigsetsize) +ARCH_COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, set, + compat_sigset_t __user *, oset, + unsigned int, sigsetsize) {sigset_t s;compat_sigset_t s32;
@@ -327,7 +327,7 @@ asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,return 0 ; } -asmlinkage long sys32_alarm (unsigned int seconds) +ARCH_COMPAT_SYSCALL_DEFINE1(alarm, unsigned int, seconds) {return alarm_setitimer (seconds); }
@@ -340,7 +340,7 @@ struct sel_arg_struct {unsigned int tvp; }; -asmlinkage long sys32_old_select (struct sel_arg_struct __user *arg) +ARCH_COMPAT_SYSCALL_DEFINE1(old_select, struct sel_arg_struct __user *, arg) {struct sel_arg_struct a;
@@ -350,21 +350,21 @@ asmlinkage long sys32_old_select(struct sel_arg_struct __user *arg) compat_ptr(a.exp), compat_ptr(a.tvp)); } -asmlinkage long sys32_waitpid (compat_pid_t pid,unsigned int *stat_addr, -int options) +ARCH_COMPAT_SYSCALL_DEFINE3(waitpid, compat_pid_t, pid, unsigned int *, stat_addr, + int, options) {return compat_sys_wait4 (pid, stat_addr, options,NULL ); }/* 32-bit timeval and related flotsam. */ -asmlinkage long sys32_sysfs (int option,u32 arg1,u32 arg2) +ARCH_COMPAT_SYSCALL_DEFINE3(sysfs, int, option, u32, arg1, u32, arg2) {return sys_sysfs (option, arg1, arg2); } -asmlinkage long sys32_sched_rr_get_interval (compat_pid_t pid, -struct compat_timespec __user *interval) +ARCH_COMPAT_SYSCALL_DEFINE2 (sched_rr_get_interval, compat_pid_t, pid, + struct compat_timespec __user *, interval) {struct timespec t;int ret;
@@ -378,8 +378,8 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,return ret; } -asmlinkage long sys32_rt_sigpending (compat_sigset_t __user *set, -compat_size_t sigsetsize) +ARCH_COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t __user *, set, + compat_size_t, sigsetsize) {sigset_t s;compat_sigset_t s32;
@@ -402,8 +402,8 @@ asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,return ret; } -asmlinkage long sys32_rt_sigqueueinfo (int pid,int sig, -compat_siginfo_t __user *uinfo) +ARCH_COMPAT_SYSCALL_DEFINE3 (rt_sigqueueinfo, int, pid, int, sig, + compat_siginfo_t __user *, uinfo) {siginfo_t info;int ret;
@@ -418,22 +418,22 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig, }/* warning: next two assume little endian */ -asmlinkage long sys32_pread (unsigned int fd,char __user *ubuf,u32 count, -u32 poslo,u32 poshi) +ARCH_COMPAT_SYSCALL_DEFINE5(pread, unsigned int, fd, char __user *, ubuf, u32, count, + u32, poslo, u32, poshi) {return sys_pread64 (fd, ubuf, count, ((loff_t )AA (poshi) <<32 ) |AA (poslo)); } -asmlinkage long sys32_pwrite (unsigned int fd,char __user *ubuf,u32 count, -u32 poslo,u32 poshi) +ARCH_COMPAT_SYSCALL_DEFINE5(pwrite, unsigned int, fd, char __user *, ubuf, u32, count, + u32, poslo, u32, poshi) {return sys_pwrite64 (fd, ubuf, count, ((loff_t )AA (poshi) <<32 ) |AA (poslo)); } -asmlinkage long sys32_personality (unsigned long personality) +ARCH_COMPAT_SYSCALL_DEFINE1(personality, unsigned long, personality) {int ret;
@@ -446,8 +446,8 @@ asmlinkage long sys32_personality(unsigned long personality)return ret; } -asmlinkage long sys32_sendfile (int out_fd,int in_fd, -compat_off_t __user *offset,s32 count) +ARCH_COMPAT_SYSCALL_DEFINE4 (sendfile, int, out_fd, int, in_fd, + compat_off_t __user *, offset, s32, count) {mm_segment_t old_fs =get_fs ();int ret;
@@ -466,7 +466,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,return ret; } -asmlinkage long sys32_olduname (struct oldold_utsname __user *name) +ARCH_COMPAT_SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name) {char *arch ="x86_64" ;int err;
@@ -518,8 +518,8 @@ long sys32_uname(struct old_utsname __user *name)return err ? -EFAULT :0 ; } -asmlinkage long sys32_execve (char __user *name,compat_uptr_t __user *argv, -compat_uptr_t __user *envp,struct pt_regs *regs) +ARCH_COMPAT_SYSCALL_DEFINE4(execve, char __user *, name, compat_uptr_t __user *, argv, + compat_uptr_t __user *, envp, struct pt_regs *, regs) {long error;char *filename;
@@ -533,8 +533,8 @@ asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,return error; } -asmlinkage long sys32_clone (unsigned int clone_flags,unsigned int newsp, -struct pt_regs *regs) +ARCH_COMPAT_SYSCALL_DEFINE3(clone, unsigned int, clone_flags, unsigned int, newsp, + struct pt_regs *, regs) {void __user *parent_tid = (void __user *)regs->dx;void __user *child_tid = (void __user *)regs->di;
@@ -593,24 +593,24 @@ asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,return sys_readahead (fd, ((u64 )off_hi <<32 ) | off_lo, count); } -asmlinkage long sys32_sync_file_range (int fd,unsigned off_low,unsigned off_hi, -unsigned n_low,unsigned n_hi,int flags) +ARCH_COMPAT_SYSCALL_DEFINE6 (sync_file_range, int, fd, unsigned, off_low, unsigned, off_hi, + unsigned, n_low, unsigned, n_hi, int, flags) {return sys_sync_file_range (fd, ((u64 )off_hi <<32 ) | off_low, ((u64 )n_hi <<32 ) | n_low, flags); } -asmlinkage long sys32_fadvise64 (int fd,unsigned offset_lo,unsigned offset_hi, -size_t len,int advice) +ARCH_COMPAT_SYSCALL_DEFINE5 (fadvise64, int, fd, unsigned, offset_lo, unsigned, offset_hi, + size_t, len, int, advice) {return sys_fadvise64_64 (fd, ((u64 )offset_hi <<32 ) | offset_lo, len, advice); } -asmlinkage long sys32_fallocate (int fd,int mode,unsigned offset_lo, -unsigned offset_hi,unsigned len_lo, -unsigned len_hi) +ARCH_COMPAT_SYSCALL_DEFINE6 (fallocate, int, fd, int, mode, unsigned, offset_lo, + unsigned, offset_hi, unsigned, len_lo, + unsigned, len_hi) {return sys_fallocate (fd, mode, ((u64 )offset_hi <<32 ) | offset_lo, ((u64 )len_hi <<32 ) | len_lo);
Signature · 1 line
1.6.5.1
PATCH 11/14 compat: convert fs compat to use COMPAT_SYSCALL_DEFINE#N() macros
In reply to Jason Baronconvert the fs/compat.c file to use the COMPAT_SYSCALL_DEFINE#N() macros to tie them into the generic compat layer.
--- fs/compat.c | 147 +++++++++++++++++++++++++++++------------------------------ 1 files changed, 72 insertions(+), 75 deletions(-)
fs/compat.c +72 -75
@@ -75,7 +75,7 @@ int compat_printk(const char *fmt, ...)* Not all architectures have sys_utime, so implement this in terms * of sys_utimes. */ -asmlinkage long compat_sys_utime (char __user *filename,struct compat_utimbuf __user *t) +COMPAT_SYSCALL_DEFINE2(utime, char __user *, filename, struct compat_utimbuf __user *, t) {struct timespec tv[2 ];
@@ -89,7 +89,7 @@ asmlinkage long compat_sys_utime(char __user *filename, struct compat_utimbuf __return do_utimes (AT_FDCWD , filename, t ? tv :NULL ,0 ); } -asmlinkage long compat_sys_utimensat (unsigned int dfd,char __user *filename,struct compat_timespec __user *t,int flags) +COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, char __user *, filename, struct compat_timespec __user *, t, int, flags) {struct timespec tv[2 ];
@@ -104,7 +104,7 @@ asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, streturn do_utimes (dfd, filename, t ? tv :NULL , flags); } -asmlinkage long compat_sys_futimesat (unsigned int dfd,char __user *filename,struct compat_timeval __user *t) +COMPAT_SYSCALL_DEFINE3(futimesat, unsigned int, dfd, char __user *, filename, struct compat_timeval __user *, t) {struct timespec tv[2 ];
@@ -123,7 +123,7 @@ asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, streturn do_utimes (dfd, filename, t ? tv :NULL ,0 ); } -asmlinkage long compat_sys_utimes (char __user *filename,struct compat_timeval __user *t) +COMPAT_SYSCALL_DEFINE2(utimes, char __user *, filename, struct compat_timeval __user *, t) {return compat_sys_futimesat (AT_FDCWD , filename, t); }
@@ -167,8 +167,8 @@ static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf)return err; } -asmlinkage long compat_sys_newstat (char __user * filename, -struct compat_stat __user *statbuf) +COMPAT_SYSCALL_DEFINE2(newstat, char __user *, filename, + struct compat_stat __user *, statbuf) {struct kstat stat;int error;
@@ -179,8 +179,8 @@ asmlinkage long compat_sys_newstat(char __user * filename,return cp_compat_stat (&stat, statbuf); } -asmlinkage long compat_sys_newlstat (char __user * filename, -struct compat_stat __user *statbuf) +COMPAT_SYSCALL_DEFINE2(newlstat, char __user *, filename, + struct compat_stat __user *, statbuf) {struct kstat stat;int error;
@@ -192,8 +192,8 @@ asmlinkage long compat_sys_newlstat(char __user * filename, }#ifndef __ARCH_WANT_STAT64 -asmlinkage long compat_sys_newfstatat (unsigned int dfd,char __user *filename, -struct compat_stat __user *statbuf,int flag) +COMPAT_SYSCALL_DEFINE4(newfstatat, unsigned int, dfd, char __user *, filename, + struct compat_stat __user *, statbuf, int, flag) {struct kstat stat;int error;
@@ -205,8 +205,8 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename, }#endif -asmlinkage long compat_sys_newfstat (unsigned int fd, -struct compat_stat __user * statbuf) +COMPAT_SYSCALL_DEFINE2(newfstat, unsigned int, fd, + struct compat_stat __user *, statbuf) {struct kstat stat;int error =vfs_fstat (fd, &stat);
@@ -257,7 +257,7 @@ static int put_compat_statfs(struct compat_statfs __user *ubuf, struct kstatfs ** The following statfs calls are copies of code from fs/open.c and * should be checked against those from time to time */ -asmlinkage long compat_sys_statfs (const char __user *pathname,struct compat_statfs __user *buf) +COMPAT_SYSCALL_DEFINE2(statfs, const char __user *, pathname, struct compat_statfs __user *, buf) {struct path path;int error;
@@ -273,7 +273,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_stareturn error; } -asmlinkage long compat_sys_fstatfs (unsigned int fd,struct compat_statfs __user *buf) +COMPAT_SYSCALL_DEFINE2(fstatfs, unsigned int, fd, struct compat_statfs __user *, buf) {struct file * file;struct kstatfs tmp;
@@ -322,7 +322,7 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatreturn 0 ; } -asmlinkage long compat_sys_statfs64 (const char __user *pathname,compat_size_t sz,struct compat_statfs64 __user *buf) +COMPAT_SYSCALL_DEFINE3(statfs64, const char __user *, pathname, compat_size_t, sz, struct compat_statfs64 __user *, buf) {struct path path;int error;
@@ -341,7 +341,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t sreturn error; } -asmlinkage long compat_sys_fstatfs64 (unsigned int fd,compat_size_t sz,struct compat_statfs64 __user *buf) +COMPAT_SYSCALL_DEFINE3(fstatfs64, unsigned int, fd, compat_size_t, sz, struct compat_statfs64 __user *, buf) {struct file * file;struct kstatfs tmp;
@@ -367,7 +367,7 @@ out:* Given how simple this syscall is that apporach is more maintainable * than the various conversion hacks. */ -asmlinkage long compat_sys_ustat (unsigned dev,struct compat_ustat __user *u) +COMPAT_SYSCALL_DEFINE2(ustat, unsigned, dev, struct compat_ustat __user *, u) {struct super_block *sb;struct compat_ustat tmp;
@@ -442,8 +442,8 @@ static int put_compat_flock64(struct flock *kfl, struct compat_flock64 __user *u }#endif -asmlinkage long compat_sys_fcntl64 (unsigned int fd,unsigned int cmd, -unsigned long arg) +COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, + unsigned long, arg) {mm_segment_t old_fs;struct flock f;
@@ -511,16 +511,15 @@ asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,return ret; } -asmlinkage long compat_sys_fcntl (unsigned int fd,unsigned int cmd, -unsigned long arg) +COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, + unsigned long, arg) {if ((cmd ==F_GETLK64 ) || (cmd ==F_SETLK64 ) || (cmd ==F_SETLKW64 ))return -EINVAL ;return compat_sys_fcntl64 (fd, cmd, arg); } -asmlinkage long -compat_sys_io_setup (unsigned nr_reqs,u32 __user *ctx32p) +COMPAT_SYSCALL_DEFINE2(io_setup, unsigned, nr_reqs, u32 __user *, ctx32p) {long ret;aio_context_t ctx64;
@@ -539,12 +538,11 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)return ret; } -asmlinkage long -compat_sys_io_getevents (aio_context_t ctx_id, -unsigned long min_nr, -unsigned long nr, -struct io_event __user *events, -struct compat_timespec __user *timeout) +COMPAT_SYSCALL_DEFINE5 (io_getevents, aio_context_t, ctx_id, + unsigned long, min_nr, + unsigned long, nr, + struct io_event __user *, events, + struct compat_timespec __user *, timeout) {long ret;struct timespec t;
@@ -584,8 +582,7 @@ copy_iocb(long nr, u32 __user *ptr32, struct iocb __user * __user *ptr64)#define MAX_AIO_SUBMITS (PAGE_SIZE/sizeof(struct iocb *)) -asmlinkage long -compat_sys_io_submit (aio_context_t ctx_id,int nr,u32 __user *iocb) +COMPAT_SYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, int, nr, u32 __user *, iocb) {struct iocb __user *__user *iocb64;long ret;
@@ -762,9 +759,9 @@ static int do_nfs4_super_data_conv(void *raw_data)#define NCPFS_NAME "ncpfs"#define NFS4_NAME "nfs4" -asmlinkage long compat_sys_mount (char __user * dev_name,char __user * dir_name, -char __user * type,unsigned long flags, -void __user * data) +COMPAT_SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, + char __user *, type, unsigned long, flags, + void __user *, data) {char *kernel_type;unsigned long data_page;
@@ -863,8 +860,9 @@ efault:return -EFAULT ; } -asmlinkage long compat_sys_old_readdir (unsigned int fd, -struct compat_old_linux_dirent __user *dirent,unsigned int count) +COMPAT_SYSCALL_DEFINE3(old_readdir, unsigned int, fd, + struct compat_old_linux_dirent __user *, dirent, + unsigned int, count) {int error;struct file *file;
@@ -943,8 +941,9 @@ efault:return -EFAULT ; } -asmlinkage long compat_sys_getdents (unsigned int fd, -struct compat_linux_dirent __user *dirent,unsigned int count) +COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd, + struct compat_linux_dirent __user *, dirent, + unsigned int, count) {struct file * file;struct compat_linux_dirent __user * lastdirent;
@@ -1031,8 +1030,9 @@ efault:return -EFAULT ; } -asmlinkage long compat_sys_getdents64 (unsigned int fd, -struct linux_dirent64 __user * dirent,unsigned int count) +COMPAT_SYSCALL_DEFINE3(getdents64, unsigned int, fd, + struct linux_dirent64 __user *, dirent, + unsigned int, count) {struct file * file;struct linux_dirent64 __user * lastdirent;
@@ -1291,9 +1291,8 @@ compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec,return ret; } -asmlinkage long -compat_sys_vmsplice (int fd,const struct compat_iovec __user *iov32, -unsigned int nr_segs,unsigned int flags) +COMPAT_SYSCALL_DEFINE4(vmsplice, int, fd, const struct compat_iovec __user *, iov32, + unsigned int, nr_segs, unsigned int, flags) {unsigned i;struct iovec __user *iov;
@@ -1315,8 +1314,7 @@ compat_sys_vmsplice(int fd, const struct compat_iovec __user *iov32,* Exactly like fs/open.c:sys_open(), except that it doesn't set the * O_LARGEFILE flag. */ -asmlinkage long -compat_sys_open (const char __user *filename,int flags,int mode) +COMPAT_SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode) {return do_sys_open (AT_FDCWD , filename, flags, mode); }
@@ -1325,8 +1323,7 @@ compat_sys_open(const char __user *filename, int flags, int mode)* Exactly like fs/open.c:sys_openat(), except that it doesn't set the * O_LARGEFILE flag. */ -asmlinkage long -compat_sys_openat (unsigned int dfd,const char __user *filename,int flags,int mode) +COMPAT_SYSCALL_DEFINE4(openat, unsigned int, dfd, const char __user *, filename, int, flags, int, mode) {return do_sys_open (dfd, filename, flags, mode); }
@@ -1770,9 +1767,9 @@ out_nofds:return ret; } -asmlinkage long compat_sys_select (int n,compat_ulong_t __user *inp, -compat_ulong_t __user *outp,compat_ulong_t __user *exp, -struct compat_timeval __user *tvp) +COMPAT_SYSCALL_DEFINE5(select, int, n, compat_ulong_t __user *, inp, + compat_ulong_t __user *, outp, compat_ulong_t __user *, exp, + struct compat_timeval __user *, tvp) {struct timespec end_time, *to =NULL ;struct compat_timeval tv;
@@ -1847,9 +1844,9 @@ static long do_compat_pselect(int n, compat_ulong_t __user *inp,return ret; } -asmlinkage long compat_sys_pselect6 (int n,compat_ulong_t __user *inp, -compat_ulong_t __user *outp,compat_ulong_t __user *exp, -struct compat_timespec __user *tsp,void __user *sig) +COMPAT_SYSCALL_DEFINE6(pselect6, int, n, compat_ulong_t __user *, inp, + compat_ulong_t __user *, outp, compat_ulong_t __user *, exp, + struct compat_timespec __user *, tsp, void __user *, sig) {compat_size_t sigsetsize =0 ;compat_uptr_t up =0 ;
@@ -1866,9 +1863,9 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp, sigsetsize); } -asmlinkage long compat_sys_ppoll (struct pollfd __user *ufds, -unsigned int nfds,struct compat_timespec __user *tsp, -const compat_sigset_t __user *sigmask,compat_size_t sigsetsize) +COMPAT_SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds, + unsigned int, nfds, struct compat_timespec __user *, tsp, + const compat_sigset_t __user *, sigmask, compat_size_t, sigsetsize) {compat_sigset_t ss32;sigset_t ksigmask, sigsaved;
@@ -2096,9 +2093,9 @@ static int compat_nfs_getfh_res_trans(union nfsctl_res *kres,return (err) ? -EFAULT :0 ; } -asmlinkage long compat_sys_nfsservctl (int cmd, -struct compat_nfsctl_arg __user *arg, -union compat_nfsctl_res __user *res) +COMPAT_SYSCALL_DEFINE3(nfsservctl, int cmd, + struct compat_nfsctl_arg __user *, arg, + union compat_nfsctl_res __user *, res) {struct nfsctl_arg *karg;union nfsctl_res *kres;
@@ -2174,11 +2171,11 @@ long asmlinkage compat_sys_nfsservctl(int cmd, void *notused, void *notused2) #ifdef CONFIG_EPOLL #ifdef HAVE_SET_RESTORE_SIGMASK -asmlinkage long compat_sys_epoll_pwait(int epfd, - struct compat_epoll_event __user *events, - int maxevents, int timeout, - const compat_sigset_t __user *sigmask, - compat_size_t sigsetsize) +COMPAT_SYSCALL_DEFINE6(epoll_pwait, int, epfd, + struct compat_epoll_event __user *, events, + int, maxevents, int, timeout, + const compat_sigset_t __user *, sigmask, + compat_size_t, sigsetsize) { long err; compat_sigset_t csigmask;
@@ -2223,9 +2220,9 @@ asmlinkage long compat_sys_epoll_pwait(int epfd,#ifdef CONFIG_SIGNALFD -asmlinkage long compat_sys_signalfd4 (int ufd, -const compat_sigset_t __user *sigmask, -compat_size_t sigsetsize,int flags) +COMPAT_SYSCALL_DEFINE4 (signalfd4, int, ufd, + const compat_sigset_t __user *, sigmask, + compat_size_t, sigsetsize, int, flags) {compat_sigset_t ss32;sigset_t tmp;
@@ -2243,9 +2240,9 @@ asmlinkage long compat_sys_signalfd4(int ufd,return sys_signalfd4 (ufd, ksigmask,sizeof (sigset_t), flags); } -asmlinkage long compat_sys_signalfd (int ufd, -const compat_sigset_t __user *sigmask, -compat_size_t sigsetsize) +COMPAT_SYSCALL_DEFINE3 (signalfd, int, ufd, + const compat_sigset_t __user *, sigmask, + compat_size_t, sigsetsize) {return compat_sys_signalfd4 (ufd, sigmask, sigsetsize,0 ); }
@@ -2253,9 +2250,9 @@ asmlinkage long compat_sys_signalfd(int ufd,#ifdef CONFIG_TIMERFD -asmlinkage long compat_sys_timerfd_settime (int ufd,int flags, -const struct compat_itimerspec __user *utmr, -struct compat_itimerspec __user *otmr) +COMPAT_SYSCALL_DEFINE4 (timerfd_settime, int, ufd, int, flags, + const struct compat_itimerspec __user *, utmr, + struct compat_itimerspec __user *, otmr) {int error;struct itimerspec t;
@@ -2274,8 +2271,8 @@ asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,return error; } -asmlinkage long compat_sys_timerfd_gettime (int ufd, -struct compat_itimerspec __user *otmr) +COMPAT_SYSCALL_DEFINE2 (timerfd_gettime, int, ufd, + struct compat_itimerspec __user *, otmr) {int error;struct itimerspec t;
Signature · 1 line
1.6.5.1
PATCH 12/14 tags: recognize compat syscalls
In reply to Jason Baronmake tags.sh recognize the new syscall macros:
COMPAT_SYSCALL_DEFINE#N()
ARCH_COMPAT_SYSCALL_DEFINE#N()
--- scripts/tags.sh | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
scripts/tags.sh +6 -2
@@ -110,7 +110,9 @@ exuberant() -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ --extra=+f --c-kinds=-px \ --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \ - --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' + --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ + --regex-c='/^COMPAT_SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/compat_sys_\1/' \ + --regex-c='/^ARCH_COMPAT_SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys32_\1/' all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \
@@ -130,7 +132,9 @@ emacs() { all_sources | xargs $1 -a \ --regex='/^ENTRY(\([^)]*\)).*/\1/' \ - --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' + --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ + --regex='/^COMPAT_SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/compat_sys_\1/' \ + --regex='/^ARCH_COMPAT_SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys32_\1/' all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
PATCH 14/14 tracing: make a "compat_syscalls" tracing subsys
In reply to Jason BaronCreate a new "compat_syscalls" subsys for tracing
--- include/linux/syscalls.h | 38 +++++++++++++++++++------------------- 1 files changed, 19 insertions(+), 19 deletions(-)
include/linux/syscalls.h +19 -19
@@ -128,7 +128,7 @@ struct perf_event_attr;#define __SC_STR_TDECL5 (t, a, ...) #t, __SC_STR_TDECL4(__VA_ARGS__)#define __SC_STR_TDECL6 (t, a, ...) #t, __SC_STR_TDECL5(__VA_ARGS__) -#define SYSCALL_TRACE_ENTER_EVENT (sname) \ +#define SYSCALL_TRACE_ENTER_EVENT (sname, subsys) \ static const struct syscall_metadata __syscall_meta_##sname; \ static struct ftrace_event_call \ __attribute__((__aligned__(4))) event_enter_##sname; \
@@ -140,7 +140,7 @@ struct perf_event_attr; __attribute__((section("_ftrace_events"))) \ event_enter_##sname = { \ .name = "enter_"#sname, \ - .system = "syscalls", \ + .system = #subsys, \ .event = &enter_syscall_print_##sname, \ .raw_init = init_syscall_trace, \ .define_fields = syscall_enter_define_fields, \
@@ -150,7 +150,7 @@ struct perf_event_attr; TRACE_SYS_ENTER_PROFILE_INIT \ } -#define SYSCALL_TRACE_EXIT_EVENT (sname) \ +#define SYSCALL_TRACE_EXIT_EVENT (sname, subsys) \ static const struct syscall_metadata __syscall_meta_##sname; \ static struct ftrace_event_call \ __attribute__((__aligned__(4))) event_exit_##sname; \
@@ -162,7 +162,7 @@ struct perf_event_attr; __attribute__((section("_ftrace_events"))) \ event_exit_##sname = { \ .name = "exit_"#sname, \ - .system = "syscalls", \ + .system = #subsys, \ .event = &exit_syscall_print_##sname, \ .raw_init = init_syscall_trace, \ .define_fields = syscall_exit_define_fields, \
@@ -172,9 +172,9 @@ struct perf_event_attr; TRACE_SYS_EXIT_PROFILE_INIT \ } -#define SYSCALL_METADATA (rname, sname, nb) \ - SYSCALL_TRACE_ENTER_EVENT(sname); \ - SYSCALL_TRACE_EXIT_EVENT(sname); \ +#define SYSCALL_METADATA (rname, sname, nb, subsys) \ + SYSCALL_TRACE_ENTER_EVENT(sname, subsys); \ + SYSCALL_TRACE_EXIT_EVENT(sname, subsys); \ static const struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \
@@ -192,8 +192,8 @@ struct perf_event_attr; };#define SYSCALL_DEFINE0 (sname) \ - SYSCALL_TRACE_ENTER_EVENT(sys_##sname); \ - SYSCALL_TRACE_EXIT_EVENT(sys_##sname); \ + SYSCALL_TRACE_ENTER_EVENT(sys_##sname, syscalls); \ + SYSCALL_TRACE_EXIT_EVENT(sys_##sname, syscalls); \ static const struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \
@@ -236,17 +236,17 @@ struct perf_event_attr;#define COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, compat_sys_##name, name, __VA_ARGS__)#ifdef CONFIG_FTRACE_SYSCALLS -#define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ - static const char *types_compat_sys_##sname[] = { \ - __SC_STR_TDECL##x(__VA_ARGS__) \ - }; \ - static const char *args_compat_sys_##sname[] = { \ - __SC_STR_ADECL##x(__VA_ARGS__) \ - }; \ - SYSCALL_METADATA(syscall, compat_sys_##sname, x); \ +#define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ + static const char *types_compat_sys_##sname[] = { \ + __SC_STR_TDECL##x(__VA_ARGS__) \ + }; \ + static const char *args_compat_sys_##sname[] = { \ + __SC_STR_ADECL##x(__VA_ARGS__) \ + }; \ + SYSCALL_METADATA(syscall, compat_sys_##sname, x, compat_syscalls);\ asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))#else -#define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \ +#define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \ asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))#endif
@@ -274,7 +274,7 @@ struct perf_event_attr; static const char *args_sys##sname[] = { \ __SC_STR_ADECL##x(__VA_ARGS__) \ }; \ - SYSCALL_METADATA(sys##sname, sys##sname, x); \ + SYSCALL_METADATA(sys##sname, sys##sname, x, syscalls); \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)#else #define SYSCALL_DEFINEx (x, sname, ...) \
Signature · 1 line
1.6.5.1
PATCH 13/14 cleanup: remove arg from TRACE_SYS_ENTER_PROFILE_INIT() macro
In reply to Jason BaronSince TRACE_SYS_ENTER_PROFILE_INIT() and TRACE_SYS_EXIT_PROFILE_INIT() don't do anything with their arguments, remove them. Also, TRACE_SYS_ENTER_PROFILE() and TRACE_SYS_EXIT_PROFILE() don't appear to be used. remove them.
--- include/linux/syscalls.h | 14 ++++++-------- 1 files changed, 6 insertions(+), 8 deletions(-)
include/linux/syscalls.h +6 -8
@@ -101,18 +101,16 @@ struct perf_event_attr;#ifdef CONFIG_PERF_EVENTS -#define TRACE_SYS_ENTER_PROFILE_INIT (sname) \ +#define TRACE_SYS_ENTER_PROFILE_INIT \ .profile_enable = prof_sysenter_enable, \ .profile_disable = prof_sysenter_disable, -#define TRACE_SYS_EXIT_PROFILE_INIT (sname) \ +#define TRACE_SYS_EXIT_PROFILE_INIT \ .profile_enable = prof_sysexit_enable, \ .profile_disable = prof_sysexit_disable,#else -#define TRACE_SYS_ENTER_PROFILE (sname) -#define TRACE_SYS_ENTER_PROFILE_INIT (sname) -#define TRACE_SYS_EXIT_PROFILE (sname) -#define TRACE_SYS_EXIT_PROFILE_INIT (sname) +#define TRACE_SYS_ENTER_PROFILE_INIT +#define TRACE_SYS_EXIT_PROFILE_INIT #endif /* CONFIG_PERF_EVENTS */ #ifdef CONFIG_FTRACE_SYSCALLS
@@ -149,7 +147,7 @@ struct perf_event_attr; .regfunc = reg_event_syscall_enter, \ .unregfunc = unreg_event_syscall_enter, \ .data = (void *)&__syscall_meta_##sname,\ - TRACE_SYS_ENTER_PROFILE_INIT(sname) \ + TRACE_SYS_ENTER_PROFILE_INIT \ }#define SYSCALL_TRACE_EXIT_EVENT (sname) \
@@ -171,7 +169,7 @@ struct perf_event_attr; .regfunc = reg_event_syscall_exit, \ .unregfunc = unreg_event_syscall_exit, \ .data = (void *)&__syscall_meta_##sname,\ - TRACE_SYS_EXIT_PROFILE_INIT(sname) \ + TRACE_SYS_EXIT_PROFILE_INIT \ }#define SYSCALL_METADATA (rname, sname, nb) \
Signature · 1 line
1.6.5.1
PATCH 9/14 syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro
In reply to Jason BaronAdd COMPAT_SYSCALL_DEFINE#N() macro define common compat syscalls that are not arch specific. Prepends "compat_sys_" to the syscall name to identify it.
--- include/linux/syscalls.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
include/linux/syscalls.h +7 -0
@@ -230,6 +230,13 @@ struct perf_event_attr;#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) COMPAT_SYSCALL_DEFINEx(5, sys32_##name, name, __VA_ARGS__)#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, sys32_##name, name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE1 (name, ...) COMPAT_SYSCALL_DEFINEx(1, compat_sys_##name, name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE2 (name, ...) COMPAT_SYSCALL_DEFINEx(2, compat_sys_##name, name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE3 (name, ...) COMPAT_SYSCALL_DEFINEx(3, compat_sys_##name, name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE4 (name, ...) COMPAT_SYSCALL_DEFINEx(4, compat_sys_##name, name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE5 (name, ...) COMPAT_SYSCALL_DEFINEx(5, compat_sys_##name, name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, compat_sys_##name, name, __VA_ARGS__) +#ifdef CONFIG_FTRACE_SYSCALLS #define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ static const char *types_compat_sys_##sname[] = { \
Signature · 1 line
1.6.5.1
PATCH 4/14 tracing: remove syscall bitmaps in preparation for compat support
In reply to Jason BaronIn preparation for compat syscall tracing support, let's store the enabled syscalls, with the struct syscall_metadata itself. That way we don't duplicate enabled information when the compat table points to an entry in the regular syscall table. Also, allows us to remove the bitmap data structures completely.
--- include/linux/syscalls.h | 8 +++++++ include/trace/syscall.h | 4 +++ kernel/trace/trace_syscalls.c | 42 +++++++++++++++++++--------------------- 3 files changed, 32 insertions(+), 22 deletions(-)
include/linux/syscalls.h +8 -0
@@ -185,6 +185,10 @@ struct perf_event_attr; .nb_args = nb, \ .types = types_##sname, \ .args = args_##sname, \ + .ftrace_enter = 0, \ + .ftrace_exit = 0, \ + .perf_enter = 0, \ + .perf_exit = 0, \ .enter_event = &event_enter_##sname, \ .exit_event = &event_exit_##sname, \ };
@@ -198,6 +202,10 @@ struct perf_event_attr; __syscall_meta__##sname = { \ .name = "sys_"#sname, \ .nb_args = 0, \ + .ftrace_enter = 0, \ + .ftrace_exit = 0, \ + .perf_enter = 0, \ + .perf_exit = 0, \ .enter_event = &event_enter__##sname, \ .exit_event = &event_exit__##sname, \ }; \
include/trace/syscall.h +4 -0
@@ -25,6 +25,10 @@ struct syscall_metadata {int nb_args;const char **types;const char **args; +char ftrace_enter; +char ftrace_exit; +char perf_enter; +char perf_exit;struct ftrace_event_call *enter_event;struct ftrace_event_call *exit_event;
kernel/trace/trace_syscalls.c +20 -22
144 lines not on this page · raw message
Signature · 1 line
1.6.5.1
PATCH 3/14 compat: have generic is_compat_task for !CONFIG_COMPAT
In reply to Jason BaronFrom: Heiko Carstens <[email protected]>
add generic is_compat_task()
--- arch/s390/include/asm/compat.h | 7 ------- arch/s390/kernel/ptrace.c | 2 +- arch/s390/kernel/setup.c | 2 +- arch/s390/mm/mmap.c | 2 +- drivers/s390/block/dasd_eckd.c | 2 +- drivers/s390/block/dasd_ioctl.c | 1 + drivers/s390/char/fs3270.c | 1 + drivers/s390/char/vmcp.c | 1 + drivers/s390/cio/chsc_sch.c | 1 + drivers/s390/scsi/zfcp_cfdc.c | 1 + include/linux/compat.h | 7 +++++++ 11 files changed, 16 insertions(+), 11 deletions(-)
arch/s390/include/asm/compat.h +0 -7
@@ -171,13 +171,6 @@ static inline int is_compat_task(void) return test_thread_flag(TIF_31BIT); } -#else - -static inline int is_compat_task (void ) -{ -return 0 ; -} -#endif static inline void __user *compat_alloc_user_space (long len)
arch/s390/kernel/ptrace.c +1 -1
@@ -36,8 +36,8 @@#include <linux/regset.h> #include <linux/tracehook.h> #include <linux/seccomp.h> +#include <linux/compat.h> #include <trace/syscall.h> -#include <asm/compat.h> #include <asm/segment.h> #include <asm/page.h> #include <asm/pgtable.h>
arch/s390/kernel/setup.c +1 -1
@@ -43,7 +43,7 @@#include <linux/reboot.h> #include <linux/topology.h> #include <linux/ftrace.h> - +#include <linux/compat.h> #include <asm/ipl.h> #include <asm/uaccess.h> #include <asm/system.h>
arch/s390/mm/mmap.c +1 -1
@@ -27,8 +27,8 @@#include <linux/personality.h> #include <linux/mm.h> #include <linux/module.h> +#include <linux/compat.h> #include <asm/pgalloc.h> -#include <asm/compat.h> /* * Top of mmap area (just below the process stack).
drivers/s390/block/dasd_eckd.c +1 -1
@@ -14,6 +14,7 @@#include <linux/stddef.h> #include <linux/kernel.h> +#include <linux/compat.h> #include <linux/slab.h> #include <linux/hdreg.h> /* HDIO_GETGEO */ #include <linux/bio.h>
@@ -23,7 +24,6 @@#include <asm/debug.h> #include <asm/idals.h> #include <asm/ebcdic.h> -#include <asm/compat.h> #include <asm/io.h> #include <asm/uaccess.h> #include <asm/cio.h>
drivers/s390/block/dasd_ioctl.c +1 -0
@@ -17,6 +17,7 @@#include <linux/fs.h> #include <linux/blkpg.h> #include <linux/smp_lock.h> +#include <linux/compat.h> #include <asm/compat.h> #include <asm/ccwdev.h> #include <asm/cmb.h>
drivers/s390/char/fs3270.c +1 -0
@@ -14,6 +14,7 @@#include <linux/list.h> #include <linux/types.h> #include <linux/smp_lock.h> +#include <linux/compat.h> #include <asm/compat.h> #include <asm/ccwdev.h>
drivers/s390/char/vmcp.c +1 -0
@@ -19,6 +19,7 @@#include <linux/kernel.h> #include <linux/miscdevice.h> #include <linux/module.h> +#include <linux/compat.h> #include <asm/compat.h> #include <asm/cpcmd.h> #include <asm/debug.h>
drivers/s390/cio/chsc_sch.c +1 -0
@@ -8,6 +8,7 @@*/ #include <linux/device.h> +#include <linux/compat.h> #include <linux/module.h> #include <linux/uaccess.h> #include <linux/miscdevice.h>
drivers/s390/scsi/zfcp_cfdc.c +1 -0
@@ -12,6 +12,7 @@#include <linux/types.h> #include <linux/miscdevice.h> +#include <linux/compat.h> #include <asm/compat.h> #include <asm/ccwdev.h> #include "zfcp_def.h"
include/linux/compat.h +7 -0
@@ -353,5 +353,12 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename,asmlinkage long compat_sys_openat (unsigned int dfd,const char __user *filename,int flags,int mode); +#else /* CONFIG_COMPAT */ + +static inline int is_compat_task (void ) +{ +return 0 ; +} +#endif /* CONFIG_COMPAT */ #endif /* _LINUX_COMPAT_H */
Signature · 1 line
1.6.5.1
PATCH 10/14 compat: convert to use COMPAT_SYSCALL_DEFINE#N()
In reply to Jason Baronconvert kernel/compat.c to use the new COMPAT_SYSCALL_DEFINE#N macro. Thus, tying these syscalls into the syscall event layer.
--- kernel/compat.c | 106 ++++++++++++++++++++++++++---------------------------- 1 files changed, 51 insertions(+), 55 deletions(-)
kernel/compat.c +51 -55
@@ -51,8 +51,8 @@ static int compat_put_timeval(struct compat_timeval __user *o, put_user(i->tv_usec, &o->tv_usec)) ? -EFAULT : 0; } -asmlinkage long compat_sys_gettimeofday (struct compat_timeval __user *tv, -struct timezone __user *tz) +COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv, + struct timezone __user *, tz) {if (tv) {struct timeval ktv;
@@ -68,8 +68,8 @@ asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,return 0 ; } -asmlinkage long compat_sys_settimeofday (struct compat_timeval __user *tv, -struct timezone __user *tz) +COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv, + struct timezone __user *, tz) {struct timespec kts;struct timezone ktz;
@@ -123,8 +123,8 @@ static long compat_nanosleep_restart(struct restart_block *restart)return ret; } -asmlinkage long compat_sys_nanosleep (struct compat_timespec __user *rqtp, -struct compat_timespec __user *rmtp) +COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp, + struct compat_timespec __user *, rmtp) {struct timespec tu, rmt;mm_segment_t oldfs;
@@ -177,8 +177,8 @@ static inline long put_compat_itimerval(struct compat_itimerval __user *o, __put_user(i->it_value.tv_usec, &o->it_value.tv_usec))); } -asmlinkage long compat_sys_getitimer (int which, -struct compat_itimerval __user *it) +COMPAT_SYSCALL_DEFINE2 (getitimer, int, which, + struct compat_itimerval __user *, it) {struct itimerval kit;int error;
@@ -189,9 +189,9 @@ asmlinkage long compat_sys_getitimer(int which,return error; } -asmlinkage long compat_sys_setitimer (int which, -struct compat_itimerval __user *in, -struct compat_itimerval __user *out) +COMPAT_SYSCALL_DEFINE3 (setitimer, int, which, + struct compat_itimerval __user *, in, + struct compat_itimerval __user *, out) {struct itimerval kin, kout;int error;
@@ -215,7 +215,7 @@ static compat_clock_t clock_t_to_compat_clock_t(clock_t x)return compat_jiffies_to_clock_t (clock_t_to_jiffies (x)); } -asmlinkage long compat_sys_times (struct compat_tms __user *tbuf) +COMPAT_SYSCALL_DEFINE1(times, struct compat_tms __user *, tbuf) {if (tbuf) {struct tms tms;
@@ -239,7 +239,7 @@ asmlinkage long compat_sys_times(struct compat_tms __user *tbuf)* types that can be passed to put_user()/get_user(). */ -asmlinkage long compat_sys_sigpending (compat_old_sigset_t __user *set) +COMPAT_SYSCALL_DEFINE1(sigpending, compat_old_sigset_t __user *, set) {old_sigset_t s;long ret;
@@ -253,8 +253,8 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)return ret; } -asmlinkage long compat_sys_sigprocmask (int how,compat_old_sigset_t __user *set, -compat_old_sigset_t __user *oset) +COMPAT_SYSCALL_DEFINE3(sigprocmask, int, how, compat_old_sigset_t __user *, set, + compat_old_sigset_t __user *, oset) {old_sigset_t s;long ret;
@@ -274,8 +274,8 @@ asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *set,return ret; } -asmlinkage long compat_sys_setrlimit (unsigned int resource, -struct compat_rlimit __user *rlim) +COMPAT_SYSCALL_DEFINE2(setrlimit, unsigned int, resource, + struct compat_rlimit __user *, rlim) {struct rlimit r;int ret;
@@ -301,8 +301,8 @@ asmlinkage long compat_sys_setrlimit(unsigned int resource,#ifdef COMPAT_RLIM_OLD_INFINITY -asmlinkage long compat_sys_old_getrlimit (unsigned int resource, -struct compat_rlimit __user *rlim) +COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource, + struct compat_rlimit __user *, rlim) {struct rlimit r;int ret;
@@ -328,8 +328,8 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,#endif -asmlinkage long compat_sys_getrlimit (unsigned int resource, -struct compat_rlimit __user *rlim) +COMPAT_SYSCALL_DEFINE2(getrlimit, unsigned int, resource, + struct compat_rlimit __user *, rlim) {struct rlimit r;int ret;
@@ -377,7 +377,7 @@ int put_compat_rusage(const struct rusage *r, struct compat_rusage __user *ru)return 0 ; } -asmlinkage long compat_sys_getrusage (int who,struct compat_rusage __user *ru) +COMPAT_SYSCALL_DEFINE2(getrusage, int, who, struct compat_rusage __user *, ru) {struct rusage r;int ret;
@@ -396,9 +396,8 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)return 0 ; } -asmlinkage long -compat_sys_wait4 (compat_pid_t pid,compat_uint_t __user *stat_addr,int options, -struct compat_rusage __user *ru) +COMPAT_SYSCALL_DEFINE4(wait4, compat_pid_t, pid, compat_uint_t __user *, stat_addr, int, options, + struct compat_rusage __user *, ru) {if (!ru) {return sys_wait4 (pid, stat_addr, options,NULL );
@@ -425,9 +424,9 @@ compat_sys_wait4(compat_pid_t pid, compat_uint_t __user *stat_addr, int options, } } -asmlinkage long compat_sys_waitid (int which,compat_pid_t pid, -struct compat_siginfo __user *uinfo,int options, -struct compat_rusage __user *uru) +COMPAT_SYSCALL_DEFINE5 (waitid, int, which, compat_pid_t, pid, + struct compat_siginfo __user *, uinfo, int, options, + struct compat_rusage __user *, uru) {siginfo_t info;struct rusage ru;
@@ -469,9 +468,9 @@ static int compat_get_user_cpu_mask(compat_ulong_t __user *user_mask_ptr,return compat_get_bitmap (k, user_mask_ptr, len *8 ); } -asmlinkage long compat_sys_sched_setaffinity (compat_pid_t pid, -unsigned int len, -compat_ulong_t __user *user_mask_ptr) +COMPAT_SYSCALL_DEFINE3 (sched_setaffinity, compat_pid_t, pid, + unsigned int, len, + compat_ulong_t __user *, user_mask_ptr) {cpumask_var_t new_mask;int retval;
@@ -489,8 +488,8 @@ out:return retval; } -asmlinkage long compat_sys_sched_getaffinity (compat_pid_t pid,unsigned int len, -compat_ulong_t __user *user_mask_ptr) +COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len, + compat_ulong_t __user *, user_mask_ptr) {int ret;cpumask_var_t mask;
@@ -815,10 +814,9 @@ sigset_from_compat (sigset_t *set, compat_sigset_t *compat) } } -asmlinkage long -compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese, -struct compat_siginfo __user *uinfo, -struct compat_timespec __user *uts,compat_size_t sigsetsize) +COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait, compat_sigset_t __user *, uthese, + struct compat_siginfo __user *, uinfo, + struct compat_timespec __user *, uts, compat_size_t, sigsetsize) {compat_sigset_t s32;sigset_t s;
@@ -882,9 +880,8 @@ compat_sys_rt_sigtimedwait (compat_sigset_t __user *uthese, } -asmlinkage long -compat_sys_rt_tgsigqueueinfo (compat_pid_t tgid,compat_pid_t pid,int sig, -struct compat_siginfo __user *uinfo) +COMPAT_SYSCALL_DEFINE4 (rt_tgsigqueueinfo, compat_pid_t, tgid, compat_pid_t, pid, int, sig, + struct compat_siginfo __user *, uinfo) {siginfo_t info;
@@ -897,7 +894,7 @@ compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,/* compat_time_t is a 32 bit "long" and needs to get converted. */ -asmlinkage long compat_sys_time (compat_time_t __user * tloc) +COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc) {compat_time_t i;struct timeval tv;
@@ -913,7 +910,7 @@ asmlinkage long compat_sys_time(compat_time_t __user * tloc)return i; } -asmlinkage long compat_sys_stime (compat_time_t __user *tptr) +COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr) {struct timespec tv;int err;
@@ -934,7 +931,7 @@ asmlinkage long compat_sys_stime(compat_time_t __user *tptr)#endif /* __ARCH_WANT_COMPAT_SYS_TIME */ #ifdef __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND -asmlinkage long compat_sys_rt_sigsuspend (compat_sigset_t __user *unewset,compat_size_t sigsetsize) +COMPAT_SYSCALL_DEFINE2(rt_sigsuspend, compat_sigset_t __user *, unewset, compat_size_t, sigsetsize) {sigset_t newset;compat_sigset_t newset32;
@@ -961,7 +958,7 @@ asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset, compat }#endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */ -asmlinkage long compat_sys_adjtimex (struct compat_timex __user *utp) +COMPAT_SYSCALL_DEFINE1(adjtimex, struct compat_timex __user *, utp) {struct timex txc;int ret;
@@ -1021,11 +1018,11 @@ asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp) }#ifdef CONFIG_NUMA -asmlinkage long compat_sys_move_pages (pid_t pid,unsigned long nr_pages, -compat_uptr_t __user *pages32, -const int __user *nodes, -int __user *status, -int flags) +COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, + compat_uptr_t __user *, pages32, + const int __user *, nodes, + int __user *, status, + int, flags) {const void __user *__user *pages;int i;
@@ -1041,10 +1038,10 @@ asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_pages,return sys_move_pages (pid, nr_pages, pages, nodes, status, flags); } -asmlinkage long compat_sys_migrate_pages (compat_pid_t pid, -compat_ulong_t maxnode, -const compat_ulong_t __user *old_nodes, -const compat_ulong_t __user *new_nodes) +COMPAT_SYSCALL_DEFINE4 (migrate_pages, compat_pid_t, pid, + compat_ulong_t, maxnode, + const compat_ulong_t __user *, old_nodes, + const compat_ulong_t __user *, new_nodes) {unsigned long __user *old =NULL ;unsigned long __user *new =NULL ;
@@ -1092,8 +1089,7 @@ struct compat_sysinfo {char _f[20 -2 *sizeof (u32)-sizeof (int )]; }; -asmlinkage long -compat_sys_sysinfo (struct compat_sysinfo __user *info) +COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info) {struct sysinfo s;
Signature · 1 line
1.6.5.1
PATCH 7/14 syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
In reply to Jason BaronAdd ARCH_COMPAT_SYSCALL_DEFINE#N() macro which prepends "sys32_" to arch specific compat syscall names. Identifies the 'compat' syscalls.
--- include/linux/syscalls.h | 50 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 38 insertions(+), 12 deletions(-)
include/linux/syscalls.h +38 -12
@@ -141,7 +141,7 @@ struct perf_event_attr; __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_events"))) \ event_enter_##sname = { \ - .name = "sys_enter"#sname, \ + .name = "enter_"#sname, \ .system = "syscalls", \ .event = &enter_syscall_print_##sname, \ .raw_init = init_syscall_trace, \
@@ -163,7 +163,7 @@ struct perf_event_attr; __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_events"))) \ event_exit_##sname = { \ - .name = "sys_exit"#sname, \ + .name = "exit_"#sname, \ .system = "syscalls", \ .event = &exit_syscall_print_##sname, \ .raw_init = init_syscall_trace, \
@@ -174,14 +174,14 @@ struct perf_event_attr; TRACE_SYS_EXIT_PROFILE_INIT(sname) \ } -#define SYSCALL_METADATA (sname, nb) \ +#define SYSCALL_METADATA (rname, sname, nb) \ SYSCALL_TRACE_ENTER_EVENT(sname); \ SYSCALL_TRACE_EXIT_EVENT(sname); \ static const struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ __syscall_meta_##sname = { \ - .name = "sys"#sname, \ + .name = #rname, \ .nb_args = nb, \ .types = types_##sname, \ .args = args_##sname, \
@@ -194,20 +194,20 @@ struct perf_event_attr; };#define SYSCALL_DEFINE0 (sname) \ - SYSCALL_TRACE_ENTER_EVENT(_##sname); \ - SYSCALL_TRACE_EXIT_EVENT(_##sname); \ + SYSCALL_TRACE_ENTER_EVENT(sys_##sname); \ + SYSCALL_TRACE_EXIT_EVENT(sys_##sname); \ static const struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ - __syscall_meta__##sname = { \ + __syscall_meta_sys_##sname = { \ .name = "sys_"#sname, \ .nb_args = 0, \ .ftrace_enter = 0, \ .ftrace_exit = 0, \ .perf_enter = 0, \ .perf_exit = 0, \ - .enter_event = &event_enter__##sname, \ - .exit_event = &event_exit__##sname, \ + .enter_event = &event_enter_sys_##sname, \ + .exit_event = &event_exit_sys_##sname, \ }; \ asmlinkage long sys_##sname(void)#else
@@ -221,6 +221,32 @@ struct perf_event_attr;#define SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)#define SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) +#ifdef CONFIG_COMPAT + +#define ARCH_COMPAT_SYSCALL_DEFINE1 (name, ...) COMPAT_SYSCALL_DEFINEx(1, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE2 (name, ...) COMPAT_SYSCALL_DEFINEx(2, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE3 (name, ...) COMPAT_SYSCALL_DEFINEx(3, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE4 (name, ...) COMPAT_SYSCALL_DEFINEx(4, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) COMPAT_SYSCALL_DEFINEx(5, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, sys32_##name, name, __VA_ARGS__) + +#ifdef CONFIG_FTRACE_SYSCALLS +#define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ + static const char *types_compat_sys_##sname[] = { \ + __SC_STR_TDECL##x(__VA_ARGS__) \ + }; \ + static const char *args_compat_sys_##sname[] = { \ + __SC_STR_ADECL##x(__VA_ARGS__) \ + }; \ + SYSCALL_METADATA(syscall, compat_sys_##sname, x); \ + asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__)) +#else +#define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \ + asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__)) +#endif + +#endif +#ifdef CONFIG_PPC64 #define SYSCALL_ALIAS (alias, name) \ asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \
@@ -237,13 +263,13 @@ struct perf_event_attr;#ifdef CONFIG_FTRACE_SYSCALLS #define SYSCALL_DEFINEx (x, sname, ...) \ - static const char *types_##sname[] = { \ + static const char *types_sys##sname[] = { \ __SC_STR_TDECL##x(__VA_ARGS__) \ }; \ - static const char *args_##sname[] = { \ + static const char *args_sys##sname[] = { \ __SC_STR_ADECL##x(__VA_ARGS__) \ }; \ - SYSCALL_METADATA(sname, x); \ + SYSCALL_METADATA(sys##sname, sys##sname, x); \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)#else #define SYSCALL_DEFINEx (x, sname, ...) \
Signature · 1 line
1.6.5.1
Re: [PATCH 02/14] x86: add arch_compat_syscall_addr()
In reply to Jason BaronQuoted 14 lines · Jason Baron
Add
arch_compat_syscall_addr(int nr)forx86_64. This is in preparation for adding compat syscall support to the event tracer.Signed-off-by Jason Baron <[email protected]>--- arch/x86/include/asm/syscall.h | 5 +++++ arch/x86/kernel/ftrace.c | 8 ++++++++ 2 files changed, 13 insertions(+), 0 deletions(-)arch/x86/include/asm/syscall.h +0
-0
arch/x86/include/asm/syscall.h line 22
Quoted 7 lines
arch/x86/include/asm/syscall.h +4
-0@@ -16,7 +16,12 @@#include <linux/sched.h> #include <linux/err.h> +#if defined(CONFIG_COMPAT ) && defined(CONFIG_FTRACE_SYSCALLS ) +#define __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS +#endif +
A config would be better:
arch/Kconfig:
config HAVE_COMPAT_FTRACE_SYSCALLS bool config COMPAT_FTRACE_SYSCALLS def_bool y depends on COMPAT && FTRACE_SYSCALLS && HAVE_COMPAT_FTRACE_SYSCALLS
arch/x86/Kconfig:
config X86 [...] select HAVE_COMPAT_FTRACE_SYSCALLS [...]
So that we centralize the definition of COMPAT_FTRACE_SYSCALLS and we don't need every archs to redefine the dependency and to stay sync with potential dependency changes.
Thanks.
Quoted 31 lines
arch/x86/include/asm/syscall.h +1
-0extern const unsigned long sys_call_table[]; +extern const unsigned long *ia32_sys_call_table;/* * Only the low 32 bits of orig_ax are meaningful, so we return int. arch/x86/kernel/ftrace.c +8
-0@@ -26,6 +26,7 @@#include <asm/ftrace.h> #include <asm/nops.h> #include <asm/nmi.h> +#include <asm/syscall.h> #ifdef CONFIG_DYNAMIC_FTRACE @@ -510,3 +511,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, } }#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ + +#ifdef __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS +unsigned long __init arch_compat_syscall_addr (int nr) +{ +return (unsigned long )(&ia32_sys_call_table)[nr]; +} +#endif Signature · 1 line
1.6.5.1
Re: [PATCH 15/14] compat_syscalls: introduce CONFIG_COMPAT_FTRACE_SYSCALLS
In reply to Jason Baronmove the logic for enabling compat syscalls to common arch/Kconfig, where config_compat_ftrace_syscalls depends on CONFIG_COMPAT, CONFIG_FTRACE_SYSCALLS, and a per-arch CONFIG_HAVE_COMPAT_FTRACE_SYSCALLS. In this way arches that want to add support for compat syscalls, can request it via selecting HAVE_COMPAT_FTRACE_SYSCALLS in their respective arch Kconfig files.
--- arch/Kconfig | 7 +++++++ arch/x86/Kconfig | 1 + arch/x86/include/asm/syscall.h | 4 ---- arch/x86/kernel/ftrace.c | 2 +- include/linux/syscalls.h | 2 +- kernel/trace/trace_syscalls.c | 2 +- 6 files changed, 11 insertions(+), 7 deletions(-)
arch/Kconfig +7 -0
@@ -153,4 +153,11 @@ config HAVE_HW_BREAKPOINT config HAVE_USER_RETURN_NOTIFIER bool +config HAVE_COMPAT_FTRACE_SYSCALLS + bool + +config COMPAT_FTRACE_SYSCALLS + def_bool y + depends on COMPAT && FTRACE_SYSCALLS && HAVE_COMPAT_FTRACE_SYSCALLS + source "kernel/gcov/Kconfig"
arch/x86/Kconfig +1 -0
@@ -40,6 +40,7 @@ config X86 select HAVE_FUNCTION_TRACE_MCOUNT_TEST select HAVE_FTRACE_NMI_ENTER if DYNAMIC_FTRACE select HAVE_SYSCALL_TRACEPOINTS + select HAVE_COMPAT_FTRACE_SYSCALLS select HAVE_KVM select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK
arch/x86/include/asm/syscall.h +0 -4
@@ -16,10 +16,6 @@#include <linux/sched.h> #include <linux/err.h> -#if defined(CONFIG_COMPAT ) && defined(CONFIG_FTRACE_SYSCALLS ) -#define __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS -#endif -extern const unsigned long sys_call_table[];extern const unsigned long *ia32_sys_call_table;
arch/x86/kernel/ftrace.c +1 -1
@@ -512,7 +512,7 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, }#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ -#ifdef __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS +#ifdef CONFIG_COMPAT_FTRACE_SYSCALLS unsigned long __init arch_compat_syscall_addr (int nr) {return (unsigned long )(&ia32_sys_call_table)[nr];
include/linux/syscalls.h +1 -1
@@ -235,7 +235,7 @@ struct perf_event_attr;#define COMPAT_SYSCALL_DEFINE5 (name, ...) COMPAT_SYSCALL_DEFINEx(5, compat_sys_##name, name, __VA_ARGS__)#define COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, compat_sys_##name, name, __VA_ARGS__) -#ifdef CONFIG_FTRACE_SYSCALLS +#ifdef CONFIG_COMPAT_FTRACE_SYSCALLS #define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ static const char *types_compat_sys_##sname[] = { \ __SC_STR_TDECL##x(__VA_ARGS__) \
kernel/trace/trace_syscalls.c +1 -1
@@ -439,7 +439,7 @@ int __init init_ftrace_syscalls(void) meta->syscall_nr = i; syscalls_metadata[i] = meta; } -#ifdef __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS +#ifdef CONFIG_COMPAT_FTRACE_SYSCALLS if (NR_syscalls_compat) {int match;struct ftrace_event_call *ftrace_event;
Signature · 1 line
1.6.5.1
Re: [PATCH 07/14 re-post] syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
In reply to Jason BaronRe-post due to missing macro parameter. interdiff:
include/linux/syscalls.h +1 -1
@@ -241,7 +241,7 @@ SYSCALL_METADATA(syscall, compat_sys_##sname, x); \ asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))#else -#define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \ +#define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))#endif
--------------------------------------------------------
Add ARCH_COMPAT_SYSCALL_DEFINE#N() macro which prepends "sys32_" to arch specific compat syscall names. Identifies the 'compat' syscalls.
--- include/linux/syscalls.h | 50 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 38 insertions(+), 12 deletions(-)
include/linux/syscalls.h +38 -12
105 lines not on this page · raw message
Signature · 1 line
1.6.5.1
Re: [PATCH 06/14] tracing: add tracing support for compat syscalls
In reply to Jason BaronQuoted 12 lines · Jason Baron
#else /*
CONFIG_COMPAT*/include/linux/compat.h +2
-0+#define NR_syscalls_compat 0 +static inline int is_compat_task (void ) {return 0 ;include/trace/syscall.h +0
-0
include/trace/syscall.h line 25
Quoted 4 lines
include/trace/syscall.h +1
-0@@ -22,6 +22,7 @@struct syscall_metadata {const char *name;int syscall_nr; +int compat_syscall_nr;
Why do you need both syscall_nr and compat_syscall_nr? Compat and usual syscalls never share the same syscall metadata.
Quoted 15 lines
include/trace/syscall.h +15
-0+#ifdef __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS +if (NR_syscalls_compat) { +int match; +struct ftrace_event_call *ftrace_event; + + compat_syscalls_metadata =kzalloc (sizeof (*syscalls_metadata) * + NR_syscalls_compat,GFP_KERNEL ); +if (!compat_syscalls_metadata) { +WARN_ON (1 ); +kfree (syscalls_metadata); +return -ENOMEM ; + } +for (i =0 ; i < NR_syscalls_compat; i++) { + addr =arch_compat_syscall_addr (i); + meta =find_syscall_meta (addr);
include/trace/syscall.h
Quoted 10 lines
include/trace/syscall.h +10
-0+if (!meta) +continue ; + + meta->compat_syscall_nr = i; + compat_syscalls_metadata[i] = meta; + } +/* now check if any compat_syscalls are not referenced */ +for (ftrace_event = __start_ftrace_events; + (unsigned long )ftrace_event < + (unsigned long )__stop_ftrace_events; ftrace_event++) {
You could reuse for_each_event()
include/trace/syscall.h
Quoted 10 lines
include/trace/syscall.h +10
-0+ match =0 ; +if (!ftrace_event->name) +continue ; +if (strcmp (ftrace_event->system,"compat_syscalls" )) +continue ; +for (i =0 ; i < NR_syscalls_compat; i++) { +if (ftrace_event->data == + compat_syscalls_metadata[i]) { + match =1 ; +break ;
Nano-neat: starting the whole block with if (NR_syscalls_compat) or making the whole a separate init_ftrace_syscalls() would have made it win one level of indentation.
include/trace/syscall.h
Quoted 4 lines
include/trace/syscall.h +4
-0+ } + } +if (!match) + ftrace_event->name =NULL ;
Nice :)
Thanks.
Re: [PATCH 06/14] tracing: add tracing support for compat syscalls
Quoted 14 lines · Frederic Weisbecker
Quoted 14 lines
#else /*
CONFIG_COMPAT*/include/linux/compat.h +2
-0+#define NR_syscalls_compat 0 +static inline int is_compat_task (void ) {return 0 ;include/trace/syscall.h +0
-0@@ -22,6 +22,7 @@struct syscall_metadata {const char *name;
Quoted 10 lines
include/trace/syscall.h line 25
Quoted 2 lines
include/trace/syscall.h +1
-0int syscall_nr; +int compat_syscall_nr;Why do you need both
syscall_nrandcompat_syscall_nr? Compat and usual syscalls never share the same syscall metadata.
For example, something like 'sys_read()' is pointed to by both syscalls_metadata and compat_syscalls_metadata. Thus, the same syscall metadata record is referenced by two different tables. That said, I'm not making use of compat_syscall_nr. Although it could be added to the checks in 'reg_event_syscall_enter()', to make sure that the compat_syscall_nr is valid.
Quoted 22 lines
Quoted 22 lines
include/trace/syscall.h +21
-0+#ifdef __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS +if (NR_syscalls_compat) { +int match; +struct ftrace_event_call *ftrace_event; + + compat_syscalls_metadata =kzalloc (sizeof (*syscalls_metadata) * + NR_syscalls_compat,GFP_KERNEL ); +if (!compat_syscalls_metadata) { +WARN_ON (1 ); +kfree (syscalls_metadata); +return -ENOMEM ; + } +for (i =0 ; i < NR_syscalls_compat; i++) { + addr =arch_compat_syscall_addr (i); + meta =find_syscall_meta (addr); +if (!meta) +continue ; + + meta->compat_syscall_nr = i; + compat_syscalls_metadata[i] = meta; + }
Quoted 10 lines
include/trace/syscall.h
Quoted 4 lines
include/trace/syscall.h +4
-0+/* now check if any compat_syscalls are not referenced */ +for (ftrace_event = __start_ftrace_events; + (unsigned long )ftrace_event < + (unsigned long )__stop_ftrace_events; ftrace_event++) {You could reuse
for_each_event()
ok. will update.
Quoted 17 lines
include/trace/syscall.h
Quoted 11 lines
include/trace/syscall.h +10
-0+ match =0 ; +if (!ftrace_event->name) +continue ; +if (strcmp (ftrace_event->system,"compat_syscalls" )) +continue ; +for (i =0 ; i < NR_syscalls_compat; i++) { +if (ftrace_event->data == + compat_syscalls_metadata[i]) { + match =1 ; +break ;Nano-neat: starting the whole block with if (
NR_syscalls_compat) or making the whole a separateinit_ftrace_syscalls()would have made it win one level of indentation.
yeah...I did that to add local variables at the beginning of the block so I wouldn't get unused warnings. A separate function is probably cleaner...will fix.
thanks,
-Jason
Re: [PATCH 06/14] tracing: add tracing support for compat syscalls
Quoted 26 lines · Jason Baron
Quoted 14 lines · Frederic Weisbecker
Quoted 14 lines
#else /*
CONFIG_COMPAT*/include/linux/compat.h +2
-0+#define NR_syscalls_compat 0 +static inline int is_compat_task (void ) {return 0 ;include/trace/syscall.h +0
-0@@ -22,6 +22,7 @@struct syscall_metadata {const char *name;Quoted 10 lines
include/trace/syscall.h line 25
Quoted 2 lines
include/trace/syscall.h +1
-0int syscall_nr; +int compat_syscall_nr;Why do you need both
syscall_nrandcompat_syscall_nr? Compat and usual syscalls never share the same syscall metadata.
Quoted 6 lines
For example, something like '
sys_read()' is pointed to by bothsyscalls_metadataandcompat_syscalls_metadata. Thus, the same syscall metadata record is referenced by two different tables. That said, I'm not making use ofcompat_syscall_nr. Although it could be added to the checks in 'reg_event_syscall_enter()', to make sure that thecompat_syscall_nris valid.
Yep, but we need it to be referenced by two different tables as normal and compat syscalls don't have the exact same parameters. It is not about the same syscall metadata.
Once we'll get support for user pointer dereferencing to get user parameters content in the traces, we'll need to build a table of types to be aware of the type. And these types will be different between compat and normal syscalls.
Re: [PATCH 07/14 re-post] syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
In reply to Jason BaronQuoted 30 lines · Jason Baron
Re-post due to missing macro parameter. interdiff:
diff -u
b/include/linux/syscalls.hb/include/linux/syscalls.hinclude/linux/syscalls.h +1
-2@@ -241,7 +241,7 @@ SYSCALL_METADATA(syscall, compat_sys_##sname, x); \ asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))#else -#define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \ +#define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))#endif --------------------------------------------------------Add ARCH_COMPAT_SYSCALL_DEFINE#N() macro which prepends "
sys32_" to arch specific compat syscall names. Identifies the 'compat' syscalls.Signed-off-by Jason Baron <[email protected]>--- include/linux/syscalls.h | 50 ++++++++++++++++++++++++++++++++++----------- 1 files changed, 38 insertions(+), 12 deletions(-)include/linux/syscalls.h +0
-0
include/linux/syscalls.h struct perf_event_attr; · line 144
Quoted 5 lines
include/linux/syscalls.h +1
-1@@ -141,7 +141,7 @@ struct perf_event_attr; __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_events"))) \ event_enter_##sname = { \ - .name = "sys_enter"#sname, \ + .name = "enter_"#sname, \
BTW, removing the sys_ prefix would be a cool change but I'd prefer we limit the ABI changes if possible (although I must confess the ABI is going to be seriously damaged if we support user pointer deref later :p)
Thanks.
Quoted 21 lines · Jason Baron
Hi,
Re-post to add infrastructure for compat syscall event tracing support. This patch series also adds
x86_64arch specific support as an example consumer of the new infrastructure.Arches can request compat syscall tracing by setting:
__HAVE_ARCH_FTRACE_COMPAT_SYSCALLS, ifCONFIG_COMPATandCONFIG_FTRACE_SYSCALLSare set. Arches then need to implement the following interfaces:1) int
is_compat_task(void);
- most arches seem to have this already
2) unsigned longarch_compat_syscall_addr(int nr);
- returns a pointer to the compat syscall entry corresponding to syscall 'nr'
3) intNR_syscalls_compat;
- number of entries in the compat syscall table.thanks,
-Jason
Quoted 8 lines
Changes in v3:
- create a separate "
compat_syscalls" event subsystem
- ARCH_COMPAT_SYSCALL_DEFINE#N() tacks "sys32" to start of syscall name
- COMPAT_SYSCALL_DEFINE#N() tacks "compat_sys" to start of syscall name
- both above macros create perf events as: [enter|exit]_compat_sys_blah
- non-compat syscall naming changes to: [enter|exit]_sys_blah
- removes any unreferenced compat syscalls from debugfs
Other than the small comments I had, it's a very nice stuff. Just waiting for your next iteration before applying.
Thanks!
Hi Jason,
I'm currently in the process of implementing syscall tracepoints for PowerPC, and a considerable amount of my work is going to end up requiring these patches of yours. I've reviewed and tested your patches (and spent a good chunk of time rebasing them on top of tip/tracing/core) and they all seem pretty good.
I *particularly* like the way in which they prevent ftrace syscalls from reporting that sys_swapoff was constantly firing on x86_64 kernels with a 32bit userspace ;)
Anyway, I'm just wondering if you have an ETA for the v4 patchset to address the remaining issues that Frederic raised so that they can be merged.
Cheers,
-Ian
Excerpts from Jason Baron's message of Wed Mar 17 04:46:08 +1100 2010:
Quoted 16 lines
Hi,
Re-post to add infrastructure for compat syscall event tracing support. This patch series also adds
x86_64arch specific support as an example consumer of the new infrastructure.Arches can request compat syscall tracing by setting:
__HAVE_ARCH_FTRACE_COMPAT_SYSCALLS, ifCONFIG_COMPATandCONFIG_FTRACE_SYSCALLSare set. Arches then need to implement the following interfaces:1) int
is_compat_task(void);
- most arches seem to have this already
2) unsigned longarch_compat_syscall_addr(int nr);
- returns a pointer to the compat syscall entry corresponding to syscall 'nr'
3) intNR_syscalls_compat;
- number of entries in the compat syscall table.
Quoted 12 lines · Ian Munsie
Hi Jason,
I'm currently in the process of implementing syscall tracepoints for PowerPC, and a considerable amount of my work is going to end up requiring these patches of yours. I've reviewed and tested your patches (and spent a good chunk of time rebasing them on top of tip/tracing/core) and they all seem pretty good.
I *particularly* like the way in which they prevent ftrace syscalls from reporting that
sys_swapoffwas constantly firing onx86_64kernels with a 32bit userspace ;)
Quoted 7 lines
Anyway, I'm just wondering if you have an ETA for the v4 patchset to address the remaining issues that Frederic raised so that they can be merged.
Cheers,
-Ian
hi Ian,
I think the main issue left was that I am using the same meta data for both the 32-bit and 64-bit table entries, when they reference the same syscall. for example, for x86 both the compat and underlying 64-bit kernel reference 'sys_rename'. Thus, i am pointing both perf events at the same meta data. Frederic was saying they need to be separate. I'm not sure i completely understand why, since the 32-bit are just sign extended to 64-bit in this case. Frederic, perhaps, you can explain this a bit more for me?
thanks,
-Jason
Quoted 32 lines · Jason Baron
Quoted 12 lines · Ian Munsie
Hi Jason,
I'm currently in the process of implementing syscall tracepoints for PowerPC, and a considerable amount of my work is going to end up requiring these patches of yours. I've reviewed and tested your patches (and spent a good chunk of time rebasing them on top of tip/tracing/core) and they all seem pretty good.
I *particularly* like the way in which they prevent ftrace syscalls from reporting that
sys_swapoffwas constantly firing onx86_64kernels with a 32bit userspace ;)Quoted 7 lines
Anyway, I'm just wondering if you have an ETA for the v4 patchset to address the remaining issues that Frederic raised so that they can be merged.
Cheers,
-Ianhi Ian,
I think the main issue left was that I am using the same meta data for both the 32-bit and 64-bit table entries, when they reference the same syscall. for example, for x86 both the compat and underlying 64-bit kernel reference '
sys_rename'. Thus, i am pointing both perf events at the same meta data. Frederic was saying they need to be separate. I'm not sure i completely understand why, since the 32-bit are just sign extended to 64-bit in this case. Frederic, perhaps, you can explain this a bit more for me?
Quoted 3 lines
thanks,
-Jason
If they are pointing to the same function with the same parameters, then yeah it's fine.
I think I worried about two different handlers that don't have the exact same parameters (one having compat things, and the other having not). But now that I think about it that's probably not what you did.
I'll give another shot to this patchset then, as I've probably confused something, I just need to wait a bit for the giant patchset from Steve on trace events to be applied, before applying this set. Should happen soon.
Will look at this next week.
Thanks.
Re: [PATCH 07/14] syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
In reply to Jason BaronExcerpts from Jason Baron's message of Wed Mar 17 04:46:42 +1100 2010:
<snip>
include/linux/syscalls.h struct perf_event_attr; · line 244
Quoted 4 lines
include/linux/syscalls.h +4
-0+ SYSCALL_METADATA(syscall, compat_sys_##sname, x); \ + asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__)) +#else +#define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \
I think that should be:
#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)
To avoid breaking archs without compat syscalls.
Cheers,
-Ian
Re: [PATCH 07/14] syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
Quoted 11 lines · Ian Munsie
Excerpts from Jason Baron's message of Wed Mar 17 04:46:42 +1100 2010:
<snip>Review
Quoted 4 lines
(quoted diff) +4
-0+ SYSCALL_METADATA(syscall, compat_sys_##sname, x); \ + asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__)) +#else +#define COMPAT_SYSCALL_DEFINEx(x, sname, ...) \I think that should be:
#defineCOMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)
Quoted 4 lines
To avoid breaking archs without compat syscalls.
Cheers,
-Ian
yes. good catch. I had spotted this as well. here's the complete re-spun patch.
thanks,
-Jason
include/linux/syscalls.h +38 -12
@@ -141,7 +141,7 @@ struct perf_event_attr; __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_events"))) \ event_enter_##sname = { \ - .name = "sys_enter"#sname, \ + .name = "enter_"#sname, \ .system = "syscalls", \ .event = &enter_syscall_print_##sname, \ .raw_init = init_syscall_trace, \
@@ -163,7 +163,7 @@ struct perf_event_attr; __attribute__((__aligned__(4))) \ __attribute__((section("_ftrace_events"))) \ event_exit_##sname = { \ - .name = "sys_exit"#sname, \ + .name = "exit_"#sname, \ .system = "syscalls", \ .event = &exit_syscall_print_##sname, \ .raw_init = init_syscall_trace, \
@@ -174,14 +174,14 @@ struct perf_event_attr; TRACE_SYS_EXIT_PROFILE_INIT(sname) \ } -#define SYSCALL_METADATA (sname, nb) \ +#define SYSCALL_METADATA (rname, sname, nb) \ SYSCALL_TRACE_ENTER_EVENT(sname); \ SYSCALL_TRACE_EXIT_EVENT(sname); \ static const struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ __syscall_meta_##sname = { \ - .name = "sys"#sname, \ + .name = #rname, \ .nb_args = nb, \ .types = types_##sname, \ .args = args_##sname, \
@@ -194,20 +194,20 @@ struct perf_event_attr; };#define SYSCALL_DEFINE0 (sname) \ - SYSCALL_TRACE_ENTER_EVENT(_##sname); \ - SYSCALL_TRACE_EXIT_EVENT(_##sname); \ + SYSCALL_TRACE_ENTER_EVENT(sys_##sname); \ + SYSCALL_TRACE_EXIT_EVENT(sys_##sname); \ static const struct syscall_metadata __used \ __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ - __syscall_meta__##sname = { \ + __syscall_meta_sys_##sname = { \ .name = "sys_"#sname, \ .nb_args = 0, \ .ftrace_enter = 0, \ .ftrace_exit = 0, \ .perf_enter = 0, \ .perf_exit = 0, \ - .enter_event = &event_enter__##sname, \ - .exit_event = &event_exit__##sname, \ + .enter_event = &event_enter_sys_##sname, \ + .exit_event = &event_exit_sys_##sname, \ }; \ asmlinkage long sys_##sname(void)#else
@@ -221,6 +221,32 @@ struct perf_event_attr;#define SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)#define SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) +#ifdef CONFIG_COMPAT + +#define ARCH_COMPAT_SYSCALL_DEFINE1 (name, ...) COMPAT_SYSCALL_DEFINEx(1, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE2 (name, ...) COMPAT_SYSCALL_DEFINEx(2, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE3 (name, ...) COMPAT_SYSCALL_DEFINEx(3, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE4 (name, ...) COMPAT_SYSCALL_DEFINEx(4, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) COMPAT_SYSCALL_DEFINEx(5, sys32_##name, name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, sys32_##name, name, __VA_ARGS__) + +#ifdef CONFIG_FTRACE_SYSCALLS +#define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ + static const char *types_compat_sys_##sname[] = { \ + __SC_STR_TDECL##x(__VA_ARGS__) \ + }; \ + static const char *args_compat_sys_##sname[] = { \ + __SC_STR_ADECL##x(__VA_ARGS__) \ + }; \ + SYSCALL_METADATA(syscall, compat_sys_##sname, x); \ + asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__)) +#else +#define COMPAT_SYSCALL_DEFINEx (x, syscall, sname, ...) \ + asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__)) +#endif + +#endif +#ifdef CONFIG_PPC64 #define SYSCALL_ALIAS (alias, name) \ asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \
@@ -237,13 +263,13 @@ struct perf_event_attr;#ifdef CONFIG_FTRACE_SYSCALLS #define SYSCALL_DEFINEx (x, sname, ...) \ - static const char *types_##sname[] = { \ + static const char *types_sys##sname[] = { \ __SC_STR_TDECL##x(__VA_ARGS__) \ }; \ - static const char *args_##sname[] = { \ + static const char *args_sys##sname[] = { \ __SC_STR_ADECL##x(__VA_ARGS__) \ }; \ - SYSCALL_METADATA(sname, x); \ + SYSCALL_METADATA(sys##sname, sys##sname, x); \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)#else #define SYSCALL_DEFINEx (x, sname, ...) \
Excerpts from Jason Baron's message of Fri May 21 23:24:07 +1000 2010:
Quoted 32 lines · Ian Munsie
Quoted 12 lines
Hi Jason,
I'm currently in the process of implementing syscall tracepoints for PowerPC, and a considerable amount of my work is going to end up requiring these patches of yours. I've reviewed and tested your patches (and spent a good chunk of time rebasing them on top of tip/tracing/core) and they all seem pretty good.
I *particularly* like the way in which they prevent ftrace syscalls from reporting that
sys_swapoffwas constantly firing onx86_64kernels with a 32bit userspace ;)Quoted 7 lines
Anyway, I'm just wondering if you have an ETA for the v4 patchset to address the remaining issues that Frederic raised so that they can be merged.
Cheers,
-Ianhi Ian,
I think the main issue left was that I am using the same meta data for both the 32-bit and 64-bit table entries, when they reference the same syscall. for example, for x86 both the compat and underlying 64-bit kernel reference '
sys_rename'. Thus, i am pointing both perf events at the same meta data. Frederic was saying they need to be separate. I'm not sure i completely understand why, since the 32-bit are just sign extended to 64-bit in this case. Frederic, perhaps, you can explain this a bit more for me?
Quoted 3 lines
thanks,
-Jason
Hi Jason,
I'm currently cleaning up my patch series for ftrace syscalls on PowerPC and want to release it soon.
It's probably easiest for me if I release your compat syscall support v3 patches as part of the series. You'd still be marked as the author of those commits - the only changes I have made to them was rebasing them against the current tip tree and resolving the conflicts that I came across.
Is that OK with you? Otherwise I can wait until you put out the v4 patches then rebase mine on top of those.
Cheers,
-Ian
Quoted 39 lines · Ian Munsie
Excerpts from Jason Baron's message of Fri May 21 23:24:07 +1000 2010:
Quoted 32 lines · Ian Munsie
Quoted 12 lines
Hi Jason,
I'm currently in the process of implementing syscall tracepoints for PowerPC, and a considerable amount of my work is going to end up requiring these patches of yours. I've reviewed and tested your patches (and spent a good chunk of time rebasing them on top of tip/tracing/core) and they all seem pretty good.
I *particularly* like the way in which they prevent ftrace syscalls from reporting that
sys_swapoffwas constantly firing onx86_64kernels with a 32bit userspace ;)Quoted 7 lines
Anyway, I'm just wondering if you have an ETA for the v4 patchset to address the remaining issues that Frederic raised so that they can be merged.
Cheers,
-Ianhi Ian,
I think the main issue left was that I am using the same meta data for both the 32-bit and 64-bit table entries, when they reference the same syscall. for example, for x86 both the compat and underlying 64-bit kernel reference '
sys_rename'. Thus, i am pointing both perf events at the same meta data. Frederic was saying they need to be separate. I'm not sure i completely understand why, since the 32-bit are just sign extended to 64-bit in this case. Frederic, perhaps, you can explain this a bit more for me?Quoted 3 lines
thanks,
-Jason
Hi Jason,
Quoted 8 lines
I'm currently cleaning up my patch series for ftrace syscalls on PowerPC and want to release it soon.
It's probably easiest for me if I release your compat syscall support v3 patches as part of the series. You'd still be marked as the author of those commits - the only changes I have made to them was rebasing them against the current tip tree and resolving the conflicts that I came across.
Perfect! I was about to ask Jason to rebase his patchset against latest -tip.
If you send this set, please also add your own Signed-off-by.
Thanks.
Quoted 42 lines · Ian Munsie
Excerpts from Jason Baron's message of Fri May 21 23:24:07 +1000 2010:
Quoted 32 lines · Ian Munsie
Quoted 12 lines
Hi Jason,
I'm currently in the process of implementing syscall tracepoints for PowerPC, and a considerable amount of my work is going to end up requiring these patches of yours. I've reviewed and tested your patches (and spent a good chunk of time rebasing them on top of tip/tracing/core) and they all seem pretty good.
I *particularly* like the way in which they prevent ftrace syscalls from reporting that
sys_swapoffwas constantly firing onx86_64kernels with a 32bit userspace ;)Quoted 7 lines
Anyway, I'm just wondering if you have an ETA for the v4 patchset to address the remaining issues that Frederic raised so that they can be merged.
Cheers,
-Ianhi Ian,
I think the main issue left was that I am using the same meta data for both the 32-bit and 64-bit table entries, when they reference the same syscall. for example, for x86 both the compat and underlying 64-bit kernel reference '
sys_rename'. Thus, i am pointing both perf events at the same meta data. Frederic was saying they need to be separate. I'm not sure i completely understand why, since the 32-bit are just sign extended to 64-bit in this case. Frederic, perhaps, you can explain this a bit more for me?Quoted 3 lines
thanks,
-Jason
Hi Jason,
I'm currently cleaning up my patch series for ftrace syscalls on PowerPC and want to release it soon.
Quoted 9 lines
It's probably easiest for me if I release your compat syscall support v3 patches as part of the series. You'd still be marked as the author of those commits - the only changes I have made to them was rebasing them against the current tip tree and resolving the conflicts that I came across.
Is that OK with you? Otherwise I can wait until you put out the v4 patches then rebase mine on top of those.
Hi Ian
if its easier for you, that's fine, feel free to include my patches with your patchset.
thanks,
-Jason