linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2
@ 2010-06-23 10:02 Ian Munsie
  2010-06-23 10:02 ` [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
                   ` (37 more replies)
  0 siblings, 38 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman

This patch series implements ftrace syscall tracing on PowerPC. All PPC 32bit,
64bit and 32bit compat syscalls are supported along with all the missing
generic compat syscalls.

This patch series includes Jason Baron's Compat Syscall Support v3 patches
rebased atop the current tip tree as patches 05 through 18 inclusive - refer to
http://lkml.org/lkml/2010/3/16/308 for their discussion. Any alterations I have
made other than what was necessary to rebase them are in separate later
commits. In particular, patch #38 removes the test for unmapped syscalls as
patch #1 prevents the events from being created if the mapping failed. Patch
#39 also undoes an ABI change from Jason's patches.

Some of the PowerPC syscalls have been renamed in this series - particularly
any with a ppc_ prefix or similar that did not use an assembly wrapper - most
of these now have a sys_ppc_ prefix or similar.

Those syscalls with assembly wrappers are now rigidly named such that only the
first three characters differ from the function name (i.e. ppc_fork is the
wrapper for sys_fork) so that the arch_syscall_match_sym_name function will
still match them to their metadata (it ignores the 3 character prefix).

I have avoided changing the return types of any of the syscalls as I was
concerned about the affect of doing so, rather adding the infrastructure to
allow their metadata to be recorded as well (patches #33 through #35).

If the system is booted with loglevel=8, any system calls that have not mapped
to their metadata will be printed, which can help track down any further
unmapped syscalls. This could be useful for other archs adding ftrace syscall
tracing support.


The patches base is tip/master.

Changes since v1:
 * Add Jason's compat syscall support as part of the series
 * Convert all the PPC syscalls to use the SYSCALL_DEFINE macros
 * Remaining generic syscalls supported
 * Handle PPC syscalls with register access through 7th parameter
 * Support for syscalls with !long return types
 * Support for syscalls using their own syscall wrappers
 * Clean up some of the metadata recording preprocessor code
 * Some other general cleanups


^ permalink raw reply	[flat|nested] 56+ messages in thread

* [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 15:02   ` Steven Rostedt
  2010-06-23 10:02 ` [PATCH 02/40] ftrace syscalls: Make arch_syscall_addr weak Ian Munsie
                   ` (36 subsequent siblings)
  37 siblings, 1 reply; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar, Masami Hiramatsu

From: Ian Munsie <imunsie@au1.ibm.com>

FTRACE_SYSCALLS would create events for each and every system call, even
if it had failed to map the system call's name with it's number. This
resulted in a number of events being created that would not behave as
expected.

This could happen, for example, on architectures who's symbol names are
unusual and will not match the system call name. It could also happen
with system calls which were mapped to sys_ni_syscall.

This patch changes the default system call number in the metadata to -1.
If the system call name from the metadata is not successfully mapped to
a system call number during boot, than the event initialisation routine
will now return an error, preventing the event from being created.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h      |    2 ++
 kernel/trace/trace_syscalls.c |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 7f614ce..86f082b 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -159,6 +159,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta_##sname = {				\
 		.name 		= "sys"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
 		.args		= args_##sname,			\
@@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta__##sname = {				\
 		.name 		= "sys_"#sname,			\
+		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= 0,				\
 		.enter_event	= &event_enter__##sname,	\
 		.exit_event	= &event_exit__##sname,		\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 34e3580..82246ce 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -431,6 +431,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
 	int id;
+	int num;
+
+	num = ((struct syscall_metadata *)call->data)->syscall_nr;
+	if (num < 0 || num >= NR_syscalls) {
+		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
+				((struct syscall_metadata *)call->data)->name);
+		return -ENOSYS;
+	}
 
 	if (set_syscall_print_fmt(call) < 0)
 		return -ENOMEM;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 02/40] ftrace syscalls: Make arch_syscall_addr weak
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
  2010-06-23 10:02 ` [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 03/40] ftrace syscalls: Allow arch specific syscall symbol matching Ian Munsie
                   ` (35 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Randy Dunlap, Mike Frysinger, Heiko Carstens,
	Masami Hiramatsu, linux-doc

From: Ian Munsie <imunsie@au1.ibm.com>

Some architectures use non-trivial system call tables and will not work
with the generic arch_syscall_addr code. For example, PowerPC64 uses a
table of twin long longs.

This patch makes the generic arch_syscall_addr weak to allow
architectures with non-trivial system call tables to override it.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 Documentation/trace/ftrace-design.txt |    3 +++
 kernel/trace/trace_syscalls.c         |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index f1f81af..8369a1c 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -244,6 +244,9 @@ You need very few things to get the syscalls tracing in an arch.
 - Support the TIF_SYSCALL_TRACEPOINT thread flags.
 - Put the trace_sys_enter() and trace_sys_exit() tracepoints calls from ptrace
   in the ptrace syscalls tracing path.
+- If the system call table on this arch is more complicated than a simple array
+  of addresses of the system calls, implement an arch_syscall_addr to return
+  the address of a given system call.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 82246ce..e2b657e 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -453,7 +453,7 @@ int init_syscall_trace(struct ftrace_event_call *call)
 	return id;
 }
 
-unsigned long __init arch_syscall_addr(int nr)
+unsigned long __init __weak arch_syscall_addr(int nr)
 {
 	return (unsigned long)sys_call_table[nr];
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 03/40] ftrace syscalls: Allow arch specific syscall symbol matching
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
  2010-06-23 10:02 ` [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
  2010-06-23 10:02 ` [PATCH 02/40] ftrace syscalls: Make arch_syscall_addr weak Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 04/40] trace, powerpc: Implement raw syscall tracepoints on PowerPC Ian Munsie
                   ` (34 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Randy Dunlap, Mike Frysinger, Heiko Carstens,
	David S. Miller, Jiri Olsa, Masami Hiramatsu, linux-doc

From: Ian Munsie <imunsie@au1.ibm.com>

Some architectures have unusual symbol names and the generic code to
match the symbol name with the function name for the syscall metadata
will fail. For example, symbols on PPC64 start with a period and the
generic code will fail to match them.

This patch splits out the match logic into a standalone weak function
that can be overridden on archs with unusual symbol names.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 Documentation/trace/ftrace-design.txt |    3 +++
 include/linux/ftrace.h                |    1 +
 kernel/trace/trace_syscalls.c         |   19 ++++++++++++-------
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/Documentation/trace/ftrace-design.txt b/Documentation/trace/ftrace-design.txt
index 8369a1c..3936d5f 100644
--- a/Documentation/trace/ftrace-design.txt
+++ b/Documentation/trace/ftrace-design.txt
@@ -247,6 +247,9 @@ You need very few things to get the syscalls tracing in an arch.
 - If the system call table on this arch is more complicated than a simple array
   of addresses of the system calls, implement an arch_syscall_addr to return
   the address of a given system call.
+- If the symbol names of the system calls do not match the function names on
+  this arch, implement an arch_syscall_match_sym_name with the appropriate
+  logic to return true if the function name corresponds with the symbol name.
 - Tag this arch as HAVE_SYSCALL_TRACEPOINTS.
 
 
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 41e4633..bb4914d 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -522,6 +522,7 @@ extern enum ftrace_dump_mode ftrace_dump_on_oops;
 #ifdef CONFIG_FTRACE_SYSCALLS
 
 unsigned long arch_syscall_addr(int nr);
+bool arch_syscall_match_sym_name(const char *sym, const char *name);
 
 #endif /* CONFIG_FTRACE_SYSCALLS */
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index e2b657e..18f27bb 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -80,13 +80,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
 	for ( ; start < stop; start++) {
-		/*
-		 * Only compare after the "sys" prefix. Archs that use
-		 * syscall wrappers may have syscalls symbols aliases prefixed
-		 * with "SyS" instead of "sys", leading to an unwanted
-		 * mismatch.
-		 */
-		if (start->name && !strcmp(start->name + 3, str + 3))
+		if (start->name && arch_syscall_match_sym_name(str, start->name))
 			return start;
 	}
 	return NULL;
@@ -458,6 +452,17 @@ unsigned long __init __weak arch_syscall_addr(int nr)
 	return (unsigned long)sys_call_table[nr];
 }
 
+bool __weak arch_syscall_match_sym_name(const char *sym, const char *name)
+{
+	/*
+	 * Only compare after the "sys" prefix. Archs that use
+	 * syscall wrappers may have syscalls symbols aliases prefixed
+	 * with "SyS" instead of "sys", leading to an unwanted
+	 * mismatch.
+	 */
+	return (!strcmp(sym + 3, name + 3));
+}
+
 int __init init_ftrace_syscalls(void)
 {
 	struct syscall_metadata *meta;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 04/40] trace, powerpc: Implement raw syscall tracepoints on PowerPC
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (2 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 03/40] ftrace syscalls: Allow arch specific syscall symbol matching Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 05/40] x86: add NR_syscalls_compat, make ia32 syscall table visible Ian Munsie
                   ` (33 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ian Munsie, FUJITA Tomonori, Grant Likely,
	Andrew Morton, Anton Blanchard, Nathan Lynch, Andreas Schwab,
	Matt Mackall, Jiri Kosina, Kumar Gala, Scott Wood, Dave Kleikamp,
	David Gibson, Mahesh Salgaonkar, Masami Hiramatsu

From: Ian Munsie <imunsie@au.ibm.com>

This patch implements the raw syscall tracepoints on PowerPC and exports
them for ftrace syscalls to use.

To minimise reworking existing code, I slightly re-ordered the thread
info flags such that the new TIF_SYSCALL_TRACEPOINT bit would still fit
within the 16 bits of the andi. instruction's UI field. The instructions
in question are in /arch/powerpc/kernel/entry_{32,64}.S to and the
_TIF_SYSCALL_T_OR_A with the thread flags to see if system call tracing
is enabled.

In the case of 64bit PowerPC, arch_syscall_addr and
arch_syscall_match_sym_name are overridden to allow ftrace syscalls to
work given the unusual system call table structure and symbol names that
start with a period.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/Kconfig                   |    1 +
 arch/powerpc/include/asm/syscall.h     |    5 +++++
 arch/powerpc/include/asm/thread_info.h |    7 +++++--
 arch/powerpc/kernel/Makefile           |    1 +
 arch/powerpc/kernel/ftrace.c           |   19 +++++++++++++++++++
 arch/powerpc/kernel/ptrace.c           |   10 ++++++++++
 6 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 328774b..0d5c28d 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -141,6 +141,7 @@ config PPC
 	select GENERIC_ATOMIC64 if PPC32
 	select HAVE_PERF_EVENTS
 	select HAVE_REGS_AND_STACK_ACCESS_API
+	select HAVE_SYSCALL_TRACEPOINTS
 
 config EARLY_PRINTK
 	bool
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index 23913e9..b54b2ad 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -15,6 +15,11 @@
 
 #include <linux/sched.h>
 
+/* ftrace syscalls requires exporting the sys_call_table */
+#ifdef CONFIG_FTRACE_SYSCALLS
+extern const unsigned long *sys_call_table;
+#endif /* CONFIG_FTRACE_SYSCALLS */
+
 static inline long syscall_get_nr(struct task_struct *task,
 				  struct pt_regs *regs)
 {
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 65eb859..4403f09 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_NOERROR		12	/* Force successful syscall return */
 #define TIF_NOTIFY_RESUME	13	/* callback before returning to user */
 #define TIF_FREEZE		14	/* Freezing for suspend */
-#define TIF_RUNLATCH		15	/* Is the runlatch enabled? */
+#define TIF_SYSCALL_TRACEPOINT	15	/* syscall tracepoint instrumentation */
+#define TIF_RUNLATCH		16	/* Is the runlatch enabled? */
 
 /* as above, but as bit values */
 #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
@@ -127,8 +128,10 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_NOERROR		(1<<TIF_NOERROR)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 #define _TIF_FREEZE		(1<<TIF_FREEZE)
+#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 #define _TIF_RUNLATCH		(1<<TIF_RUNLATCH)
-#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
+#define _TIF_SYSCALL_T_OR_A	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
+				 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
 
 #define _TIF_USER_WORK_MASK	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
 				 _TIF_NOTIFY_RESUME)
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 58d0572..6977196 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -102,6 +102,7 @@ obj64-$(CONFIG_AUDIT)		+= compat_audit.o
 
 obj-$(CONFIG_DYNAMIC_FTRACE)	+= ftrace.o
 obj-$(CONFIG_FUNCTION_GRAPH_TRACER)	+= ftrace.o
+obj-$(CONFIG_FTRACE_SYSCALLS)	+= ftrace.o
 obj-$(CONFIG_PERF_EVENTS)	+= perf_callchain.o
 
 obj-$(CONFIG_PPC_PERF_CTRS)	+= perf_event.o
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index ce1f3e4..f5fadbb 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -22,6 +22,7 @@
 #include <asm/cacheflush.h>
 #include <asm/code-patching.h>
 #include <asm/ftrace.h>
+#include <asm/syscall.h>
 
 
 #ifdef CONFIG_DYNAMIC_FTRACE
@@ -600,3 +601,21 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
 	}
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
+#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64)
+unsigned long __init arch_syscall_addr(int nr)
+{
+	return sys_call_table[nr*2];
+}
+
+inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
+{
+	/*
+	 * Compare the symbol name with the system call name. Skip the .sys or
+	 * .SyS prefix from the symbol name and the sys prefix from the system
+	 * call name and just match the rest. 32bit can use the generic
+	 * function since their symbol names don't start with a period.
+	 */
+	return (!strcmp(sym + 4, name + 3));
+}
+#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 7a0c019..eb7eeb8 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -29,6 +29,7 @@
 #include <linux/signal.h>
 #include <linux/seccomp.h>
 #include <linux/audit.h>
+#include <trace/syscall.h>
 #ifdef CONFIG_PPC32
 #include <linux/module.h>
 #endif
@@ -38,6 +39,9 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 /*
  * The parameter save area on the stack is used to store arguments being passed
  * to callee function and is located at fixed offset from stack pointer.
@@ -1615,6 +1619,9 @@ long do_syscall_trace_enter(struct pt_regs *regs)
 		 */
 		ret = -1L;
 
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+		trace_sys_enter(regs, regs->gpr[0]);
+
 	if (unlikely(current->audit_context)) {
 #ifdef CONFIG_PPC64
 		if (!test_thread_flag(TIF_32BIT))
@@ -1643,6 +1650,9 @@ void do_syscall_trace_leave(struct pt_regs *regs)
 		audit_syscall_exit((regs->ccr&0x10000000)?AUDITSC_FAILURE:AUDITSC_SUCCESS,
 				   regs->result);
 
+	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
+		trace_sys_exit(regs, regs->result);
+
 	step = test_thread_flag(TIF_SINGLESTEP);
 	if (step || test_thread_flag(TIF_SYSCALL_TRACE))
 		tracehook_report_syscall_exit(regs, step);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 05/40] x86: add NR_syscalls_compat, make ia32 syscall table visible
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (3 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 04/40] trace, powerpc: Implement raw syscall tracepoints on PowerPC Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 06/40] x86: add arch_compat_syscall_addr() Ian Munsie
                   ` (32 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Thomas Gleixner, H. Peter Anvin, x86, Andrew Morton,
	Christoph Hellwig, David S. Miller

From: Jason Baron <jbaron@redhat.com>

Add 'NR_syscalls_compat' global for x86. Also, make 'ia32_sys_call_table' into a
global.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/x86/ia32/ia32entry.S     |    3 +++
 arch/x86/include/asm/compat.h |    2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index e790bc1..94b9022 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -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)
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index 306160e..55109f8 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -216,4 +216,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 */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 06/40] x86: add arch_compat_syscall_addr()
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (4 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 05/40] x86: add NR_syscalls_compat, make ia32 syscall table visible Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support Ian Munsie
                   ` (31 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Thomas Gleixner, H. Peter Anvin, x86, Paul Mundt,
	David S. Miller, Heiko Carstens

From: Jason Baron <jbaron@redhat.com>

Add arch_compat_syscall_addr(int nr) for x86_64. This is in preparation for adding
compat syscall support to the event tracer.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/x86/include/asm/syscall.h |    5 +++++
 arch/x86/kernel/ftrace.c       |    8 ++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h
index c4a348f..4e462cc 100644
--- a/arch/x86/include/asm/syscall.h
+++ b/arch/x86/include/asm/syscall.h
@@ -16,7 +16,12 @@
 #include <linux/sched.h>
 #include <linux/err.h>
 
+#if defined(CONFIG_COMPAT) && defined(CONFIG_FTRACE_SYSCALLS)
+ #define __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS
+#endif
+
 extern const unsigned long sys_call_table[];
+extern const unsigned long *ia32_sys_call_table;
 
 /*
  * Only the low 32 bits of orig_ax are meaningful, so we return int.
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index cd37469..4b36a0b 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -26,6 +26,7 @@
 #include <asm/ftrace.h>
 #include <asm/nops.h>
 #include <asm/nmi.h>
+#include <asm/syscall.h>
 
 
 #ifdef CONFIG_DYNAMIC_FTRACE
@@ -510,3 +511,10 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr,
 	}
 }
 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
+
+#ifdef __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS
+unsigned long __init arch_compat_syscall_addr(int nr)
+{
+	return (unsigned long)(&ia32_sys_call_table)[nr];
+}
+#endif
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (5 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 06/40] x86: add arch_compat_syscall_addr() Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 15:16   ` Steven Rostedt
  2010-06-23 10:02 ` [PATCH 09/40] tracing: move __start_ftrace_events and __stop_ftrace_events to header file Ian Munsie
                   ` (30 subsequent siblings)
  37 siblings, 1 reply; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar, Lai Jiangshan, Masami Hiramatsu

From: Jason Baron <jbaron@redhat.com>

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 <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.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 86f082b..755d05b 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -163,6 +163,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 		.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,		\
 		.enter_fields	= LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
@@ -179,6 +183,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 		.name 		= "sys_"#sname,			\
 		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.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_fields	= LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 257e089..75f3dce 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -27,6 +27,10 @@ struct syscall_metadata {
 	const char	**args;
 	struct list_head enter_fields;
 	struct list_head exit_fields;
+	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 18f27bb..f5ddb9c 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -12,8 +12,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);
 
 static int syscall_enter_register(struct ftrace_event_call *event,
 				 enum trace_reg type);
@@ -299,13 +297,14 @@ void ftrace_syscall_enter(void *ignore, 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,
@@ -333,13 +332,14 @@ void ftrace_syscall_exit(void *ignore, 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->event.type, sizeof(*entry), 0, 0);
 	if (!event)
@@ -366,7 +366,7 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
 	if (!sys_refcount_enter)
 		ret = register_trace_sys_enter(ftrace_syscall_enter, NULL);
 	if (!ret) {
-		set_bit(num, enabled_enter_syscalls);
+		((struct syscall_metadata *)call->data)->ftrace_enter = 1;
 		sys_refcount_enter++;
 	}
 	mutex_unlock(&syscall_trace_lock);
@@ -382,7 +382,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, NULL);
 	mutex_unlock(&syscall_trace_lock);
@@ -400,7 +400,7 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
 	if (!sys_refcount_exit)
 		ret = register_trace_sys_exit(ftrace_syscall_exit, NULL);
 	if (!ret) {
-		set_bit(num, enabled_exit_syscalls);
+		((struct syscall_metadata *)call->data)->ftrace_exit = 1;
 		sys_refcount_exit++;
 	}
 	mutex_unlock(&syscall_trace_lock);
@@ -416,7 +416,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, NULL);
 	mutex_unlock(&syscall_trace_lock);
@@ -492,8 +492,6 @@ core_initcall(init_ftrace_syscalls);
 
 #ifdef CONFIG_PERF_EVENTS
 
-static DECLARE_BITMAP(enabled_perf_enter_syscalls, NR_syscalls);
-static DECLARE_BITMAP(enabled_perf_exit_syscalls, NR_syscalls);
 static int sys_perf_refcount_enter;
 static int sys_perf_refcount_exit;
 
@@ -507,13 +505,13 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 	int size;
 
 	syscall_nr = syscall_get_nr(current, regs);
-	if (!test_bit(syscall_nr, enabled_perf_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));
@@ -550,7 +548,7 @@ int perf_sysenter_enable(struct ftrace_event_call *call)
 		pr_info("event trace: Could not activate"
 				"syscall entry trace point");
 	} else {
-		set_bit(num, enabled_perf_enter_syscalls);
+		((struct syscall_metadata *)call->data)->perf_enter = 1;
 		sys_perf_refcount_enter++;
 	}
 	mutex_unlock(&syscall_trace_lock);
@@ -565,7 +563,7 @@ void perf_sysenter_disable(struct ftrace_event_call *call)
 
 	mutex_lock(&syscall_trace_lock);
 	sys_perf_refcount_enter--;
-	clear_bit(num, enabled_perf_enter_syscalls);
+	((struct syscall_metadata *)call->data)->perf_enter = 0;
 	if (!sys_perf_refcount_enter)
 		unregister_trace_sys_enter(perf_syscall_enter, NULL);
 	mutex_unlock(&syscall_trace_lock);
@@ -581,13 +579,13 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 	int size;
 
 	syscall_nr = syscall_get_nr(current, regs);
-	if (!test_bit(syscall_nr, enabled_perf_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);
@@ -626,7 +624,7 @@ int perf_sysexit_enable(struct ftrace_event_call *call)
 		pr_info("event trace: Could not activate"
 				"syscall exit trace point");
 	} else {
-		set_bit(num, enabled_perf_exit_syscalls);
+		((struct syscall_metadata *)call->data)->perf_exit = 1;
 		sys_perf_refcount_exit++;
 	}
 	mutex_unlock(&syscall_trace_lock);
@@ -641,7 +639,7 @@ void perf_sysexit_disable(struct ftrace_event_call *call)
 
 	mutex_lock(&syscall_trace_lock);
 	sys_perf_refcount_exit--;
-	clear_bit(num, enabled_perf_exit_syscalls);
+	((struct syscall_metadata *)call->data)->perf_exit = 0;
 	if (!sys_perf_refcount_exit)
 		unregister_trace_sys_exit(perf_syscall_exit, NULL);
 	mutex_unlock(&syscall_trace_lock);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 09/40] tracing: move __start_ftrace_events and __stop_ftrace_events to header file
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (6 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 10/40] tracing: add tracing support for compat syscalls Ian Munsie
                   ` (29 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar, Li Zefan, Masami Hiramatsu

From: Jason Baron <jbaron@redhat.com>

trace_syscalls.c uses __start_ftrace_events and __stop_ftrace_events in order
to prune compat syscall ftrace events that are not referenced by the compat
syscall table. So move the 'extern' definitions to a common header file.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/ftrace_event.h |    3 +++
 kernel/trace/trace_events.c  |    3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 0af31cd..54b020b 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -189,6 +189,9 @@ struct ftrace_event_call {
 #endif
 };
 
+extern struct ftrace_event_call __start_ftrace_events[];
+extern struct ftrace_event_call __stop_ftrace_events[];
+
 #define PERF_MAX_TRACE_SIZE	2048
 
 #define MAX_FILTER_PRED		32
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index a594f9a..b03f82f 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -1260,9 +1260,6 @@ static struct notifier_block trace_module_nb = {
 	.priority = 0,
 };
 
-extern struct ftrace_event_call __start_ftrace_events[];
-extern struct ftrace_event_call __stop_ftrace_events[];
-
 static char bootup_event_buf[COMMAND_LINE_SIZE] __initdata;
 
 static __init int setup_trace_event(char *str)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 10/40] tracing: add tracing support for compat syscalls
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (7 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 09/40] tracing: move __start_ftrace_events and __stop_ftrace_events to header file Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 15:26   ` Steven Rostedt
  2010-06-23 10:02 ` [PATCH 11/40] syscalls: add ARCH_COMPAT_SYSCALL_DEFINE() Ian Munsie
                   ` (28 subsequent siblings)
  37 siblings, 1 reply; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, David S. Miller, Andrew Morton, Arnd Bergmann,
	Lai Jiangshan, Masami Hiramatsu, Li Zefan

From: Jason Baron <jbaron@redhat.com>

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

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/compat.h        |    2 +
 include/trace/syscall.h       |    4 ++
 kernel/trace/trace.h          |    2 +
 kernel/trace/trace_syscalls.c |   86 +++++++++++++++++++++++++++++++++++++----
 4 files changed, 86 insertions(+), 8 deletions(-)

