tracing: add compat syscall support v2
PATCH 1/12 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
cover tracing: add compat syscall support v2
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.
The new interface consists of:
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.
Thus, arches that set CONFIG_FTRACE_SYSCALLS and CONFIG_COMPAT are going to need to implement the above interfaces in order to build. Thus, I'm 'cc arch maintainers.
Naming. I've also introduced a couple of new syscall macros:
ARCH_COMPAT_SYSCALL_DEFINE#N()
COMPAT_SYSCALL_DEFINE#N()
These tack on, "arch_compat_sys" and "compat_sys" respectively, to the beginning of the compat syscall names.
thanks,
-Jason
Jason Baron (11):
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: add tracing support for compat syscalls
syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
x86, compat: convert ia32 layer to use ARCH_COMPAT_SYSCALL_DEFINE#N()
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 syscalls
cleanup: remove arg from TRACE_SYS_ENTER_PROFILE_INIT() macro
Heiko Carstens (1):
compat: have generic is_compat_task for !CONFIG_COMPAT
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 | 53 ++++++++------- arch/x86/ia32/sys_ia32.c | 106 ++++++++++++++-------------- arch/x86/include/asm/compat.h | 2 + arch/x86/kernel/ftrace.c | 11 +++ 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/syscalls.h | 70 ++++++++++++------- include/trace/syscall.h | 8 ++ kernel/compat.c | 106 ++++++++++++++--------------- kernel/trace/trace.h | 2 + kernel/trace/trace_syscalls.c | 101 +++++++++++++++++++-------- scripts/tags.sh | 8 ++- 22 files changed, 369 insertions(+), 274 deletions(-)
PATCH 2/12 x86: add arch_compat_syscall_addr()
Add arch_compat_syscall_addr(int nr) for x86_64. This is in preparation for adding compat syscall support to the event tracer.
--- arch/x86/kernel/ftrace.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
arch/x86/kernel/ftrace.c +11 -0
@@ -510,3 +510,14 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr, } }#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ + +#ifdef CONFIG_FTRACE_SYSCALLS +extern unsigned long *ia32_sys_call_table; + +#ifdef CONFIG_COMPAT +unsigned long __init arch_compat_syscall_addr (int nr) +{ +return (unsigned long )(&ia32_sys_call_table)[nr]; +} +#endif +#endif
Signature · 1 line
1.6.5.1
PATCH 8/12 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
@@ -228,6 +228,13 @@ struct perf_event_attr;#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, arch_compat_sys_##name, __VA_ARGS__)#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, arch_compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE1 (name, ...) SYSCALL_DEFINEx(1, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE2 (name, ...) SYSCALL_DEFINEx(2, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE3 (name, ...) SYSCALL_DEFINEx(3, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE4 (name, ...) SYSCALL_DEFINEx(4, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, compat_sys_##name, __VA_ARGS__) +#ifdef CONFIG_PPC64 #define SYSCALL_ALIAS (alias, name) \ asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n" \
Signature · 1 line
1.6.5.1
PATCH 3/12 compat: have generic is_compat_task for !CONFIG_COMPAT
In reply to Jason Baronadd 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 9/12 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 12/12 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 (sname, nb) \
Signature · 1 line
1.6.5.1
PATCH 6/12 syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
In reply to Jason BaronAdd ARCH_COMPAT_SYSCALL_DEFINE#N() macro which prepends "arch_compat_sys" to arch specific compat syscall names. Identifies the 'compat' syscalls.
--- include/linux/syscalls.h | 41 ++++++++++++++++++++++++----------------- 1 files changed, 24 insertions(+), 17 deletions(-)
include/linux/syscalls.h +24 -17
@@ -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, \
@@ -181,7 +181,7 @@ struct perf_event_attr; __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ __syscall_meta_##sname = { \ - .name = "sys"#sname, \ + .name = #sname, \ .nb_args = nb, \ .types = types_##sname, \ .args = args_##sname, \
@@ -194,32 +194,39 @@ 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 #define SYSCALL_DEFINE0 (name) asmlinkage long sys_##name(void)#endif -#define SYSCALL_DEFINE1 (name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) -#define SYSCALL_DEFINE2 (name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) -#define SYSCALL_DEFINE3 (name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__) -#define SYSCALL_DEFINE4 (name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__) -#define SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__) -#define SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) +#define SYSCALL_DEFINE1 (name, ...) SYSCALL_DEFINEx(1, sys_##name, __VA_ARGS__) +#define SYSCALL_DEFINE2 (name, ...) SYSCALL_DEFINEx(2, sys_##name, __VA_ARGS__) +#define SYSCALL_DEFINE3 (name, ...) SYSCALL_DEFINEx(3, sys_##name, __VA_ARGS__) +#define SYSCALL_DEFINE4 (name, ...) SYSCALL_DEFINEx(4, sys_##name, __VA_ARGS__) +#define SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, sys_##name, __VA_ARGS__) +#define SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, sys_##name, __VA_ARGS__) + +#define ARCH_COMPAT_SYSCALL_DEFINE1 (name, ...) SYSCALL_DEFINEx(1, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE2 (name, ...) SYSCALL_DEFINEx(2, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE3 (name, ...) SYSCALL_DEFINEx(3, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE4 (name, ...) SYSCALL_DEFINEx(4, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, arch_compat_sys_##name, __VA_ARGS__)#ifdef CONFIG_PPC64 #define SYSCALL_ALIAS (alias, name) \
@@ -255,21 +262,21 @@ struct perf_event_attr;#define SYSCALL_DEFINE (name) static inline long SYSC_##name#define __SYSCALL_DEFINEx (x, name, ...) \ - asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \ + asmlinkage long name(__SC_DECL##x(__VA_ARGS__)); \ static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \ asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \ { \ __SC_TEST##x(__VA_ARGS__); \ return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \ } \ - SYSCALL_ALIAS(sys##name, SyS##name); \ + SYSCALL_ALIAS(name, SyS##name); \ static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__))#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ #define SYSCALL_DEFINE (name) asmlinkage long sys_##name#define __SYSCALL_DEFINEx (x, name, ...) \ - asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)) + asmlinkage long name(__SC_DECL##x(__VA_ARGS__))#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
Signature · 1 line
1.6.5.1
PATCH 10/12 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 11/12 tags: recognize 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:]]?\(([^,)]*).*/arch_compat_sys_\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]?(\([^,)]*\).*/arch_compat_sys_\1/' all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
Signature · 1 line
1.6.5.1
PATCH 4/12 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 7/12 x86, compat: convert ia32 layer to use ARCH_COMPAT_SYSCALL_DEFINE#N()
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/ia32entry.S | 50 +++++++++++----------- arch/x86/ia32/sys_ia32.c | 106 ++++++++++++++++++++++---------------------- 2 files changed, 78 insertions(+), 78 deletions(-)
arch/x86/ia32/ia32entry.S +25 -25
@@ -472,9 +472,9 @@ quiet_ni_syscall: PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx - PTREGSCALL stub32_execve, sys32_execve, %rcx + PTREGSCALL stub32_execve, arch_compat_sys_execve, %rcx PTREGSCALL stub32_fork, sys_fork, %rdi - PTREGSCALL stub32_clone, sys32_clone, %rdx + PTREGSCALL stub32_clone, arch_compat_sys_clone, %rdx PTREGSCALL stub32_vfork, sys_vfork, %rdi PTREGSCALL stub32_iopl, sys_iopl, %rsi
@@ -512,7 +512,7 @@ ia32_sys_call_table: .quad sys_write .quad compat_sys_open /* 5 */ .quad sys_close - .quad sys32_waitpid + .quad arch_compat_sys_waitpid .quad sys_creat .quad sys_link .quad sys_unlink /* 10 */
@@ -564,7 +564,7 @@ ia32_sys_call_table: .quad quiet_ni_syscall /* old mpx syscall holder */ .quad sys_setpgid .quad quiet_ni_syscall /* old ulimit syscall holder */ - .quad sys32_olduname + .quad arch_compat_sys_olduname .quad sys_umask /* 60 */ .quad sys_chroot .quad compat_sys_ustat
@@ -572,7 +572,7 @@ ia32_sys_call_table: .quad sys_getppid .quad sys_getpgrp /* 65 */ .quad sys_setsid - .quad sys32_sigaction + .quad arch_compat_sys_sigaction .quad sys_sgetmask .quad sys_ssetmask .quad sys_setreuid16 /* 70 */
@@ -587,7 +587,7 @@ ia32_sys_call_table: .quad compat_sys_settimeofday .quad sys_getgroups16 /* 80 */ .quad sys_setgroups16 - .quad sys32_old_select + .quad arch_compat_sys_old_select .quad sys_symlink .quad sys_lstat .quad sys_readlink /* 85 */
@@ -595,7 +595,7 @@ ia32_sys_call_table: .quad sys_swapon .quad sys_reboot .quad compat_sys_old_readdir - .quad sys32_mmap /* 90 */ + .quad arch_compat_sys_mmap /* 90 */ .quad sys_munmap .quad sys_truncate .quad sys_ftruncate
@@ -630,7 +630,7 @@ ia32_sys_call_table: .quad sys_uname .quad sys_modify_ldt .quad compat_sys_adjtimex - .quad sys32_mprotect /* 125 */ + .quad arch_compat_sys_mprotect /* 125 */ .quad compat_sys_sigprocmask .quad quiet_ni_syscall /* create_module */ .quad sys_init_module
@@ -666,7 +666,7 @@ ia32_sys_call_table: .quad sys_sched_yield .quad sys_sched_get_priority_max .quad sys_sched_get_priority_min /* 160 */ - .quad sys32_sched_rr_get_interval + .quad arch_compat_sys_sched_rr_get_interval .quad compat_sys_nanosleep .quad sys_mremap .quad sys_setresuid16
@@ -679,30 +679,30 @@ ia32_sys_call_table: .quad sys_getresgid16 .quad sys_prctl .quad stub32_rt_sigreturn - .quad sys32_rt_sigaction - .quad sys32_rt_sigprocmask /* 175 */ - .quad sys32_rt_sigpending + .quad arch_compat_sys_rt_sigaction + .quad arch_compat_sys_rt_sigprocmask /* 175 */ + .quad arch_compat_sys_rt_sigpending .quad compat_sys_rt_sigtimedwait - .quad sys32_rt_sigqueueinfo + .quad arch_compat_sys_rt_sigqueueinfo .quad sys_rt_sigsuspend - .quad sys32_pread /* 180 */ - .quad sys32_pwrite + .quad arch_compat_sys_pread /* 180 */ + .quad arch_compat_sys_pwrite .quad sys_chown16 .quad sys_getcwd .quad sys_capget .quad sys_capset .quad stub32_sigaltstack - .quad sys32_sendfile + .quad arch_compat_sys_sendfile .quad quiet_ni_syscall /* streams1 */ .quad quiet_ni_syscall /* streams2 */ .quad stub32_vfork /* 190 */ .quad compat_sys_getrlimit .quad sys_mmap_pgoff - .quad sys32_truncate64 - .quad sys32_ftruncate64 - .quad sys32_stat64 /* 195 */ - .quad sys32_lstat64 - .quad sys32_fstat64 + .quad arch_compat_sys_truncate64 + .quad arch_compat_sys_ftruncate64 + .quad arch_compat_sys_stat64 /* 195 */ + .quad arch_compat_sys_lstat64 + .quad arch_compat_sys_fstat64 .quad sys_lchown .quad sys_getuid .quad sys_getgid /* 200 */
@@ -755,7 +755,7 @@ ia32_sys_call_table: .quad compat_sys_io_getevents .quad compat_sys_io_submit .quad sys_io_cancel - .quad sys32_fadvise64 /* 250 */ + .quad arch_compat_sys_fadvise64 /* 250 */ .quad quiet_ni_syscall /* free_huge_pages */ .quad sys_exit_group .quad sys32_lookup_dcookie
@@ -805,7 +805,7 @@ ia32_sys_call_table: .quad sys_mknodat .quad sys_fchownat .quad compat_sys_futimesat - .quad sys32_fstatat /* 300 */ + .quad arch_compat_sys_fstatat /* 300 */ .quad sys_unlinkat .quad sys_renameat .quad sys_linkat
@@ -819,7 +819,7 @@ ia32_sys_call_table: .quad compat_sys_set_robust_list .quad compat_sys_get_robust_list .quad sys_splice - .quad sys32_sync_file_range + .quad arch_compat_sys_sync_file_range .quad sys_tee /* 315 */ .quad compat_sys_vmsplice .quad compat_sys_move_pages
@@ -829,7 +829,7 @@ ia32_sys_call_table: .quad compat_sys_signalfd .quad sys_timerfd_create .quad sys_eventfd - .quad sys32_fallocate + .quad arch_compat_sys_fallocate .quad compat_sys_timerfd_settime /* 325 */ .quad compat_sys_timerfd_gettime .quad compat_sys_signalfd4
arch/x86/ia32/sys_ia32.c +53 -53
266 lines not on this page · raw message
Signature · 1 line
1.6.5.1
PATCH 5/12 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 | 63 +++++++++++++++++++++++++++++++++++----- 4 files changed, 63 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 +55 -8
162 lines not on this page · raw message
Signature · 1 line
1.6.5.1
Re: [PATCH 08/12] syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro
In reply to Jason BaronQuoted 14 lines · Jason Baron
Add COMPAT_SYSCALL_DEFINE#N() macro define common compat syscalls that are not arch specific. Prepends "
compat_sys_" to the syscall name to identify it.Signed-off-by Jason Baron <[email protected]>--- include/linux/syscalls.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)include/linux/syscalls.h +0
-0
include/linux/syscalls.h struct perf_event_attr; · line 237
Quoted 10 lines
include/linux/syscalls.h +7
-0@@ -228,6 +228,13 @@ struct perf_event_attr;#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, arch_compat_sys_##name, __VA_ARGS__)#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, arch_compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE1 (name, ...) SYSCALL_DEFINEx(1, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE2 (name, ...) SYSCALL_DEFINEx(2, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE3 (name, ...) SYSCALL_DEFINEx(3, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE4 (name, ...) SYSCALL_DEFINEx(4, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, compat_sys_##name, __VA_ARGS__) +
For architectures which select CONFIG_HAVE_SYSCALL_WRAPPERS this adds unnecessary sign extension code to each compat syscall.
On the other hand we could get rid partly of the arch specific sign extension code but that would need some other changes before as well.
For example this one:
asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
struct timezone __user *tz)
should be converted to a function which takes two compat_uptr_t's and let the syscall code itself do the proper pointer conversion (compat_ptr()).
Besides that the syscall alias names for these compat calls do look a bit strange:
000000000008b57c T SyScompat_sys_adjtimex000000000008b57c T compat_sys_adjtimex
That needs to be fixed as well.
Or simply add a 1:1 wrapper independent of CONFIG_HAVE_SYSCALL_WRAPPERS.
Re: [PATCH 08/12] syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro
Quoted 38 lines · Heiko Carstens
Quoted 14 lines · Jason Baron
Add COMPAT_SYSCALL_DEFINE#N() macro define common compat syscalls that are not arch specific. Prepends "
compat_sys_" to the syscall name to identify it.Signed-off-by Jason Baron <[email protected]>--- include/linux/syscalls.h | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)include/linux/syscalls.h +0
-0include/linux/syscalls.h struct perf_event_attr; · line 237
Quoted 10 lines
include/linux/syscalls.h +7
-0@@ -228,6 +228,13 @@ struct perf_event_attr;#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, arch_compat_sys_##name, __VA_ARGS__)#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, arch_compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE1 (name, ...) SYSCALL_DEFINEx(1, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE2 (name, ...) SYSCALL_DEFINEx(2, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE3 (name, ...) SYSCALL_DEFINEx(3, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE4 (name, ...) SYSCALL_DEFINEx(4, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE5 (name, ...) SYSCALL_DEFINEx(5, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE6 (name, ...) SYSCALL_DEFINEx(6, compat_sys_##name, __VA_ARGS__) +For architectures which select
CONFIG_HAVE_SYSCALL_WRAPPERSthis adds unnecessary sign extension code to each compat syscall.
On the other hand we could get rid partly of the arch specific sign extension code but that would need some other changes before as well.
For example this one:asmlinkage long compat_sys_gettimeofday(struct
compat_timeval__user*tv,
struct timezone__user*tz)should be converted to a function which takes two compat_uptr_t's and let the syscall code itself do the proper pointer conversion (
compat_ptr()).
Quoted 8 lines
Besides that the syscall alias names for these compat calls do look a bit strange:
000000000008b57cTSyScompat_sys_adjtimex000000000008b57cTcompat_sys_adjtimexThat needs to be fixed as well.
Or simply add a 1:1 wrapper independent ofCONFIG_HAVE_SYSCALL_WRAPPERS.
ok, the later suggestion seems simpler. Below I've re-spun patch #6 and #8. how do they look?
thanks,
-Jason
patch 6/12:
include/linux/syscalls.h +37 -11
@@ -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, \
@@ -181,7 +181,7 @@ struct perf_event_attr; __attribute__((__aligned__(4))) \ __attribute__((section("__syscalls_metadata"))) \ __syscall_meta_##sname = { \ - .name = "sys"#sname, \ + .name = #sname, \ .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, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE2 (name, ...) COMPAT_SYSCALL_DEFINEx(2, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE3 (name, ...) COMPAT_SYSCALL_DEFINEx(3, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE4 (name, ...) COMPAT_SYSCALL_DEFINEx(4, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) COMPAT_SYSCALL_DEFINEx(5, arch_compat_sys_##name, __VA_ARGS__) +#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, arch_compat_sys_##name, __VA_ARGS__) + +#ifdef CONFIG_FTRACE_SYSCALLS +#define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \ + static const char *types_##sname[] = { \ + __SC_STR_TDECL##x(__VA_ARGS__) \ + }; \ + static const char *args_##sname[] = { \ + __SC_STR_ADECL##x(__VA_ARGS__) \ + }; \ + SYSCALL_METADATA(sname, x); \ + asmlinkage long sname(__SC_DECL##x(__VA_ARGS__)) +#else +#define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \ + asmlinkage long sname(__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, x); \ __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)#else #define SYSCALL_DEFINEx (x, sname, ...) \
patch 8/12:
include/linux/syscalls.h +7 -0
@@ -230,6 +230,13 @@ struct perf_event_attr;#define ARCH_COMPAT_SYSCALL_DEFINE5 (name, ...) COMPAT_SYSCALL_DEFINEx(5, arch_compat_sys_##name, __VA_ARGS__)#define ARCH_COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, arch_compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE1 (name, ...) COMPAT_SYSCALL_DEFINEx(1, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE2 (name, ...) COMPAT_SYSCALL_DEFINEx(2, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE3 (name, ...) COMPAT_SYSCALL_DEFINEx(3, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE4 (name, ...) COMPAT_SYSCALL_DEFINEx(4, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE5 (name, ...) COMPAT_SYSCALL_DEFINEx(5, compat_sys_##name, __VA_ARGS__) +#define COMPAT_SYSCALL_DEFINE6 (name, ...) COMPAT_SYSCALL_DEFINEx(6, compat_sys_##name, __VA_ARGS__) +#ifdef CONFIG_FTRACE_SYSCALLS #define COMPAT_SYSCALL_DEFINEx (x, sname, ...) \ static const char *types_##sname[] = { \
Re: [PATCH 08/12] syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro
Quoted 16 lines · Jason Baron
Quoted 15 lines · Heiko Carstens
For architectures which select
CONFIG_HAVE_SYSCALL_WRAPPERSthis adds unnecessary sign extension code to each compat syscall.
On the other hand we could get rid partly of the arch specific sign extension code but that would need some other changes before as well.
For example this one:asmlinkage long compat_sys_gettimeofday(struct
compat_timeval__user*tv,
struct timezone__user*tz)should be converted to a function which takes two compat_uptr_t's and let the syscall code itself do the proper pointer conversion (
compat_ptr()).Besides that the syscall alias names for these compat calls do look a bit strange:
Quoted 8 lines
Quoted 5 lines
000000000008b57cTSyScompat_sys_adjtimex000000000008b57cTcompat_sys_adjtimexThat needs to be fixed as well.
Or simply add a 1:1 wrapper independent ofCONFIG_HAVE_SYSCALL_WRAPPERS.ok, the later suggestion seems simpler. Below I've re-spun patch #6 and #8. how do they look?
Looks good to me! :)
Quoted 24 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.The new interface consists of:
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.Thus, arches that set
CONFIG_FTRACE_SYSCALLSandCONFIG_COMPATare going to need to implement the above interfaces in order to build. Thus, I'm 'cc arch maintainers.Naming. I've also introduced a couple of new syscall macros:
ARCH_COMPAT_SYSCALL_DEFINE#N()
COMPAT_SYSCALL_DEFINE#N()
Quoted 6 lines
These tack on, "
arch_compat_sys" and "compat_sys" respectively, to the beginning of the compat syscall names.thanks,
-Jason
I'll review this series soon.
Thanks a lot!
Quoted 41 lines
Jason Baron (11):
x86: addNR_syscalls_compat, make ia32 syscall table visible
x86: addarch_compat_syscall_addr()
tracing: remove syscall bitmaps in preparation for compat support
tracing: add tracing support for compat syscalls
syscalls: addARCH_COMPAT_SYSCALL_DEFINE()
x86, compat: convert ia32 layer to use ARCH_COMPAT_SYSCALL_DEFINE#N()
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 syscalls
cleanup: remove arg fromTRACE_SYS_ENTER_PROFILE_INIT()macroHeiko Carstens (1):
compat: have genericis_compat_taskfor !CONFIG_COMPATarch/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 | 53 ++++++++------- arch/x86/ia32/sys_ia32.c | 106 ++++++++++++++-------------- arch/x86/include/asm/compat.h | 2 + arch/x86/kernel/ftrace.c | 11 +++ 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/syscalls.h | 70 ++++++++++++------- include/trace/syscall.h | 8 ++ kernel/compat.c | 106 ++++++++++++++--------------- kernel/trace/trace.h | 2 + kernel/trace/trace_syscalls.c | 101 +++++++++++++++++++-------- scripts/tags.sh | 8 ++- 22 files changed, 369 insertions(+), 274 deletions(-)
Quoted 24 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.The new interface consists of:
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.Thus, arches that set
CONFIG_FTRACE_SYSCALLSandCONFIG_COMPATare going to need to implement the above interfaces in order to build. Thus, I'm 'cc arch maintainers.Naming. I've also introduced a couple of new syscall macros:
ARCH_COMPAT_SYSCALL_DEFINE#N()
COMPAT_SYSCALL_DEFINE#N()
Quoted 6 lines
These tack on, "
arch_compat_sys" and "compat_sys" respectively, to the beginning of the compat syscall names.thanks,
-Jason
That's a very nice work!
Some neats about it, some of them can be probably done incrementally:
- The new COMPAT_SYSCALL_DEFINE/ARCH_COMPAT_SYSCALL_DEFINE macros nicely standardize the syscalls naming. Most arch use the sys32_* prefix for compat though. We could simply make ARCH_COMPAT_SYSCALL_DEFINE() prepend with sys32_* as this will involve less changes in the syscall table of archs that want the compat syscall tracing support. (Although in itself, having arch_compat_ prefixes is also an intuitive naming)
- Why bothering with a trace event namespace separation between arch overriden compat syscalls and common ones?
Tools want to deal with a single shot of syscalls:compat_*, and not syscalls:compat_* + syscalls:arch_compat_*
Even in the trace, such a naming separation may look weird. The *_SYSCALL_DEFINE macros can make it easy to use different names between syscall functions and syscall trace event names. So, we can keep the distinct arch_compat (or sys32 that involves less changes) and compat prefixes for functions names, as arch_compat may call compat things; and have only compat prefixes as trace events names. And may be if we have collisions between arch and generic compat callback names, let's drop the generic one as it will never trigger, since it's not in the syscall table anyway.
- We probably want a compat_syscalls trace event subsystem (separated from syscalls), can be done incrementally though
- Commit e7b8e675d9c71b868b66f62f725a948047514719 (tracing: Unify arch_syscall_addr() implementations)
has made a good use of the unified syscall table name between archs that support syscall tracing so that we can, most of the time, directly dereference it from generic code. Exotic archs can still override arch_syscall_addr() if we can't do that with their syscall table.
I wish we can do that with the compat syscall tables too. Compat syscall tables names seem to be less unified for now though. Again, can be done incrementally.
Other than that, that's a cool batch!
Thanks!
Quoted 41 lines
Jason Baron (11):
x86: addNR_syscalls_compat, make ia32 syscall table visible
x86: addarch_compat_syscall_addr()
tracing: remove syscall bitmaps in preparation for compat support
tracing: add tracing support for compat syscalls
syscalls: addARCH_COMPAT_SYSCALL_DEFINE()
x86, compat: convert ia32 layer to use ARCH_COMPAT_SYSCALL_DEFINE#N()
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 syscalls
cleanup: remove arg fromTRACE_SYS_ENTER_PROFILE_INIT()macroHeiko Carstens (1):
compat: have genericis_compat_taskfor !CONFIG_COMPATarch/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 | 53 ++++++++------- arch/x86/ia32/sys_ia32.c | 106 ++++++++++++++-------------- arch/x86/include/asm/compat.h | 2 + arch/x86/kernel/ftrace.c | 11 +++ 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/syscalls.h | 70 ++++++++++++------- include/trace/syscall.h | 8 ++ kernel/compat.c | 106 ++++++++++++++--------------- kernel/trace/trace.h | 2 + kernel/trace/trace_syscalls.c | 101 +++++++++++++++++++-------- scripts/tags.sh | 8 ++- 22 files changed, 369 insertions(+), 274 deletions(-)
Quoted 40 lines · Frederic Weisbecker
Quoted 24 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.The new interface consists of:
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.Thus, arches that set
CONFIG_FTRACE_SYSCALLSandCONFIG_COMPATare going to need to implement the above interfaces in order to build. Thus, I'm 'cc arch maintainers.Naming. I've also introduced a couple of new syscall macros:
ARCH_COMPAT_SYSCALL_DEFINE#N()
COMPAT_SYSCALL_DEFINE#N()Quoted 6 lines
These tack on, "
arch_compat_sys" and "compat_sys" respectively, to the beginning of the compat syscall names.thanks,
-Jason
That's a very nice work!
Some neats about it, some of them can be probably done incrementally:
Quoted 8 lines
- The new COMPAT_SYSCALL_DEFINE/ARCH_COMPAT_SYSCALL_DEFINE macros nicely standardize the syscalls naming. Most arch use the sys32_* prefix for compat though. We could simply make
ARCH_COMPAT_SYSCALL_DEFINE()prepend with sys32_* as this will involve less changes in the syscall table of archs that want the compat syscall tracing support. (Although in itself, havingarch_compat_prefixes is also an intuitive naming)
ok. i'll make the ARCH_COMPAT_SYSCALL_DEFINE output "sys32_blah"
Quoted 5 lines
- Why bothering with a trace event namespace separation between arch overriden compat syscalls and common ones?
Tools want to deal with a single shot of syscalls:compat_*, and not syscalls:compat_* + syscalls:arch_compat_*
Even in the trace, such a naming separation may look weird.
Quoted 9 lines
The
*_SYSCALL_DEFINEmacros can make it easy to use different names between syscall functions and syscall trace event names. So, we can keep the distinctarch_compat(or sys32 that involves less changes) and compat prefixes for functions names, asarch_compatmay call compat things; and have only compat prefixes as trace events names. And may be if we have collisions between arch and generic compat callback names, let's drop the generic one as it will never trigger, since it's not in the syscall table anyway.
I kept separate namespaces to avoid collisions and generally simplify things. However, you are right - we can maintain namespace separation at the "sys32_blah", "compat_sys", level and map to a common "compat_blah" for the trace event name. We can avoid collisions by simply storing the "sys32" or "compat_sys" name in the syscall metadata structure name field.
Quoted 14 lines
- We probably want a
compat_syscallstrace event subsystem (separated from syscalls), can be done incrementally though- Commit
e7b8e675d9c71b868b66f62f725a948047514719(tracing: Unifyarch_syscall_addr()implementations)
has made a good use of the unified syscall table name between archs that support syscall tracing so that we can, most of the time, directly dereference it from generic code. Exotic archs can still overridearch_syscall_addr()if we can't do that with their syscall table.
I wish we can do that with the compat syscall tables too. Compat syscall tables names seem to be less unified for now though. Again, can be done incrementally.
Quoted 4 lines
Other than that, that's a cool batch!
Thanks!
the other question is how to go about getting arch support, since right now we break non-x86 arches which have CONFIG_FTRACE_SYSCALLS and CONFIG_COMPAT set with this patch.
thanks,
-Jason
Quoted 5 lines · Jason Baron
I kept separate namespaces to avoid collisions and generally simplify things. However, you are right - we can maintain namespace separation at the "
sys32_blah", "compat_sys", level and map to a common "compat_blah" for the trace event name. We can avoid collisions by simply storing the "sys32" or "compat_sys" name in the syscall metadata structure name field.
Well, the purpose is also to reach a state near to cross arch generic for tools.
If we have a script that parses compat syscalls events in arch X, it would be nice if it works on arch Y.
If arch X overrides compat_blah through sys32_blah and arch Y just keep compat_blah, the script won't cross work.
The problem is not that trivial to solve though, I guess the best is to remove the compat_blah trace event if we already have sys32_blah. Also the syscall handler naming doesn't seem to be always unified (not talking about the sys32 thing but the name of the syscall itself).
So let's start simple for now, we can just include everything and solve that incrementally. But a good start would be to have a separate compat_syscalls event subsystem.
Quoted 14 lines
Quoted 14 lines
- We probably want a
compat_syscallstrace event subsystem (separated from syscalls), can be done incrementally though- Commit
e7b8e675d9c71b868b66f62f725a948047514719(tracing: Unifyarch_syscall_addr()implementations)
has made a good use of the unified syscall table name between archs that support syscall tracing so that we can, most of the time, directly dereference it from generic code. Exotic archs can still overridearch_syscall_addr()if we can't do that with their syscall table.
I wish we can do that with the compat syscall tables too. Compat syscall tables names seem to be less unified for now though. Again, can be done incrementally.
Quoted 8 lines
Quoted 4 lines
Other than that, that's a cool batch!
Thanks!
the other question is how to go about getting arch support, since right now we break non-x86 arches which have
CONFIG_FTRACE_SYSCALLSandCONFIG_COMPATset with this patch.
I guess we can handle that with an ARCH_HAVE_FTRACE_COMPAT_SYSCALLS. It's not that broken actually, compat syscalls events will just not trigger.
Quoted 3 lines
thanks,
-Jason