Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH 00/14] tracing: add compat syscall support v3

2 views
Skip to first unread message

Jason Baron

unread,
Mar 16, 2010, 1:50:04 PM3/16/10
to
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(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Jason Baron

unread,
Mar 16, 2010, 2:00:02 PM3/16/10
to
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 <jba...@redhat.com>
---
include/linux/syscalls.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 14ecfcc..4cbc370 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -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[] = { \
--
1.6.5.1

Jason Baron

unread,
Mar 16, 2010, 2:00:01 PM3/16/10
to
make tags.sh recognize the new syscall macros:

COMPAT_SYSCALL_DEFINE#N()
ARCH_COMPAT_SYSCALL_DEFINE#N()

Signed-off-by: Jason Baron <jba...@redhat.com>
---

scripts/tags.sh | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/tags.sh b/scripts/tags.sh
index 1a0c44d..fe5d4a3 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -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/'

Jason Baron

unread,
Mar 16, 2010, 2:00:02 PM3/16/10
to
In 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.

Signed-off-by: Jason Baron <jba...@redhat.com>
---

include/linux/syscalls.h | 8 +++++++
include/trace/syscall.h | 4 +++
kernel/trace/trace_syscalls.c | 42 +++++++++++++++++++---------------------
3 files changed, 32 insertions(+), 22 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 8126f23..e601985 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -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, \
}; \
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 0387100..8f5ac38 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -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;
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index cba47d7..9cb814b 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -11,8 +11,6 @@
static DEFINE_MUTEX(syscall_trace_lock);
static int sys_refcount_enter;
static int sys_refcount_exit;
-static DECLARE_BITMAP(enabled_enter_syscalls, NR_syscalls);
-static DECLARE_BITMAP(enabled_exit_syscalls, NR_syscalls);

extern unsigned long __start_syscalls_metadata[];
extern unsigned long __stop_syscalls_metadata[];
@@ -254,13 +252,14 @@ void ftrace_syscall_enter(struct pt_regs *regs, long id)
syscall_nr = syscall_get_nr(current, regs);
if (syscall_nr < 0)
return;
- if (!test_bit(syscall_nr, enabled_enter_syscalls))
- return;

sys_data = syscall_nr_to_meta(syscall_nr);
if (!sys_data)
return;

+ if (!sys_data->ftrace_enter)
+ return;
+
size = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args;

event = trace_current_buffer_lock_reserve(&buffer,
@@ -288,13 +287,14 @@ void ftrace_syscall_exit(struct pt_regs *regs, long ret)
syscall_nr = syscall_get_nr(current, regs);
if (syscall_nr < 0)
return;
- if (!test_bit(syscall_nr, enabled_exit_syscalls))
- return;

sys_data = syscall_nr_to_meta(syscall_nr);
if (!sys_data)
return;

+ if (!sys_data->ftrace_exit)
+ return;
+
event = trace_current_buffer_lock_reserve(&buffer,
sys_data->exit_event->id, sizeof(*entry), 0, 0);
if (!event)
@@ -321,7 +321,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
if (!sys_refcount_enter)
ret = register_trace_sys_enter(ftrace_syscall_enter);
if (!ret) {
- set_bit(num, enabled_enter_syscalls);
+ ((struct syscall_metadata *)call->data)->ftrace_enter = 1;
sys_refcount_enter++;
}
mutex_unlock(&syscall_trace_lock);
@@ -337,7 +337,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call)
return;
mutex_lock(&syscall_trace_lock);
sys_refcount_enter--;
- clear_bit(num, enabled_enter_syscalls);
+ ((struct syscall_metadata *)call->data)->ftrace_enter = 0;
if (!sys_refcount_enter)
unregister_trace_sys_enter(ftrace_syscall_enter);
mutex_unlock(&syscall_trace_lock);
@@ -355,7 +355,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
if (!sys_refcount_exit)
ret = register_trace_sys_exit(ftrace_syscall_exit);
if (!ret) {
- set_bit(num, enabled_exit_syscalls);
+ ((struct syscall_metadata *)call->data)->ftrace_exit = 1;
sys_refcount_exit++;
}
mutex_unlock(&syscall_trace_lock);
@@ -371,7 +371,7 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
return;
mutex_lock(&syscall_trace_lock);
sys_refcount_exit--;
- clear_bit(num, enabled_exit_syscalls);
+ ((struct syscall_metadata *)call->data)->ftrace_exit = 0;
if (!sys_refcount_exit)
unregister_trace_sys_exit(ftrace_syscall_exit);
mutex_unlock(&syscall_trace_lock);
@@ -428,8 +428,6 @@ core_initcall(init_ftrace_syscalls);

#ifdef CONFIG_PERF_EVENTS

-static DECLARE_BITMAP(enabled_prof_enter_syscalls, NR_syscalls);
-static DECLARE_BITMAP(enabled_prof_exit_syscalls, NR_syscalls);
static int sys_prof_refcount_enter;
static int sys_prof_refcount_exit;

@@ -443,13 +441,13 @@ static void prof_syscall_enter(struct pt_regs *regs, long id)
int size;

syscall_nr = syscall_get_nr(current, regs);
- if (!test_bit(syscall_nr, enabled_prof_enter_syscalls))
- return;
-
sys_data = syscall_nr_to_meta(syscall_nr);
if (!sys_data)
return;

+ if (!sys_data->perf_enter)
+ return;
+
/* get the size after alignment with the u32 buffer size field */
size = sizeof(unsigned long) * sys_data->nb_args + sizeof(*rec);
size = ALIGN(size + sizeof(u32), sizeof(u64));
@@ -484,7 +482,7 @@ int prof_sysenter_enable(struct ftrace_event_call *call)
pr_info("event trace: Could not activate"
"syscall entry trace point");
} else {
- set_bit(num, enabled_prof_enter_syscalls);
+ ((struct syscall_metadata *)call->data)->perf_enter = 1;
sys_prof_refcount_enter++;
}
mutex_unlock(&syscall_trace_lock);
@@ -499,7 +497,7 @@ void prof_sysenter_disable(struct ftrace_event_call *call)