diff --git a/include/linux/compat.h b/include/linux/compat.h
index ab638e9..a94f13d 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -363,6 +363,8 @@ extern ssize_t compat_rw_copy_check_uvector(int type,
 
 #else /* CONFIG_COMPAT */
 
+#define NR_syscalls_compat 0
+
 static inline int is_compat_task(void)
 {
 	return 0;
diff --git a/include/trace/syscall.h b/include/trace/syscall.h
index 75f3dce..67d4e64 100644
--- a/include/trace/syscall.h
+++ b/include/trace/syscall.h
@@ -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;
@@ -38,6 +39,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 reg_event_syscall_enter(struct ftrace_event_call *call);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 01ce088..53ace4b 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -79,12 +79,14 @@ enum trace_type {
 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;
 };
 
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index f5ddb9c..d910cba 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -4,6 +4,7 @@
 #include <linux/kernel.h>
 #include <linux/ftrace.h>
 #include <linux/perf_event.h>
+#include <linux/compat.h>
 #include <asm/syscall.h>
 
 #include "trace_output.h"
@@ -65,6 +66,7 @@ extern unsigned long __start_syscalls_metadata[];
 extern unsigned long __stop_syscalls_metadata[];
 
 static struct syscall_metadata **syscalls_metadata;
+static struct syscall_metadata **compat_syscalls_metadata;
 
 static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 {
@@ -84,8 +86,14 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 	return NULL;
 }
 
-static struct syscall_metadata *syscall_nr_to_meta(int nr)
+static struct syscall_metadata *syscall_nr_to_meta(int nr, int compat)
 {
+	if (compat) {
+		if (!compat_syscalls_metadata || nr >= NR_syscalls_compat ||
+									nr < 0)
+			return NULL;
+		return compat_syscalls_metadata[nr];
+	}
 	if (!syscalls_metadata || nr >= NR_syscalls || nr < 0)
 		return NULL;
 
@@ -104,7 +112,7 @@ print_syscall_enter(struct trace_iterator *iter, int flags,
 
 	trace = (typeof(trace))ent;
 	syscall = trace->nr;
-	entry = syscall_nr_to_meta(syscall);
+	entry = syscall_nr_to_meta(syscall, trace->compat);
 
 	if (!entry)
 		goto end;
@@ -158,7 +166,7 @@ print_syscall_exit(struct trace_iterator *iter, int flags,
 
 	trace = (typeof(trace))ent;
 	syscall = trace->nr;
-	entry = syscall_nr_to_meta(syscall);
+	entry = syscall_nr_to_meta(syscall, trace->compat);
 
 	if (!entry) {
 		trace_seq_printf(s, "\n");
@@ -293,12 +301,16 @@ void ftrace_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 	struct ring_buffer *buffer;
 	int size;
 	int syscall_nr;
+	int compat = 0;
 
 	syscall_nr = syscall_get_nr(current, regs);
 	if (syscall_nr < 0)
 		return;
 
-	sys_data = syscall_nr_to_meta(syscall_nr);
+	if (is_compat_task())
+		compat = 1;
+
+	sys_data = syscall_nr_to_meta(syscall_nr, compat);
 	if (!sys_data)
 		return;
 
@@ -314,6 +326,7 @@ void ftrace_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 
 	entry = ring_buffer_event_data(event);
 	entry->nr = syscall_nr;
+	entry->compat = compat;
 	syscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args);
 
 	if (!filter_current_check_discard(buffer, sys_data->enter_event,
@@ -328,12 +341,16 @@ void ftrace_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 	struct ring_buffer_event *event;
 	struct ring_buffer *buffer;
 	int syscall_nr;
+	int compat = 0;
 
 	syscall_nr = syscall_get_nr(current, regs);
 	if (syscall_nr < 0)
 		return;
 
-	sys_data = syscall_nr_to_meta(syscall_nr);
+	if (is_compat_task())
+		compat = 1;
+
+	sys_data = syscall_nr_to_meta(syscall_nr, compat);
 	if (!sys_data)
 		return;
 
@@ -347,6 +364,7 @@ void ftrace_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 
 	entry = ring_buffer_event_data(event);
 	entry->nr = syscall_nr;
+	entry->compat = compat;
 	entry->ret = syscall_get_return_value(current, regs);
 
 	if (!filter_current_check_discard(buffer, sys_data->exit_event,
@@ -485,7 +503,49 @@ int __init init_ftrace_syscalls(void)
 		meta->syscall_nr = i;
 		syscalls_metadata[i] = meta;
 	}
-
+#ifdef __HAVE_ARCH_FTRACE_COMPAT_SYSCALLS
+	if (NR_syscalls_compat) {
+		int match;
+		struct ftrace_event_call *ftrace_event;
+
+		compat_syscalls_metadata = kzalloc(sizeof(*syscalls_metadata) *
+						NR_syscalls_compat, GFP_KERNEL);
+		if (!compat_syscalls_metadata) {
+			WARN_ON(1);
+			kfree(syscalls_metadata);
+			return -ENOMEM;
+		}
+		for (i = 0; i < NR_syscalls_compat; i++) {
+			addr = arch_compat_syscall_addr(i);
+			meta = find_syscall_meta(addr);
+			if (!meta)
+				continue;
+
+			meta->compat_syscall_nr = i;
+			compat_syscalls_metadata[i] = meta;
+		}
+		/* now check if any compat_syscalls are not referenced */
+		for (ftrace_event = __start_ftrace_events;
+			(unsigned long)ftrace_event <
+			(unsigned long)__stop_ftrace_events; ftrace_event++) {
+
+			match = 0;
+			if (!ftrace_event->name)
+				continue;
+			if (strcmp(ftrace_event->class->system, "compat_syscalls"))
+				continue;
+			for (i = 0; i < NR_syscalls_compat; i++) {
+				if (ftrace_event->data ==
+						compat_syscalls_metadata[i]) {
+					match = 1;
+					break;
+				}
+			}
+			if (!match)
+				ftrace_event->name = NULL;
+		}
+	}
+#endif
 	return 0;
 }
 core_initcall(init_ftrace_syscalls);
@@ -503,9 +563,13 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 	int syscall_nr;
 	int rctx;
 	int size;
+	int compat = 0;
 
 	syscall_nr = syscall_get_nr(current, regs);
-	sys_data = syscall_nr_to_meta(syscall_nr);
+	if (is_compat_task())
+		compat = 1;
+
+	sys_data = syscall_nr_to_meta(syscall_nr, compat);
 	if (!sys_data)
 		return;
 
@@ -527,6 +591,7 @@ static void perf_syscall_enter(void *ignore, struct pt_regs *regs, long id)
 		return;
 
 	rec->nr = syscall_nr;
+	rec->compat = compat;
 	syscall_get_arguments(current, regs, 0, sys_data->nb_args,
 			       (unsigned long *)&rec->args);
 
@@ -577,9 +642,13 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 	int syscall_nr;
 	int rctx;
 	int size;
+	int compat = 0;
 
 	syscall_nr = syscall_get_nr(current, regs);
-	sys_data = syscall_nr_to_meta(syscall_nr);
+	if (is_compat_task())
+		compat = 1;
+
+	sys_data = syscall_nr_to_meta(syscall_nr, compat);
 	if (!sys_data)
 		return;
 
@@ -604,6 +673,7 @@ static void perf_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 		return;
 
 	rec->nr = syscall_nr;
+	rec->compat = compat;
 	rec->ret = syscall_get_return_value(current, regs);
 
 	head = this_cpu_ptr(sys_data->exit_event->perf_events);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 11/40] syscalls: add ARCH_COMPAT_SYSCALL_DEFINE()
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (8 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 10/40] tracing: add tracing support for compat syscalls Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 12/40] x86, compat: convert ia32 layer to use Ian Munsie
                   ` (27 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar

From: Jason Baron <jbaron@redhat.com>

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 <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.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 755d05b..d7096ab 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -131,7 +131,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((__aligned__(4)))				\
 	  __attribute__((section("_ftrace_events")))			\
 	  event_enter_##sname = {					\
-		.name                   = "sys_enter"#sname,		\
+		.name                   = "enter_"#sname,		\
 		.class			= &event_class_syscall_enter,	\
 		.event.funcs            = &enter_syscall_print_funcs,	\
 		.data			= (void *)&__syscall_meta_##sname,\
@@ -145,20 +145,20 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((__aligned__(4)))				\
 	  __attribute__((section("_ftrace_events")))			\
 	  event_exit_##sname = {					\
-		.name                   = "sys_exit"#sname,		\
+		.name                   = "exit_"#sname,		\
 		.class			= &event_class_syscall_exit,	\
 		.event.funcs		= &exit_syscall_print_funcs,	\
 		.data			= (void *)&__syscall_meta_##sname,\
 	}
 
-#define SYSCALL_METADATA(sname, nb)				\
+#define SYSCALL_METADATA(rname, sname, nb)			\
 	SYSCALL_TRACE_ENTER_EVENT(sname);			\
 	SYSCALL_TRACE_EXIT_EVENT(sname);			\
 	static struct syscall_metadata __used			\
 	  __attribute__((__aligned__(4)))			\
 	  __attribute__((section("__syscalls_metadata")))	\
 	  __syscall_meta_##sname = {				\
-		.name 		= "sys"#sname,			\
+		.name 		= #rname,			\
 		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= nb,				\
 		.types		= types_##sname,		\
@@ -174,12 +174,12 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	};
 
 #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 struct syscall_metadata __used			\
 	  __attribute__((__aligned__(4)))			\
 	  __attribute__((section("__syscalls_metadata")))	\
-	  __syscall_meta__##sname = {				\
+	  __syscall_meta_sys_##sname = {			\
 		.name 		= "sys_"#sname,			\
 		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.nb_args 	= 0,				\
@@ -187,8 +187,8 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 		.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,	\
 		.enter_fields	= LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
 		.exit_fields	= LIST_HEAD_INIT(__syscall_meta__##sname.exit_fields), \
 	};							\
@@ -204,6 +204,32 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
 #define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
 
+#ifdef CONFIG_COMPAT
+
+#define ARCH_COMPAT_SYSCALL_DEFINE1(name, ...) COMPAT_SYSCALL_DEFINEx(1, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE2(name, ...) COMPAT_SYSCALL_DEFINEx(2, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE3(name, ...) COMPAT_SYSCALL_DEFINEx(3, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE4(name, ...) COMPAT_SYSCALL_DEFINEx(4, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE5(name, ...) COMPAT_SYSCALL_DEFINEx(5, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE6(name, ...) COMPAT_SYSCALL_DEFINEx(6, sys32_##name, name, __VA_ARGS__)
+
+#ifdef CONFIG_FTRACE_SYSCALLS
+#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)		\
+	static const char *types_compat_sys_##sname[] = {	\
+		__SC_STR_TDECL##x(__VA_ARGS__)			\
+	};							\
+	static const char *args_compat_sys_##sname[] = {	\
+		__SC_STR_ADECL##x(__VA_ARGS__)			\
+	};							\
+	SYSCALL_METADATA(syscall, compat_sys_##sname, x);	\
+	asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))
+#else
+#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)		\
+	asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))
+#endif
+
+#endif
+
 #ifdef CONFIG_PPC64
 #define SYSCALL_ALIAS(alias, name)					\
 	asm ("\t.globl " #alias "\n\t.set " #alias ", " #name "\n"	\
@@ -220,13 +246,13 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 
 #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.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 12/40] x86, compat: convert ia32 layer to use
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (9 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 11/40] syscalls: add ARCH_COMPAT_SYSCALL_DEFINE() Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:14   ` Christoph Hellwig
  2010-06-23 10:02 ` [PATCH 13/40] syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro Ian Munsie
                   ` (26 subsequent siblings)
  37 siblings, 1 reply; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Thomas Gleixner, H. Peter Anvin, x86, Andrew Morton,
	Christoph Hellwig, Russell King, Greg Ungerer

From: Jason Baron <jbaron@redhat.com>

Make use of the new ARCH_COMPAT_SYSCALL_DEFINE#N() macros to tie the compat
syscalls into the event tracer.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/x86/ia32/sys_ia32.c |  102 +++++++++++++++++++++++-----------------------
 1 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
index 626be15..a844f54 100644
--- a/arch/x86/ia32/sys_ia32.c
+++ b/arch/x86/ia32/sys_ia32.c
@@ -51,15 +51,15 @@
 #define AA(__x)		((unsigned long)(__x))
 
 
-asmlinkage long sys32_truncate64(char __user *filename,
-				 unsigned long offset_low,
-				 unsigned long offset_high)
+ARCH_COMPAT_SYSCALL_DEFINE3(truncate64, char __user *, filename,
+				 unsigned long, offset_low,
+				 unsigned long, offset_high)
 {
        return sys_truncate(filename, ((loff_t) offset_high << 32) | offset_low);
 }
 
-asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
-				  unsigned long offset_high)
+ARCH_COMPAT_SYSCALL_DEFINE3(ftruncate64, unsigned int, fd, unsigned long, offset_low,
+				  unsigned long, offset_high)
 {
        return sys_ftruncate(fd, ((loff_t) offset_high << 32) | offset_low);
 }
@@ -96,8 +96,8 @@ static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
 	return 0;
 }
 
-asmlinkage long sys32_stat64(char __user *filename,
-			     struct stat64 __user *statbuf)
+ARCH_COMPAT_SYSCALL_DEFINE2(stat64, char __user *, filename,
+			     struct stat64 __user *, statbuf)
 {
 	struct kstat stat;
 	int ret = vfs_stat(filename, &stat);
@@ -107,8 +107,8 @@ asmlinkage long sys32_stat64(char __user *filename,
 	return ret;
 }
 
-asmlinkage long sys32_lstat64(char __user *filename,
-			      struct stat64 __user *statbuf)
+ARCH_COMPAT_SYSCALL_DEFINE2(lstat64, char __user *, filename,
+			      struct stat64 __user *, statbuf)
 {
 	struct kstat stat;
 	int ret = vfs_lstat(filename, &stat);
@@ -117,7 +117,7 @@ asmlinkage long sys32_lstat64(char __user *filename,
 	return ret;
 }
 
-asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
+ARCH_COMPAT_SYSCALL_DEFINE2(fstat64, unsigned int, fd, struct stat64 __user *, statbuf)
 {
 	struct kstat stat;
 	int ret = vfs_fstat(fd, &stat);
@@ -126,8 +126,8 @@ asmlinkage long sys32_fstat64(unsigned int fd, struct stat64 __user *statbuf)
 	return ret;
 }
 
-asmlinkage long sys32_fstatat(unsigned int dfd, char __user *filename,
-			      struct stat64 __user *statbuf, int flag)
+ARCH_COMPAT_SYSCALL_DEFINE4(fstatat, unsigned int, dfd, char __user *, filename,
+			      struct stat64 __user *, statbuf, int, flag)
 {
 	struct kstat stat;
 	int error;
@@ -153,7 +153,7 @@ struct mmap_arg_struct32 {
 	unsigned int offset;
 };
 
-asmlinkage long sys32_mmap(struct mmap_arg_struct32 __user *arg)
+ARCH_COMPAT_SYSCALL_DEFINE1(mmap, struct mmap_arg_struct32 __user *, arg)
 {
 	struct mmap_arg_struct32 a;
 
@@ -167,15 +167,15 @@ asmlinkage long sys32_mmap(struct mmap_arg_struct32 __user *arg)
 			       a.offset>>PAGE_SHIFT);
 }
 
-asmlinkage long sys32_mprotect(unsigned long start, size_t len,
-			       unsigned long prot)
+ARCH_COMPAT_SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
+			       unsigned long, prot)
 {
 	return sys_mprotect(start, len, prot);
 }
 
-asmlinkage long sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
-				   struct sigaction32 __user *oact,
-				   unsigned int sigsetsize)
+ARCH_COMPAT_SYSCALL_DEFINE4(rt_sigaction, int, sig, struct sigaction32 __user *, act,
+				   struct sigaction32 __user *, oact,
+				   unsigned int, sigsetsize)
 {
 	struct k_sigaction new_ka, old_ka;
 	int ret;
@@ -249,8 +249,8 @@ asmlinkage long sys32_rt_sigaction(int sig, struct sigaction32 __user *act,
 	return ret;
 }
 
-asmlinkage long sys32_sigaction(int sig, struct old_sigaction32 __user *act,
-				struct old_sigaction32 __user *oact)
+ARCH_COMPAT_SYSCALL_DEFINE3(sigaction, int, sig, struct old_sigaction32 __user *, act,
+				struct old_sigaction32 __user *, oact)
 {
 	struct k_sigaction new_ka, old_ka;
 	int ret;
@@ -288,9 +288,9 @@ asmlinkage long sys32_sigaction(int sig, struct old_sigaction32 __user *act,
 	return ret;
 }
 
-asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
-				     compat_sigset_t __user *oset,
-				     unsigned int sigsetsize)
+ARCH_COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, set,
+				     compat_sigset_t __user *, oset,
+				     unsigned int, sigsetsize)
 {
 	sigset_t s;
 	compat_sigset_t s32;
@@ -328,26 +328,26 @@ asmlinkage long sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
 	return 0;
 }
 
-asmlinkage long sys32_alarm(unsigned int seconds)
+ARCH_COMPAT_SYSCALL_DEFINE1(alarm, unsigned int, seconds)
 {
 	return alarm_setitimer(seconds);
 }
 
-asmlinkage long sys32_waitpid(compat_pid_t pid, unsigned int *stat_addr,
-			      int options)
+ARCH_COMPAT_SYSCALL_DEFINE3(waitpid, compat_pid_t, pid, unsigned int *, stat_addr,
+			      int, options)
 {
 	return compat_sys_wait4(pid, stat_addr, options, NULL);
 }
 
 /* 32-bit timeval and related flotsam.  */
 
-asmlinkage long sys32_sysfs(int option, u32 arg1, u32 arg2)
+ARCH_COMPAT_SYSCALL_DEFINE3(sysfs, int, option, u32, arg1, u32, arg2)
 {
 	return sys_sysfs(option, arg1, arg2);
 }
 
-asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
-				    struct compat_timespec __user *interval)
+ARCH_COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval, compat_pid_t, pid,
+				    struct compat_timespec __user *, interval)
 {
 	struct timespec t;
 	int ret;
@@ -361,8 +361,8 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
 	return ret;
 }
 
-asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
-				    compat_size_t sigsetsize)
+ARCH_COMPAT_SYSCALL_DEFINE2(rt_sigpending, compat_sigset_t __user *, set,
+				    compat_size_t, sigsetsize)
 {
 	sigset_t s;
 	compat_sigset_t s32;
@@ -385,8 +385,8 @@ asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
 	return ret;
 }
 
-asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
-				      compat_siginfo_t __user *uinfo)
+ARCH_COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo, int, pid, int, sig,
+				      compat_siginfo_t __user *, uinfo)
 {
 	siginfo_t info;
 	int ret;
@@ -401,22 +401,22 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
 }
 
 /* warning: next two assume little endian */
-asmlinkage long sys32_pread(unsigned int fd, char __user *ubuf, u32 count,
-			    u32 poslo, u32 poshi)
+ARCH_COMPAT_SYSCALL_DEFINE5(pread, unsigned int, fd, char __user *, ubuf, u32, count,
+			    u32, poslo, u32, poshi)
 {
 	return sys_pread64(fd, ubuf, count,
 			 ((loff_t)AA(poshi) << 32) | AA(poslo));
 }
 
-asmlinkage long sys32_pwrite(unsigned int fd, char __user *ubuf, u32 count,
-			     u32 poslo, u32 poshi)
+ARCH_COMPAT_SYSCALL_DEFINE5(pwrite, unsigned int, fd, char __user *, ubuf, u32, count,
+			     u32, poslo, u32, poshi)
 {
 	return sys_pwrite64(fd, ubuf, count,
 			  ((loff_t)AA(poshi) << 32) | AA(poslo));
 }
 
 
-asmlinkage long sys32_personality(unsigned long personality)
+ARCH_COMPAT_SYSCALL_DEFINE1(personality, unsigned long, personality)
 {
 	int ret;
 
@@ -429,8 +429,8 @@ asmlinkage long sys32_personality(unsigned long personality)
 	return ret;
 }
 
-asmlinkage long sys32_sendfile(int out_fd, int in_fd,
-			       compat_off_t __user *offset, s32 count)
+ARCH_COMPAT_SYSCALL_DEFINE4(sendfile, int, out_fd, int, in_fd,
+			       compat_off_t __user *, offset, s32, count)
 {
 	mm_segment_t old_fs = get_fs();
 	int ret;
@@ -449,8 +449,8 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
 	return ret;
 }
 
-asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
-			     compat_uptr_t __user *envp, struct pt_regs *regs)
+ARCH_COMPAT_SYSCALL_DEFINE4(execve, char __user *, name, compat_uptr_t __user *, argv,
+			compat_uptr_t __user *, envp, struct pt_regs *, regs)
 {
 	long error;
 	char *filename;
@@ -464,8 +464,8 @@ asmlinkage long sys32_execve(char __user *name, compat_uptr_t __user *argv,
 	return error;
 }
 
-asmlinkage long sys32_clone(unsigned int clone_flags, unsigned int newsp,
-			    struct pt_regs *regs)
+ARCH_COMPAT_SYSCALL_DEFINE3(clone, unsigned int, clone_flags, unsigned int, newsp,
+			    struct pt_regs *, regs)
 {
 	void __user *parent_tid = (void __user *)regs->dx;
 	void __user *child_tid = (void __user *)regs->di;
@@ -524,24 +524,24 @@ asmlinkage ssize_t sys32_readahead(int fd, unsigned off_lo, unsigned off_hi,
 	return sys_readahead(fd, ((u64)off_hi << 32) | off_lo, count);
 }
 
-asmlinkage long sys32_sync_file_range(int fd, unsigned off_low, unsigned off_hi,
-				      unsigned n_low, unsigned n_hi,  int flags)
+ARCH_COMPAT_SYSCALL_DEFINE6(sync_file_range, int, fd, unsigned, off_low, unsigned, off_hi,
+			unsigned, n_low, unsigned, n_hi,  int, flags)
 {
 	return sys_sync_file_range(fd,
 				   ((u64)off_hi << 32) | off_low,
 				   ((u64)n_hi << 32) | n_low, flags);
 }
 
-asmlinkage long sys32_fadvise64(int fd, unsigned offset_lo, unsigned offset_hi,
-				size_t len, int advice)
+ARCH_COMPAT_SYSCALL_DEFINE5(fadvise64, int, fd, unsigned, offset_lo, unsigned, offset_hi,
+				size_t, len, int, advice)
 {
 	return sys_fadvise64_64(fd, ((u64)offset_hi << 32) | offset_lo,
 				len, advice);
 }
 
-asmlinkage long sys32_fallocate(int fd, int mode, unsigned offset_lo,
-				unsigned offset_hi, unsigned len_lo,
-				unsigned len_hi)
+ARCH_COMPAT_SYSCALL_DEFINE6(fallocate, int, fd, int, mode, unsigned, offset_lo,
+				unsigned, offset_hi, unsigned, len_lo,
+				unsigned, len_hi)
 {
 	return sys_fallocate(fd, mode, ((u64)offset_hi << 32) | offset_lo,
 			     ((u64)len_hi << 32) | len_lo);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 13/40] syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (10 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 12/40] x86, compat: convert ia32 layer to use Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 14/40] compat: convert to use COMPAT_SYSCALL_DEFINE#N() Ian Munsie
                   ` (25 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar

From: Jason Baron <jbaron@redhat.com>

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 <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.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 d7096ab..a7d1114 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -213,6 +213,13 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #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.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 14/40] compat: convert to use COMPAT_SYSCALL_DEFINE#N()
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (11 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 13/40] syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 15/40] compat: convert fs compat to use COMPAT_SYSCALL_DEFINE#N() macros Ian Munsie
                   ` (24 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Rusty Russell, KOSAKI Motohiro, Tejun Heo

From: Jason Baron <jbaron@redhat.com>

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 <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/compat.c |  106 ++++++++++++++++++++++++++----------------------------
 1 files changed, 51 insertions(+), 55 deletions(-)

diff --git a/kernel/compat.c b/kernel/compat.c
index 5adab05..7ab99e1 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -52,8 +52,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;
@@ -69,8 +69,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;
@@ -124,8 +124,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;
@@ -178,8 +178,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;
@@ -190,9 +190,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;
@@ -216,7 +216,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;
@@ -240,7 +240,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;
@@ -254,8 +254,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;
@@ -275,8 +275,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;
@@ -302,8 +302,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;
@@ -329,8 +329,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;
@@ -378,7 +378,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;
@@ -397,9 +397,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);
@@ -426,9 +425,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;
@@ -470,9 +469,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;
@@ -490,8 +489,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;
@@ -813,10 +812,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;
@@ -880,9 +878,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;
 
@@ -895,7 +892,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;
@@ -911,7 +908,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;
@@ -932,7 +929,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;
@@ -959,7 +956,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;
@@ -1019,11 +1016,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;
@@ -1039,10 +1036,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;
@@ -1090,8 +1087,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.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 15/40] compat: convert fs compat to use COMPAT_SYSCALL_DEFINE#N() macros
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (12 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 14/40] compat: convert to use COMPAT_SYSCALL_DEFINE#N() Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 16/40] tags: recognize compat syscalls Ian Munsie
                   ` (23 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Alexander Viro, Andrew Morton, Jeff Moyer,
	David Howells, Oleg Nesterov, linux-fsdevel

From: Jason Baron <jbaron@redhat.com>

convert the fs/compat.c file to use the COMPAT_SYSCALL_DEFINE#N() macros to tie
them into the generic compat layer.

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 fs/compat.c |  147 +++++++++++++++++++++++++++++------------------------------
 1 files changed, 72 insertions(+), 75 deletions(-)

diff --git a/fs/compat.c b/fs/compat.c
index 6490d21..df0b502 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -76,7 +76,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];
 
@@ -90,7 +90,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];
 
@@ -105,7 +105,7 @@ asmlinkage long compat_sys_utimensat(unsigned int dfd, char __user *filename, st
 	return 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];
 
@@ -124,7 +124,7 @@ asmlinkage long compat_sys_futimesat(unsigned int dfd, char __user *filename, st
 	return 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);
 }
@@ -168,8 +168,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;
@@ -180,8 +180,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;
@@ -193,8 +193,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;
@@ -206,8 +206,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);
@@ -258,7 +258,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;
@@ -274,7 +274,7 @@ asmlinkage long compat_sys_statfs(const char __user *pathname, struct compat_sta
 	return 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;
@@ -323,7 +323,7 @@ static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstat
 	return 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;
@@ -342,7 +342,7 @@ asmlinkage long compat_sys_statfs64(const char __user *pathname, compat_size_t s
 	return 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;
@@ -368,7 +368,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;
@@ -443,8 +443,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;
@@ -512,16 +512,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;
@@ -540,12 +539,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;
@@ -658,8 +656,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;
@@ -836,9 +833,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;
@@ -937,8 +934,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;
@@ -1017,8 +1015,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;
@@ -1105,8 +1104,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;
@@ -1316,9 +1316,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;
@@ -1340,8 +1339,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);
 }
@@ -1350,8 +1348,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);
 }
@@ -1793,9 +1790,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;
@@ -1888,9 +1885,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;
@@ -1907,9 +1904,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;
@@ -2137,9 +2134,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;
@@ -2215,11 +2212,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;
@@ -2264,9 +2261,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;
@@ -2284,9 +2281,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);
 }
@@ -2294,9 +2291,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;
@@ -2315,8 +2312,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;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 16/40] tags: recognize compat syscalls
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (13 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 15/40] compat: convert fs compat to use COMPAT_SYSCALL_DEFINE#N() macros Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-24 12:02   ` Michal Marek
  2010-06-23 10:02 ` [PATCH 17/40] tracing: make a "compat_syscalls" tracing subsys Ian Munsie
                   ` (22 subsequent siblings)
  37 siblings, 1 reply; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Michal Marek, WANG Cong, John Kacur, Andrew Morton,
	Stefani Seibold

From: Jason Baron <jbaron@redhat.com>

make tags.sh recognize the new syscall macros:

COMPAT_SYSCALL_DEFINE#N()
ARCH_COMPAT_SYSCALL_DEFINE#N()

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 scripts/tags.sh |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/tags.sh b/scripts/tags.sh
index 8509bb5..1c015eb 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -125,7 +125,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              \
@@ -145,7 +147,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/'
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 17/40] tracing: make a "compat_syscalls" tracing subsys
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (14 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 16/40] tags: recognize compat syscalls Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:02 ` [PATCH 18/40] compat_syscalls: introduce CONFIG_COMPAT_FTRACE_SYSCALLS Ian Munsie
                   ` (21 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar, Masami Hiramatsu

From: Jason Baron <jbaron@redhat.com>

Create a new "compat_syscalls" subsys for tracing

Signed-off-by: Jason Baron <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h      |   40 +++++++++++++++++++++-------------------
 kernel/trace/trace_syscalls.c |   16 ++++++++++++++++
 2 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a7d1114..e115569 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -120,10 +120,12 @@ struct perf_event_attr;
 
 extern struct ftrace_event_class event_class_syscall_enter;
 extern struct ftrace_event_class event_class_syscall_exit;
+extern struct ftrace_event_class event_class_compat_syscall_enter;
+extern struct ftrace_event_class event_class_compat_syscall_exit;
 extern struct trace_event_functions enter_syscall_print_funcs;
 extern struct trace_event_functions exit_syscall_print_funcs;
 
-#define SYSCALL_TRACE_ENTER_EVENT(sname)				\
+#define SYSCALL_TRACE_ENTER_EVENT(sname, event_class)			\
 	static struct syscall_metadata __syscall_meta_##sname;		\
 	static struct ftrace_event_call					\
 	__attribute__((__aligned__(4))) event_enter_##sname;		\
@@ -132,12 +134,12 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("_ftrace_events")))			\
 	  event_enter_##sname = {					\
 		.name                   = "enter_"#sname,		\
-		.class			= &event_class_syscall_enter,	\
+		.class			= &event_class_##event_class##_enter,\
 		.event.funcs            = &enter_syscall_print_funcs,	\
 		.data			= (void *)&__syscall_meta_##sname,\
 	}
 
-#define SYSCALL_TRACE_EXIT_EVENT(sname)					\
+#define SYSCALL_TRACE_EXIT_EVENT(sname, event_class)			\
 	static struct syscall_metadata __syscall_meta_##sname;		\
 	static struct ftrace_event_call					\
 	__attribute__((__aligned__(4))) event_exit_##sname;		\
@@ -146,14 +148,14 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __attribute__((section("_ftrace_events")))			\
 	  event_exit_##sname = {					\
 		.name                   = "exit_"#sname,		\
-		.class			= &event_class_syscall_exit,	\
+		.class			= &event_class_##event_class##_exit,\
 		.event.funcs		= &exit_syscall_print_funcs,	\
 		.data			= (void *)&__syscall_meta_##sname,\
 	}
 
-#define SYSCALL_METADATA(rname, sname, nb)			\
-	SYSCALL_TRACE_ENTER_EVENT(sname);			\
-	SYSCALL_TRACE_EXIT_EVENT(sname);			\
+#define SYSCALL_METADATA(rname, sname, nb, event_class)		\
+	SYSCALL_TRACE_ENTER_EVENT(sname, event_class);		\
+	SYSCALL_TRACE_EXIT_EVENT(sname, event_class);		\
 	static struct syscall_metadata __used			\
 	  __attribute__((__aligned__(4)))			\
 	  __attribute__((section("__syscalls_metadata")))	\
@@ -174,8 +176,8 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	};
 
 #define SYSCALL_DEFINE0(sname)					\
-	SYSCALL_TRACE_ENTER_EVENT(sys_##sname);			\
-	SYSCALL_TRACE_EXIT_EVENT(sys_##sname);			\
+	SYSCALL_TRACE_ENTER_EVENT(sys_##sname, syscall);	\
+	SYSCALL_TRACE_EXIT_EVENT(sys_##sname, syscall);		\
 	static struct syscall_metadata __used			\
 	  __attribute__((__aligned__(4)))			\
 	  __attribute__((section("__syscalls_metadata")))	\
@@ -221,17 +223,17 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #define COMPAT_SYSCALL_DEFINE6(name, ...) COMPAT_SYSCALL_DEFINEx(6, compat_sys_##name, name, __VA_ARGS__)
 
 #ifdef CONFIG_FTRACE_SYSCALLS
-#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)		\
-	static const char *types_compat_sys_##sname[] = {	\
-		__SC_STR_TDECL##x(__VA_ARGS__)			\
-	};							\
-	static const char *args_compat_sys_##sname[] = {	\
-		__SC_STR_ADECL##x(__VA_ARGS__)			\
-	};							\
-	SYSCALL_METADATA(syscall, compat_sys_##sname, x);	\
+#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)			\
+	static const char *types_compat_sys_##sname[] = {		\
+		__SC_STR_TDECL##x(__VA_ARGS__)				\
+	};								\
+	static const char *args_compat_sys_##sname[] = {		\
+		__SC_STR_ADECL##x(__VA_ARGS__)				\
+	};								\
+	SYSCALL_METADATA(syscall, compat_sys_##sname, x, compat_syscall);\
 	asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))
 #else
-#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)		\
+#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)			\
 	asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))
 #endif
 
@@ -259,7 +261,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	static const char *args_sys##sname[] = {		\
 		__SC_STR_ADECL##x(__VA_ARGS__)			\
 	};							\