mutex_lock(&syscall_trace_lock);
sys_prof_refcount_enter--;
- clear_bit(num, enabled_prof_enter_syscalls);
+ ((struct syscall_metadata *)call->data)->perf_enter = 0;
if (!sys_prof_refcount_enter)
unregister_trace_sys_enter(prof_syscall_enter);
mutex_unlock(&syscall_trace_lock);
@@ -515,13 +513,13 @@ static void prof_syscall_exit(struct pt_regs *regs, long ret)
int size;

syscall_nr = syscall_get_nr(current, regs);
- if (!test_bit(syscall_nr, enabled_prof_exit_syscalls))
- return;
-
sys_data = syscall_nr_to_meta(syscall_nr);
if (!sys_data)
return;

+ if (!sys_data->perf_exit)
+ return;
+
/* We can probably do that at build time */
size = ALIGN(sizeof(*rec) + sizeof(u32), sizeof(u64));
size -= sizeof(u32);
@@ -559,7 +557,7 @@ int prof_sysexit_enable(struct ftrace_event_call *call)
pr_info("event trace: Could not activate"
"syscall exit trace point");
} else {
- set_bit(num, enabled_prof_exit_syscalls);
+ ((struct syscall_metadata *)call->data)->perf_exit = 1;
sys_prof_refcount_exit++;
}
mutex_unlock(&syscall_trace_lock);
@@ -574,7 +572,7 @@ void prof_sysexit_disable(struct ftrace_event_call *call)

mutex_lock(&syscall_trace_lock);
sys_prof_refcount_exit--;
- clear_bit(num, enabled_prof_exit_syscalls);
+ ((struct syscall_metadata *)call->data)->perf_exit = 0;
if (!sys_prof_refcount_exit)
unregister_trace_sys_exit(prof_syscall_exit);
mutex_unlock(&syscall_trace_lock);
--
1.6.5.1

Jason Baron

unread,
Mar 16, 2010, 2:00:02 PM3/16/10
to
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 <jba...@redhat.com>
---

include/linux/syscalls.h | 50 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e601985..14ecfcc 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -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, ...) \
--
1.6.5.1

Jason Baron

unread,
Mar 16, 2010, 2:00:02 PM3/16/10
to
convert kernel/compat.c to use the new COMPAT_SYSCALL_DEFINE#N macro. Thus,
tying these syscalls into the syscall event layer.

Signed-off-by: Jason Baron <jba...@redhat.com>
---

kernel/compat.c | 106 ++++++++++++++++++++++++++----------------------------
1 files changed, 51 insertions(+), 55 deletions(-)

diff --git a/kernel/compat.c b/kernel/compat.c
index f6c204f..46dd9c7 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -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;

--
1.6.5.1

Jason Baron

unread,
Mar 16, 2010, 2:00:02 PM3/16/10
to
From: Heiko Carstens <heiko.c...@de.ibm.com>

add generic is_compat_task()

Signed-off-by: Jason Baron <jba...@redhat.com>
Signed-off-by: Heiko Carstens <heiko.c...@de.ibm.com>
---
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(-)

diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h
index 01a0802..442795c 100644
--- a/arch/s390/include/asm/compat.h
+++ b/arch/s390/include/asm/compat.h
@@ -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)
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 7cf4642..f69079f 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -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>
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 8d8957b..b30d9ff 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -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>
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index 869efba..b7669c5 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -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).
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 1cca21a..9b9b444 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -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>
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 7039d9c..407726a 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -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>
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index 31c59b0..83a353a 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -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>
diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c
index 921dcda..c29e3ad 100644
--- a/drivers/s390/char/vmcp.c
+++ b/drivers/s390/char/vmcp.c
@@ -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>
diff --git a/drivers/s390/cio/chsc_sch.c b/drivers/s390/cio/chsc_sch.c
index c84ac94..93536eb 100644
--- a/drivers/s390/cio/chsc_sch.c
+++ b/drivers/s390/cio/chsc_sch.c
@@ -8,6 +8,7 @@
*/

#include <linux/device.h>
+#include <linux/compat.h>
#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
diff --git a/drivers/s390/scsi/zfcp_cfdc.c b/drivers/s390/scsi/zfcp_cfdc.c
index 0eb6eef..274140f 100644
--- a/drivers/s390/scsi/zfcp_cfdc.c
+++ b/drivers/s390/scsi/zfcp_cfdc.c
@@ -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"
diff --git a/include/linux/compat.h b/include/linux/compat.h
index ef68119..2fca741 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -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 */
--
1.6.5.1

Jason Baron

unread,
Mar 18, 2010, 2:30:02 PM3/18/10
to
move 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.

Signed-off-by: Jason Baron <jba...@redhat.com>
---

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(-)

diff --git a/arch/Kconfig b/arch/Kconfig
index e0ad3ca..0aca622 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -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"
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 6de8f35..4083c0f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -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
diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h
index 4e462cc..f734812 100644
--- a/arch/x86/include/asm/syscall.h
+++ b/arch/x86/include/asm/syscall.h
@@ -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;

diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 4b36a0b..662343b 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -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];
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 2361d9a..cf230a6 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -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__) \
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 3f88b8e..6db3794 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -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;
--
1.6.5.1

Jason Baron

unread,
Mar 18, 2010, 2:40:01 PM3/18/10
to

Re-post due to missing macro parameter. interdiff:

diff -u b/include/linux/syscalls.h b/include/linux/syscalls.h
--- b/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -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 <jba...@redhat.com>
---
include/linux/syscalls.h | 50 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e601985..b5f66dc 100644

+#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...) \

Frederic Weisbecker

unread,
Mar 27, 2010, 1:00:02 AM3/27/10
to

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.

Frederic Weisbecker

unread,
Mar 27, 2010, 1:10:01 AM3/27/10
to
On Tue, Mar 16, 2010 at 01:46:08PM -0400, Jason Baron wrote:
> 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

Other than the small comments I had, it's a very nice stuff.
Just waiting for your next iteration before applying.

Thanks!

Ian Munsie

unread,
May 21, 2010, 5:50:02 AM5/21/10
to
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:


> 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.

Jason Baron

unread,
May 21, 2010, 9:30:03 AM5/21/10
to
On Fri, May 21, 2010 at 07:40:21PM +1000, Ian Munsie wrote:
> 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
>

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

Frederic Weisbecker

unread,
May 21, 2010, 9:40:01 AM5/21/10
to


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.

Ian Munsie

unread,
May 24, 2010, 3:10:01 AM5/24/10
to
Excerpts from Jason Baron's message of Wed Mar 17 04:46:42 +1100 2010:
<snip>

> + 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

Jason Baron

unread,
May 24, 2010, 4:30:03 PM5/24/10
to
On Mon, May 24, 2010 at 05:05:42PM +1000, Ian Munsie wrote:
>
> Excerpts from Jason Baron's message of Wed Mar 17 04:46:42 +1100 2010:
> <snip>
> > + 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

yes. good catch. I had spotted this as well. here's the complete re-spun
patch.

thanks,

-Jason


diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index e601985..b5f66dc 100644

+ 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, ...) \

Ian Munsie

unread,
Jun 17, 2010, 3:40:01 AM6/17/10
to
Excerpts from Jason Baron's message of Fri May 21 23:24:07 +1000 2010:

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

Frederic Weisbecker

unread,
Jun 17, 2010, 3:50:03 AM6/17/10
to

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.

Jason Baron

unread,
Jun 17, 2010, 11:40:02 AM6/17/10
to
On Thu, Jun 17, 2010 at 05:39:07PM +1000, Ian Munsie wrote:

Hi Ian

if its easier for you, that's fine, feel free to include my patches with
your patchset.

thanks,

-Jason

0 new messages