-	SYSCALL_METADATA(sys##sname, sys##sname, x);		\
+	SYSCALL_METADATA(sys##sname, sys##sname, x, syscall);	\
 	__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
 #else
 #define SYSCALL_DEFINEx(x, sname, ...)				\
diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index d910cba..ff6cd7a 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -62,6 +62,22 @@ struct ftrace_event_class event_class_syscall_exit = {
 	.raw_init		= init_syscall_trace,
 };
 
+struct ftrace_event_class event_class_compat_syscall_enter = {
+	.system			= "compat_syscalls",
+	.reg			= syscall_enter_register,
+	.define_fields		= syscall_enter_define_fields,
+	.get_fields		= syscall_get_enter_fields,
+	.raw_init		= init_syscall_trace,
+};
+
+struct ftrace_event_class event_class_compat_syscall_exit = {
+	.system			= "compat_syscalls",
+	.reg			= syscall_exit_register,
+	.define_fields		= syscall_exit_define_fields,
+	.get_fields		= syscall_get_exit_fields,
+	.raw_init		= init_syscall_trace,
+};
+
 extern unsigned long __start_syscalls_metadata[];
 extern unsigned long __stop_syscalls_metadata[];
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 18/40] compat_syscalls: introduce CONFIG_COMPAT_FTRACE_SYSCALLS
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (15 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 17/40] tracing: make a "compat_syscalls" tracing subsys Ian Munsie
@ 2010-06-23 10:02 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 19/40] trace syscalls: Remove redundant syscall_nr checks Ian Munsie
                   ` (20 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:02 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar, Robert Richter, Masami Hiramatsu,
	Heiko Carstens, Thomas Gleixner, H. Peter Anvin, x86,
	Andrew Morton, Roland McGrath, David S. Miller

From: Jason Baron <jbaron@redhat.com>

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 <jbaron@redhat.com>
Signed-off-by: Ian Munsie <imunsie@au1.ibm.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 4877a8c..056f81f 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -158,4 +158,11 @@ config HAVE_PERF_EVENTS_NMI
 	  subsystem.  Also has support for calculating CPU cycle events
 	  to determine how many clock cycles in a given period.
 
+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 3069a6d..2a2d65c 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 e115569..55a9f2b 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -222,7 +222,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #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 ff6cd7a..6acba20 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -519,7 +519,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.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 19/40] trace syscalls: Remove redundant syscall_nr checks
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (16 preceding siblings ...)
  2010-06-23 10:02 ` [PATCH 18/40] compat_syscalls: introduce CONFIG_COMPAT_FTRACE_SYSCALLS Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 20/40] trace syscalls: Considder compat_syscall_nr when verifying syscall_nr Ian Munsie
                   ` (19 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Masami Hiramatsu

From: Ian Munsie <imunsie@au1.ibm.com>

With the ftrace events now checking if the syscall_nr is valid upon
initialisation, there is no need to verify it when registering and
unregistering the events, so remove the check.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |   18 ------------------
 1 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 6acba20..9010405 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -391,11 +391,7 @@ void ftrace_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
 int reg_event_syscall_enter(struct ftrace_event_call *call)
 {
 	int ret = 0;
-	int num;
 
-	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
-		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_enter)
 		ret = register_trace_sys_enter(ftrace_syscall_enter, NULL);
@@ -409,11 +405,6 @@ int reg_event_syscall_enter(struct ftrace_event_call *call)
 
 void unreg_event_syscall_enter(struct ftrace_event_call *call)
 {
-	int num;
-
-	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
-		return;
 	mutex_lock(&syscall_trace_lock);
 	sys_refcount_enter--;
 	((struct syscall_metadata *)call->data)->ftrace_enter = 0;
@@ -425,11 +416,7 @@ void unreg_event_syscall_enter(struct ftrace_event_call *call)
 int reg_event_syscall_exit(struct ftrace_event_call *call)
 {
 	int ret = 0;
-	int num;
 
-	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
-		return -ENOSYS;
 	mutex_lock(&syscall_trace_lock);
 	if (!sys_refcount_exit)
 		ret = register_trace_sys_exit(ftrace_syscall_exit, NULL);
@@ -443,11 +430,6 @@ int reg_event_syscall_exit(struct ftrace_event_call *call)
 
 void unreg_event_syscall_exit(struct ftrace_event_call *call)
 {
-	int num;
-
-	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls)
-		return;
 	mutex_lock(&syscall_trace_lock);
 	sys_refcount_exit--;
 	((struct syscall_metadata *)call->data)->ftrace_exit = 0;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 20/40] trace syscalls: Considder compat_syscall_nr when verifying syscall_nr
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (17 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 19/40] trace syscalls: Remove redundant syscall_nr checks Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 21/40] trace syscalls, PPC: Add ftrace compat syscall support for PPC64 Ian Munsie
                   ` (18 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Masami Hiramatsu

From: Ian Munsie <imunsie@au1.ibm.com>

With the new compat syscall tracing, either syscall_nr or
compat_syscall_nr may be set, so test both before assuming that the
initialisation failed.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 9010405..264441e 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -441,10 +441,12 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
 int init_syscall_trace(struct ftrace_event_call *call)
 {
 	int id;
-	int num;
+	int num, compat_num;
 
 	num = ((struct syscall_metadata *)call->data)->syscall_nr;
-	if (num < 0 || num >= NR_syscalls) {
+	compat_num = ((struct syscall_metadata *)call->data)->compat_syscall_nr;
+	if ((       num < 0 ||        num >= NR_syscalls) &&
+	    (compat_num < 0 || compat_num >= NR_syscalls)) {
 		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
 				((struct syscall_metadata *)call->data)->name);
 		return -ENOSYS;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 21/40] trace syscalls, PPC: Add ftrace compat syscall support for PPC64
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (18 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 20/40] trace syscalls: Considder compat_syscall_nr when verifying syscall_nr Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 22/40] trace syscalls, PPC: Convert syscalls to SYSCALL_DEFINE Ian Munsie
                   ` (17 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, FUJITA Tomonori, Grant Likely, Andrew Morton,
	Anton Blanchard, Christoph Hellwig, Russell King, H. Peter Anvin

From: Ian Munsie <imunsie@au1.ibm.com>

This patch adds the necessary infrastructure to trace 32bit compat
syscalls on PowerPC64.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/Kconfig              |    1 +
 arch/powerpc/include/asm/unistd.h |    4 ++++
 arch/powerpc/kernel/ftrace.c      |    7 +++++++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 0d5c28d..a724c93 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -142,6 +142,7 @@ config PPC
 	select HAVE_PERF_EVENTS
 	select HAVE_REGS_AND_STACK_ACCESS_API
 	select HAVE_SYSCALL_TRACEPOINTS
+	select HAVE_COMPAT_FTRACE_SYSCALLS if PPC64
 
 config EARLY_PRINTK
 	bool
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index f0a1026..f584b71 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -353,6 +353,10 @@
 #define __NR__exit __NR_exit
 #define NR_syscalls	__NR_syscalls
 
+#ifdef CONFIG_PPC64
+#define NR_syscalls_compat NR_syscalls
+#endif
+
 #ifndef __ASSEMBLY__
 
 #include <linux/types.h>
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index f5fadbb..dddbc33 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -619,3 +619,10 @@ inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
 	return (!strcmp(sym + 4, name + 3));
 }
 #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 */
+
+#ifdef CONFIG_COMPAT_FTRACE_SYSCALLS
+unsigned long __init arch_compat_syscall_addr(int nr)
+{
+	return sys_call_table[nr*2+1];
+}
+#endif
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 22/40] trace syscalls, PPC: Convert syscalls to SYSCALL_DEFINE
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (19 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 21/40] trace syscalls, PPC: Add ftrace compat syscall support for PPC64 Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 23/40] trace syscalls, PPC: Convert ppc32 compat syscalls to COMPAT_SYSCALL Ian Munsie
                   ` (16 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Andrew Morton, Christoph Hellwig, Jesper Nilsson,
	David Howells, Chase Douglas, Kumar Gala, Grant Likely,
	Stephen Rothwell, Tejun Heo, Michal Simek, Arnd Bergmann,
	cbe-oss-dev

From: Ian Munsie <imunsie@au1.ibm.com>

This patch alters the trivial syscalls (with a return type of long) in
PPC to use the SYSCALL_DEFINE family of macros to record their metadata
for ftrace syscalls.

It does not alter any non-trivial syscalls with different return types.

Several of the syscalls with a ppc_ prefix are renamed by this patch to
have a sys_ppc_ prefix so that they can be used easily with the
SYSCALL_DEFINE macro.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/include/asm/syscalls.h        |    2 +-
 arch/powerpc/include/asm/systbl.h          |    4 ++--
 arch/powerpc/kernel/pci_32.c               |    5 +++--
 arch/powerpc/kernel/pci_64.c               |    4 ++--
 arch/powerpc/kernel/syscalls.c             |    6 +++---
 arch/powerpc/platforms/cell/spu_syscalls.c |    6 +++---
 6 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index 4084e56..be37ef8 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -34,7 +34,7 @@ asmlinkage long sys_pipe2(int __user *fildes, int flags);
 asmlinkage long sys_rt_sigaction(int sig,
 		const struct sigaction __user *act,
 		struct sigaction __user *oact, size_t sigsetsize);
-asmlinkage long ppc64_personality(unsigned long personality);
+asmlinkage long sys_ppc64_personality(unsigned long personality);
 asmlinkage int ppc_rtas(struct rtas_args __user *uargs);
 asmlinkage time_t sys64_time(time_t __user * tloc);
 
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index a5ee345..dd8494a 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -139,7 +139,7 @@ COMPAT_SYS_SPU(getpgid)
 SYSCALL_SPU(fchdir)
 SYSCALL_SPU(bdflush)
 COMPAT_SYS(sysfs)
-SYSX_SPU(ppc64_personality,ppc64_personality,sys_personality)
+SYSX_SPU(sys_ppc64_personality,sys_ppc64_personality,sys_personality)
 SYSCALL(ni_syscall)
 SYSCALL_SPU(setfsuid)
 SYSCALL_SPU(setfsgid)
@@ -257,7 +257,7 @@ COMPAT_SYS_SPU(tgkill)
 COMPAT_SYS_SPU(utimes)
 COMPAT_SYS_SPU(statfs64)
 COMPAT_SYS_SPU(fstatfs64)
-SYSX(sys_ni_syscall, ppc_fadvise64_64, ppc_fadvise64_64)
+SYSX(sys_ni_syscall, sys_ppc_fadvise64_64, sys_ppc_fadvise64_64)
 PPC_SYS_SPU(rtas)
 OLDSYS(debug_setcontext)
 SYSCALL(ni_syscall)
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index e7db5b4..fb2391a 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -15,6 +15,7 @@
 #include <linux/list.h>
 #include <linux/of.h>
 #include <linux/slab.h>
+#include <linux/syscalls.h>
 
 #include <asm/processor.h>
 #include <asm/io.h>
@@ -423,8 +424,8 @@ pci_bus_to_hose(int bus)
  * root bridge.
  * Note that the returned IO or memory base is a physical address
  */
-
-long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn)
+SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
+		unsigned long, devfn)
 {
 	struct pci_controller* hose;
 	long result = -EOPNOTSUPP;
diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c
index d43fc65..1b1b846 100644
--- a/arch/powerpc/kernel/pci_64.c
+++ b/arch/powerpc/kernel/pci_64.c
@@ -211,8 +211,8 @@ void __devinit pcibios_setup_phb_io_space(struct pci_controller *hose)
 #define IOBASE_ISA_IO		3
 #define IOBASE_ISA_MEM		4
 
-long sys_pciconfig_iobase(long which, unsigned long in_bus,
-			  unsigned long in_devfn)
+SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, in_bus,
+			  unsigned long, in_devfn)
 {
 	struct pci_controller* hose;
 	struct list_head *ln;
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index f2496f2..f3bce3a 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -102,7 +102,7 @@ ppc_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, s
 #endif
 
 #ifdef CONFIG_PPC64
-long ppc64_personality(unsigned long personality)
+SYSCALL_DEFINE1(ppc64_personality, unsigned long, personality)
 {
 	long ret;
 
@@ -116,8 +116,8 @@ long ppc64_personality(unsigned long personality)
 }
 #endif
 
-long ppc_fadvise64_64(int fd, int advice, u32 offset_high, u32 offset_low,
-		      u32 len_high, u32 len_low)
+SYSCALL_DEFINE6(ppc_fadvise64_64, int, fd, int, advice, u32, offset_high,
+		u32, offset_low, u32, len_high, u32, len_low)
 {
 	return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low,
 			     (u64)len_high << 32 | len_low, advice);
diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c
index 75530d9..68ce26e 100644
--- a/arch/powerpc/platforms/cell/spu_syscalls.c
+++ b/arch/powerpc/platforms/cell/spu_syscalls.c
@@ -65,8 +65,8 @@ static inline void spufs_calls_put(struct spufs_calls *calls) { }
 
 #endif /* CONFIG_SPU_FS_MODULE */
 
-asmlinkage long sys_spu_create(const char __user *name,
-		unsigned int flags, mode_t mode, int neighbor_fd)
+SYSCALL_DEFINE4(spu_create, const char __user *, name,
+		unsigned int, flags, mode_t, mode, int, neighbor_fd)
 {
 	long ret;
 	struct file *neighbor;
@@ -91,7 +91,7 @@ asmlinkage long sys_spu_create(const char __user *name,
 	return ret;
 }
 
-asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus)
+SYSCALL_DEFINE3(spu_run, int, fd, __u32 __user *, unpc, __u32 __user *, ustatus)
 {
 	long ret;
 	struct file *filp;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 23/40] trace syscalls, PPC: Convert ppc32 compat syscalls to COMPAT_SYSCALL
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (20 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 22/40] trace syscalls, PPC: Convert syscalls to SYSCALL_DEFINE Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 24/40] trace syscalls, PPC: Convert more " Ian Munsie
                   ` (15 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Andrew Morton, Christoph Hellwig, Chase Douglas,
	Eric W. Biederman, Alexey Dobriyan

From: Ian Munsie <imunsie@au1.ibm.com>

Convert all the trivial 32bit PowerPC compat syscalls to use the
COMPAT_SYSCALL_DEFINE family of macros. This commit only converts the
syscalls with a return type of long for safety, syscalls with differing
return types will be dealt with in a separate commit.

This patch also alters the prefix of ppc32_select to sys32_select to fit
in with the ARCH_COMPAT_SYSCALL_DEFINE macro without conflicting with
the native sys_select syscall.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/include/asm/systbl.h |    2 +-
 arch/powerpc/kernel/sys_ppc32.c   |  103 +++++++++++++++++++++---------------
 2 files changed, 61 insertions(+), 44 deletions(-)

diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index dd8494a..228eecb 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -145,7 +145,7 @@ SYSCALL_SPU(setfsuid)
 SYSCALL_SPU(setfsgid)
 SYSCALL_SPU(llseek)
 COMPAT_SYS_SPU(getdents)
-SYSX_SPU(sys_select,ppc32_select,sys_select)
+SYSX_SPU(sys_select,sys32_select,sys_select)
 SYSCALL_SPU(flock)
 SYSCALL_SPU(msync)
 COMPAT_SYS_SPU(readv)
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index 19471a1..ab45dde 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -53,9 +53,9 @@
 #include <asm/syscalls.h>
 
 
-asmlinkage long ppc32_select(u32 n, compat_ulong_t __user *inp,
-		compat_ulong_t __user *outp, compat_ulong_t __user *exp,
-		compat_uptr_t tvp_x)
+ARCH_COMPAT_SYSCALL_DEFINE5(select, u32, n, compat_ulong_t __user *, inp,
+		compat_ulong_t __user *, outp, compat_ulong_t __user *, exp,
+		compat_uptr_t, tvp_x)
 {
 	/* sign extend n */
 	return compat_sys_select((int)n, inp, outp, exp, compat_ptr(tvp_x));
@@ -66,7 +66,8 @@ asmlinkage long ppc32_select(u32 n, compat_ulong_t __user *inp,
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sysfs(u32 option, u32 arg1, u32 arg2)
+COMPAT_SYSCALL_DEFINE3(sysfs, u32, option, u32, arg1,
+		u32, arg2)
 {
 	return sys_sysfs((int)option, arg1, arg2);
 }
@@ -143,7 +144,8 @@ long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t pt
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sendfile(u32 out_fd, u32 in_fd, compat_off_t __user * offset, u32 count)
+COMPAT_SYSCALL_DEFINE4(sendfile, u32, out_fd, u32, in_fd,
+		compat_off_t __user *, offset, u32, count)
 {
 	mm_segment_t old_fs = get_fs();
 	int ret;
@@ -214,7 +216,8 @@ out:
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_prctl(u32 option, u32 arg2, u32 arg3, u32 arg4, u32 arg5)
+COMPAT_SYSCALL_DEFINE5(prctl, u32, option, u32, arg2,
+		u32, arg3, u32, arg4, u32, arg5)
 {
 	return sys_prctl((int)option,
 			 (unsigned long) arg2,
@@ -228,7 +231,8 @@ asmlinkage long compat_sys_prctl(u32 option, u32 arg2, u32 arg3, u32 arg4, u32 a
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sched_rr_get_interval(u32 pid, struct compat_timespec __user *interval)
+COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval, u32, pid,
+		struct compat_timespec __user *, interval)
 {
 	struct timespec t;
 	int ret;
@@ -248,7 +252,8 @@ asmlinkage long compat_sys_sched_rr_get_interval(u32 pid, struct compat_timespec
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_access(const char __user * filename, u32 mode)
+COMPAT_SYSCALL_DEFINE2(access, const char __user *, filename,
+		u32, mode)
 {
 	return sys_access(filename, (int)mode);
 }
@@ -259,7 +264,8 @@ asmlinkage long compat_sys_access(const char __user * filename, u32 mode)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_creat(const char __user * pathname, u32 mode)
+COMPAT_SYSCALL_DEFINE2(creat, const char __user *, pathname,
+		u32, mode)
 {
 	return sys_creat(pathname, (int)mode);
 }
@@ -270,7 +276,8 @@ asmlinkage long compat_sys_creat(const char __user * pathname, u32 mode)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_waitpid(u32 pid, unsigned int __user * stat_addr, u32 options)
+COMPAT_SYSCALL_DEFINE3(waitpid, u32, pid,
+		unsigned int __user *, stat_addr, u32, options)
 {
 	return sys_waitpid((int)pid, stat_addr, (int)options);
 }
@@ -281,7 +288,8 @@ asmlinkage long compat_sys_waitpid(u32 pid, unsigned int __user * stat_addr, u32
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_getgroups(u32 gidsetsize, gid_t __user *grouplist)
+COMPAT_SYSCALL_DEFINE2(getgroups, u32, gidsetsize,
+		gid_t __user *, grouplist)
 {
 	return sys_getgroups((int)gidsetsize, grouplist);
 }
@@ -292,7 +300,7 @@ asmlinkage long compat_sys_getgroups(u32 gidsetsize, gid_t __user *grouplist)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_getpgid(u32 pid)
+COMPAT_SYSCALL_DEFINE1(getpgid, u32, pid)
 {
 	return sys_getpgid((int)pid);
 }
@@ -304,7 +312,7 @@ asmlinkage long compat_sys_getpgid(u32 pid)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_getsid(u32 pid)
+COMPAT_SYSCALL_DEFINE1(getsid, u32, pid)
 {
 	return sys_getsid((int)pid);
 }
@@ -315,7 +323,7 @@ asmlinkage long compat_sys_getsid(u32 pid)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_kill(u32 pid, u32 sig)
+COMPAT_SYSCALL_DEFINE2(kill, u32, pid, u32, sig)
 {
 	return sys_kill((int)pid, (int)sig);
 }
@@ -326,7 +334,8 @@ asmlinkage long compat_sys_kill(u32 pid, u32 sig)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_mkdir(const char __user * pathname, u32 mode)
+COMPAT_SYSCALL_DEFINE2(mkdir, const char __user *, pathname,
+		u32, mode)
 {
 	return sys_mkdir(pathname, (int)mode);
 }
@@ -360,7 +369,8 @@ long compat_sys_ftruncate(int fd, u32 length)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_readlink(const char __user * path, char __user * buf, u32 bufsiz)
+COMPAT_SYSCALL_DEFINE3(readlink, const char __user *, path,
+		char __user *, buf, u32, bufsiz)
 {
 	return sys_readlink(path, buf, (int)bufsiz);
 }
@@ -370,7 +380,7 @@ asmlinkage long compat_sys_readlink(const char __user * path, char __user * buf,
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sched_get_priority_max(u32 policy)
+COMPAT_SYSCALL_DEFINE1(sched_get_priority_max, u32, policy)
 {
 	return sys_sched_get_priority_max((int)policy);
 }
@@ -381,7 +391,7 @@ asmlinkage long compat_sys_sched_get_priority_max(u32 policy)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sched_get_priority_min(u32 policy)
+COMPAT_SYSCALL_DEFINE1(sched_get_priority_min, u32, policy)
 {
 	return sys_sched_get_priority_min((int)policy);
 }
@@ -392,7 +402,8 @@ asmlinkage long compat_sys_sched_get_priority_min(u32 policy)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sched_getparam(u32 pid, struct sched_param __user *param)
+COMPAT_SYSCALL_DEFINE2(sched_getparam, u32, pid,
+		struct sched_param __user *, param)
 {
 	return sys_sched_getparam((int)pid, param);
 }
@@ -403,7 +414,7 @@ asmlinkage long compat_sys_sched_getparam(u32 pid, struct sched_param __user *pa
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sched_getscheduler(u32 pid)
+COMPAT_SYSCALL_DEFINE1(sched_getscheduler, u32, pid)
 {
 	return sys_sched_getscheduler((int)pid);
 }
@@ -414,7 +425,8 @@ asmlinkage long compat_sys_sched_getscheduler(u32 pid)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sched_setparam(u32 pid, struct sched_param __user *param)
+COMPAT_SYSCALL_DEFINE2(sched_setparam, u32, pid,
+		struct sched_param __user *, param)
 {
 	return sys_sched_setparam((int)pid, param);
 }
@@ -425,7 +437,8 @@ asmlinkage long compat_sys_sched_setparam(u32 pid, struct sched_param __user *pa
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_sched_setscheduler(u32 pid, u32 policy, struct sched_param __user *param)
+COMPAT_SYSCALL_DEFINE3(sched_setscheduler, u32, pid,
+		u32, policy, struct sched_param __user *, param)
 {
 	return sys_sched_setscheduler((int)pid, (int)policy, param);
 }
@@ -436,7 +449,8 @@ asmlinkage long compat_sys_sched_setscheduler(u32 pid, u32 policy, struct sched_
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_setdomainname(char __user *name, u32 len)
+COMPAT_SYSCALL_DEFINE2(setdomainname, char __user *, name,
+		u32, len)
 {
 	return sys_setdomainname(name, (int)len);
 }
@@ -447,13 +461,15 @@ asmlinkage long compat_sys_setdomainname(char __user *name, u32 len)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_setgroups(u32 gidsetsize, gid_t __user *grouplist)
+COMPAT_SYSCALL_DEFINE2(setgroups, u32, gidsetsize,
+		gid_t __user *, grouplist)
 {
 	return sys_setgroups((int)gidsetsize, grouplist);
 }
 
 
-asmlinkage long compat_sys_sethostname(char __user *name, u32 len)
+COMPAT_SYSCALL_DEFINE2(sethostname, char __user *, name,
+		u32, len)
 {
 	/* sign extend len */
 	return sys_sethostname(name, (int)len);
@@ -465,7 +481,7 @@ asmlinkage long compat_sys_sethostname(char __user *name, u32 len)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_setpgid(u32 pid, u32 pgid)
+COMPAT_SYSCALL_DEFINE2(setpgid, u32, pid, u32, pgid)
 {
 	return sys_setpgid((int)pid, (int)pgid);
 }
@@ -499,12 +515,13 @@ long compat_sys_ioprio_set(u32 which, u32 who, u32 ioprio)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_ssetmask(u32 newmask)
+COMPAT_SYSCALL_DEFINE1(ssetmask, u32, newmask)
 {
 	return sys_ssetmask((int) newmask);
 }
 
-asmlinkage long compat_sys_syslog(u32 type, char __user * buf, u32 len)
+COMPAT_SYSCALL_DEFINE3(syslog, u32, type, char __user *, buf,
+		u32, len)
 {
 	/* sign extend len */
 	return sys_syslog(type, buf, (int)len);
@@ -516,7 +533,7 @@ asmlinkage long compat_sys_syslog(u32 type, char __user * buf, u32 len)
  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode)
  * and the register representation of a signed int (msr in 64-bit mode) is performed.
  */
-asmlinkage long compat_sys_umask(u32 mask)
+COMPAT_SYSCALL_DEFINE1(umask, u32, mask)
 {
 	return sys_umask((int)mask);
 }
@@ -563,8 +580,8 @@ asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
 	return sys_truncate(path, (high << 32) | low);
 }
 
-asmlinkage long compat_sys_fallocate(int fd, int mode, u32 offhi, u32 offlo,
-				     u32 lenhi, u32 lenlo)
+COMPAT_SYSCALL_DEFINE6(fallocate, int, fd, int, mode,
+		u32, offhi, u32, offlo, u32, lenhi, u32, lenlo)
 {
 	return sys_fallocate(fd, mode, ((loff_t)offhi << 32) | offlo,
 			     ((loff_t)lenhi << 32) | lenlo);
@@ -590,26 +607,26 @@ long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
 			     advice);
 }
 
-asmlinkage long compat_sys_add_key(const char __user *_type,
-			      const char __user *_description,
-			      const void __user *_payload,
-			      u32 plen,
-			      u32 ringid)
+COMPAT_SYSCALL_DEFINE5(add_key, const char __user *, _type,
+			      const char __user *, _description,
+			      const void __user *, _payload,
+			      u32, plen,
+			      u32, ringid)
 {
 	return sys_add_key(_type, _description, _payload, plen, ringid);
 }
 
-asmlinkage long compat_sys_request_key(const char __user *_type,
-				  const char __user *_description,
-				  const char __user *_callout_info,
-				  u32 destringid)
+COMPAT_SYSCALL_DEFINE4(request_key, const char __user *, _type,
+				  const char __user *, _description,
+				  const char __user *, _callout_info,
+				  u32, destringid)
 {
 	return sys_request_key(_type, _description, _callout_info, destringid);
 }
 
-asmlinkage long compat_sys_sync_file_range2(int fd, unsigned int flags,
-				   unsigned offset_hi, unsigned offset_lo,
-				   unsigned nbytes_hi, unsigned nbytes_lo)
+COMPAT_SYSCALL_DEFINE6(sync_file_range2, int, fd, unsigned int, flags,
+				   unsigned, offset_hi, unsigned, offset_lo,
+				   unsigned, nbytes_hi, unsigned, nbytes_lo)
 {
 	loff_t offset = ((loff_t)offset_hi << 32) | offset_lo;
 	loff_t nbytes = ((loff_t)nbytes_hi << 32) | nbytes_lo;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 24/40] trace syscalls, PPC: Convert more ppc32 compat syscalls to COMPAT_SYSCALL
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (21 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 23/40] trace syscalls, PPC: Convert ppc32 compat syscalls to COMPAT_SYSCALL Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 25/40] trace syscalls: Refactor syscall metadata creation Ian Munsie
                   ` (14 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Dave Kleikamp, David Gibson, Chase Douglas,
	Eric W. Biederman, Alexey Dobriyan

From: Ian Munsie <imunsie@au1.ibm.com>

Convert the remaining trivial 32bit compat syscalls to use the
COMPAT_SYSCALL_DEFINE family of macros.

The syscalls addressed by this commit were lacking the asmlinkage flag,
which will be added by the COMPAT_SYSCALL_DEFINE macros. This should not
be an issue as asmlinkage has no effect on PowerPC.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/kernel/signal_32.c |   19 +++++++++++++------
 arch/powerpc/kernel/sys_ppc32.c |   20 ++++++++++----------
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 2666101..e65d311 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -595,8 +595,10 @@ static long restore_user_regs(struct pt_regs *regs,
 }
 
 #ifdef CONFIG_PPC64
-long compat_sys_rt_sigaction(int sig, const struct sigaction32 __user *act,
-		struct sigaction32 __user *oact, size_t sigsetsize)
+COMPAT_SYSCALL_DEFINE4(rt_sigaction, int, sig,
+		const struct sigaction32 __user *, act,
+		struct sigaction32 __user *, oact,
+		size_t, sigsetsize)
 {
 	struct k_sigaction new_ka, old_ka;
 	int ret;
@@ -632,8 +634,10 @@ long compat_sys_rt_sigaction(int sig, const struct sigaction32 __user *act,
  * of a signed int (msr in 32-bit mode) and the register representation
  * of a signed int (msr in 64-bit mode) is performed.
  */
-long compat_sys_rt_sigprocmask(u32 how, compat_sigset_t __user *set,
-		compat_sigset_t __user *oset, size_t sigsetsize)
+COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, u32, how,
+		compat_sigset_t __user *, set,
+		compat_sigset_t __user *, oset,
+		size_t, sigsetsize)
 {
 	sigset_t s;
 	sigset_t __user *up;
@@ -660,7 +664,9 @@ long compat_sys_rt_sigprocmask(u32 how, compat_sigset_t __user *set,
 	return 0;
 }
 
-long compat_sys_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize)
+COMPAT_SYSCALL_DEFINE2(rt_sigpending,
+		compat_sigset_t __user *, set,
+		compat_size_t, sigsetsize)
 {
 	sigset_t s;
 	int ret;
@@ -754,7 +760,8 @@ int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from)
  * (msr in 32-bit mode) and the register representation of a signed int
  * (msr in 64-bit mode) is performed.
  */
-long compat_sys_rt_sigqueueinfo(u32 pid, u32 sig, compat_siginfo_t __user *uinfo)
+COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo, u32, pid, u32, sig,
+		compat_siginfo_t __user *, uinfo)
 {
 	siginfo_t info;
 	int ret;
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index ab45dde..6fc8ba9 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -73,8 +73,8 @@ COMPAT_SYSCALL_DEFINE3(sysfs, u32, option, u32, arg1,
 }
 
 #ifdef CONFIG_SYSVIPC
-long compat_sys_ipc(u32 call, u32 first, u32 second, u32 third, compat_uptr_t ptr,
-	       u32 fifth)
+COMPAT_SYSCALL_DEFINE6(ipc, u32, call, u32, first, u32, second, u32, third,
+		compat_uptr_t, ptr, u32, fifth)
 {
 	int version;
 
@@ -340,7 +340,7 @@ COMPAT_SYSCALL_DEFINE2(mkdir, const char __user *, pathname,
 	return sys_mkdir(pathname, (int)mode);
 }
 
-long compat_sys_nice(u32 increment)
+COMPAT_SYSCALL_DEFINE1(nice, u32, increment)
 {
 	/* sign extend increment */
 	return sys_nice((int)increment);
@@ -352,13 +352,13 @@ off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin)
 	return sys_lseek(fd, (int)offset, origin);
 }
 
-long compat_sys_truncate(const char __user * path, u32 length)
+COMPAT_SYSCALL_DEFINE2(truncate, const char __user *, path, u32, length)
 {
 	/* sign extend length */
 	return sys_truncate(path, (int)length);
 }
 
-long compat_sys_ftruncate(int fd, u32 length)
+COMPAT_SYSCALL_DEFINE2(ftruncate, int, fd, u32, length)
 {
 	/* sign extend length */
 	return sys_ftruncate(fd, (int)length);
@@ -486,25 +486,25 @@ COMPAT_SYSCALL_DEFINE2(setpgid, u32, pid, u32, pgid)
 	return sys_setpgid((int)pid, (int)pgid);
 }
 
-long compat_sys_getpriority(u32 which, u32 who)
+COMPAT_SYSCALL_DEFINE2(getpriority, u32, which, u32, who)
 {
 	/* sign extend which and who */
 	return sys_getpriority((int)which, (int)who);
 }
 
-long compat_sys_setpriority(u32 which, u32 who, u32 niceval)
+COMPAT_SYSCALL_DEFINE3(setpriority, u32, which, u32, who, u32, niceval)
 {
 	/* sign extend which, who and niceval */
 	return sys_setpriority((int)which, (int)who, (int)niceval);
 }
 
-long compat_sys_ioprio_get(u32 which, u32 who)
+COMPAT_SYSCALL_DEFINE2(ioprio_get, u32, which, u32, who)
 {
 	/* sign extend which and who */
 	return sys_ioprio_get((int)which, (int)who);
 }
 
-long compat_sys_ioprio_set(u32 which, u32 who, u32 ioprio)
+COMPAT_SYSCALL_DEFINE3(ioprio_set, u32, which, u32, who, u32, ioprio)
 {
 	/* sign extend which, who and ioprio */
 	return sys_ioprio_set((int)which, (int)who, (int)ioprio);
@@ -546,7 +546,7 @@ unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
 	return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
 }
 
-long compat_sys_tgkill(u32 tgid, u32 pid, int sig)
+COMPAT_SYSCALL_DEFINE3(tgkill, u32, tgid, u32, pid, int, sig)
 {
 	/* sign extend tgid, pid */
 	return sys_tgkill((int)tgid, (int)pid, sig);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 25/40] trace syscalls: Refactor syscall metadata creation
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (22 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 24/40] trace syscalls, PPC: Convert more " Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 26/40] trace syscalls, PPC: Add PPC_REGS_SYSCALL_DEFINE macros Ian Munsie
                   ` (13 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar

From: Ian Munsie <imunsie@au1.ibm.com>

The syscall metadata creation macros are a bit convoluted with some
duplicated code - particularly the duplication in SYSCALL_DEFINE0 with
SYSCALL_METADATA and related macros.

As demonstrated by the compat syscalls, there may be needs to introduce
additional high level *_SYSCALL_DEFINE[0-6] macros with subtle
differences from the existing ones. This patch aims to make the macros
more atomic, move more of the complexity of the macros down, and remove
some duplicated code without changing existing functionality so that
defining new high level macros is easier.

In particular, certain system calls on PowerPC access the state of the
registers, through the use of some assembly that places the registers on
the stack in the place of the 7th argument to the function. These system
calls require specialised macros to record their metadata and this patch
greatly simplifies their implementation.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h |   77 ++++++++++++++++------------------------------
 1 files changed, 27 insertions(+), 50 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 55a9f2b..a608565 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -153,7 +153,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 		.data			= (void *)&__syscall_meta_##sname,\
 	}
 
-#define SYSCALL_METADATA(rname, sname, nb, event_class)		\
+#define SYSCALL_METADATA(rname, sname, nb, event_class, stypes, sargs)\
 	SYSCALL_TRACE_ENTER_EVENT(sname, event_class);		\
 	SYSCALL_TRACE_EXIT_EVENT(sname, event_class);		\
 	static struct syscall_metadata __used			\
@@ -162,9 +162,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	  __syscall_meta_##sname = {				\
 		.name 		= #rname,			\
 		.syscall_nr	= -1,	/* Filled in at boot */	\
+		.compat_syscall_nr = -1,/* Filled in at boot */	\
 		.nb_args 	= nb,				\
-		.types		= types_##sname,		\
-		.args		= args_##sname,			\
+		.types		= stypes,			\
+		.args		= sargs,			\
 		.ftrace_enter	= 0,				\
 		.ftrace_exit	= 0,				\
 		.perf_enter	= 0,				\
@@ -175,29 +176,22 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 		.exit_fields	= LIST_HEAD_INIT(__syscall_meta_##sname.exit_fields), \
 	};
 
-#define SYSCALL_DEFINE0(sname)					\
-	SYSCALL_TRACE_ENTER_EVENT(sys_##sname, syscall);	\
-	SYSCALL_TRACE_EXIT_EVENT(sys_##sname, syscall);		\
-	static struct syscall_metadata __used			\
-	  __attribute__((__aligned__(4)))			\
-	  __attribute__((section("__syscalls_metadata")))	\
-	  __syscall_meta_sys_##sname = {			\
-		.name 		= "sys_"#sname,			\
-		.syscall_nr	= -1,	/* Filled in at boot */	\
-		.nb_args 	= 0,				\
-		.ftrace_enter	= 0,				\
-		.ftrace_exit	= 0,				\
-		.perf_enter	= 0,				\
-		.perf_exit	= 0,				\
-		.enter_event	= &event_enter_sys_##sname,	\
-		.exit_event	= &event_exit_sys_##sname,	\
-		.enter_fields	= LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \
-		.exit_fields	= LIST_HEAD_INIT(__syscall_meta__##sname.exit_fields), \
+#define SYSCALL_METADATAx(rname, sname, nb, event_class, ...)	\
+	static const char *types_##sname[] = {			\
+		__SC_STR_TDECL##nb(__VA_ARGS__)			\
 	};							\
-	asmlinkage long sys_##sname(void)
-#else
-#define SYSCALL_DEFINE0(name)	   asmlinkage long sys_##name(void)
-#endif
+	static const char *args_##sname[] = {			\
+		__SC_STR_ADECL##nb(__VA_ARGS__)			\
+	};							\
+	SYSCALL_METADATA(rname, sname, nb, event_class, types_##sname, args_##sname)
+
+#define SYSCALL_METADATA0(rname, sname, event_class)			\
+	SYSCALL_METADATA(rname, sname, 0, event_class, NULL, NULL)
+
+#else /* !CONFIG_FTRACE_SYSCALLS */
+#define SYSCALL_METADATAx(...)
+#define SYSCALL_METADATA0(...)
+#endif /* CONFIG_FTRACE_SYSCALLS */
 
 #define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
 #define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
@@ -222,22 +216,12 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #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_COMPAT_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, compat_syscall);\
+	SYSCALL_METADATAx(syscall, compat_sys_##sname, x, compat_syscall, __VA_ARGS__);\
 	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
+#endif /* CONFIG_COMPAT */
+
 
 #ifdef CONFIG_PPC64
 #define SYSCALL_ALIAS(alias, name)					\
@@ -253,20 +237,13 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #endif
 #endif
 
-#ifdef CONFIG_FTRACE_SYSCALLS
-#define SYSCALL_DEFINEx(x, sname, ...)				\
-	static const char *types_sys##sname[] = {		\
-		__SC_STR_TDECL##x(__VA_ARGS__)			\
-	};							\
-	static const char *args_sys##sname[] = {		\
-		__SC_STR_ADECL##x(__VA_ARGS__)			\
-	};							\
-	SYSCALL_METADATA(sys##sname, sys##sname, x, syscall);	\
-	__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
-#else
 #define SYSCALL_DEFINEx(x, sname, ...)				\
+	SYSCALL_METADATAx(sys##sname, sys##sname, x, syscall, __VA_ARGS__);\
 	__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
-#endif
+
+#define SYSCALL_DEFINE0(name)					\
+	SYSCALL_METADATA0(sys_##name, name, syscall)		\
+	asmlinkage long sys_##name(void)
 
 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 26/40] trace syscalls, PPC: Add PPC_REGS_SYSCALL_DEFINE macros
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (23 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 25/40] trace syscalls: Refactor syscall metadata creation Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 27/40] trace syscalls: Add COMPAT_SYSCALL_DEFINE0 macro Ian Munsie
                   ` (12 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Andrew Morton, Christoph Hellwig, Jesper Nilsson,
	David Howells

From: Ian Munsie <imunsie@au1.ibm.com>

Certain system calls on PowerPC access to the registers through a 7th
parameter, which will not fit into the model of the existing
SYSCALL_DEFINE macros.

This patch a new class of macros to handle this situation, recording the
metadata required for ftrace syscalls but still using the correct syntax
to place the registers in the 7th parameter.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/include/asm/syscalls.h |   54 +++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index be37ef8..72badaa 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -5,12 +5,66 @@
 #include <linux/compiler.h>
 #include <linux/linkage.h>
 #include <linux/types.h>
+#include <linux/syscalls.h>
 #include <asm/signal.h>
 
 struct pt_regs;
 struct rtas_args;
 struct sigaction;
 
+#define __SC_DUMMY_ARGS0 unsigned long __dummy_arg_1, __SC_DUMMY_ARGS1
+#define __SC_DUMMY_ARGS1 unsigned long __dummy_arg_2, __SC_DUMMY_ARGS2
+#define __SC_DUMMY_ARGS2 unsigned long __dummy_arg_3, __SC_DUMMY_ARGS3
+#define __SC_DUMMY_ARGS3 unsigned long __dummy_arg_4, __SC_DUMMY_ARGS4
+#define __SC_DUMMY_ARGS4 unsigned long __dummy_arg_5, __SC_DUMMY_ARGS5
+#define __SC_DUMMY_ARGS5 unsigned long __dummy_arg_6, __SC_DUMMY_ARGS6
+#define __SC_DUMMY_ARGS6
+
+/* Native syscalls that require register access */
+#define PPC_REGS_SYSCALL_DEFINE1_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(1, ret, sys_##name, _##name, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE2_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(2, ret, sys_##name, _##name, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE3_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(3, ret, sys_##name, _##name, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE4_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(4, ret, sys_##name, _##name, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE5_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(5, ret, sys_##name, _##name, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE6_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(6, ret, sys_##name, _##name, regs, __VA_ARGS__)
+
+#ifdef CONFIG_COMPAT
+
+/* 32bit compat syscalls that require register access */
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE1_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_##name, name, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE2_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_##name, name, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE3_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_##name, name, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE4_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_##name, name, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE5_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_##name, name, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE6_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_##name, name, regs, __VA_ARGS__)
+
+#define PPC_REGS_COMPAT_SYSCALL_DEFINEx(x, ret, sysname, sname, regs,  ...)	\
+	SYSCALL_METADATAx(sysname, compat_sys_##sname, x, compat_syscall, __VA_ARGS__);\
+	__PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, __VA_ARGS__)
+
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(ret, name, regs)			\
+	SYSCALL_METADATA0(compat_sys_##name, name, syscall)			\
+	__PPC_REGS_SYSCALL_DEFINE0(ret, compat_sys_##name, regs)
+
+#endif /*CONFIG_COMPAT */
+
+#define PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, sname, regs, ...)		\
+	SYSCALL_METADATAx(sysname, sname, x, syscall, __VA_ARGS__);		\
+	__PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, __VA_ARGS__)
+
+#define PPC_REGS_SYSCALL_DEFINE0_RET(ret, name, regs)				\
+	SYSCALL_METADATA0(sys_##name, name, syscall)				\
+	__PPC_REGS_SYSCALL_DEFINE0(ret, sys_##name, regs)
+
+#define __PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, ...)			\
+	ret sysname(__SC_DECL##x(__VA_ARGS__),					\
+			__SC_DUMMY_ARGS##x					\
+			struct pt_regs *regs)
+
+#define __PPC_REGS_SYSCALL_DEFINE0(ret, sysname, regs)				\
+	ret sysname(__SC_DUMMY_ARGS0 struct pt_regs *regs)
+
+
 asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len,
 		unsigned long prot, unsigned long flags,
 		unsigned long fd, off_t offset);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 27/40] trace syscalls: Add COMPAT_SYSCALL_DEFINE0 macro
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (24 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 26/40] trace syscalls, PPC: Add PPC_REGS_SYSCALL_DEFINE macros Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 28/40] trace syscalls, PPC: Convert syscalls using regs to REGS_SYSCALL_DEFINE macros Ian Munsie
                   ` (11 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar

From: Ian Munsie <imunsie@au1.ibm.com>

This patchs adds the COMPAT_SYSCALL_DEFINE0 macros for compat syscalls
that do not take any arguments.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index a608565..1076ae8 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -220,6 +220,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	SYSCALL_METADATAx(syscall, compat_sys_##sname, x, compat_syscall, __VA_ARGS__);\
 	asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))
 
+#define COMPAT_SYSCALL_DEFINE0(name)					\
+	SYSCALL_METADATA0(compat_sys_##name, name, compat_syscall)	\
+	asmlinkage long compat_sys_##name()
+
 #endif /* CONFIG_COMPAT */
 
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 28/40] trace syscalls, PPC: Convert syscalls using regs to REGS_SYSCALL_DEFINE macros
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (25 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 27/40] trace syscalls: Add COMPAT_SYSCALL_DEFINE0 macro Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 29/40] trace syscalls, PPC: Convert ppc32_ syscalls to ARCH_COMPAT_SYSCALL_DEFINE Ian Munsie
                   ` (10 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Andrew Morton, Christoph Hellwig, Jesper Nilsson,
	David Howells, Dave Kleikamp, Kumar Gala, Ingo Molnar,
	Peter Zijlstra, David Gibson, Eric W. Biederman, Alexey Dobriyan,
	Chase Douglas

From: Ian Munsie <imunsie@au1.ibm.com>

This patch coverts a number of system calls on PowerPC to use the new
PPC_REGS_SYSCALL_DEFINE class of macros, to record their metadata but
still use the correct syntax to access the registers through the 7th
parameter.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/include/asm/syscalls.h |   10 ++++++----
 arch/powerpc/kernel/process.c       |   27 +++++++++++----------------
 arch/powerpc/kernel/signal.c        |    7 ++++---
 arch/powerpc/kernel/signal_32.c     |   11 +++++------
 arch/powerpc/kernel/signal_64.c     |   11 ++++-------
 arch/powerpc/kernel/sys_ppc32.c     |   11 ++++++-----
 6 files changed, 36 insertions(+), 41 deletions(-)

diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index 72badaa..531b45d 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -71,12 +71,14 @@ asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len,
 asmlinkage unsigned long sys_mmap2(unsigned long addr, size_t len,
 		unsigned long prot, unsigned long flags,
 		unsigned long fd, unsigned long pgoff);
-asmlinkage int sys_execve(unsigned long a0, unsigned long a1,
-		unsigned long a2, unsigned long a3, unsigned long a4,
-		unsigned long a5, struct pt_regs *regs);
+asmlinkage int sys_execve(char __user * ufilename,
+		char __user * __user * argv,
+		char __user * __user * envp,
+		unsigned long, unsigned long, unsigned long,
+		struct pt_regs *regs);
 asmlinkage int sys_clone(unsigned long clone_flags, unsigned long usp,
 		int __user *parent_tidp, void __user *child_threadptr,
-		int __user *child_tidp, int p6, struct pt_regs *regs);
+		int __user *child_tidp, unsigned long p6, struct pt_regs *regs);
 asmlinkage int sys_fork(unsigned long p1, unsigned long p2,
 		unsigned long p3, unsigned long p4, unsigned long p5,
 		unsigned long p6, struct pt_regs *regs);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 9b41ece..df08d05 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -950,10 +950,9 @@ int get_unalign_ctl(struct task_struct *tsk, unsigned long adr)
 
 #define TRUNC_PTR(x)	((typeof(x))(((unsigned long)(x)) & 0xffffffff))
 
-int sys_clone(unsigned long clone_flags, unsigned long usp,
-	      int __user *parent_tidp, void __user *child_threadptr,
-	      int __user *child_tidp, int p6,
-	      struct pt_regs *regs)
+PPC_REGS_SYSCALL_DEFINE5_RET(int, clone, regs, unsigned long, clone_flags, unsigned long, usp,
+	      int __user *, parent_tidp, void __user *, child_threadptr,
+	      int __user *, child_tidp)
 {
 	CHECK_FULL_REGS(regs);
 	if (usp == 0)
@@ -967,39 +966,35 @@ int sys_clone(unsigned long clone_flags, unsigned long usp,
  	return do_fork(clone_flags, usp, regs, 0, parent_tidp, child_tidp);
 }
 
-int sys_fork(unsigned long p1, unsigned long p2, unsigned long p3,
-	     unsigned long p4, unsigned long p5, unsigned long p6,
-	     struct pt_regs *regs)
+PPC_REGS_SYSCALL_DEFINE0_RET(int, fork, regs)
 {
 	CHECK_FULL_REGS(regs);
 	return do_fork(SIGCHLD, regs->gpr[1], regs, 0, NULL, NULL);
 }
 
-int sys_vfork(unsigned long p1, unsigned long p2, unsigned long p3,
-	      unsigned long p4, unsigned long p5, unsigned long p6,
-	      struct pt_regs *regs)
+PPC_REGS_SYSCALL_DEFINE0_RET(int, vfork, regs)
 {
 	CHECK_FULL_REGS(regs);
 	return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->gpr[1],
 			regs, 0, NULL, NULL);
 }
 
-int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
-	       unsigned long a3, unsigned long a4, unsigned long a5,
-	       struct pt_regs *regs)
+PPC_REGS_SYSCALL_DEFINE3_RET(int, execve, regs,
+		char __user *, ufilename,
+		char __user * __user *, argv,
+		char __user * __user *, envp)
 {
 	int error;
 	char *filename;
 
-	filename = getname((char __user *) a0);
+	filename = getname(ufilename);
 	error = PTR_ERR(filename);
 	if (IS_ERR(filename))
 		goto out;
 	flush_fp_to_thread(current);
 	flush_altivec_to_thread(current);
 	flush_spe_to_thread(current);
-	error = do_execve(filename, (char __user * __user *) a1,
-			  (char __user * __user *) a2, regs);
+	error = do_execve(filename, argv, envp, regs);
 	putname(filename);
 out:
 	return error;
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index a0afb55..8ebc83b 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -13,6 +13,7 @@
 #include <linux/signal.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
+#include <asm/syscalls.h>
 
 #include "signal.h"
 
@@ -197,9 +198,9 @@ void do_signal(struct pt_regs *regs, unsigned long thread_info_flags)
 	}
 }
 
-long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
-		unsigned long r5, unsigned long r6, unsigned long r7,
-		unsigned long r8, struct pt_regs *regs)
+PPC_REGS_SYSCALL_DEFINE2_RET(long, sigaltstack, regs,
+		const stack_t __user *, uss,
+		stack_t __user *, uoss)
 {
 	return do_sigaltstack(uss, uoss, regs->gpr[1]);
 }
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index e65d311..212583d 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -784,8 +784,8 @@ COMPAT_SYSCALL_DEFINE3(rt_sigqueueinfo, u32, pid, u32, sig,
  *       sigaltatck               compat_sys_sigaltstack
  */
 
-int compat_sys_sigaltstack(u32 __new, u32 __old, int r5,
-		      int r6, int r7, int r8, struct pt_regs *regs)
+PPC_REGS_COMPAT_SYSCALL_DEFINE2_RET(int, sigaltstack, regs,
+		u32, __new, u32, __old)
 {
 	stack_32_t __user * newstack = compat_ptr(__new);
 	stack_32_t __user * oldstack = compat_ptr(__old);
@@ -1076,10 +1076,9 @@ long sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
 }
 
 #ifdef CONFIG_PPC32
-int sys_debug_setcontext(struct ucontext __user *ctx,
-			 int ndbg, struct sig_dbg_op __user *dbg,
-			 int r6, int r7, int r8,
-			 struct pt_regs *regs)
+PPC_REGS_SYSCALL_DEFINE3_RET(int, debug_setcontext, regs,
+		struct ucontext __user *, ctx, int, ndbg,
+		struct sig_dbg_op __user *, dbg)
 {
 	struct sig_dbg_op op;
 	int i;
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 2fe6fc6..a44781a 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -276,9 +276,9 @@ static long setup_trampoline(unsigned int syscall, unsigned int __user *tramp)
 /*
  * Handle {get,set,swap}_context operations
  */
-int sys_swapcontext(struct ucontext __user *old_ctx,
-		    struct ucontext __user *new_ctx,
-		    long ctx_size, long r6, long r7, long r8, struct pt_regs *regs)
+PPC_REGS_SYSCALL_DEFINE3_RET(int, swapcontext, regs,
+		struct ucontext __user *, old_ctx,
+		struct ucontext __user *, new_ctx, long, ctx_size)
 {
 	unsigned char tmp;
 	sigset_t set;
@@ -347,10 +347,7 @@ int sys_swapcontext(struct ucontext __user *old_ctx,
 /*
  * Do a signal return; undo the signal stack.
  */
-
-int sys_rt_sigreturn(unsigned long r3, unsigned long r4, unsigned long r5,
-		     unsigned long r6, unsigned long r7, unsigned long r8,
-		     struct pt_regs *regs)
+PPC_REGS_SYSCALL_DEFINE0_RET(int, rt_sigreturn, regs)
 {
 	struct ucontext __user *uc = (struct ucontext __user *)regs->gpr[1];
 	sigset_t set;
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index 6fc8ba9..27cf460 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -189,21 +189,22 @@ asmlinkage int compat_sys_sendfile64(int out_fd, int in_fd, compat_loff_t __user
 	return ret;
 }
 
-long compat_sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
-		  unsigned long a3, unsigned long a4, unsigned long a5,
-		  struct pt_regs *regs)
+PPC_REGS_COMPAT_SYSCALL_DEFINE3_RET(long, execve, regs,
+		char __user *, ufilename,
+		unsigned long, argv,
+		unsigned long, envp)
 {
 	int error;
 	char * filename;
 	
-	filename = getname((char __user *) a0);
+	filename = getname(ufilename);
 	error = PTR_ERR(filename);
 	if (IS_ERR(filename))
 		goto out;
 	flush_fp_to_thread(current);
 	flush_altivec_to_thread(current);
 
-	error = compat_do_execve(filename, compat_ptr(a1), compat_ptr(a2), regs);
+	error = compat_do_execve(filename, compat_ptr(argv), compat_ptr(envp), regs);
 
 	putname(filename);
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 29/40] trace syscalls, PPC: Convert ppc32_ syscalls to ARCH_COMPAT_SYSCALL_DEFINE
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (26 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 28/40] trace syscalls, PPC: Convert syscalls using regs to REGS_SYSCALL_DEFINE macros Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 30/40] trace syscalls: Convert remaining kernel/compat.c syscalls to COMPAT_SYSCALL_DEFINE Ian Munsie
                   ` (9 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Andrew Morton, Christoph Hellwig, Chase Douglas,
	Eric W. Biederman, Alexey Dobriyan

From: Ian Munsie <imunsie@au1.ibm.com>

This patch renames the 32bit compat syscalls prefixed with ppc32_ to
sys32_ and uses the ARCH_COMPAT_SYSCALL_DEFINE macros to record their
metadata for tracing.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/include/asm/systbl.h |    4 ++--
 arch/powerpc/kernel/sys_ppc32.c   |    8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 228eecb..bbcc700 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -236,9 +236,9 @@ COMPAT_SYS_SPU(io_getevents)
 COMPAT_SYS_SPU(io_submit)
 SYSCALL_SPU(io_cancel)
 SYSCALL(set_tid_address)
-SYSX_SPU(sys_fadvise64,ppc32_fadvise64,sys_fadvise64)
+SYSX_SPU(sys_fadvise64,sys32_fadvise64,sys_fadvise64)
 SYSCALL(exit_group)
-SYSX(sys_lookup_dcookie,ppc32_lookup_dcookie,sys_lookup_dcookie)
+SYSX(sys_lookup_dcookie,sys32_lookup_dcookie,sys_lookup_dcookie)
 SYSCALL_SPU(epoll_create)
 SYSCALL_SPU(epoll_ctl)
 SYSCALL_SPU(epoll_wait)
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index 27cf460..cf18164 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -594,15 +594,15 @@ asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long h
 	return sys_ftruncate(fd, (high << 32) | low);
 }
 
-long ppc32_lookup_dcookie(u32 cookie_high, u32 cookie_low, char __user *buf,
-			  size_t len)
+ARCH_COMPAT_SYSCALL_DEFINE4(lookup_dcookie, u32, cookie_high, u32, cookie_low,
+		char __user *, buf, size_t, len)
 {
 	return sys_lookup_dcookie((u64)cookie_high << 32 | cookie_low,
 				  buf, len);
 }
 
-long ppc32_fadvise64(int fd, u32 unused, u32 offset_high, u32 offset_low,
-		     size_t len, int advice)
+ARCH_COMPAT_SYSCALL_DEFINE6(fadvise64, int, fd, u32, unused, u32, offset_high,
+		u32, offset_low, size_t, len, int, advice)
 {
 	return sys_fadvise64(fd, (u64)offset_high << 32 | offset_low, len,
 			     advice);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 30/40] trace syscalls: Convert remaining kernel/compat.c syscalls to COMPAT_SYSCALL_DEFINE
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (27 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 29/40] trace syscalls, PPC: Convert ppc32_ syscalls to ARCH_COMPAT_SYSCALL_DEFINE Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 33/40] trace syscalls: Infrastructure for syscalls different return types Ian Munsie
                   ` (8 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Rusty Russell, KOSAKI Motohiro, Tejun Heo

From: Ian Munsie <imunsie@au1.ibm.com>

This patch converts the remaining system calls from kernel/compat.c to
use the COMPAT_SYSCALL_DEFINE family of macros.

The particular system calls in question did not originally have the
asmlinkage tag which will be added by this conversion.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/compat.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/kernel/compat.c b/kernel/compat.c
index 7ab99e1..81762e4 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -535,9 +535,9 @@ int put_compat_itimerspec(struct compat_itimerspec __user *dst,
 	return 0;
 }
 
-long compat_sys_timer_create(clockid_t which_clock,
-			struct compat_sigevent __user *timer_event_spec,
-			timer_t __user *created_timer_id)
+COMPAT_SYSCALL_DEFINE3(timer_create, clockid_t, which_clock,
+			struct compat_sigevent __user *, timer_event_spec,
+			timer_t __user *, created_timer_id)
 {
 	struct sigevent __user *event = NULL;
 
@@ -553,9 +553,9 @@ long compat_sys_timer_create(clockid_t which_clock,
 	return sys_timer_create(which_clock, event, created_timer_id);
 }
 
-long compat_sys_timer_settime(timer_t timer_id, int flags,
-			  struct compat_itimerspec __user *new,
-			  struct compat_itimerspec __user *old)
+COMPAT_SYSCALL_DEFINE4(timer_settime, timer_t, timer_id, int, flags,
+			  struct compat_itimerspec __user *, new,
+			  struct compat_itimerspec __user *, old)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -576,8 +576,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
 	return err;
 }
 
-long compat_sys_timer_gettime(timer_t timer_id,
-		struct compat_itimerspec __user *setting)
+COMPAT_SYSCALL_DEFINE2(timer_gettime, timer_t, timer_id,
+		struct compat_itimerspec __user *, setting)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -593,8 +593,8 @@ long compat_sys_timer_gettime(timer_t timer_id,
 	return err;
 }
 
-long compat_sys_clock_settime(clockid_t which_clock,
-		struct compat_timespec __user *tp)
+COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
+		struct compat_timespec __user *, tp)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -610,8 +610,8 @@ long compat_sys_clock_settime(clockid_t which_clock,
 	return err;
 }
 
-long compat_sys_clock_gettime(clockid_t which_clock,
-		struct compat_timespec __user *tp)
+COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
+		struct compat_timespec __user *, tp)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -627,8 +627,8 @@ long compat_sys_clock_gettime(clockid_t which_clock,
 	return err;
 }
 
-long compat_sys_clock_getres(clockid_t which_clock,
-		struct compat_timespec __user *tp)
+COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
+		struct compat_timespec __user *, tp)
 {
 	long err;
 	mm_segment_t oldfs;
@@ -668,9 +668,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
 	return err;
 }
 
-long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
-			    struct compat_timespec __user *rqtp,
-			    struct compat_timespec __user *rmtp)
+COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
+			    struct compat_timespec __user *, rqtp,
+			    struct compat_timespec __user *, rmtp)
 {
 	long err;
 	mm_segment_t oldfs;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 33/40] trace syscalls: Infrastructure for syscalls different return types
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (28 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 30/40] trace syscalls: Convert remaining kernel/compat.c syscalls to COMPAT_SYSCALL_DEFINE Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 34/40] trace syscalls: Convert generic syscalls without long return type Ian Munsie
                   ` (7 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Ingo Molnar

From: Ian Munsie <imunsie@au1.ibm.com>

A number of syscalls have return types other than long, which the
existing SYSCALL_DEFINE macros assumed. This patch adds aditional macros
that specify the return types (semantics of existing high level macros are
unchanged) for use with system calls with other return types.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 include/linux/syscalls.h |  102 +++++++++++++++++++++++++++++-----------------
 1 files changed, 64 insertions(+), 38 deletions(-)

diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index d7eaa4b..0cef707 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -193,36 +193,62 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #define SYSCALL_METADATA0(...)
 #endif /* CONFIG_FTRACE_SYSCALLS */
 
-#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_DEFINE0(name) SYSCALL_DEFINE0_RET(long, name)
+#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, long, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, long, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, long, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, long, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, long, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, long, _##name, __VA_ARGS__)
+
+#define SYSCALL_DEFINE1_RET(ret, name, ...) SYSCALL_DEFINEx(1, ret, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE2_RET(ret, name, ...) SYSCALL_DEFINEx(2, ret, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE3_RET(ret, name, ...) SYSCALL_DEFINEx(3, ret, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE4_RET(ret, name, ...) SYSCALL_DEFINEx(4, ret, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE5_RET(ret, name, ...) SYSCALL_DEFINEx(5, ret, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE6_RET(ret, name, ...) SYSCALL_DEFINEx(6, ret, _##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__)
-
-#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__)
-
-#define COMPAT_SYSCALL_DEFINEx(x, syscall, sname, ...)			\
+#define ARCH_COMPAT_SYSCALL_DEFINE0(name) COMPAT_SYSCALL_DEFINE0_RET(long, sys32_##name, name)
+#define ARCH_COMPAT_SYSCALL_DEFINE1(name, ...) COMPAT_SYSCALL_DEFINEx(1, long, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE2(name, ...) COMPAT_SYSCALL_DEFINEx(2, long, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE3(name, ...) COMPAT_SYSCALL_DEFINEx(3, long, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE4(name, ...) COMPAT_SYSCALL_DEFINEx(4, long, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE5(name, ...) COMPAT_SYSCALL_DEFINEx(5, long, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE6(name, ...) COMPAT_SYSCALL_DEFINEx(6, long, sys32_##name, name, __VA_ARGS__)
+
+#define ARCH_COMPAT_SYSCALL_DEFINE0_RET(ret, name) COMPAT_SYSCALL_DEFINE0_RET(0, ret, sys32_##name, name)
+#define ARCH_COMPAT_SYSCALL_DEFINE1_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(1, ret, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE2_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(2, ret, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE3_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(3, ret, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE4_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(4, ret, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE5_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(5, ret, sys32_##name, name, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE6_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(6, ret, sys32_##name, name, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINE0(name) COMPAT_SYSCALL_DEFINE0_RET(long, compat_sys_##name, name)
+#define COMPAT_SYSCALL_DEFINE1(name, ...) COMPAT_SYSCALL_DEFINEx(1, long, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE2(name, ...) COMPAT_SYSCALL_DEFINEx(2, long, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE3(name, ...) COMPAT_SYSCALL_DEFINEx(3, long, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE4(name, ...) COMPAT_SYSCALL_DEFINEx(4, long, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE5(name, ...) COMPAT_SYSCALL_DEFINEx(5, long, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE6(name, ...) COMPAT_SYSCALL_DEFINEx(6, long, compat_sys_##name, name, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINE0_RET(ret, name) __COMPAT_SYSCALL_DEFINE0(ret, compat_sys_##name, name)
+#define COMPAT_SYSCALL_DEFINE1_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE2_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE3_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE4_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE5_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_##name, name, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE6_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_##name, name, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINEx(x, ret, syscall, sname, ...)		\
 	SYSCALL_METADATAx(syscall, compat_sys_##sname, x, compat_syscall, __VA_ARGS__);\
-	asmlinkage long syscall(__SC_DECL##x(__VA_ARGS__))
+	asmlinkage ret syscall(__SC_DECL##x(__VA_ARGS__))
 
-#define COMPAT_SYSCALL_DEFINE0(name)					\
-	SYSCALL_METADATA0(compat_sys_##name, name, compat_syscall)	\
-	asmlinkage long compat_sys_##name()
+#define __COMPAT_SYSCALL_DEFINE0_RET(ret, syscall, name)		\
+	SYSCALL_METADATA0(syscall, name, compat_syscall)		\
+	asmlinkage ret syscall()
 
 #endif /* CONFIG_COMPAT */
 
@@ -241,13 +267,13 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #endif
 #endif
 
-#define SYSCALL_DEFINEx(x, sname, ...)				\
+#define SYSCALL_DEFINEx(x, ret, sname, ...)				\
 	SYSCALL_METADATAx(sys##sname, sys##sname, x, syscall, __VA_ARGS__);\
-	__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
+	__SYSCALL_DEFINEx(x, ret, sname, __VA_ARGS__)
 
-#define SYSCALL_DEFINE0(name)					\
-	SYSCALL_METADATA0(sys_##name, name, syscall)		\
-	asmlinkage long sys_##name(void)
+#define SYSCALL_DEFINE0_RET(ret, name)					\
+	SYSCALL_METADATA0(sys_##name, name, syscall)			\
+	asmlinkage ret sys_##name(void)
 
 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
 
@@ -255,16 +281,16 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	SYSCALL_METADATAx(sys_##name, sys_##name, x, syscall, __VA_ARGS__);\
 	static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__))
 
-#define __SYSCALL_DEFINEx(x, name, ...)					\
-	asmlinkage long sys##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__))		\
+#define __SYSCALL_DEFINEx(x, ret, name, ...)				\
+	asmlinkage ret sys##name(__SC_DECL##x(__VA_ARGS__));		\
+	static inline ret SYSC##name(__SC_DECL##x(__VA_ARGS__));	\
+	asmlinkage ret SyS##name(__SC_LONG##x(__VA_ARGS__))		\
 	{								\
 		__SC_TEST##x(__VA_ARGS__);				\
-		return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__));	\
+		return (ret) SYSC##name(__SC_CAST##x(__VA_ARGS__));	\
 	}								\
 	SYSCALL_ALIAS(sys##name, SyS##name);				\
-	static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__))
+	static inline ret SYSC##name(__SC_DECL##x(__VA_ARGS__))
 
 #else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
 
@@ -272,8 +298,8 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 	SYSCALL_METADATAx(sys_##name, sys_##name, x, syscall, __VA_ARGS__);\
 	asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__))
 
-#define __SYSCALL_DEFINEx(x, name, ...)					\
-	asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))
+#define __SYSCALL_DEFINEx(x, ret, name, ...)				\
+	asmlinkage ret sys##name(__SC_DECL##x(__VA_ARGS__))
 
 #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 34/40] trace syscalls: Convert generic syscalls without long return type
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (29 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 33/40] trace syscalls: Infrastructure for syscalls different return types Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 35/40] trace syscalls, PPC: Convert PPC syscalls without long return types Ian Munsie
                   ` (6 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Alexander Viro, Andrew Morton, Jeff Moyer,
	David Howells, Oleg Nesterov, linux-fsdevel

From: Ian Munsie <imunsie@au1.ibm.com>

This patch converts a number of syscalls from the generic code that had
return types other than long to use the new COMPAT_SYSCALL_DEFINEx_RET
macros so their metadata is recorded for tracing.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 fs/compat.c     |   24 ++++++++++++------------
 ipc/compat_mq.c |    8 ++++----
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/fs/compat.c b/fs/compat.c
index 9897b7b..edfa4b5 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1224,9 +1224,9 @@ out:
 	return ret;
 }
 
-asmlinkage ssize_t
-compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec,
-		 unsigned long vlen)
+COMPAT_SYSCALL_DEFINE3_RET(ssize_t, readv, unsigned long, fd,
+		const struct compat_iovec __user *, vec,
+		unsigned long, vlen)
 {
 	struct file *file;
 	int fput_needed;
@@ -1240,9 +1240,9 @@ compat_sys_readv(unsigned long fd, const struct compat_iovec __user *vec,
 	return ret;
 }
 
-asmlinkage ssize_t
-compat_sys_preadv(unsigned long fd, const struct compat_iovec __user *vec,
-		  unsigned long vlen, u32 pos_low, u32 pos_high)
+COMPAT_SYSCALL_DEFINE5_RET(ssize_t, preadv, unsigned long, fd,
+		const struct compat_iovec __user *, vec,
+		unsigned long, vlen, u32, pos_low, u32, pos_high)
 {
 	loff_t pos = ((loff_t)pos_high << 32) | pos_low;
 	struct file *file;
@@ -1281,9 +1281,9 @@ out:
 	return ret;
 }
 
-asmlinkage ssize_t
-compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec,
-		  unsigned long vlen)
+COMPAT_SYSCALL_DEFINE3_RET(ssize_t, writev, unsigned long, fd,
+		const struct compat_iovec __user *, vec,
+		unsigned long, vlen)
 {
 	struct file *file;
 	int fput_needed;
@@ -1297,9 +1297,9 @@ compat_sys_writev(unsigned long fd, const struct compat_iovec __user *vec,
 	return ret;
 }
 
-asmlinkage ssize_t
-compat_sys_pwritev(unsigned long fd, const struct compat_iovec __user *vec,
-		   unsigned long vlen, u32 pos_low, u32 pos_high)
+COMPAT_SYSCALL_DEFINE5_RET(ssize_t, pwritev, unsigned long, fd,
+		const struct compat_iovec __user *, vec,
+		unsigned long, vlen, u32, pos_low, u32, pos_high)
 {
 	loff_t pos = ((loff_t)pos_high << 32) | pos_low;
 	struct file *file;
diff --git a/ipc/compat_mq.c b/ipc/compat_mq.c
index 53593d3..22a394e 100644
--- a/ipc/compat_mq.c
+++ b/ipc/compat_mq.c
@@ -89,10 +89,10 @@ COMPAT_SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes,
 			msg_prio, u_ts);
 }
 
-asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
-			char __user *u_msg_ptr,
-			size_t msg_len, unsigned int __user *u_msg_prio,
-			const struct compat_timespec __user *u_abs_timeout)
+COMPAT_SYSCALL_DEFINE5_RET(ssize_t, mq_timedreceive, mqd_t, mqdes,
+			char __user *, u_msg_ptr,
+			size_t, msg_len, unsigned int __user *, u_msg_prio,
+			const struct compat_timespec __user *, u_abs_timeout)
 {
 	struct timespec __user *u_ts;
 	if (compat_prepare_timeout(&u_ts, u_abs_timeout))
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 35/40] trace syscalls, PPC: Convert PPC syscalls without long return types
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (30 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 34/40] trace syscalls: Convert generic syscalls without long return type Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 36/40] trace syscalls: Early terminate search for sys_ni_syscall Ian Munsie
                   ` (5 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Andrew Morton, Christoph Hellwig, Jesper Nilsson,
	David Howells, Chase Douglas, Peter Zijlstra, David S. Miller,
	Thomas Gleixner, Ingo Molnar, Eric W. Biederman, Alexey Dobriyan

From: Ian Munsie <imunsie@au1.ibm.com>

This patch converts the PowerPC system calls with return types other
than long to use the various *SYSCALL_DEFINEx_RET family of macros so
their metadata is recorded for tracing.

This patch also renamed the ppc_rtas syscall to sys_rtas to fit in with
the naming convention of the SYSCALL_DEFINE macros.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/include/asm/syscalls.h |    2 +-
 arch/powerpc/include/asm/systbl.h   |    4 ++--
 arch/powerpc/kernel/rtas.c          |    2 +-
 arch/powerpc/kernel/sys_ppc32.c     |   33 +++++++++++++++++++--------------
 arch/powerpc/kernel/syscalls.c      |   12 ++++++------
 5 files changed, 29 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index 531b45d..050cca3 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -91,7 +91,7 @@ asmlinkage long sys_rt_sigaction(int sig,
 		const struct sigaction __user *act,
 		struct sigaction __user *oact, size_t sigsetsize);
 asmlinkage long sys_ppc64_personality(unsigned long personality);
-asmlinkage int ppc_rtas(struct rtas_args __user *uargs);
+asmlinkage int sys_rtas(struct rtas_args __user *uargs);
 asmlinkage time_t sys64_time(time_t __user * tloc);
 
 asmlinkage long sys_rt_sigsuspend(sigset_t __user *unewset,
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index bbcc700..06c0a73 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -22,7 +22,7 @@ SYSCALL_SPU(chmod)
 SYSCALL_SPU(lchown)
 SYSCALL(ni_syscall)
 OLDSYS(stat)
-SYSX_SPU(sys_lseek,ppc32_lseek,sys_lseek)
+SYSX_SPU(sys_lseek,sys32_lseek,sys_lseek)
 SYSCALL_SPU(getpid)
 COMPAT_SYS(mount)
 SYSX(sys_ni_syscall,sys_oldumount,sys_oldumount)
@@ -258,7 +258,7 @@ COMPAT_SYS_SPU(utimes)
 COMPAT_SYS_SPU(statfs64)
 COMPAT_SYS_SPU(fstatfs64)
 SYSX(sys_ni_syscall, sys_ppc_fadvise64_64, sys_ppc_fadvise64_64)
-PPC_SYS_SPU(rtas)
+SYSCALL_SPU(rtas)
 OLDSYS(debug_setcontext)
 SYSCALL(ni_syscall)
 COMPAT_SYS(migrate_pages)
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 0e1ec6f..ca5f8ea 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -826,7 +826,7 @@ static int rtas_ibm_suspend_me(struct rtas_args *args)
 }
 #endif
 
-asmlinkage int ppc_rtas(struct rtas_args __user *uargs)
+SYSCALL_DEFINE1_RET(int, rtas, struct rtas_args __user *, uargs)
 {
 	struct rtas_args args;
 	unsigned long flags;
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index cf18164..431de48 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -167,7 +167,8 @@ COMPAT_SYSCALL_DEFINE4(sendfile, u32, out_fd, u32, in_fd,
 	return ret;
 }
 
-asmlinkage int compat_sys_sendfile64(int out_fd, int in_fd, compat_loff_t __user *offset, s32 count)
+COMPAT_SYSCALL_DEFINE4_RET(int, sendfile64, int, out_fd, int, in_fd,
+		compat_loff_t __user *, offset, s32, count)
 {
 	mm_segment_t old_fs = get_fs();
 	int ret;
@@ -347,7 +348,8 @@ COMPAT_SYSCALL_DEFINE1(nice, u32, increment)
 	return sys_nice((int)increment);
 }
 
-off_t ppc32_lseek(unsigned int fd, u32 offset, unsigned int origin)
+ARCH_COMPAT_SYSCALL_DEFINE3_RET(off_t, lseek,
+		unsigned int, fd, u32, offset, unsigned int, origin)
 {
 	/* sign extend n */
 	return sys_lseek(fd, (int)offset, origin);
@@ -539,9 +541,9 @@ COMPAT_SYSCALL_DEFINE1(umask, u32, mask)
 	return sys_umask((int)mask);
 }
 
-unsigned long compat_sys_mmap2(unsigned long addr, size_t len,
-			  unsigned long prot, unsigned long flags,
-			  unsigned long fd, unsigned long pgoff)
+COMPAT_SYSCALL_DEFINE6_RET(unsigned long, mmap2, unsigned long, addr, size_t, len,
+			  unsigned long, prot, unsigned long, flags,
+			  unsigned long, fd, unsigned long, pgoff)
 {
 	/* This should remain 12 even if PAGE_SIZE changes */
 	return sys_mmap(addr, len, prot, flags, fd, pgoff << 12);
@@ -558,25 +560,28 @@ COMPAT_SYSCALL_DEFINE3(tgkill, u32, tgid, u32, pid, int, sig)
  * The 32 bit ABI passes long longs in an odd even register pair.
  */
 
-compat_ssize_t compat_sys_pread64(unsigned int fd, char __user *ubuf, compat_size_t count,
-			     u32 reg6, u32 poshi, u32 poslo)
+COMPAT_SYSCALL_DEFINE6_RET(compat_ssize_t, pread64,
+		unsigned int, fd, char __user *, ubuf, compat_size_t, count,
+		u32, reg6, u32, poshi, u32, poslo)
 {
 	return sys_pread64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
 }
 
-compat_ssize_t compat_sys_pwrite64(unsigned int fd, char __user *ubuf, compat_size_t count,
-			      u32 reg6, u32 poshi, u32 poslo)
+COMPAT_SYSCALL_DEFINE6_RET(compat_ssize_t, pwrite64,
+		unsigned int, fd, char __user *, ubuf, compat_size_t, count,
+		u32, reg6, u32, poshi, u32, poslo)
 {
 	return sys_pwrite64(fd, ubuf, count, ((loff_t)poshi << 32) | poslo);
 }
 
-compat_ssize_t compat_sys_readahead(int fd, u32 r4, u32 offhi, u32 offlo, u32 count)
+COMPAT_SYSCALL_DEFINE5_RET(compat_ssize_t, readahead,
+		int, fd, u32, r4, u32, offhi, u32, offlo, u32, count)
 {
 	return sys_readahead(fd, ((loff_t)offhi << 32) | offlo, count);
 }
 
-asmlinkage int compat_sys_truncate64(const char __user * path, u32 reg4,
-				unsigned long high, unsigned long low)
+COMPAT_SYSCALL_DEFINE4_RET(int, truncate64, const char __user *, path,
+		u32, reg4, unsigned long, high, unsigned long, low)
 {
 	return sys_truncate(path, (high << 32) | low);
 }
@@ -588,8 +593,8 @@ COMPAT_SYSCALL_DEFINE6(fallocate, int, fd, int, mode,
 			     ((loff_t)lenhi << 32) | lenlo);
 }
 
-asmlinkage int compat_sys_ftruncate64(unsigned int fd, u32 reg4, unsigned long high,
-				 unsigned long low)
+COMPAT_SYSCALL_DEFINE4_RET(int, ftruncate64, unsigned int, fd,
+		u32, reg4, unsigned long, high, unsigned long, low)
 {
 	return sys_ftruncate(fd, (high << 32) | low);
 }
diff --git a/arch/powerpc/kernel/syscalls.c b/arch/powerpc/kernel/syscalls.c
index f3bce3a..aee8ebb 100644
--- a/arch/powerpc/kernel/syscalls.c
+++ b/arch/powerpc/kernel/syscalls.c
@@ -62,16 +62,16 @@ out:
 	return ret;
 }
 
-unsigned long sys_mmap2(unsigned long addr, size_t len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long pgoff)
+SYSCALL_DEFINE6_RET(unsigned long, mmap2, unsigned long, addr, size_t, len,
+			unsigned long, prot, unsigned long, flags,
+			unsigned long, fd, unsigned long, pgoff)
 {
 	return do_mmap2(addr, len, prot, flags, fd, pgoff, PAGE_SHIFT-12);
 }
 
-unsigned long sys_mmap(unsigned long addr, size_t len,
-		       unsigned long prot, unsigned long flags,
-		       unsigned long fd, off_t offset)
+SYSCALL_DEFINE6_RET(unsigned long, mmap, unsigned long, addr, size_t, len,
+		       unsigned long, prot, unsigned long, flags,
+		       unsigned long, fd, off_t, offset)
 {
 	return do_mmap2(addr, len, prot, flags, fd, offset, PAGE_SHIFT);
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 36/40] trace syscalls: Early terminate search for sys_ni_syscall
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (31 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 35/40] trace syscalls, PPC: Convert PPC syscalls without long return types Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 37/40] trace syscalls: Print out unmapped syscalls at boot Ian Munsie
                   ` (4 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Masami Hiramatsu

From: Ian Munsie <imunsie@au1.ibm.com>

Many system calls are unimplemented and mapped to sys_ni_syscall, but at
boot ftrace would still search through every syscall metadata entry for
a match which wouldn't be there.

This patch adds causes the search to terminate early if the system call
is not mapped.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 264441e..58ef002 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -95,6 +95,9 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 	stop = (struct syscall_metadata *)__stop_syscalls_metadata;
 	kallsyms_lookup(syscall, NULL, NULL, NULL, str);
 
+	if (arch_syscall_match_sym_name(str, "sys_ni_syscall"))
+		return NULL;
+
 	for ( ; start < stop; start++) {
 		if (start->name && arch_syscall_match_sym_name(str, start->name))
 			return start;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 37/40] trace syscalls: Print out unmapped syscalls at boot
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (32 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 36/40] trace syscalls: Early terminate search for sys_ni_syscall Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 38/40] trace syscalls: Remove redundant test for unmapped compat syscalls Ian Munsie
                   ` (3 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Masami Hiramatsu

From: Ian Munsie <imunsie@au1.ibm.com>

This patch will print out implemented but unmapped system calls at boot
to help quickly identify remaining unmapped system calls.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index 58ef002..c0041e3 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -102,6 +102,7 @@ static struct syscall_metadata *find_syscall_meta(unsigned long syscall)
 		if (start->name && arch_syscall_match_sym_name(str, start->name))
 			return start;
 	}
+	printk(KERN_DEBUG "ftrace syscalls: missing metadata for %s\n", str);
 	return NULL;
 }
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 38/40] trace syscalls: Remove redundant test for unmapped compat syscalls
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (33 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 37/40] trace syscalls: Print out unmapped syscalls at boot Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 10:03 ` [PATCH 39/40] trace syscalls: Clean confusing {s,r,}name and fix ABI breakage Ian Munsie
                   ` (2 subsequent siblings)
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Masami Hiramatsu

From: Ian Munsie <imunsie@au1.ibm.com>

Since the ftrace event initialisation routine now verifies that either
the syscall number or the compat syscall number is valid and will not
create events for unmapped syscalls, it is unnecessary to explicitly
search for them, so remove it.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 kernel/trace/trace_syscalls.c |   20 --------------------
 1 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
index c0041e3..108c2eb 100644
--- a/kernel/trace/trace_syscalls.c
+++ b/kernel/trace/trace_syscalls.c
@@ -528,26 +528,6 @@ int __init init_ftrace_syscalls(void)
 			meta->compat_syscall_nr = i;
 			compat_syscalls_metadata[i] = meta;
 		}
-		/* now check if any compat_syscalls are not referenced */
-		for (ftrace_event = __start_ftrace_events;
-			(unsigned long)ftrace_event <
-			(unsigned long)__stop_ftrace_events; ftrace_event++) {
-
-			match = 0;
-			if (!ftrace_event->name)
-				continue;
-			if (strcmp(ftrace_event->class->system, "compat_syscalls"))
-				continue;
-			for (i = 0; i < NR_syscalls_compat; i++) {
-				if (ftrace_event->data ==
-						compat_syscalls_metadata[i]) {
-					match = 1;
-					break;
-				}
-			}
-			if (!match)
-				ftrace_event->name = NULL;
-		}
 	}
 #endif
 	return 0;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 39/40] trace syscalls: Clean confusing {s,r,}name and fix ABI breakage
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (34 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 38/40] trace syscalls: Remove redundant test for unmapped compat syscalls Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
  2010-06-23 18:03   ` Jason Baron
  2010-06-23 10:03 ` [PATCH 40/40] trace syscalls, PPC: Convert morphing native/compat syscalls Ian Munsie
       [not found] ` <1277287401-28571-32-git-send-email-imunsie@au1.ibm.com>
  37 siblings, 1 reply; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Andrew Morton, Christoph Hellwig, Jesper Nilsson,
	David Howells, Ingo Molnar

From: Ian Munsie <imunsie@au1.ibm.com>

This patch cleans up the preprocessor macros defining system calls by
standidising on the parameters passing around the system call name, with
and without it's prefix.

Overall this makes the preprocessor code easier to understand and
follow and less likely to introduce bugs due to misunderstanding what to
place into each parameter.

The parameters henceforth should be named:

sname is the system call name WITHOUT the prefix (e.g. read)
prefix is the prefix INCLUDING the trailing underscore (e.g. sys_)

These are mashed together to form the full syscall name when required
like blah##prefix##sname. For just prefix##sname please use the provided
SYSNAME(prefix,sname) macro instead as it will be safe if prefix itself
is a macro.

This patch also fixes an ABI breakage - the ftrace events are once again
named like 'sys_enter_read' instead of 'enter_sys_read'. The rwtop
script shipped with perf relies on this ABI. Others may as well.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/include/asm/syscalls.h |   58 +++++-----
 include/linux/syscalls.h            |  200 ++++++++++++++++++-----------------
 2 files changed, 131 insertions(+), 127 deletions(-)

diff --git a/arch/powerpc/include/asm/syscalls.h b/arch/powerpc/include/asm/syscalls.h
index 050cca3..b01fedf 100644
--- a/arch/powerpc/include/asm/syscalls.h
+++ b/arch/powerpc/include/asm/syscalls.h
@@ -21,48 +21,50 @@ struct sigaction;
 #define __SC_DUMMY_ARGS6
 
 /* Native syscalls that require register access */
-#define PPC_REGS_SYSCALL_DEFINE1_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(1, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE2_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(2, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE3_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(3, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE4_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(4, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE5_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(5, ret, sys_##name, _##name, regs, __VA_ARGS__)
-#define PPC_REGS_SYSCALL_DEFINE6_RET(ret, name, regs, ...) PPC_REGS_SYSCALL_DEFINEx(6, ret, sys_##name, _##name, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE0_RET(ret, sname, regs     ) PPC_REGS_SYSCALL_DEFINE0(   ret, sys_, sname, regs)
+#define PPC_REGS_SYSCALL_DEFINE1_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(1, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE2_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(2, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE3_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(3, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE4_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(4, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE5_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(5, ret, sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINE6_RET(ret, sname, regs, ...) PPC_REGS_SYSCALL_DEFINEx(6, ret, sys_, sname, regs, __VA_ARGS__)
 
 #ifdef CONFIG_COMPAT
 
 /* 32bit compat syscalls that require register access */
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE1_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE2_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE3_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE4_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE5_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE6_RET(ret, name, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_##name, name, regs, __VA_ARGS__)
-
-#define PPC_REGS_COMPAT_SYSCALL_DEFINEx(x, ret, sysname, sname, regs,  ...)	\
-	SYSCALL_METADATAx(sysname, compat_sys_##sname, x, compat_syscall, __VA_ARGS__);\
-	__PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, __VA_ARGS__)
-
-#define PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(ret, name, regs)			\
-	SYSCALL_METADATA0(compat_sys_##name, name, syscall)			\
-	__PPC_REGS_SYSCALL_DEFINE0(ret, compat_sys_##name, regs)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(ret, sname, regs     ) PPC_REGS_COMPAT_SYSCALL_DEFINE0(   ret, compat_sys_, sname, regs)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE1_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE2_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE3_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE4_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE5_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_, sname, regs, __VA_ARGS__)
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE6_RET(ret, sname, regs, ...) PPC_REGS_COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_, sname, regs, __VA_ARGS__)
+
+#define PPC_REGS_COMPAT_SYSCALL_DEFINEx(x, ret, prefix, sname, regs,  ...)	\
+	SYSCALL_METADATAx(prefix, sname, x, compat_syscall, __VA_ARGS__);	\
+	__PPC_REGS_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, __VA_ARGS__)
+
+#define PPC_REGS_COMPAT_SYSCALL_DEFINE0(ret, prefix, sname, regs)		\
+	SYSCALL_METADATA0(prefix, sname, syscall)				\
+	__PPC_REGS_SYSCALL_DEFINE0(ret, prefix, sname, regs)
 
 #endif /*CONFIG_COMPAT */
 
-#define PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, sname, regs, ...)		\
-	SYSCALL_METADATAx(sysname, sname, x, syscall, __VA_ARGS__);		\
-	__PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, __VA_ARGS__)
+#define PPC_REGS_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, ...)		\
+	SYSCALL_METADATAx(prefix, sname, x, syscall, __VA_ARGS__);		\
+	__PPC_REGS_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, __VA_ARGS__)
 
-#define PPC_REGS_SYSCALL_DEFINE0_RET(ret, name, regs)				\
-	SYSCALL_METADATA0(sys_##name, name, syscall)				\
-	__PPC_REGS_SYSCALL_DEFINE0(ret, sys_##name, regs)
+#define PPC_REGS_SYSCALL_DEFINE0(ret, prefix, sname, regs)			\
+	SYSCALL_METADATA0(prefix, sname, syscall)				\
+	__PPC_REGS_SYSCALL_DEFINE0(ret, prefix, sname, regs)
 
-#define __PPC_REGS_SYSCALL_DEFINEx(x, ret, sysname, regs, ...)			\
-	ret sysname(__SC_DECL##x(__VA_ARGS__),					\
+#define __PPC_REGS_SYSCALL_DEFINEx(x, ret, prefix, sname, regs, ...)		\
+	ret SYSNAME(prefix, sname)(__SC_DECL##x(__VA_ARGS__),			\
 			__SC_DUMMY_ARGS##x					\
 			struct pt_regs *regs)
 
-#define __PPC_REGS_SYSCALL_DEFINE0(ret, sysname, regs)				\
-	ret sysname(__SC_DUMMY_ARGS0 struct pt_regs *regs)
+#define __PPC_REGS_SYSCALL_DEFINE0(ret, prefix, sname, regs)			\
+	ret SYSNAME(prefix, sname)(__SC_DUMMY_ARGS0 struct pt_regs *regs)
 
 
 asmlinkage unsigned long sys_mmap(unsigned long addr, size_t len,
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 0cef707..dbc630a 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -103,6 +103,8 @@ struct perf_event_attr;
 #define __SC_TEST5(t5, a5, ...)	__SC_TEST(t5); __SC_TEST4(__VA_ARGS__)
 #define __SC_TEST6(t6, a6, ...)	__SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
 
+#define SYSNAME(prefix, sname) prefix##sname
+
 #ifdef CONFIG_FTRACE_SYSCALLS
 #define __SC_STR_ADECL1(t, a)		#a
 #define __SC_STR_ADECL2(t, a, ...)	#a, __SC_STR_ADECL1(__VA_ARGS__)
@@ -125,42 +127,42 @@ extern struct ftrace_event_class event_class_compat_syscall_exit;
 extern struct trace_event_functions enter_syscall_print_funcs;
 extern struct trace_event_functions exit_syscall_print_funcs;
 
-#define SYSCALL_TRACE_ENTER_EVENT(sname, event_class)			\
-	static struct syscall_metadata __syscall_meta_##sname;		\
+#define SYSCALL_TRACE_ENTER_EVENT(prefix, sname, event_class)		\
+	static struct syscall_metadata __syscall_meta_##prefix##sname;	\
 	static struct ftrace_event_call					\
-	__attribute__((__aligned__(4))) event_enter_##sname;		\
+	__attribute__((__aligned__(4))) event_enter_##prefix##sname;	\
 	static struct ftrace_event_call __used				\
 	  __attribute__((__aligned__(4)))				\
 	  __attribute__((section("_ftrace_events")))			\
-	  event_enter_##sname = {					\
-		.name                   = "enter_"#sname,		\
+	  event_enter_##prefix##sname = {				\
+		.name                   = #prefix"enter_"#sname,	\
 		.class			= &event_class_##event_class##_enter,\
 		.event.funcs            = &enter_syscall_print_funcs,	\
-		.data			= (void *)&__syscall_meta_##sname,\
+		.data			= (void *)&__syscall_meta_##prefix##sname,\
 	}
 
-#define SYSCALL_TRACE_EXIT_EVENT(sname, event_class)			\
-	static struct syscall_metadata __syscall_meta_##sname;		\
+#define SYSCALL_TRACE_EXIT_EVENT(prefix, sname, event_class)		\
+	static struct syscall_metadata __syscall_meta_##prefix##sname;	\
 	static struct ftrace_event_call					\
-	__attribute__((__aligned__(4))) event_exit_##sname;		\
+	__attribute__((__aligned__(4))) event_exit_##prefix##sname;	\
 	static struct ftrace_event_call __used				\
 	  __attribute__((__aligned__(4)))				\
 	  __attribute__((section("_ftrace_events")))			\
-	  event_exit_##sname = {					\
-		.name                   = "exit_"#sname,		\
+	  event_exit_##prefix##sname = {				\
+		.name                   = #prefix"exit_"#sname,		\
 		.class			= &event_class_##event_class##_exit,\
 		.event.funcs		= &exit_syscall_print_funcs,	\
-		.data			= (void *)&__syscall_meta_##sname,\
+		.data			= (void *)&__syscall_meta_##prefix##sname,\
 	}
 
-#define SYSCALL_METADATA(rname, sname, nb, event_class, stypes, sargs)\
-	SYSCALL_TRACE_ENTER_EVENT(sname, event_class);		\
-	SYSCALL_TRACE_EXIT_EVENT(sname, event_class);		\
+#define SYSCALL_METADATA(prefix, sname, nb, event_class, stypes, sargs)\
+	SYSCALL_TRACE_ENTER_EVENT(prefix, sname, event_class);	\
+	SYSCALL_TRACE_EXIT_EVENT(prefix, sname, event_class);	\
 	static struct syscall_metadata __used			\
 	  __attribute__((__aligned__(4)))			\
 	  __attribute__((section("__syscalls_metadata")))	\
-	  __syscall_meta_##sname = {				\
-		.name 		= #rname,			\
+	  __syscall_meta_##prefix##sname = {			\
+		.name 		= #prefix#sname,		\
 		.syscall_nr	= -1,	/* Filled in at boot */	\
 		.compat_syscall_nr = -1,/* Filled in at boot */	\
 		.nb_args 	= nb,				\
@@ -170,85 +172,85 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 		.ftrace_exit	= 0,				\
 		.perf_enter	= 0,				\
 		.perf_exit	= 0,				\
-		.enter_event	= &event_enter_##sname,		\
-		.exit_event	= &event_exit_##sname,		\
-		.enter_fields	= LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
-		.exit_fields	= LIST_HEAD_INIT(__syscall_meta_##sname.exit_fields), \
+		.enter_event	= &event_enter_##prefix##sname,	\
+		.exit_event	= &event_exit_##prefix##sname,	\
+		.enter_fields	= LIST_HEAD_INIT(__syscall_meta_##prefix##sname.enter_fields), \
+		.exit_fields	= LIST_HEAD_INIT(__syscall_meta_##prefix##sname.exit_fields), \
 	};
 
-#define SYSCALL_METADATAx(rname, sname, nb, event_class, ...)	\
-	static const char *types_##sname[] = {			\
+#define SYSCALL_METADATAx(prefix, sname, nb, event_class, ...)	\
+	static const char *types_##prefix##sname[] = {		\
 		__SC_STR_TDECL##nb(__VA_ARGS__)			\
 	};							\
-	static const char *args_##sname[] = {			\
+	static const char *args_##prefix##sname[] = {		\
 		__SC_STR_ADECL##nb(__VA_ARGS__)			\
 	};							\
-	SYSCALL_METADATA(rname, sname, nb, event_class, types_##sname, args_##sname)
+	SYSCALL_METADATA(prefix, sname, nb, event_class, types_##prefix##sname, args_##prefix##sname)
 
-#define SYSCALL_METADATA0(rname, sname, event_class)			\
-	SYSCALL_METADATA(rname, sname, 0, event_class, NULL, NULL)
+#define SYSCALL_METADATA0(prefix, sname, event_class)		\
+	SYSCALL_METADATA(prefix, sname, 0, event_class, NULL, NULL)
 
 #else /* !CONFIG_FTRACE_SYSCALLS */
 #define SYSCALL_METADATAx(...)
 #define SYSCALL_METADATA0(...)
 #endif /* CONFIG_FTRACE_SYSCALLS */
 
-#define SYSCALL_DEFINE0(name) SYSCALL_DEFINE0_RET(long, name)
-#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, long, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, long, _##name, __VA_ARGS__)
-
-#define SYSCALL_DEFINE1_RET(ret, name, ...) SYSCALL_DEFINEx(1, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE2_RET(ret, name, ...) SYSCALL_DEFINEx(2, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE3_RET(ret, name, ...) SYSCALL_DEFINEx(3, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE4_RET(ret, name, ...) SYSCALL_DEFINEx(4, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE5_RET(ret, name, ...) SYSCALL_DEFINEx(5, ret, _##name, __VA_ARGS__)
-#define SYSCALL_DEFINE6_RET(ret, name, ...) SYSCALL_DEFINEx(6, ret, _##name, __VA_ARGS__)
+#define SYSCALL_DEFINE0(sname) SYSCALL_DEFINE0_RET(long, sname)
+#define SYSCALL_DEFINE1(sname, ...) SYSCALL_DEFINEx(1, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE2(sname, ...) SYSCALL_DEFINEx(2, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE3(sname, ...) SYSCALL_DEFINEx(3, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE4(sname, ...) SYSCALL_DEFINEx(4, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE5(sname, ...) SYSCALL_DEFINEx(5, long, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE6(sname, ...) SYSCALL_DEFINEx(6, long, sname, __VA_ARGS__)
+
+#define SYSCALL_DEFINE1_RET(ret, sname, ...) SYSCALL_DEFINEx(1, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE2_RET(ret, sname, ...) SYSCALL_DEFINEx(2, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE3_RET(ret, sname, ...) SYSCALL_DEFINEx(3, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE4_RET(ret, sname, ...) SYSCALL_DEFINEx(4, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE5_RET(ret, sname, ...) SYSCALL_DEFINEx(5, ret, sname, __VA_ARGS__)
+#define SYSCALL_DEFINE6_RET(ret, sname, ...) SYSCALL_DEFINEx(6, ret, sname, __VA_ARGS__)
 
 #ifdef CONFIG_COMPAT
 
-#define ARCH_COMPAT_SYSCALL_DEFINE0(name) COMPAT_SYSCALL_DEFINE0_RET(long, sys32_##name, name)
-#define ARCH_COMPAT_SYSCALL_DEFINE1(name, ...) COMPAT_SYSCALL_DEFINEx(1, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE2(name, ...) COMPAT_SYSCALL_DEFINEx(2, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE3(name, ...) COMPAT_SYSCALL_DEFINEx(3, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE4(name, ...) COMPAT_SYSCALL_DEFINEx(4, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE5(name, ...) COMPAT_SYSCALL_DEFINEx(5, long, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE6(name, ...) COMPAT_SYSCALL_DEFINEx(6, long, sys32_##name, name, __VA_ARGS__)
-
-#define ARCH_COMPAT_SYSCALL_DEFINE0_RET(ret, name) COMPAT_SYSCALL_DEFINE0_RET(0, ret, sys32_##name, name)
-#define ARCH_COMPAT_SYSCALL_DEFINE1_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(1, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE2_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(2, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE3_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(3, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE4_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(4, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE5_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(5, ret, sys32_##name, name, __VA_ARGS__)
-#define ARCH_COMPAT_SYSCALL_DEFINE6_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(6, ret, sys32_##name, name, __VA_ARGS__)
-
-#define COMPAT_SYSCALL_DEFINE0(name) COMPAT_SYSCALL_DEFINE0_RET(long, compat_sys_##name, name)
-#define COMPAT_SYSCALL_DEFINE1(name, ...) COMPAT_SYSCALL_DEFINEx(1, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE2(name, ...) COMPAT_SYSCALL_DEFINEx(2, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE3(name, ...) COMPAT_SYSCALL_DEFINEx(3, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE4(name, ...) COMPAT_SYSCALL_DEFINEx(4, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE5(name, ...) COMPAT_SYSCALL_DEFINEx(5, long, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE6(name, ...) COMPAT_SYSCALL_DEFINEx(6, long, compat_sys_##name, name, __VA_ARGS__)
-
-#define COMPAT_SYSCALL_DEFINE0_RET(ret, name) __COMPAT_SYSCALL_DEFINE0(ret, compat_sys_##name, name)
-#define COMPAT_SYSCALL_DEFINE1_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE2_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE3_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE4_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE5_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_##name, name, __VA_ARGS__)
-#define COMPAT_SYSCALL_DEFINE6_RET(ret, name, ...) COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_##name, name, __VA_ARGS__)
-
-#define COMPAT_SYSCALL_DEFINEx(x, ret, syscall, sname, ...)		\
-	SYSCALL_METADATAx(syscall, compat_sys_##sname, x, compat_syscall, __VA_ARGS__);\
-	asmlinkage ret syscall(__SC_DECL##x(__VA_ARGS__))
-
-#define __COMPAT_SYSCALL_DEFINE0_RET(ret, syscall, name)		\
-	SYSCALL_METADATA0(syscall, name, compat_syscall)		\
-	asmlinkage ret syscall()
+#define ARCH_COMPAT_SYSCALL_DEFINE0(sname) COMPAT_SYSCALL_DEFINE0_RET(long, sys32_, sname)
+#define ARCH_COMPAT_SYSCALL_DEFINE1(sname, ...) COMPAT_SYSCALL_DEFINEx(1, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE2(sname, ...) COMPAT_SYSCALL_DEFINEx(2, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE3(sname, ...) COMPAT_SYSCALL_DEFINEx(3, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE4(sname, ...) COMPAT_SYSCALL_DEFINEx(4, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE5(sname, ...) COMPAT_SYSCALL_DEFINEx(5, long, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE6(sname, ...) COMPAT_SYSCALL_DEFINEx(6, long, sys32_, sname, __VA_ARGS__)
+
+#define ARCH_COMPAT_SYSCALL_DEFINE0_RET(ret, sname) COMPAT_SYSCALL_DEFINE0_RET(0, ret, sys32_, sname)
+#define ARCH_COMPAT_SYSCALL_DEFINE1_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(1, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE2_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(2, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE3_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(3, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE4_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(4, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE5_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(5, ret, sys32_, sname, __VA_ARGS__)
+#define ARCH_COMPAT_SYSCALL_DEFINE6_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(6, ret, sys32_, sname, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINE0(sname) COMPAT_SYSCALL_DEFINE0_RET(long, compat_sys_, sname)
+#define COMPAT_SYSCALL_DEFINE1(sname, ...) COMPAT_SYSCALL_DEFINEx(1, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE2(sname, ...) COMPAT_SYSCALL_DEFINEx(2, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE3(sname, ...) COMPAT_SYSCALL_DEFINEx(3, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE4(sname, ...) COMPAT_SYSCALL_DEFINEx(4, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE5(sname, ...) COMPAT_SYSCALL_DEFINEx(5, long, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE6(sname, ...) COMPAT_SYSCALL_DEFINEx(6, long, compat_sys_, sname, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINE0_RET(ret, sname) __COMPAT_SYSCALL_DEFINE0(ret, compat_sys_, sname)
+#define COMPAT_SYSCALL_DEFINE1_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(1, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE2_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(2, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE3_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(3, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE4_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(4, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE5_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(5, ret, compat_sys_, sname, __VA_ARGS__)
+#define COMPAT_SYSCALL_DEFINE6_RET(ret, sname, ...) COMPAT_SYSCALL_DEFINEx(6, ret, compat_sys_, sname, __VA_ARGS__)
+
+#define COMPAT_SYSCALL_DEFINEx(x, ret, prefix, sname, ...)		\
+	SYSCALL_METADATAx(prefix, sname, x, compat_syscall, __VA_ARGS__);\
+	asmlinkage ret SYSNAME(prefix, sname)(__SC_DECL##x(__VA_ARGS__))
+
+#define __COMPAT_SYSCALL_DEFINE0_RET(ret, prefix, sname)		\
+	SYSCALL_METADATA0(prefix, sname, compat_syscall)		\
+	asmlinkage ret SYSNAME(prefix, sname)()
 
 #endif /* CONFIG_COMPAT */
 
@@ -268,38 +270,38 @@ extern struct trace_event_functions exit_syscall_print_funcs;
 #endif
 
 #define SYSCALL_DEFINEx(x, ret, sname, ...)				\
-	SYSCALL_METADATAx(sys##sname, sys##sname, x, syscall, __VA_ARGS__);\
+	SYSCALL_METADATAx(sys_, sname, x, syscall, __VA_ARGS__);	\
 	__SYSCALL_DEFINEx(x, ret, sname, __VA_ARGS__)
 
-#define SYSCALL_DEFINE0_RET(ret, name)					\
-	SYSCALL_METADATA0(sys_##name, name, syscall)			\
-	asmlinkage ret sys_##name(void)
+#define SYSCALL_DEFINE0_RET(ret, sname)					\
+	SYSCALL_METADATA0(sys_, sname, syscall)				\
+	asmlinkage ret sys_##sname(void)
 
 #ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
 
-#define SYSCALL_DEFINE(name, x, ...)					\
-	SYSCALL_METADATAx(sys_##name, sys_##name, x, syscall, __VA_ARGS__);\
-	static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__))
+#define SYSCALL_DEFINE(sname, x, ...)					\
+	SYSCALL_METADATAx(sys_, sname, x, syscall, __VA_ARGS__);	\
+	static inline long SYSC_##sname(__SC_DECL##x(__VA_ARGS__))
 
-#define __SYSCALL_DEFINEx(x, ret, name, ...)				\
-	asmlinkage ret sys##name(__SC_DECL##x(__VA_ARGS__));		\
-	static inline ret SYSC##name(__SC_DECL##x(__VA_ARGS__));	\
-	asmlinkage ret SyS##name(__SC_LONG##x(__VA_ARGS__))		\
+#define __SYSCALL_DEFINEx(x, ret, sname, ...)				\
+	asmlinkage ret sys_##sname(__SC_DECL##x(__VA_ARGS__));		\
+	static inline ret SYSC_##sname(__SC_DECL##x(__VA_ARGS__));	\
+	asmlinkage ret SyS_##sname(__SC_LONG##x(__VA_ARGS__))		\
 	{								\
 		__SC_TEST##x(__VA_ARGS__);				\
-		return (ret) SYSC##name(__SC_CAST##x(__VA_ARGS__));	\
+		return (ret) SYSC_##sname(__SC_CAST##x(__VA_ARGS__));	\
 	}								\
-	SYSCALL_ALIAS(sys##name, SyS##name);				\
-	static inline ret SYSC##name(__SC_DECL##x(__VA_ARGS__))
+	SYSCALL_ALIAS(sys_##sname, SyS_##sname);			\
+	static inline ret SYSC_##sname(__SC_DECL##x(__VA_ARGS__))
 
 #else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
 
-#define SYSCALL_DEFINE(name, x, ...)					\
-	SYSCALL_METADATAx(sys_##name, sys_##name, x, syscall, __VA_ARGS__);\
-	asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__))
+#define SYSCALL_DEFINE(sname, x, ...)					\
+	SYSCALL_METADATAx(sys_, sname, x, syscall, __VA_ARGS__);	\
+	asmlinkage long sys_##sname(__SC_DECL##x(__VA_ARGS__))
 
-#define __SYSCALL_DEFINEx(x, ret, name, ...)				\
-	asmlinkage ret sys##name(__SC_DECL##x(__VA_ARGS__))
+#define __SYSCALL_DEFINEx(x, ret, sname, ...)				\
+	asmlinkage ret sys_##sname(__SC_DECL##x(__VA_ARGS__))
 
 #endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* [PATCH 40/40] trace syscalls, PPC: Convert morphing native/compat syscalls
  2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
                   ` (35 preceding siblings ...)
  2010-06-23 10:03 ` [PATCH 39/40] trace syscalls: Clean confusing {s,r,}name and fix ABI breakage Ian Munsie
@ 2010-06-23 10:03 ` Ian Munsie
       [not found] ` <1277287401-28571-32-git-send-email-imunsie@au1.ibm.com>
  37 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-23 10:03 UTC (permalink / raw)
  To: linux-kernel, linuxppc-dev
  Cc: Jason Baron, Frederic Weisbecker, Steven Rostedt, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	Ian Munsie, Andrew Morton, Christoph Hellwig, Chase Douglas,
	Anton Blanchard, Ingo Molnar, Arjan van de Ven, Dave Kleikamp,
	David Gibson

From: Ian Munsie <imunsie@au1.ibm.com>

Several of the PowerPC system call implementations are used as both the
32bit compat version on PPC64 and the 32bit native version on PPC32.

Previousely these used the preprocessor to change the function names on
PPC64 to add the compat_ prefix.

This patch converts these system calls to use the SYSCALL_DEFINE family
of macros, with the preprocessor selecting which macro to use at their
implementation (which should also make things a little clearer, if more
verbose).

This patch also renames the swapcontext syscall and it's assembly
wrapper such that only the first three characters of their names will
differ which ftrace syscalls ignores when matching the syscall names
to their symbol names. This ensures that the appropriate meta-data will
match for this system call.

Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
---
 arch/powerpc/include/asm/systbl.h |    2 +-
 arch/powerpc/kernel/entry_64.S    |    4 +-
 arch/powerpc/kernel/signal_32.c   |   56 +++++++++++++++++++++++++-----------
 3 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 06c0a73..a0afa14 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -252,7 +252,7 @@ COMPAT_SYS_SPU(clock_settime)
 COMPAT_SYS_SPU(clock_gettime)
 COMPAT_SYS_SPU(clock_getres)
 COMPAT_SYS_SPU(clock_nanosleep)
-SYSX(ppc64_swapcontext,ppc32_swapcontext,ppc_swapcontext)
+SYSX(ppc_swapcontext,ppc32_swapcontext,ppc_swapcontext)
 COMPAT_SYS_SPU(tgkill)
 COMPAT_SYS_SPU(utimes)
 COMPAT_SYS_SPU(statfs64)
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 42e9d90..8c23ff1 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -346,10 +346,10 @@ _GLOBAL(ppc_clone)
 
 _GLOBAL(ppc32_swapcontext)
 	bl	.save_nvgprs
-	bl	.compat_sys_swapcontext
+	bl	.sys32_swapcontext
 	b	syscall_exit
 
-_GLOBAL(ppc64_swapcontext)
+_GLOBAL(ppc_swapcontext)
 	bl	.save_nvgprs
 	bl	.sys_swapcontext
 	b	syscall_exit
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index 212583d..2c4071f 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -55,13 +55,6 @@
 #undef DEBUG_SIG
 
 #ifdef CONFIG_PPC64
-#define sys_sigsuspend	compat_sys_sigsuspend
-#define sys_rt_sigsuspend	compat_sys_rt_sigsuspend
-#define sys_rt_sigreturn	compat_sys_rt_sigreturn
-#define sys_sigaction	compat_sys_sigaction
-#define sys_swapcontext	compat_sys_swapcontext
-#define sys_sigreturn	compat_sys_sigreturn
-
 #define old_sigaction	old_sigaction32
 #define sigcontext	sigcontext32
 #define mcontext	mcontext32
@@ -239,7 +232,11 @@ static inline int restore_general_regs(struct pt_regs *regs,
 /*
  * Atomically swap in the new signal mask, and wait for a signal.
  */
-long sys_sigsuspend(old_sigset_t mask)
+#ifdef CONFIG_PPC64
+COMPAT_SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
+#else
+SYSCALL_DEFINE1(sigsuspend, old_sigset_t, mask)
+#endif
 {
 	mask &= _BLOCKABLE;
 	spin_lock_irq(&current->sighand->siglock);
@@ -254,8 +251,15 @@ long sys_sigsuspend(old_sigset_t mask)
  	return -ERESTARTNOHAND;
 }
 
-long sys_sigaction(int sig, struct old_sigaction __user *act,
-		struct old_sigaction __user *oact)
+#ifdef CONFIG_PPC64
+COMPAT_SYSCALL_DEFINE3(sigaction, int, sig,
+		struct old_sigaction __user *, act,
+		struct old_sigaction __user *, oact)
+#else
+SYSCALL_DEFINE3(sigaction, int, sig,
+		struct old_sigaction __user *, act,
+		struct old_sigaction __user *, oact)
+#endif
 {
 	struct k_sigaction new_ka, old_ka;
 	int ret;
@@ -938,9 +942,21 @@ static int do_setcontext(struct ucontext __user *ucp, struct pt_regs *regs, int
 	return 0;
 }
 
-long sys_swapcontext(struct ucontext __user *old_ctx,
-		     struct ucontext __user *new_ctx,
-		     int ctx_size, int r6, int r7, int r8, struct pt_regs *regs)
+/*
+ * Note: Named sys_swapcontext on PPC32 and sys32_swapcontext on PPC64.
+ * Ensures that it's name will still match when compared with it's wrappers
+ * name (ppc_swapcontext on PPC32, ppc32_swapcontext on PPC64) for ftrace
+ * syscalls (which ignores the 1st three characters).
+ */
+#ifdef CONFIG_PPC64
+PPC_REGS_COMPAT_SYSCALL_DEFINEx(3, long, sys32_, swapcontext, regs,
+		struct ucontext __user *, old_ctx,
+		struct ucontext __user *, new_ctx, int, ctx_size)
+#else
+PPC_REGS_SYSCALL_DEFINE3_RET(long, swapcontext, regs,
+		struct ucontext __user *, old_ctx,
+		struct ucontext __user *, new_ctx, int, ctx_size)
+#endif
 {
 	unsigned char tmp;
 	int ctx_has_vsx_region = 0;
@@ -1029,8 +1045,11 @@ long sys_swapcontext(struct ucontext __user *old_ctx,
 	return 0;
 }
 
-long sys_rt_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
-		     struct pt_regs *regs)
+#ifdef CONFIG_PPC64
+PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(long, rt_sigreturn, regs)
+#else
+PPC_REGS_SYSCALL_DEFINE0_RET(long, rt_sigreturn, regs)
+#endif
 {
 	struct rt_sigframe __user *rt_sf;
 
@@ -1256,8 +1275,11 @@ badframe:
 /*
  * Do a signal return; undo the signal stack.
  */
-long sys_sigreturn(int r3, int r4, int r5, int r6, int r7, int r8,
-		       struct pt_regs *regs)
+#ifdef CONFIG_PPC64
+PPC_REGS_COMPAT_SYSCALL_DEFINE0_RET(long, sigreturn, regs)
+#else
+PPC_REGS_SYSCALL_DEFINE0_RET(long, sigreturn, regs)
+#endif
 {
 	struct sigcontext __user *sc;
 	struct sigcontext sigctx;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 56+ messages in thread

* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
  2010-06-23 10:02 ` [PATCH 12/40] x86, compat: convert ia32 layer to use Ian Munsie
@ 2010-06-23 10:14   ` Christoph Hellwig
  2010-06-23 10:36     ` Frederic Weisbecker
  0 siblings, 1 reply; 56+ messages in thread
From: Christoph Hellwig @ 2010-06-23 10:14 UTC (permalink / raw)
  To: Ian Munsie
  Cc: linux-kernel, linuxppc-dev, x86, Frederic Weisbecker,
	Jason Baron, H. Peter Anvin, Greg Ungerer, Steven Rostedt,
	Christoph Hellwig, Ingo Molnar, Paul Mackerras, Russell King,
	Thomas Gleixner, Andrew Morton

Any reason we need to differenciate between COMPAT_SYSCALL_DEFINE and
ARCH_COMPAT_SYSCALL_DEFINE?  We don't need this for native system calls,
so I can't see the reason to do it for compat system calls.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
  2010-06-23 10:14   ` Christoph Hellwig
@ 2010-06-23 10:36     ` Frederic Weisbecker
  2010-06-23 10:46       ` Christoph Hellwig
  0 siblings, 1 reply; 56+ messages in thread
From: Frederic Weisbecker @ 2010-06-23 10:36 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Ian Munsie, linux-kernel, linuxppc-dev, x86, Jason Baron,
	H. Peter Anvin, Greg Ungerer, Steven Rostedt, Ingo Molnar,
	Paul Mackerras, Russell King, Thomas Gleixner, Andrew Morton

On Wed, Jun 23, 2010 at 12:14:02PM +0200, Christoph Hellwig wrote:
> Any reason we need to differenciate between COMPAT_SYSCALL_DEFINE and
> ARCH_COMPAT_SYSCALL_DEFINE?  We don't need this for native system calls,
> so I can't see the reason to do it for compat system calls.
> 


I think we wanted that to keep the sys32_ prefixed based naming, to avoid
collisions with generic compat handler names.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
  2010-06-23 10:36     ` Frederic Weisbecker
@ 2010-06-23 10:46       ` Christoph Hellwig
  2010-06-23 11:41         ` Frederic Weisbecker
  0 siblings, 1 reply; 56+ messages in thread
From: Christoph Hellwig @ 2010-06-23 10:46 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Christoph Hellwig, Ian Munsie, linux-kernel, linuxppc-dev, x86,
	Jason Baron, H. Peter Anvin, Greg Ungerer, Steven Rostedt,
	Ingo Molnar, Paul Mackerras, Russell King, Thomas Gleixner,
	Andrew Morton

On Wed, Jun 23, 2010 at 12:36:21PM +0200, Frederic Weisbecker wrote:
> I think we wanted that to keep the sys32_ prefixed based naming, to avoid
> collisions with generic compat handler names.

For native syscalls we do this by adding a arch prefix inside the
syscall name, e.g.:

arch/s390/kernel/sys_s390.c:SYSCALL_DEFINE(s390_fallocate)(int fd, int mode, loff_t offset,
arch/sparc/kernel/sys_sparc_64.c:SYSCALL_DEFINE1(sparc_pipe_real, struct pt_regs *, regs)


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
  2010-06-23 10:46       ` Christoph Hellwig
@ 2010-06-23 11:41         ` Frederic Weisbecker
  2010-06-23 19:23           ` H. Peter Anvin
  0 siblings, 1 reply; 56+ messages in thread
From: Frederic Weisbecker @ 2010-06-23 11:41 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Ian Munsie, linux-kernel, linuxppc-dev, x86, Jason Baron,
	H. Peter Anvin, Greg Ungerer, Steven Rostedt, Ingo Molnar,
	Paul Mackerras, Russell King, Thomas Gleixner, Andrew Morton

On Wed, Jun 23, 2010 at 12:46:04PM +0200, Christoph Hellwig wrote:
> On Wed, Jun 23, 2010 at 12:36:21PM +0200, Frederic Weisbecker wrote:
> > I think we wanted that to keep the sys32_ prefixed based naming, to avoid
> > collisions with generic compat handler names.
> 
> For native syscalls we do this by adding a arch prefix inside the
> syscall name, e.g.:
> 
> arch/s390/kernel/sys_s390.c:SYSCALL_DEFINE(s390_fallocate)(int fd, int mode, loff_t offset,
> arch/sparc/kernel/sys_sparc_64.c:SYSCALL_DEFINE1(sparc_pipe_real, struct pt_regs *, regs)


In fact we sort of wanted to standardize the name of arch overriden compat
syscalls, so that userspace programs playing with syscalls tracing won't have
to deal with arch naming differences.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls
  2010-06-23 10:02 ` [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
@ 2010-06-23 15:02   ` Steven Rostedt
  2010-06-29  1:18     ` Ian Munsie
  0 siblings, 1 reply; 56+ messages in thread
From: Steven Rostedt @ 2010-06-23 15:02 UTC (permalink / raw)
  To: Ian Munsie
  Cc: linux-kernel, linuxppc-dev, Jason Baron, Frederic Weisbecker,
	Ingo Molnar, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Ingo Molnar, Masami Hiramatsu

On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
> 
> FTRACE_SYSCALLS would create events for each and every system call, even
> if it had failed to map the system call's name with it's number. This
> resulted in a number of events being created that would not behave as
> expected.
> 
> This could happen, for example, on architectures who's symbol names are
> unusual and will not match the system call name. It could also happen
> with system calls which were mapped to sys_ni_syscall.
> 
> This patch changes the default system call number in the metadata to -1.
> If the system call name from the metadata is not successfully mapped to
> a system call number during boot, than the event initialisation routine
> will now return an error, preventing the event from being created.
> 
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---
>  include/linux/syscalls.h      |    2 ++
>  kernel/trace/trace_syscalls.c |    8 ++++++++
>  2 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
> index 7f614ce..86f082b 100644
> --- a/include/linux/syscalls.h
> +++ b/include/linux/syscalls.h
> @@ -159,6 +159,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
>  	  __attribute__((section("__syscalls_metadata")))	\
>  	  __syscall_meta_##sname = {				\
>  		.name 		= "sys"#sname,			\
> +		.syscall_nr	= -1,	/* Filled in at boot */	\
>  		.nb_args 	= nb,				\
>  		.types		= types_##sname,		\
>  		.args		= args_##sname,			\
> @@ -176,6 +177,7 @@ extern struct trace_event_functions exit_syscall_print_funcs;
>  	  __attribute__((section("__syscalls_metadata")))	\
>  	  __syscall_meta__##sname = {				\
>  		.name 		= "sys_"#sname,			\
> +		.syscall_nr	= -1,	/* Filled in at boot */	\
>  		.nb_args 	= 0,				\
>  		.enter_event	= &event_enter__##sname,	\
>  		.exit_event	= &event_exit__##sname,		\
> diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
> index 34e3580..82246ce 100644
> --- a/kernel/trace/trace_syscalls.c
> +++ b/kernel/trace/trace_syscalls.c
> @@ -431,6 +431,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
>  int init_syscall_trace(struct ftrace_event_call *call)
>  {
>  	int id;
> +	int num;
> +
> +	num = ((struct syscall_metadata *)call->data)->syscall_nr;
> +	if (num < 0 || num >= NR_syscalls) {
> +		pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
> +				((struct syscall_metadata *)call->data)->name);
> +		return -ENOSYS;
> +	}

Perhaps this should be:

	if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls)
		return -ENOSYS;

-- Steve

>  
>  	if (set_syscall_print_fmt(call) < 0)
>  		return -ENOMEM;



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support
  2010-06-23 10:02 ` [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support Ian Munsie
@ 2010-06-23 15:16   ` Steven Rostedt
  2010-06-23 19:14     ` Jason Baron
  0 siblings, 1 reply; 56+ messages in thread
From: Steven Rostedt @ 2010-06-23 15:16 UTC (permalink / raw)
  To: Ian Munsie
  Cc: linux-kernel, linuxppc-dev, Jason Baron, Frederic Weisbecker,
	Ingo Molnar, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Ingo Molnar, Lai Jiangshan, Masami Hiramatsu

On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> From: Jason Baron <jbaron@redhat.com>
> 
> 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 <jbaron@redhat.com>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.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 86f082b..755d05b 100644
> --- a/include/linux/syscalls.h
> +++ b/include/linux/syscalls.h
> @@ -163,6 +163,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
>  		.nb_args 	= nb,				\
>  		.types		= types_##sname,		\
>  		.args		= args_##sname,			\
> +		.ftrace_enter	= 0,				\
> +		.ftrace_exit	= 0,				\
> +		.perf_enter	= 0,				\
> +		.perf_exit	= 0,				\

I really hate this change!

You just removed a nice compressed bitmap (1 bit per syscall) to add 4
bytes per syscall. On my box I have 308 syscalls being traced. That was
308 bits per bitmask = 39 bytes * 2 = 78 * 2 (perf and ftrace) = 156.

Now we have 8 bytes per syscall (enter and exit), which is 1232 bytes.

Thus this change added 1076 bytes.

This may not seem as much, but the change is not worth 1K. Can't we just
add another bitmask or something for the compat case?

I also hate the moving of ftrace and perf internal data to an external
interface.

-- Steve

>  		.enter_event	= &event_enter_##sname,		\
>  		.exit_event	= &event_exit_##sname,		\
>  		.enter_fields	= LIST_HEAD_INIT(__syscall_meta_##sname.enter_fields), \
> @@ -179,6 +183,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
>  		.name 		= "sys_"#sname,			\
>  		.syscall_nr	= -1,	/* Filled in at boot */	\
>  		.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_fields	= LIST_HEAD_INIT(__syscall_meta__##sname.enter_fields), \



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 10/40] tracing: add tracing support for compat syscalls
  2010-06-23 10:02 ` [PATCH 10/40] tracing: add tracing support for compat syscalls Ian Munsie
@ 2010-06-23 15:26   ` Steven Rostedt
  2010-06-23 16:02     ` Frederic Weisbecker
  0 siblings, 1 reply; 56+ messages in thread
From: Steven Rostedt @ 2010-06-23 15:26 UTC (permalink / raw)
  To: Ian Munsie
  Cc: linux-kernel, linuxppc-dev, Jason Baron, Frederic Weisbecker,
	Ingo Molnar, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, David S. Miller, Andrew Morton, Arnd Bergmann,
	Lai Jiangshan, Masami Hiramatsu, Li Zefan

On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> From: Jason Baron <jbaron@redhat.com>
> 
> Add 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.
> 
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---
>  include/linux/compat.h        |    2 +
>  include/trace/syscall.h       |    4 ++
>  kernel/trace/trace.h          |    2 +
>  kernel/trace/trace_syscalls.c |   86 +++++++++++++++++++++++++++++++++++++----
>  4 files changed, 86 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/compat.h b/include/linux/compat.h
> index ab638e9..a94f13d 100644
> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -363,6 +363,8 @@ extern ssize_t compat_rw_copy_check_uvector(int type,
>  
>  #else /* CONFIG_COMPAT */
>  
> +#define NR_syscalls_compat 0
> +
>  static inline int is_compat_task(void)
>  {
>  	return 0;
> diff --git a/include/trace/syscall.h b/include/trace/syscall.h
> index 75f3dce..67d4e64 100644
> --- a/include/trace/syscall.h
> +++ b/include/trace/syscall.h
> @@ -22,6 +22,7 @@
>  struct syscall_metadata {
>  	const char	*name;
>  	int		syscall_nr;
> +	int		compat_syscall_nr;

This is also bloating the kernel. I don't like to add fields to the
syscall_metadata lightly.

You're adding 4 more bytes to this structure to handle a few items. Find
a better way to do this.

>  	int		nb_args;
>  	const char	**types;
>  	const char	**args;
> @@ -38,6 +39,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 reg_event_syscall_enter(struct ftrace_event_call *call);
> diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> index 01ce088..53ace4b 100644
> --- a/kernel/trace/trace.h
> +++ b/kernel/trace/trace.h
> @@ -79,12 +79,14 @@ enum trace_type {
>  struct syscall_trace_enter {
>  	struct trace_entry	ent;
>  	int			nr;
> +	int			compat;

You're adding 4 bytes to a trace (taking up precious buffer space) for a
single flag. If anything, set the 31st bit of nr if it is compat.

-- Steve

>  	unsigned long		args[];
>  };
>  
>  struct syscall_trace_exit {
>  	struct trace_entry	ent;
>  	int			nr;
> +	int			compat;
>  	long			ret;
>  };
>  



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 10/40] tracing: add tracing support for compat syscalls
  2010-06-23 15:26   ` Steven Rostedt
@ 2010-06-23 16:02     ` Frederic Weisbecker
  0 siblings, 0 replies; 56+ messages in thread
From: Frederic Weisbecker @ 2010-06-23 16:02 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ian Munsie, linux-kernel, linuxppc-dev, Jason Baron, Ingo Molnar,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	David S. Miller, Andrew Morton, Arnd Bergmann, Lai Jiangshan,
	Masami Hiramatsu, Li Zefan

On Wed, Jun 23, 2010 at 11:26:26AM -0400, Steven Rostedt wrote:
> On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> > From: Jason Baron <jbaron@redhat.com>
> > 
> > Add 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.
> > 
> > Signed-off-by: Jason Baron <jbaron@redhat.com>
> > Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> > ---
> >  include/linux/compat.h        |    2 +
> >  include/trace/syscall.h       |    4 ++
> >  kernel/trace/trace.h          |    2 +
> >  kernel/trace/trace_syscalls.c |   86 +++++++++++++++++++++++++++++++++++++----
> >  4 files changed, 86 insertions(+), 8 deletions(-)
> > 
> > diff --git a/include/linux/compat.h b/include/linux/compat.h
> > index ab638e9..a94f13d 100644
> > --- a/include/linux/compat.h
> > +++ b/include/linux/compat.h
> > @@ -363,6 +363,8 @@ extern ssize_t compat_rw_copy_check_uvector(int type,
> >  
> >  #else /* CONFIG_COMPAT */
> >  
> > +#define NR_syscalls_compat 0
> > +
> >  static inline int is_compat_task(void)
> >  {
> >  	return 0;
> > diff --git a/include/trace/syscall.h b/include/trace/syscall.h
> > index 75f3dce..67d4e64 100644
> > --- a/include/trace/syscall.h
> > +++ b/include/trace/syscall.h
> > @@ -22,6 +22,7 @@
> >  struct syscall_metadata {
> >  	const char	*name;
> >  	int		syscall_nr;
> > +	int		compat_syscall_nr;
> 
> This is also bloating the kernel. I don't like to add fields to the
> syscall_metadata lightly.
> 
> You're adding 4 more bytes to this structure to handle a few items. Find
> a better way to do this.


This is for cases when the compat and normal handlers are the same.
I haven't checked whether such case happen enough to make this a
benefit. I suspect it's not. Moreover I guess this adds more
complexity to the code.

May be this should be simply dropped.



 
> >  	int		nb_args;
> >  	const char	**types;
> >  	const char	**args;
> > @@ -38,6 +39,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 reg_event_syscall_enter(struct ftrace_event_call *call);
> > diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
> > index 01ce088..53ace4b 100644
> > --- a/kernel/trace/trace.h
> > +++ b/kernel/trace/trace.h
> > @@ -79,12 +79,14 @@ enum trace_type {
> >  struct syscall_trace_enter {
> >  	struct trace_entry	ent;
> >  	int			nr;
> > +	int			compat;
> 
> You're adding 4 bytes to a trace (taking up precious buffer space) for a
> single flag. If anything, set the 31st bit of nr if it is compat.



That too can be dropped I think. compat syscalls and normal syscalls are
different events, so the difference can be made in the event id or name.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 39/40] trace syscalls: Clean confusing {s,r,}name and fix ABI breakage
  2010-06-23 10:03 ` [PATCH 39/40] trace syscalls: Clean confusing {s,r,}name and fix ABI breakage Ian Munsie
@ 2010-06-23 18:03   ` Jason Baron
  2010-06-29  1:02     ` Ian Munsie
  0 siblings, 1 reply; 56+ messages in thread
From: Jason Baron @ 2010-06-23 18:03 UTC (permalink / raw)
  To: Ian Munsie
  Cc: linux-kernel, linuxppc-dev, Frederic Weisbecker, Steven Rostedt,
	Ingo Molnar, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Andrew Morton, Christoph Hellwig,
	Jesper Nilsson, David Howells, Ingo Molnar

On Wed, Jun 23, 2010 at 08:03:20PM +1000, Ian Munsie wrote:
> From: Ian Munsie <imunsie@au1.ibm.com>
> 
> This patch cleans up the preprocessor macros defining system calls by
> standidising on the parameters passing around the system call name, with
> and without it's prefix.
> 
> Overall this makes the preprocessor code easier to understand and
> follow and less likely to introduce bugs due to misunderstanding what to
> place into each parameter.
> 
> The parameters henceforth should be named:
> 
> sname is the system call name WITHOUT the prefix (e.g. read)
> prefix is the prefix INCLUDING the trailing underscore (e.g. sys_)
> 
> These are mashed together to form the full syscall name when required
> like blah##prefix##sname. For just prefix##sname please use the provided
> SYSNAME(prefix,sname) macro instead as it will be safe if prefix itself
> is a macro.
> 
> This patch also fixes an ABI breakage - the ftrace events are once again
> named like 'sys_enter_read' instead of 'enter_sys_read'. The rwtop
> script shipped with perf relies on this ABI. Others may as well.
> 
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
> ---

overall this patch is a major improvement! My question though is
about the naming of the compat syscalls in the context of events. I
believe this patch differeniates compat syscall event names as:
"sys32_enter_sname", and "compat_sys_enter_sname". I agree that we keep that
distinction for purposes of defining the actual syscall function. However,
we had discuessed previously about keeping the event name the same for
all compat syscalls. ie they are all called "compat_sys_sname" or some
such. Reason being you could just do "compat_*" to match all compat
events.

thanks,

-Jason


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support
  2010-06-23 15:16   ` Steven Rostedt
@ 2010-06-23 19:14     ` Jason Baron
  2010-06-23 19:34       ` Jason Baron
  0 siblings, 1 reply; 56+ messages in thread
From: Jason Baron @ 2010-06-23 19:14 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ian Munsie, linux-kernel, linuxppc-dev, Frederic Weisbecker,
	Ingo Molnar, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Ingo Molnar, Lai Jiangshan, Masami Hiramatsu

On Wed, Jun 23, 2010 at 11:16:44AM -0400, Steven Rostedt wrote:
> On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> > From: Jason Baron <jbaron@redhat.com>
> > 
> > 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 <jbaron@redhat.com>
> > Signed-off-by: Ian Munsie <imunsie@au1.ibm.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 86f082b..755d05b 100644
> > --- a/include/linux/syscalls.h
> > +++ b/include/linux/syscalls.h
> > @@ -163,6 +163,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
> >  		.nb_args 	= nb,				\
> >  		.types		= types_##sname,		\
> >  		.args		= args_##sname,			\
> > +		.ftrace_enter	= 0,				\
> > +		.ftrace_exit	= 0,				\
> > +		.perf_enter	= 0,				\
> > +		.perf_exit	= 0,				\
> 
> I really hate this change!
> 
> You just removed a nice compressed bitmap (1 bit per syscall) to add 4
> bytes per syscall. On my box I have 308 syscalls being traced. That was
> 308 bits per bitmask = 39 bytes * 2 = 78 * 2 (perf and ftrace) = 156.
> 
> Now we have 8 bytes per syscall (enter and exit), which is 1232 bytes.
> 
> Thus this change added 1076 bytes.
> 
> This may not seem as much, but the change is not worth 1K. Can't we just
> add another bitmask or something for the compat case?
> 
> I also hate the moving of ftrace and perf internal data to an external
> interface.
> 
> -- Steve
> 

I made this change (I also wrote the original bitmap), b/c compat
syscalls can share "regular" syscalls. That is the compat syscall table
points to syscalls from non-compat mode. (looking at ia32 on x86 it
looks like at least half).

Thus, if we continue along the bitmap path, we would have to introduce
another 4 bitmaps for compat. 2 for enter and exit and 2 for perf and
ftrace. Thus, using your math above: 39 bytes * 8 = 312 bytes. So
approximately 1 byte per system call.

Instead, if we store this data in the syscall metadata, we actually only
need 4 bits per syscall. Now, the above implementation uses 4 chars,
where we really only need 1 char (or really 4 bits, which we could
eventually store in the last last bit of the four existing pointer
assuming they are 2 byte aligned for no increased storage space at all).
But even assuming we use 1 byte per system call we are going to have in
the worse case the above 312 bytes + (1 byte * # of non-shared compat
syscalls). So, yes we might need a little more storage in this scheme.
Another consideration too, is obviously the alignment of
syscall_metadata, since the extra 1 byte, might be more...

However, we don't have to compute the location of the bits in the
compat syscall map each time a tracing syscall is enable/disable. This
would be more expensive, especially if we don't store the compat syscall
number with each syscall meta data structure (which you have proposed
dropping). So with compat syscalls, we are setting two bit locations
with each enable/disable instead of 1 with this new scheme.

Also, I think the more important reason to store these bits in the
syscall meta data structure is simplicity. Not all arches start their tables
counting from 0 (requiring a constant shift factor), and obviously we
waste bits for non-implemented syscalls. I don't want to have to deal
with these arch specific implementation issues, if I don't need to.

thanks,

-Jason



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
  2010-06-23 11:41         ` Frederic Weisbecker
@ 2010-06-23 19:23           ` H. Peter Anvin
  2010-06-24 14:37             ` Christoph Hellwig
  0 siblings, 1 reply; 56+ messages in thread
From: H. Peter Anvin @ 2010-06-23 19:23 UTC (permalink / raw)
  To: Frederic Weisbecker
  Cc: Christoph Hellwig, Ian Munsie, linux-kernel, linuxppc-dev, x86,
	Jason Baron, Greg Ungerer, Steven Rostedt, Ingo Molnar,
	Paul Mackerras, Russell King, Thomas Gleixner, Andrew Morton

On 06/23/2010 04:41 AM, Frederic Weisbecker wrote:
> On Wed, Jun 23, 2010 at 12:46:04PM +0200, Christoph Hellwig wrote:
>> On Wed, Jun 23, 2010 at 12:36:21PM +0200, Frederic Weisbecker wrote:
>>> I think we wanted that to keep the sys32_ prefixed based naming, to avoid
>>> collisions with generic compat handler names.
>>
>> For native syscalls we do this by adding a arch prefix inside the
>> syscall name, e.g.:
>>
>> arch/s390/kernel/sys_s390.c:SYSCALL_DEFINE(s390_fallocate)(int fd, int mode, loff_t offset,
>> arch/sparc/kernel/sys_sparc_64.c:SYSCALL_DEFINE1(sparc_pipe_real, struct pt_regs *, regs)
> 
> In fact we sort of wanted to standardize the name of arch overriden compat
> syscalls, so that userspace programs playing with syscalls tracing won't have
> to deal with arch naming differences.
> 

That seems totally wrong in so many ways.

What userspace sees is the system call name, e.g. fallocate or pipe.  It
should *not* be visible to userspace that there is an arch-specici
implementation.

There are already a huge amount of gratuitous user space ABI
differences, of course, partly because we *still* don't actually have a
systematic model for argument passing.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support
  2010-06-23 19:14     ` Jason Baron
@ 2010-06-23 19:34       ` Jason Baron
  2010-06-23 19:45         ` Steven Rostedt
  0 siblings, 1 reply; 56+ messages in thread
From: Jason Baron @ 2010-06-23 19:34 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ian Munsie, linux-kernel, linuxppc-dev, Frederic Weisbecker,
	Ingo Molnar, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Ingo Molnar, Lai Jiangshan, Masami Hiramatsu

On Wed, Jun 23, 2010 at 03:14:54PM -0400, Jason Baron wrote:
> On Wed, Jun 23, 2010 at 11:16:44AM -0400, Steven Rostedt wrote:
> > On Wed, 2010-06-23 at 20:02 +1000, Ian Munsie wrote:
> > > From: Jason Baron <jbaron@redhat.com>
> > > 
> > > 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 <jbaron@redhat.com>
> > > Signed-off-by: Ian Munsie <imunsie@au1.ibm.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 86f082b..755d05b 100644
> > > --- a/include/linux/syscalls.h
> > > +++ b/include/linux/syscalls.h
> > > @@ -163,6 +163,10 @@ extern struct trace_event_functions exit_syscall_print_funcs;
> > >  		.nb_args 	= nb,				\
> > >  		.types		= types_##sname,		\
> > >  		.args		= args_##sname,			\
> > > +		.ftrace_enter	= 0,				\
> > > +		.ftrace_exit	= 0,				\
> > > +		.perf_enter	= 0,				\
> > > +		.perf_exit	= 0,				\
> > 
> > I really hate this change!
> > 
> > You just removed a nice compressed bitmap (1 bit per syscall) to add 4
> > bytes per syscall. On my box I have 308 syscalls being traced. That was
> > 308 bits per bitmask = 39 bytes * 2 = 78 * 2 (perf and ftrace) = 156.
> > 
> > Now we have 8 bytes per syscall (enter and exit), which is 1232 bytes.
> > 
> > Thus this change added 1076 bytes.
> > 
> > This may not seem as much, but the change is not worth 1K. Can't we just
> > add another bitmask or something for the compat case?
> > 
> > I also hate the moving of ftrace and perf internal data to an external
> > interface.
> > 
> > -- Steve
> > 
> 
> I made this change (I also wrote the original bitmap), b/c compat
> syscalls can share "regular" syscalls. That is the compat syscall table
> points to syscalls from non-compat mode. (looking at ia32 on x86 it
> looks like at least half).
> 
> Thus, if we continue along the bitmap path, we would have to introduce
> another 4 bitmaps for compat. 2 for enter and exit and 2 for perf and
> ftrace. Thus, using your math above: 39 bytes * 8 = 312 bytes. So
> approximately 1 byte per system call.
> 
> Instead, if we store this data in the syscall metadata, we actually only
> need 4 bits per syscall. Now, the above implementation uses 4 chars,
> where we really only need 1 char (or really 4 bits, which we could
> eventually store in the last last bit of the four existing pointer
> assuming they are 2 byte aligned for no increased storage space at all).
> But even assuming we use 1 byte per system call we are going to have in
> the worse case the above 312 bytes + (1 byte * # of non-shared compat
> syscalls). So, yes we might need a little more storage in this scheme.
> Another consideration too, is obviously the alignment of
> syscall_metadata, since the extra 1 byte, might be more...
> 
> However, we don't have to compute the location of the bits in the
> compat syscall map each time a tracing syscall is enable/disable. This
> would be more expensive, especially if we don't store the compat syscall
> number with each syscall meta data structure (which you have proposed
> dropping). So with compat syscalls, we are setting two bit locations
> with each enable/disable instead of 1 with this new scheme.
> 
> Also, I think the more important reason to store these bits in the
> syscall meta data structure is simplicity. Not all arches start their tables
> counting from 0 (requiring a constant shift factor), and obviously we
> waste bits for non-implemented syscalls. I don't want to have to deal
> with these arch specific implementation issues, if I don't need to.
> 
> thanks,
> 
> -Jason
> 

Actually, looking at this further, what we probably want to do change
the "int nb_args" field, which is already in syscall_metadata into a bit
field. nb_args I think can be at most 6, or 3 bits, and we only need 4
bits for storing the enabled/disabled data, so we could even make it a
char. Thus, actually saving space with this patch :) (at least as far as
the syscall_metadata field is concerned).

thanks,

-Jason

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support
  2010-06-23 19:34       ` Jason Baron
@ 2010-06-23 19:45         ` Steven Rostedt
  0 siblings, 0 replies; 56+ messages in thread
From: Steven Rostedt @ 2010-06-23 19:45 UTC (permalink / raw)
  To: Jason Baron
  Cc: Ian Munsie, linux-kernel, linuxppc-dev, Frederic Weisbecker,
	Ingo Molnar, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, Ingo Molnar, Lai Jiangshan, Masami Hiramatsu

On Wed, 2010-06-23 at 15:34 -0400, Jason Baron wrote:

> Actually, looking at this further, what we probably want to do change
> the "int nb_args" field, which is already in syscall_metadata into a bit
> field. nb_args I think can be at most 6, or 3 bits, and we only need 4
> bits for storing the enabled/disabled data, so we could even make it a
> char. Thus, actually saving space with this patch :) (at least as far as
> the syscall_metadata field is concerned).

Yeah, I'm fine with turning that into a count/flags field.

-- Steve



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 16/40] tags: recognize compat syscalls
  2010-06-23 10:02 ` [PATCH 16/40] tags: recognize compat syscalls Ian Munsie
@ 2010-06-24 12:02   ` Michal Marek
  0 siblings, 0 replies; 56+ messages in thread
From: Michal Marek @ 2010-06-24 12:02 UTC (permalink / raw)
  To: Ian Munsie
  Cc: linux-kernel, linuxppc-dev, Jason Baron, Frederic Weisbecker,
	Steven Rostedt, Ingo Molnar, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, WANG Cong, John Kacur,
	Andrew Morton, Stefani Seibold

On 23.6.2010 12:02, Ian Munsie wrote:
> From: Jason Baron <jbaron@redhat.com>
> 
> make tags.sh recognize the new syscall macros:
> 
> COMPAT_SYSCALL_DEFINE#N()
> ARCH_COMPAT_SYSCALL_DEFINE#N()
> 
> Signed-off-by: Jason Baron <jbaron@redhat.com>
> Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>

Acked-by: Michal Marek <mmarek@suse.cz>

Michal

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 31/40] trace syscalls: Convert various generic compat syscalls
       [not found]       ` <4C21E3F8.9000405@linux.intel.com>
@ 2010-06-24 12:05         ` Michal Marek
  0 siblings, 0 replies; 56+ messages in thread
From: Michal Marek @ 2010-06-24 12:05 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Frederic Weisbecker, Ian Munsie, linux-kernel, linuxppc-dev,
	Jason Baron, Steven Rostedt, Ingo Molnar, Benjamin Herrenschmidt,
	Paul Mackerras, Michael Ellerman, Alexander Viro, Andrew Morton,
	Jeff Moyer, David Howells, Oleg Nesterov, Arnd Bergmann,
	David S. Miller, Greg Kroah-Hartman, Dinakar Guniguntala,
	Thomas Gleixner, Ingo Molnar, Eric Biederman, Simon Kagstrom,
	WANG Cong, Sam Ravnborg

On 23.6.2010 12:37, Andi Kleen wrote:
> It also has maintenance costs, e.g. I doubt ctags and cscope
> will be able to deal with these kinds of macros, so it has a
> high cost for everyone using these tools.

FWIW, patch 16/40 of this series teaches 'make tags' to recognize these
macros: http://permalink.gmane.org/gmane.linux.kernel/1002103

Michal

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 12/40] x86, compat: convert ia32 layer to use
  2010-06-23 19:23           ` H. Peter Anvin
@ 2010-06-24 14:37             ` Christoph Hellwig
  0 siblings, 0 replies; 56+ messages in thread
From: Christoph Hellwig @ 2010-06-24 14:37 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Frederic Weisbecker, Andrew Morton, Jason Baron, x86,
	linux-kernel, Steven Rostedt, linuxppc-dev, Ingo Molnar,
	Paul Mackerras, Ian Munsie, Greg Ungerer, Russell King,
	Thomas Gleixner, Christoph Hellwig

On Wed, Jun 23, 2010 at 12:23:44PM -0700, H. Peter Anvin wrote:
> >> arch/s390/kernel/sys_s390.c:SYSCALL_DEFINE(s390_fallocate)(int fd, int mode, loff_t offset,
> >> arch/sparc/kernel/sys_sparc_64.c:SYSCALL_DEFINE1(sparc_pipe_real, struct pt_regs *, regs)
> > 
> > In fact we sort of wanted to standardize the name of arch overriden compat
> > syscalls, so that userspace programs playing with syscalls tracing won't have
> > to deal with arch naming differences.
> > 
> 
> That seems totally wrong in so many ways.
> 
> What userspace sees is the system call name, e.g. fallocate or pipe.  It
> should *not* be visible to userspace that there is an arch-specici
> implementation.

This is really just the in-kernel name.  With tracing we export it to
userspace, so agreed that we should stay consistent.  We need a good
way to override both native and compat system calls with arch version
to always export the sys_ / compat_sys names.


^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 39/40] trace syscalls: Clean confusing {s,r,}name and fix ABI breakage
  2010-06-23 18:03   ` Jason Baron
@ 2010-06-29  1:02     ` Ian Munsie
  0 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-29  1:02 UTC (permalink / raw)
  To: Jason Baron
  Cc: Jesper Nilsson, Ingo Molnar, linux-kernel, Steven Rostedt,
	linuxppc-dev, Ingo Molnar, Paul Mackerras, Frederic Weisbecker,
	Andrew Morton, Christoph Hellwig

Excerpts from Jason Baron's message of Thu Jun 24 04:03:54 +1000 2010:
> overall this patch is a major improvement! My question though is
> about the naming of the compat syscalls in the context of events. I
> believe this patch differeniates compat syscall event names as:
> "sys32_enter_sname", and "compat_sys_enter_sname". I agree that we keep that
> distinction for purposes of defining the actual syscall function. However,
> we had discuessed previously about keeping the event name the same for
> all compat syscalls. ie they are all called "compat_sys_sname" or some
> such. Reason being you could just do "compat_*" to match all compat
> events.


Sorry for the delay in replying - I've been pretty busy with other work
over the last few days.

I can certainly change that to name them all compat_sys to be more
consistent. In terms of activating all of them at once that can still be
done fairly easily since they are in their own compat_sys category with
something like "perf record -e 'compat_syscalls:*' ..." or "echo 1 >
/sys/kernel/debug/tracing/events/compat_syscalls/enable".

Ideally I would actually like to consolidate these events with the
ordinary syscall events and just print out compat=0|1 as part of their
output.

Since many of the native syscalls are used as compat syscalls as well I
think that would make a whole lot more sense - at the moment to catch
all syscalls from a compat process both the compat and native syscalls
would need to be activated.

It would also have the benefit of removing any arch specific naming from
userspace, which would make things a lot nicer.

Cheers,
-Ian

^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls
  2010-06-23 15:02   ` Steven Rostedt
@ 2010-06-29  1:18     ` Ian Munsie
  0 siblings, 0 replies; 56+ messages in thread
From: Ian Munsie @ 2010-06-29  1:18 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Jason Baron, linux-kernel, linuxppc-dev, Ingo Molnar,
	Paul Mackerras, Frederic Weisbecker, Ingo Molnar,
	Masami Hiramatsu

Excerpts from Steven Rostedt's message of Thu Jun 24 01:02:19 +1000 2010:
> > diff --git a/kernel/trace/trace_syscalls.c b/kernel/trace/trace_syscalls.c
> > index 34e3580..82246ce 100644
> > --- a/kernel/trace/trace_syscalls.c
> > +++ b/kernel/trace/trace_syscalls.c
> > @@ -431,6 +431,14 @@ void unreg_event_syscall_exit(struct ftrace_event_call *call)
> >  int init_syscall_trace(struct ftrace_event_call *call)
> >  {
> >      int id;
> > +    int num;
> > +
> > +    num = ((struct syscall_metadata *)call->data)->syscall_nr;
> > +    if (num < 0 || num >= NR_syscalls) {
> > +        pr_debug("syscall %s metadata not mapped, disabling ftrace event\n",
> > +                ((struct syscall_metadata *)call->data)->name);
> > +        return -ENOSYS;
> > +    }
> 
> Perhaps this should be:
> 
>     if (WARN_ON_ONCE(num < 0 || num >= NR_syscalls)
>         return -ENOSYS;
> 
> -- Steve


Hi Steven,

I don't think this should produce a warning - it signifies that a
syscall defined in the code has not successfully matched a syscall at
boot.

That may signify the matching failed, but it may just as likely signify
that the syscall isn't used on that arch (for instance, if an arch uses
an arch specific implementation in favour of a generic implementation,
or doesn't implement a particular syscall at all that is defined in the
generic code).

The problem case is actually the other way around - when a syscall
number from an arch's syscall table has not successfully mapped to some
syscall meta-data. Patch #37 prints out those cases with KERN_DEBUG so
booting a kernel with loglevel=8 can track them down.

This pr_debug may still be useful, for example to help locate unused
syscalls which can be removed if no arch uses them.

Cheers,
-Ian

^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2010-06-29  1:19 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-23 10:02 ftrace syscalls, PowerPC: Various fixes, Compat Syscall support and PowerPC implementation, V2 Ian Munsie
2010-06-23 10:02 ` [PATCH 01/40] ftrace syscalls: don't add events for unmapped syscalls Ian Munsie
2010-06-23 15:02   ` Steven Rostedt
2010-06-29  1:18     ` Ian Munsie
2010-06-23 10:02 ` [PATCH 02/40] ftrace syscalls: Make arch_syscall_addr weak Ian Munsie
2010-06-23 10:02 ` [PATCH 03/40] ftrace syscalls: Allow arch specific syscall symbol matching Ian Munsie
2010-06-23 10:02 ` [PATCH 04/40] trace, powerpc: Implement raw syscall tracepoints on PowerPC Ian Munsie
2010-06-23 10:02 ` [PATCH 05/40] x86: add NR_syscalls_compat, make ia32 syscall table visible Ian Munsie
2010-06-23 10:02 ` [PATCH 06/40] x86: add arch_compat_syscall_addr() Ian Munsie
2010-06-23 10:02 ` [PATCH 08/40] tracing: remove syscall bitmaps in preparation for compat support Ian Munsie
2010-06-23 15:16   ` Steven Rostedt
2010-06-23 19:14     ` Jason Baron
2010-06-23 19:34       ` Jason Baron
2010-06-23 19:45         ` Steven Rostedt
2010-06-23 10:02 ` [PATCH 09/40] tracing: move __start_ftrace_events and __stop_ftrace_events to header file Ian Munsie
2010-06-23 10:02 ` [PATCH 10/40] tracing: add tracing support for compat syscalls Ian Munsie
2010-06-23 15:26   ` Steven Rostedt
2010-06-23 16:02     ` Frederic Weisbecker
2010-06-23 10:02 ` [PATCH 11/40] syscalls: add ARCH_COMPAT_SYSCALL_DEFINE() Ian Munsie
2010-06-23 10:02 ` [PATCH 12/40] x86, compat: convert ia32 layer to use Ian Munsie
2010-06-23 10:14   ` Christoph Hellwig
2010-06-23 10:36     ` Frederic Weisbecker
2010-06-23 10:46       ` Christoph Hellwig
2010-06-23 11:41         ` Frederic Weisbecker
2010-06-23 19:23           ` H. Peter Anvin
2010-06-24 14:37             ` Christoph Hellwig
2010-06-23 10:02 ` [PATCH 13/40] syscalls: add new COMPAT_SYSCALL_DEFINE#N() macro Ian Munsie
2010-06-23 10:02 ` [PATCH 14/40] compat: convert to use COMPAT_SYSCALL_DEFINE#N() Ian Munsie
2010-06-23 10:02 ` [PATCH 15/40] compat: convert fs compat to use COMPAT_SYSCALL_DEFINE#N() macros Ian Munsie
2010-06-23 10:02 ` [PATCH 16/40] tags: recognize compat syscalls Ian Munsie
2010-06-24 12:02   ` Michal Marek
2010-06-23 10:02 ` [PATCH 17/40] tracing: make a "compat_syscalls" tracing subsys Ian Munsie
2010-06-23 10:02 ` [PATCH 18/40] compat_syscalls: introduce CONFIG_COMPAT_FTRACE_SYSCALLS Ian Munsie
2010-06-23 10:03 ` [PATCH 19/40] trace syscalls: Remove redundant syscall_nr checks Ian Munsie
2010-06-23 10:03 ` [PATCH 20/40] trace syscalls: Considder compat_syscall_nr when verifying syscall_nr Ian Munsie
2010-06-23 10:03 ` [PATCH 21/40] trace syscalls, PPC: Add ftrace compat syscall support for PPC64 Ian Munsie
2010-06-23 10:03 ` [PATCH 22/40] trace syscalls, PPC: Convert syscalls to SYSCALL_DEFINE Ian Munsie
2010-06-23 10:03 ` [PATCH 23/40] trace syscalls, PPC: Convert ppc32 compat syscalls to COMPAT_SYSCALL Ian Munsie
2010-06-23 10:03 ` [PATCH 24/40] trace syscalls, PPC: Convert more " Ian Munsie
2010-06-23 10:03 ` [PATCH 25/40] trace syscalls: Refactor syscall metadata creation Ian Munsie
2010-06-23 10:03 ` [PATCH 26/40] trace syscalls, PPC: Add PPC_REGS_SYSCALL_DEFINE macros Ian Munsie
2010-06-23 10:03 ` [PATCH 27/40] trace syscalls: Add COMPAT_SYSCALL_DEFINE0 macro Ian Munsie
2010-06-23 10:03 ` [PATCH 28/40] trace syscalls, PPC: Convert syscalls using regs to REGS_SYSCALL_DEFINE macros Ian Munsie
2010-06-23 10:03 ` [PATCH 29/40] trace syscalls, PPC: Convert ppc32_ syscalls to ARCH_COMPAT_SYSCALL_DEFINE Ian Munsie
2010-06-23 10:03 ` [PATCH 30/40] trace syscalls: Convert remaining kernel/compat.c syscalls to COMPAT_SYSCALL_DEFINE Ian Munsie
2010-06-23 10:03 ` [PATCH 33/40] trace syscalls: Infrastructure for syscalls different return types Ian Munsie
2010-06-23 10:03 ` [PATCH 34/40] trace syscalls: Convert generic syscalls without long return type Ian Munsie
2010-06-23 10:03 ` [PATCH 35/40] trace syscalls, PPC: Convert PPC syscalls without long return types Ian Munsie
2010-06-23 10:03 ` [PATCH 36/40] trace syscalls: Early terminate search for sys_ni_syscall Ian Munsie
2010-06-23 10:03 ` [PATCH 37/40] trace syscalls: Print out unmapped syscalls at boot Ian Munsie
2010-06-23 10:03 ` [PATCH 38/40] trace syscalls: Remove redundant test for unmapped compat syscalls Ian Munsie
2010-06-23 10:03 ` [PATCH 39/40] trace syscalls: Clean confusing {s,r,}name and fix ABI breakage Ian Munsie
2010-06-23 18:03   ` Jason Baron
2010-06-29  1:02     ` Ian Munsie
2010-06-23 10:03 ` [PATCH 40/40] trace syscalls, PPC: Convert morphing native/compat syscalls Ian Munsie
     [not found] ` <1277287401-28571-32-git-send-email-imunsie@au1.ibm.com>
     [not found]   ` <4C21DFBA.2070202@linux.intel.com>
     [not found]     ` <20100623102931.GB5242@nowhere>
     [not found]       ` <4C21E3F8.9000405@linux.intel.com>
2010-06-24 12:05         ` [PATCH 31/40] trace syscalls: Convert various generic compat syscalls Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).