linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] kill __KERNEL_SYSCALLS__
@ 2006-08-27 21:47 Arnd Bergmann
  2006-08-27 21:47 ` [PATCH 2/7] rename the provided execve functions to kernel_execve Arnd Bergmann
                   ` (9 more replies)
  0 siblings, 10 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-27 21:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty

Ok, next try. This time a full series that tries to kill
off __KERNEL_SYSCALLS__, _syscallX() and the global errno
for good.

Practically no testing so far, so please check if this
makes sense first before applying.

I'd especially like the arch maintainers to provide
better implementations of kernel_execve, since I had to
rely on the inline assembly provided from _syscall3 to
implement them instead of doing it the right way.

	Arnd <><


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

* [PATCH 2/7] rename the provided execve functions to kernel_execve
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
@ 2006-08-27 21:47 ` Arnd Bergmann
  2006-08-28  2:20   ` Randy.Dunlap
  2006-08-27 21:47 ` [PATCH 3/7] provide kernel_execve on all architectures Arnd Bergmann
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-27 21:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty

[-- Attachment #1: kernel_execve.diff --]
[-- Type: text/plain, Size: 48813 bytes --]

Some architectures provide an execve function that does not
set errno, but instead returns the result code directly.
Rename these to kernel_execve to get the right semantics there.
Moreover, there is no reasone for any of these architectures to
still provide __KERNEL_SYSCALLS__ or _syscallN macros, so
remove these right away.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/arch/x86_64/kernel/entry.S
===================================================================
--- linux-cg.orig/arch/x86_64/kernel/entry.S	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/x86_64/kernel/entry.S	2006-08-27 23:36:42.000000000 +0200
@@ -1000,7 +1000,7 @@
  * do_sys_execve asm fallback arguments:
  *	rdi: name, rsi: argv, rdx: envp, fake frame on the stack
  */
-ENTRY(execve)
+ENTRY(kernel_execve)
 	CFI_STARTPROC
 	FAKE_STACK_FRAME $0
 	SAVE_ALL	
@@ -1013,7 +1013,7 @@
 	UNFAKE_STACK_FRAME
 	ret
 	CFI_ENDPROC
-ENDPROC(execve)
+ENDPROC(kernel_execve)
 
 KPROBE_ENTRY(page_fault)
 	errorentry do_page_fault
Index: linux-cg/drivers/sbus/char/bbc_envctrl.c
===================================================================
--- linux-cg.orig/drivers/sbus/char/bbc_envctrl.c	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/drivers/sbus/char/bbc_envctrl.c	2006-08-27 23:36:42.000000000 +0200
@@ -4,9 +4,6 @@
  * Copyright (C) 2001 David S. Miller (davem@redhat.com)
  */
 
-#define __KERNEL_SYSCALLS__
-static int errno;
-
 #include <linux/kernel.h>
 #include <linux/kthread.h>
 #include <linux/sched.h>
@@ -200,7 +197,7 @@
 	printk(KERN_CRIT "kenvctrld: Shutting down the system now.\n");
 
 	shutting_down = 1;
-	if (execve("/sbin/shutdown", argv, envp) < 0)
+	if (kernel_execve("/sbin/shutdown", argv, envp) < 0)
 		printk(KERN_CRIT "envctrl: shutdown execution failed\n");
 }
 
Index: linux-cg/drivers/sbus/char/envctrl.c
===================================================================
--- linux-cg.orig/drivers/sbus/char/envctrl.c	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/drivers/sbus/char/envctrl.c	2006-08-27 23:36:42.000000000 +0200
@@ -19,9 +19,6 @@
  *              Daniele Bellucci <bellucda@tiscali.it>
  */
 
-#define __KERNEL_SYSCALLS__
-static int errno;
-
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/kthread.h>
@@ -982,7 +979,7 @@
 
 	inprog = 1;
 	printk(KERN_CRIT "kenvctrld: WARNING: Shutting down the system now.\n");
-	if (0 > execve("/sbin/shutdown", argv, envp)) {
+	if (0 > kernel_execve("/sbin/shutdown", argv, envp)) {
 		printk(KERN_CRIT "kenvctrld: WARNING: system shutdown failed!\n"); 
 		inprog = 0;  /* unlikely to succeed, but we could try again */
 	}
Index: linux-cg/include/asm-x86_64/unistd.h
===================================================================
--- linux-cg.orig/include/asm-x86_64/unistd.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/asm-x86_64/unistd.h	2006-08-27 23:36:42.000000000 +0200
@@ -626,19 +626,6 @@
 
 #ifndef __NO_STUBS
 
-/* user-visible error numbers are in the range -1 - -4095 */
-
-#define __syscall_clobber "r11","rcx","memory" 
-
-#define __syscall_return(type, res) \
-do { \
-	if ((unsigned long)(res) >= (unsigned long)(-127)) { \
-		errno = -(res); \
-		res = -1; \
-	} \
-	return (type) (res); \
-} while (0)
-
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
 #define __ARCH_WANT_SYS_ALARM
@@ -661,168 +648,6 @@
 #define __ARCH_WANT_SYS_TIME
 #define __ARCH_WANT_COMPAT_SYS_TIME
 
-#ifndef __KERNEL_SYSCALLS__
-
-#define __syscall "syscall"
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-	: "=a" (__res) \
-	: "0" (__NR_##name) : __syscall_clobber ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"D" ((long)(arg1)) : __syscall_clobber ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)) : __syscall_clobber ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ volatile (__syscall \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
-		  "d" ((long)(arg3)) : __syscall_clobber); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-__asm__ volatile ("movq %5,%%r10 ;" __syscall \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
-	  "d" ((long)(arg3)),"g" ((long)(arg4)) : __syscall_clobber,"r10" ); \
-__syscall_return(type,__res); \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	  type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
-	  "d" ((long)(arg3)),"g" ((long)(arg4)),"g" ((long)(arg5)) : \
-	__syscall_clobber,"r8","r10" ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	  type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-long __res; \
-__asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; movq %7,%%r9 ; " __syscall \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"D" ((long)(arg1)),"S" ((long)(arg2)), \
-	  "d" ((long)(arg3)), "g" ((long)(arg4)), "g" ((long)(arg5)), \
-	  "g" ((long)(arg6)) : \
-	__syscall_clobber,"r8","r10","r9" ); \
-__syscall_return(type,__res); \
-}
-
-#else /* __KERNEL_SYSCALLS__ */
-
-#include <linux/syscalls.h>
-#include <asm/ptrace.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-
-static inline pid_t setsid(void)
-{
-	return sys_setsid();
-}
-
-static inline ssize_t write(unsigned int fd, char * buf, size_t count)
-{
-	return sys_write(fd, buf, count);
-}
-
-static inline ssize_t read(unsigned int fd, char * buf, size_t count)
-{
-	return sys_read(fd, buf, count);
-}
-
-static inline off_t lseek(unsigned int fd, off_t offset, unsigned int origin)
-{
-	return sys_lseek(fd, offset, origin);
-}
-
-static inline long dup(unsigned int fd)
-{
-	return sys_dup(fd);
-}
-
-/* implemented in asm in arch/x86_64/kernel/entry.S */
-extern int execve(const char *, char * const *, char * const *);
-
-static inline long open(const char * filename, int flags, int mode)
-{
-	return sys_open(filename, flags, mode);
-}
-
-static inline long close(unsigned int fd)
-{
-	return sys_close(fd);
-}
-
-static inline pid_t waitpid(int pid, int * wait_stat, int flags)
-{
-	return sys_wait4(pid, wait_stat, flags, NULL);
-}
-
-extern long sys_mmap(unsigned long addr, unsigned long len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long off);
-
-extern int sys_modify_ldt(int func, void *ptr, unsigned long bytecount);
-
-asmlinkage long sys_execve(char *name, char **argv, char **envp,
-			struct pt_regs regs);
-asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp,
-			void *parent_tid, void *child_tid,
-			struct pt_regs regs);
-asmlinkage long sys_fork(struct pt_regs regs);
-asmlinkage long sys_vfork(struct pt_regs regs);
-asmlinkage long sys_pipe(int *fildes);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 #ifndef __ASSEMBLY__
 
 #include <linux/linkage.h>
Index: linux-cg/arch/alpha/kernel/entry.S
===================================================================
--- linux-cg.orig/arch/alpha/kernel/entry.S	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/alpha/kernel/entry.S	2006-08-27 23:36:42.000000000 +0200
@@ -655,12 +655,12 @@
 .end kernel_thread
 
 /*
- * execve(path, argv, envp)
+ * kernel_execve(path, argv, envp)
  */
 	.align	4
-	.globl	execve
-	.ent	execve
-execve:
+	.globl	kernel_execve
+	.ent	kernel_execve
+kernel_execve:
 	/* We can be called from a module.  */
 	ldgp	$gp, 0($27)
 	lda	$sp, -(32+SIZEOF_PT_REGS+8)($sp)
@@ -704,7 +704,7 @@
 
 1:	lda	$sp, 32+SIZEOF_PT_REGS+8($sp)
 	ret
-.end execve
+.end kernel_execve
 
 \f
 /*
Index: linux-cg/arch/arm/kernel/sys_arm.c
===================================================================
--- linux-cg.orig/arch/arm/kernel/sys_arm.c	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/arm/kernel/sys_arm.c	2006-08-27 23:36:42.000000000 +0200
@@ -279,7 +279,7 @@
 	return error;
 }
 
-long execve(const char *filename, char **argv, char **envp)
+int kernel_execve(const char *filename, char *const argv[], char *const envp[]);
 {
 	struct pt_regs regs;
 	int ret;
@@ -317,7 +317,7 @@
  out:
 	return ret;
 }
-EXPORT_SYMBOL(execve);
+EXPORT_SYMBOL(kernel_execve);
 
 /*
  * Since loff_t is a 64 bit type we avoid a lot of ABI hastle
Index: linux-cg/arch/arm26/kernel/sys_arm.c
===================================================================
--- linux-cg.orig/arch/arm26/kernel/sys_arm.c	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/arm26/kernel/sys_arm.c	2006-08-27 23:36:42.000000000 +0200
@@ -283,7 +283,7 @@
 }
 
 /* FIXME - see if this is correct for arm26 */
-long execve(const char *filename, char **argv, char **envp)
+int kernel_execve(const char *filename, char *const argv[], char *const envp[]);
 {
 	struct pt_regs regs;
         int ret;
@@ -320,4 +320,4 @@
         return ret;
 }
 
-EXPORT_SYMBOL(execve);
+EXPORT_SYMBOL(kernel_execve);
Index: linux-cg/arch/powerpc/kernel/misc_32.S
===================================================================
--- linux-cg.orig/arch/powerpc/kernel/misc_32.S	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/powerpc/kernel/misc_32.S	2006-08-27 23:36:42.000000000 +0200
@@ -843,7 +843,7 @@
 	addi	r1,r1,16
 	blr
 
-_GLOBAL(execve)
+_GLOBAL(kernel_execve)
 	li	r0,__NR_execve
 	sc
 	bnslr
Index: linux-cg/arch/powerpc/kernel/misc_64.S
===================================================================
--- linux-cg.orig/arch/powerpc/kernel/misc_64.S	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/powerpc/kernel/misc_64.S	2006-08-27 23:36:42.000000000 +0200
@@ -556,7 +556,7 @@
 
 #endif /* CONFIG_ALTIVEC */
 
-_GLOBAL(execve)
+_GLOBAL(kernel_execve)
 	li	r0,__NR_execve
 	sc
 	bnslr
Index: linux-cg/include/asm-alpha/unistd.h
===================================================================
--- linux-cg.orig/include/asm-alpha/unistd.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/asm-alpha/unistd.h	2006-08-27 23:36:42.000000000 +0200
@@ -387,188 +387,6 @@
 
 #define NR_SYSCALLS			447
 
-#if defined(__GNUC__)
-
-#define _syscall_return(type)						\
-	return (_sc_err ? errno = _sc_ret, _sc_ret = -1L : 0), (type) _sc_ret
-
-#define _syscall_clobbers						\
-	"$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8",			\
-	"$22", "$23", "$24", "$25", "$27", "$28" 			\
-
-#define _syscall0(type, name)						\
-type name(void)								\
-{									\
-	long _sc_ret, _sc_err;						\
-	{								\
-		register long _sc_0 __asm__("$0");			\
-		register long _sc_19 __asm__("$19");			\
-									\
-		_sc_0 = __NR_##name;					\
-		__asm__("callsys # %0 %1 %2"				\
-			: "=r"(_sc_0), "=r"(_sc_19)			\
-			: "0"(_sc_0)					\
-			: _syscall_clobbers);				\
-		_sc_ret = _sc_0, _sc_err = _sc_19;			\
-	}								\
-	_syscall_return(type);						\
-}
-
-#define _syscall1(type,name,type1,arg1)					\
-type name(type1 arg1)							\
-{									\
-	long _sc_ret, _sc_err;						\
-	{								\
-		register long _sc_0 __asm__("$0");			\
-		register long _sc_16 __asm__("$16");			\
-		register long _sc_19 __asm__("$19");			\
-									\
-		_sc_0 = __NR_##name;					\
-		_sc_16 = (long) (arg1);					\
-		__asm__("callsys # %0 %1 %2 %3"				\
-			: "=r"(_sc_0), "=r"(_sc_19)			\
-			: "0"(_sc_0), "r"(_sc_16)			\
-			: _syscall_clobbers);				\
-		_sc_ret = _sc_0, _sc_err = _sc_19;			\
-	}								\
-	_syscall_return(type);						\
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)			\
-type name(type1 arg1,type2 arg2)					\
-{									\
-	long _sc_ret, _sc_err;						\
-	{								\
-		register long _sc_0 __asm__("$0");			\
-		register long _sc_16 __asm__("$16");			\
-		register long _sc_17 __asm__("$17");			\
-		register long _sc_19 __asm__("$19");			\
-									\
-		_sc_0 = __NR_##name;					\
-		_sc_16 = (long) (arg1);					\
-		_sc_17 = (long) (arg2);					\
-		__asm__("callsys # %0 %1 %2 %3 %4"			\
-			: "=r"(_sc_0), "=r"(_sc_19)			\
-			: "0"(_sc_0), "r"(_sc_16), "r"(_sc_17)		\
-			: _syscall_clobbers);				\
-		_sc_ret = _sc_0, _sc_err = _sc_19;			\
-	}								\
-	_syscall_return(type);						\
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)		\
-type name(type1 arg1,type2 arg2,type3 arg3)				\
-{									\
-	long _sc_ret, _sc_err;						\
-	{								\
-		register long _sc_0 __asm__("$0");			\
-		register long _sc_16 __asm__("$16");			\
-		register long _sc_17 __asm__("$17");			\
-		register long _sc_18 __asm__("$18");			\
-		register long _sc_19 __asm__("$19");			\
-									\
-		_sc_0 = __NR_##name;					\
-		_sc_16 = (long) (arg1);					\
-		_sc_17 = (long) (arg2);					\
-		_sc_18 = (long) (arg3);					\
-		__asm__("callsys # %0 %1 %2 %3 %4 %5"			\
-			: "=r"(_sc_0), "=r"(_sc_19)			\
-			: "0"(_sc_0), "r"(_sc_16), "r"(_sc_17),		\
-			  "r"(_sc_18)					\
-			: _syscall_clobbers);				\
-		_sc_ret = _sc_0, _sc_err = _sc_19;			\
-	}								\
-	_syscall_return(type);						\
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4)		 \
-{									 \
-	long _sc_ret, _sc_err;						\
-	{								\
-		register long _sc_0 __asm__("$0");			\
-		register long _sc_16 __asm__("$16");			\
-		register long _sc_17 __asm__("$17");			\
-		register long _sc_18 __asm__("$18");			\
-		register long _sc_19 __asm__("$19");			\
-									\
-		_sc_0 = __NR_##name;					\
-		_sc_16 = (long) (arg1);					\
-		_sc_17 = (long) (arg2);					\
-		_sc_18 = (long) (arg3);					\
-		_sc_19 = (long) (arg4);					\
-		__asm__("callsys # %0 %1 %2 %3 %4 %5 %6"		\
-			: "=r"(_sc_0), "=r"(_sc_19)			\
-			: "0"(_sc_0), "r"(_sc_16), "r"(_sc_17),		\
-			  "r"(_sc_18), "1"(_sc_19)			\
-			: _syscall_clobbers);				\
-		_sc_ret = _sc_0, _sc_err = _sc_19;			\
-	}								\
-	_syscall_return(type);						\
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	  type5,arg5)							 \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5)	\
-{									\
-	long _sc_ret, _sc_err;						\
-	{								\
-		register long _sc_0 __asm__("$0");			\
-		register long _sc_16 __asm__("$16");			\
-		register long _sc_17 __asm__("$17");			\
-		register long _sc_18 __asm__("$18");			\
-		register long _sc_19 __asm__("$19");			\
-		register long _sc_20 __asm__("$20");			\
-									\
-		_sc_0 = __NR_##name;					\
-		_sc_16 = (long) (arg1);					\
-		_sc_17 = (long) (arg2);					\
-		_sc_18 = (long) (arg3);					\
-		_sc_19 = (long) (arg4);					\
-		_sc_20 = (long) (arg5);					\
-		__asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7"		\
-			: "=r"(_sc_0), "=r"(_sc_19)			\
-			: "0"(_sc_0), "r"(_sc_16), "r"(_sc_17),		\
-			  "r"(_sc_18), "1"(_sc_19), "r"(_sc_20)		\
-			: _syscall_clobbers);				\
-		_sc_ret = _sc_0, _sc_err = _sc_19;			\
-	}								\
-	_syscall_return(type);						\
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	  type5,arg5,type6,arg6)					 \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6)\
-{									\
-	long _sc_ret, _sc_err;						\
-	{								\
-		register long _sc_0 __asm__("$0");			\
-		register long _sc_16 __asm__("$16");			\
-		register long _sc_17 __asm__("$17");			\
-		register long _sc_18 __asm__("$18");			\
-		register long _sc_19 __asm__("$19");			\
-		register long _sc_20 __asm__("$20");			\
-		register long _sc_21 __asm__("$21");			\
-									\
-		_sc_0 = __NR_##name;					\
-		_sc_16 = (long) (arg1);					\
-		_sc_17 = (long) (arg2);					\
-		_sc_18 = (long) (arg3);					\
-		_sc_19 = (long) (arg4);					\
-		_sc_20 = (long) (arg5);					\
-		_sc_21 = (long) (arg6);					\
-		__asm__("callsys # %0 %1 %2 %3 %4 %5 %6 %7 %8"		\
-			: "=r"(_sc_0), "=r"(_sc_19)			\
-			: "0"(_sc_0), "r"(_sc_16), "r"(_sc_17),		\
-			  "r"(_sc_18), "1"(_sc_19), "r"(_sc_20), "r"(_sc_21) \
-			: _syscall_clobbers);				\
-		_sc_ret = _sc_0, _sc_err = _sc_19;			\
-	}								\
-	_syscall_return(type);						\
-}
-
-#endif /* __GNUC__ */
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
@@ -580,75 +398,6 @@
 #define __ARCH_WANT_SYS_OLDUMOUNT
 #define __ARCH_WANT_SYS_SIGPENDING
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/string.h>
-#include <linux/signal.h>
-#include <linux/syscalls.h>
-#include <asm/ptrace.h>
-
-static inline long open(const char * name, int mode, int flags)
-{
-	return sys_open(name, mode, flags);
-}
-
-static inline long dup(int fd)
-{
-	return sys_dup(fd);
-}
-
-static inline long close(int fd)
-{
-	return sys_close(fd);
-}
-
-static inline off_t lseek(int fd, off_t off, int whence)
-{
-	return sys_lseek(fd, off, whence);
-}
-
-static inline void _exit(int value)
-{
-	sys_exit(value);
-}
-
-#define exit(x) _exit(x)
-
-static inline long write(int fd, const char * buf, size_t nr)
-{
-	return sys_write(fd, buf, nr);
-}
-
-static inline long read(int fd, char * buf, size_t nr)
-{
-	return sys_read(fd, buf, nr);
-}
-
-extern int execve(char *, char **, char **);
-
-static inline long setsid(void)
-{
-	return sys_setsid();
-}
-
-static inline pid_t waitpid(int pid, int * wait_stat, int flags)
-{
-	return sys_wait4(pid, wait_stat, flags, NULL);
-}
-
-asmlinkage int sys_execve(char *ufilename, char **argv, char **envp,
-			unsigned long a3, unsigned long a4, unsigned long a5,
-			struct pt_regs regs);
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize,
-				void *restorer);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /* "Conditional" syscalls.  What we want is
 
 	__attribute__((weak,alias("sys_ni_syscall")))
Index: linux-cg/include/asm-arm/unistd.h
===================================================================
--- linux-cg.orig/include/asm-arm/unistd.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/asm-arm/unistd.h	2006-08-27 23:36:42.000000000 +0200
@@ -377,155 +377,6 @@
 #endif
 
 #ifdef __KERNEL__
-#include <linux/linkage.h>
-
-#define __sys2(x) #x
-#define __sys1(x) __sys2(x)
-
-#ifndef __syscall
-#if defined(__thumb__) || defined(__ARM_EABI__)
-#define __SYS_REG(name) register long __sysreg __asm__("r7") = __NR_##name;
-#define __SYS_REG_LIST(regs...) "r" (__sysreg) , ##regs
-#define __syscall(name) "swi\t0"
-#else
-#define __SYS_REG(name)
-#define __SYS_REG_LIST(regs...) regs
-#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
-#endif
-#endif
-
-#define __syscall_return(type, res)					\
-do {									\
-	if ((unsigned long)(res) >= (unsigned long)(-129)) {		\
-		errno = -(res);						\
-		res = -1;						\
-	}								\
-	return (type) (res);						\
-} while (0)
-
-#define _syscall0(type,name)						\
-type name(void) {							\
-  __SYS_REG(name)							\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: __SYS_REG_LIST()						\
-	: "memory" );							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-#define _syscall1(type,name,type1,arg1) 				\
-type name(type1 arg1) { 						\
-  __SYS_REG(name)							\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: __SYS_REG_LIST( "0" (__r0) )					\
-	: "memory" );							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)			\
-type name(type1 arg1,type2 arg2) {					\
-  __SYS_REG(name)							\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: __SYS_REG_LIST( "0" (__r0), "r" (__r1) )			\
-	: "memory" );							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)		\
-type name(type1 arg1,type2 arg2,type3 arg3) {				\
-  __SYS_REG(name)							\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __r2 __asm__("r2") = (long)arg3;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2) )		\
-	: "memory" );							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) {		\
-  __SYS_REG(name)							\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __r2 __asm__("r2") = (long)arg3;			\
-  register long __r3 __asm__("r3") = (long)arg4;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2), "r" (__r3) ) \
-	: "memory" );							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-  
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5)	\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) {	\
-  __SYS_REG(name)							\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __r2 __asm__("r2") = (long)arg3;			\
-  register long __r3 __asm__("r3") = (long)arg4;			\
-  register long __r4 __asm__("r4") = (long)arg5;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2),		\
-			  "r" (__r3), "r" (__r4) )			\
-	: "memory" );							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6)	\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) {	\
-  __SYS_REG(name)							\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __r2 __asm__("r2") = (long)arg3;			\
-  register long __r3 __asm__("r3") = (long)arg4;			\
-  register long __r4 __asm__("r4") = (long)arg5;			\
-  register long __r5 __asm__("r5") = (long)arg6;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: __SYS_REG_LIST( "0" (__r0), "r" (__r1), "r" (__r2),		\
-			  "r" (__r3), "r" (__r4), "r" (__r5) )		\
-	: "memory" );							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_STAT64
@@ -548,30 +399,6 @@
 #define __ARCH_WANT_SYS_SOCKETCALL
 #endif
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/syscalls.h>
-
-extern long execve(const char *file, char **argv, char **envp);
-
-struct pt_regs;
-asmlinkage int sys_execve(char *filenamei, char **argv, char **envp,
-			struct pt_regs *regs);
-asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
-			struct pt_regs *regs);
-asmlinkage int sys_fork(struct pt_regs *regs);
-asmlinkage int sys_vfork(struct pt_regs *regs);
-asmlinkage int sys_pipe(unsigned long *fildes);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-arm26/unistd.h
===================================================================
--- linux-cg.orig/include/asm-arm26/unistd.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/asm-arm26/unistd.h	2006-08-27 23:36:42.000000000 +0200
@@ -311,138 +311,6 @@
 #define __ARM_NR_usr26			(__ARM_NR_BASE+3)
 
 #ifdef __KERNEL__
-#include <linux/linkage.h>
-
-#define __sys2(x) #x
-#define __sys1(x) __sys2(x)
-
-#ifndef __syscall
-#define __syscall(name) "swi\t" __sys1(__NR_##name) ""
-#endif
-
-#define __syscall_return(type, res)					\
-do {									\
-	if ((unsigned long)(res) >= (unsigned long)(-125)) {		\
-		errno = -(res);						\
-		res = -1;						\
-	}								\
-	return (type) (res);						\
-} while (0)
-
-#define _syscall0(type,name)						\
-type name(void) {							\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	:								\
-	: "lr");							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-#define _syscall1(type,name,type1,arg1) 				\
-type name(type1 arg1) { 						\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: "r" (__r0)							\
-	: "lr");							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)			\
-type name(type1 arg1,type2 arg2) {					\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: "r" (__r0),"r" (__r1) 					\
-	: "lr");							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)		\
-type name(type1 arg1,type2 arg2,type3 arg3) {				\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __r2 __asm__("r2") = (long)arg3;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: "r" (__r0),"r" (__r1),"r" (__r2)				\
-	: "lr");							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) {		\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __r2 __asm__("r2") = (long)arg3;			\
-  register long __r3 __asm__("r3") = (long)arg4;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3)			\
-	: "lr");							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-  
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5)	\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) {	\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __r2 __asm__("r2") = (long)arg3;			\
-  register long __r3 __asm__("r3") = (long)arg4;			\
-  register long __r4 __asm__("r4") = (long)arg5;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3),"r" (__r4)	\
-	: "lr");							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6)	\
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) {	\
-  register long __r0 __asm__("r0") = (long)arg1;			\
-  register long __r1 __asm__("r1") = (long)arg2;			\
-  register long __r2 __asm__("r2") = (long)arg3;			\
-  register long __r3 __asm__("r3") = (long)arg4;			\
-  register long __r4 __asm__("r4") = (long)arg5;			\
-  register long __r5 __asm__("r5") = (long)arg6;			\
-  register long __res_r0 __asm__("r0");					\
-  long __res;								\
-  __asm__ __volatile__ (						\
-  __syscall(name)							\
-	: "=r" (__res_r0)						\
-	: "r" (__r0),"r" (__r1),"r" (__r2),"r" (__r3), "r" (__r4),"r" (__r5)		\
-	: "lr");							\
-  __res = __res_r0;							\
-  __syscall_return(type,__res);						\
-}
 
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
@@ -463,30 +331,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/syscalls.h>
-
-extern long execve(const char *file, char **argv, char **envp);
-
-struct pt_regs;
-asmlinkage int sys_execve(char *filenamei, char **argv, char **envp,
-			struct pt_regs *regs);
-asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
-			struct pt_regs *regs);
-asmlinkage int sys_fork(struct pt_regs *regs);
-asmlinkage int sys_vfork(struct pt_regs *regs);
-asmlinkage int sys_pipe(unsigned long *fildes);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-parisc/unistd.h
===================================================================
--- linux-cg.orig/include/asm-parisc/unistd.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/asm-parisc/unistd.h	2006-08-27 23:36:42.000000000 +0200
@@ -795,141 +795,6 @@
 #ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
-#define SYS_ify(syscall_name)   __NR_##syscall_name
-
-#ifndef ASM_LINE_SEP
-# define ASM_LINE_SEP ;
-#endif
-
-/* Definition taken from glibc 2.3.3
- * sysdeps/unix/sysv/linux/hppa/sysdep.h
- */
-
-#ifdef PIC
-/* WARNING: CANNOT BE USED IN A NOP! */
-# define K_STW_ASM_PIC	"       copy %%r19, %%r4\n"
-# define K_LDW_ASM_PIC	"       copy %%r4, %%r19\n"
-# define K_USING_GR4	"%r4",
-#else
-# define K_STW_ASM_PIC	" \n"
-# define K_LDW_ASM_PIC	" \n"
-# define K_USING_GR4
-#endif
-
-/* GCC has to be warned that a syscall may clobber all the ABI
-   registers listed as "caller-saves", see page 8, Table 2
-   in section 2.2.6 of the PA-RISC RUN-TIME architecture
-   document. However! r28 is the result and will conflict with
-   the clobber list so it is left out. Also the input arguments
-   registers r20 -> r26 will conflict with the list so they
-   are treated specially. Although r19 is clobbered by the syscall
-   we cannot say this because it would violate ABI, thus we say
-   r4 is clobbered and use that register to save/restore r19
-   across the syscall. */
-
-#define K_CALL_CLOB_REGS "%r1", "%r2", K_USING_GR4 \
-	        	 "%r20", "%r29", "%r31"
-
-#undef K_INLINE_SYSCALL
-#define K_INLINE_SYSCALL(name, nr, args...)	({			\
-	long __sys_res;							\
-	{								\
-		register unsigned long __res __asm__("r28");		\
-		K_LOAD_ARGS_##nr(args)					\
-		/* FIXME: HACK stw/ldw r19 around syscall */		\
-		__asm__ volatile(					\
-			K_STW_ASM_PIC					\
-			"	ble  0x100(%%sr2, %%r0)\n"		\
-			"	ldi %1, %%r20\n"			\
-			K_LDW_ASM_PIC					\
-			: "=r" (__res)					\
-			: "i" (SYS_ify(name)) K_ASM_ARGS_##nr   	\
-			: "memory", K_CALL_CLOB_REGS K_CLOB_ARGS_##nr	\
-		);							\
-		__sys_res = (long)__res;				\
-	}								\
-	if ( (unsigned long)__sys_res >= (unsigned long)-4095 ){	\
-		errno = -__sys_res;		        		\
-		__sys_res = -1;						\
-	}								\
-	__sys_res;							\
-})
-
-#define K_LOAD_ARGS_0()
-#define K_LOAD_ARGS_1(r26)					\
-	register unsigned long __r26 __asm__("r26") = (unsigned long)(r26);   \
-	K_LOAD_ARGS_0()
-#define K_LOAD_ARGS_2(r26,r25)					\
-	register unsigned long __r25 __asm__("r25") = (unsigned long)(r25);   \
-	K_LOAD_ARGS_1(r26)
-#define K_LOAD_ARGS_3(r26,r25,r24)				\
-	register unsigned long __r24 __asm__("r24") = (unsigned long)(r24);   \
-	K_LOAD_ARGS_2(r26,r25)
-#define K_LOAD_ARGS_4(r26,r25,r24,r23)				\
-	register unsigned long __r23 __asm__("r23") = (unsigned long)(r23);   \
-	K_LOAD_ARGS_3(r26,r25,r24)
-#define K_LOAD_ARGS_5(r26,r25,r24,r23,r22)			\
-	register unsigned long __r22 __asm__("r22") = (unsigned long)(r22);   \
-	K_LOAD_ARGS_4(r26,r25,r24,r23)
-#define K_LOAD_ARGS_6(r26,r25,r24,r23,r22,r21)			\
-	register unsigned long __r21 __asm__("r21") = (unsigned long)(r21);   \
-	K_LOAD_ARGS_5(r26,r25,r24,r23,r22)
-
-/* Even with zero args we use r20 for the syscall number */
-#define K_ASM_ARGS_0
-#define K_ASM_ARGS_1 K_ASM_ARGS_0, "r" (__r26)
-#define K_ASM_ARGS_2 K_ASM_ARGS_1, "r" (__r25)
-#define K_ASM_ARGS_3 K_ASM_ARGS_2, "r" (__r24)
-#define K_ASM_ARGS_4 K_ASM_ARGS_3, "r" (__r23)
-#define K_ASM_ARGS_5 K_ASM_ARGS_4, "r" (__r22)
-#define K_ASM_ARGS_6 K_ASM_ARGS_5, "r" (__r21)
-
-/* The registers not listed as inputs but clobbered */
-#define K_CLOB_ARGS_6
-#define K_CLOB_ARGS_5 K_CLOB_ARGS_6, "%r21"
-#define K_CLOB_ARGS_4 K_CLOB_ARGS_5, "%r22"
-#define K_CLOB_ARGS_3 K_CLOB_ARGS_4, "%r23"
-#define K_CLOB_ARGS_2 K_CLOB_ARGS_3, "%r24"
-#define K_CLOB_ARGS_1 K_CLOB_ARGS_2, "%r25"
-#define K_CLOB_ARGS_0 K_CLOB_ARGS_1, "%r26"
-
-#define _syscall0(type,name)						\
-type name(void)								\
-{									\
-    return K_INLINE_SYSCALL(name, 0);	                                \
-}
-
-#define _syscall1(type,name,type1,arg1)					\
-type name(type1 arg1)							\
-{									\
-    return K_INLINE_SYSCALL(name, 1, arg1);	                        \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)			\
-type name(type1 arg1, type2 arg2)					\
-{									\
-    return K_INLINE_SYSCALL(name, 2, arg1, arg2);	                \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)		\
-type name(type1 arg1, type2 arg2, type3 arg3)				\
-{									\
-    return K_INLINE_SYSCALL(name, 3, arg1, arg2, arg3);	                \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4)		\
-{									\
-    return K_INLINE_SYSCALL(name, 4, arg1, arg2, arg3, arg4);	        \
-}
-
-/* select takes 5 arguments */
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)	\
-{									\
-    return K_INLINE_SYSCALL(name, 5, arg1, arg2, arg3, arg4, arg5);	\
-}
-
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
 #define __ARCH_WANT_SYS_ALARM
@@ -952,92 +817,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-/* mmap & mmap2 take 6 arguments */
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{									        \
-    return K_INLINE_SYSCALL(name, 6, arg1, arg2, arg3, arg4, arg5, arg6);	\
-}
-
-#ifdef __KERNEL_SYSCALLS__
-
-#include <asm/current.h>
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/syscalls.h>
-
-static inline pid_t setsid(void)
-{
-	return sys_setsid();
-}
-
-static inline int write(int fd, const char *buf, off_t count)
-{
-	return sys_write(fd, buf, count);
-}
-
-static inline int read(int fd, char *buf, off_t count)
-{
-	return sys_read(fd, buf, count);
-}
-
-static inline off_t lseek(int fd, off_t offset, int count)
-{
-	return sys_lseek(fd, offset, count);
-}
-
-static inline int dup(int fd)
-{
-	return sys_dup(fd);
-}
-
-static inline int execve(char *filename, char * argv [],
-	char * envp[])
-{
-	extern int __execve(char *, char **, char **, struct task_struct *);
-	return __execve(filename, argv, envp, current);
-}
-
-static inline int open(const char *file, int flag, int mode)
-{
-	return sys_open(file, flag, mode);
-}
-
-static inline int close(int fd)
-{
-	return sys_close(fd);
-}
-
-static inline void _exit(int exitcode)
-{
-	sys_exit(exitcode);
-}
-
-static inline pid_t waitpid(pid_t pid, int *wait_stat, int options)
-{
-	return sys_wait4(pid, wait_stat, options, NULL);
-}
-
-asmlinkage unsigned long sys_mmap(unsigned long addr, unsigned long len,
-				unsigned long prot, unsigned long flags,
-				unsigned long fd, unsigned long offset);
-asmlinkage unsigned long sys_mmap2(unsigned long addr, unsigned long len,
-				unsigned long prot, unsigned long flags,
-				unsigned long fd, unsigned long pgoff);
-struct pt_regs;
-asmlinkage int sys_execve(struct pt_regs *regs);
-int sys_clone(unsigned long clone_flags, unsigned long usp,
-		struct pt_regs *regs);
-int sys_vfork(struct pt_regs *regs);
-int sys_pipe(int *fildes);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif	/* __KERNEL_SYSCALLS__ */
-
 #endif /* __ASSEMBLY__ */
 
 #undef STR
Index: linux-cg/include/asm-powerpc/unistd.h
===================================================================
--- linux-cg.orig/include/asm-powerpc/unistd.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/asm-powerpc/unistd.h	2006-08-27 23:36:42.000000000 +0200
@@ -333,120 +333,6 @@
 
 #ifndef __ASSEMBLY__
 
-/* On powerpc a system call basically clobbers the same registers like a
- * function call, with the exception of LR (which is needed for the
- * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal
- * an error return status).
- */
-
-#define __syscall_nr(nr, type, name, args...)				\
-	unsigned long __sc_ret, __sc_err;				\
-	{								\
-		register unsigned long __sc_0  __asm__ ("r0");		\
-		register unsigned long __sc_3  __asm__ ("r3");		\
-		register unsigned long __sc_4  __asm__ ("r4");		\
-		register unsigned long __sc_5  __asm__ ("r5");		\
-		register unsigned long __sc_6  __asm__ ("r6");		\
-		register unsigned long __sc_7  __asm__ ("r7");		\
-		register unsigned long __sc_8  __asm__ ("r8");		\
-									\
-		__sc_loadargs_##nr(name, args);				\
-		__asm__ __volatile__					\
-			("sc           \n\t"				\
-			 "mfcr %0      "				\
-			: "=&r" (__sc_0),				\
-			  "=&r" (__sc_3),  "=&r" (__sc_4),		\
-			  "=&r" (__sc_5),  "=&r" (__sc_6),		\
-			  "=&r" (__sc_7),  "=&r" (__sc_8)		\
-			: __sc_asm_input_##nr				\
-			: "cr0", "ctr", "memory",			\
-			  "r9", "r10","r11", "r12");			\
-		__sc_ret = __sc_3;					\
-		__sc_err = __sc_0;					\
-	}								\
-	if (__sc_err & 0x10000000)					\
-	{								\
-		errno = __sc_ret;					\
-		__sc_ret = -1;						\
-	}								\
-	return (type) __sc_ret
-
-#define __sc_loadargs_0(name, dummy...)					\
-	__sc_0 = __NR_##name
-#define __sc_loadargs_1(name, arg1)					\
-	__sc_loadargs_0(name);						\
-	__sc_3 = (unsigned long) (arg1)
-#define __sc_loadargs_2(name, arg1, arg2)				\
-	__sc_loadargs_1(name, arg1);					\
-	__sc_4 = (unsigned long) (arg2)
-#define __sc_loadargs_3(name, arg1, arg2, arg3)				\
-	__sc_loadargs_2(name, arg1, arg2);				\
-	__sc_5 = (unsigned long) (arg3)
-#define __sc_loadargs_4(name, arg1, arg2, arg3, arg4)			\
-	__sc_loadargs_3(name, arg1, arg2, arg3);			\
-	__sc_6 = (unsigned long) (arg4)
-#define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5)		\
-	__sc_loadargs_4(name, arg1, arg2, arg3, arg4);			\
-	__sc_7 = (unsigned long) (arg5)
-#define __sc_loadargs_6(name, arg1, arg2, arg3, arg4, arg5, arg6)	\
-	__sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5);		\
-	__sc_8 = (unsigned long) (arg6)
-
-#define __sc_asm_input_0 "0" (__sc_0)
-#define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3)
-#define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4)
-#define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5)
-#define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6)
-#define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7)
-#define __sc_asm_input_6 __sc_asm_input_5, "6" (__sc_8)
-
-#define _syscall0(type,name)						\
-type name(void)								\
-{									\
-	__syscall_nr(0, type, name);					\
-}
-
-#define _syscall1(type,name,type1,arg1)					\
-type name(type1 arg1)							\
-{									\
-	__syscall_nr(1, type, name, arg1);				\
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)			\
-type name(type1 arg1, type2 arg2)					\
-{									\
-	__syscall_nr(2, type, name, arg1, arg2);			\
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)		\
-type name(type1 arg1, type2 arg2, type3 arg3)				\
-{									\
-	__syscall_nr(3, type, name, arg1, arg2, arg3);			\
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4)		\
-{									\
-	__syscall_nr(4, type, name, arg1, arg2, arg3, arg4);		\
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)	\
-{									\
-	__syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5);	\
-}
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{									\
-	__syscall_nr(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6); \
-}
-
-
-#include <linux/types.h>
-#include <linux/compiler.h>
-#include <linux/linkage.h>
-#include <asm/syscalls.h>
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
@@ -479,13 +365,6 @@
 #endif
 
 /*
- * System call prototypes.
- */
-#ifdef __KERNEL_SYSCALLS__
-extern int execve(const char *file, char **argv, char **envp);
-#endif /* __KERNEL_SYSCALLS__ */
-
-/*
  * "Conditional" syscalls
  *
  * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
Index: linux-cg/include/asm-um/unistd.h
===================================================================
--- linux-cg.orig/include/asm-um/unistd.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/asm-um/unistd.h	2006-08-27 23:41:32.000000000 +0200
@@ -37,34 +37,6 @@
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
 #endif
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-
-static inline int execve(const char *filename, char *const argv[],
-			 char *const envp[])
-{
-	mm_segment_t fs;
-	int ret;
-
-	fs = get_fs();
-	set_fs(KERNEL_DS);
-	ret = um_execve(filename, argv, envp);
-	set_fs(fs);
-
-	if (ret >= 0)
-		return ret;
-
-	errno = -(long)ret;
-	return -1;
-}
-
-int sys_execve(char *file, char **argv, char **env);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
-#undef __KERNEL_SYSCALLS__
 #include "asm/arch/unistd.h"
 
 #endif /* _UM_UNISTD_H_*/
Index: linux-cg/include/linux/syscalls.h
===================================================================
--- linux-cg.orig/include/linux/syscalls.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/linux/syscalls.h	2006-08-27 23:36:42.000000000 +0200
@@ -597,4 +597,6 @@
 asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
 				    size_t len);
 
+int kernel_execve(const char *filename, char *const argv[], char *const envp[]);
+
 #endif
Index: linux-cg/arch/ia64/kernel/entry.S
===================================================================
--- linux-cg.orig/arch/ia64/kernel/entry.S	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/ia64/kernel/entry.S	2006-08-27 23:36:42.000000000 +0200
@@ -492,11 +492,11 @@
 	br.ret.sptk.many rp
 END(prefetch_stack)
 
-GLOBAL_ENTRY(execve)
+GLOBAL_ENTRY(kernel_execve)
 	mov r15=__NR_execve			// put syscall number in place
 	break __BREAK_SYSCALL
 	br.ret.sptk.many rp
-END(execve)
+END(kernel_execve)
 
 GLOBAL_ENTRY(clone)
 	mov r15=__NR_clone			// put syscall number in place
Index: linux-cg/arch/parisc/kernel/process.c
===================================================================
--- linux-cg.orig/arch/parisc/kernel/process.c	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/parisc/kernel/process.c	2006-08-27 23:36:42.000000000 +0200
@@ -368,7 +368,14 @@
 	return error;
 }
 
-unsigned long 
+extern int __execve(const char *filename, char *const argv[],
+		char *const envp[], struct task_struct *task);
+int kernel_execve(const char *filename, char *const argv[], char *const envp[]);
+{
+	return __execve(filename, argv, envp, current);
+}
+
+unsigned long
 get_wchan(struct task_struct *p)
 {
 	struct unwind_frame_info info;
Index: linux-cg/arch/um/kernel/syscall.c
===================================================================
--- linux-cg.orig/arch/um/kernel/syscall.c	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/um/kernel/syscall.c	2006-08-27 23:36:42.000000000 +0200
@@ -164,3 +164,16 @@
 	spin_unlock(&syscall_lock);
 	return(ret);
 }
+
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	mm_segment_t fs;
+	int ret;
+
+	fs = get_fs();
+	set_fs(KERNEL_DS);
+	ret = um_execve(filename, argv, envp);
+	set_fs(fs);
+
+	return ret;
+}
Index: linux-cg/include/asm-ia64/unistd.h
===================================================================
--- linux-cg.orig/include/asm-ia64/unistd.h	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/include/asm-ia64/unistd.h	2006-08-27 23:36:42.000000000 +0200
@@ -319,78 +319,6 @@
 
 extern long __ia64_syscall (long a0, long a1, long a2, long a3, long a4, long nr);
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/string.h>
-#include <linux/signal.h>
-#include <asm/ptrace.h>
-#include <linux/stringify.h>
-#include <linux/syscalls.h>
-
-static inline long
-open (const char * name, int mode, int flags)
-{
-	return sys_open(name, mode, flags);
-}
-
-static inline long
-dup (int fd)
-{
-	return sys_dup(fd);
-}
-
-static inline long
-close (int fd)
-{
-	return sys_close(fd);
-}
-
-static inline off_t
-lseek (int fd, off_t off, int whence)
-{
-	return sys_lseek(fd, off, whence);
-}
-
-static inline void
-_exit (int value)
-{
-	sys_exit(value);
-}
-
-#define exit(x) _exit(x)
-
-static inline long
-write (int fd, const char * buf, size_t nr)
-{
-	return sys_write(fd, buf, nr);
-}
-
-static inline long
-read (int fd, char * buf, size_t nr)
-{
-	return sys_read(fd, buf, nr);
-}
-
-
-static inline long
-setsid (void)
-{
-	return sys_setsid();
-}
-
-static inline pid_t
-waitpid (int pid, int * wait_stat, int flags)
-{
-	return sys_wait4(pid, wait_stat, flags, NULL);
-}
-
-
-extern int execve (const char *filename, char *const av[], char *const ep[]);
-extern pid_t clone (unsigned long flags, void *sp);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 asmlinkage unsigned long sys_mmap(
 				unsigned long addr, unsigned long len,
 				int prot, int flags,
Index: linux-cg/arch/alpha/kernel/alpha_ksyms.c
===================================================================
--- linux-cg.orig/arch/alpha/kernel/alpha_ksyms.c	2006-08-27 23:36:36.000000000 +0200
+++ linux-cg/arch/alpha/kernel/alpha_ksyms.c	2006-08-27 23:38:19.000000000 +0200
@@ -36,7 +36,6 @@
 #include <asm/cacheflush.h>
 #include <asm/vga.h>
 
-#define __KERNEL_SYSCALLS__
 #include <asm/unistd.h>
 
 extern struct hwrpb_struct *hwrpb;
@@ -116,7 +115,7 @@
 EXPORT_SYMBOL(sys_exit);
 EXPORT_SYMBOL(sys_write);
 EXPORT_SYMBOL(sys_lseek);
-EXPORT_SYMBOL(execve);
+EXPORT_SYMBOL(kernel_execve);
 EXPORT_SYMBOL(sys_setsid);
 EXPORT_SYMBOL(sys_wait4);
 

--


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

* [PATCH 3/7] provide kernel_execve on all architectures
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
  2006-08-27 21:47 ` [PATCH 2/7] rename the provided execve functions to kernel_execve Arnd Bergmann
@ 2006-08-27 21:47 ` Arnd Bergmann
  2006-08-29  2:22   ` Ralf Baechle
  2006-08-27 21:47 ` [PATCH 4/7] Remove the use of _syscallX macros in UML Arnd Bergmann
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-27 21:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty

[-- Attachment #1: kerne-execve2.diff --]
[-- Type: text/plain, Size: 13661 bytes --]

This adds the new kernel_execve function on all architectures
that were using _syscall3() to implement execve.

The implementation uses code from the _syscall3 macros provided
in the unistd.h header file. I don't have cross-compilers for
any of these architectures, so the patch is untested with the
exception of i386.

Most architectures can probably implement this in a nicer way
in assembly or by combining it with the sys_execve implementation
itself, but this should do it for now.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/arch/frv/kernel/sys_frv.c
===================================================================
--- linux-cg.orig/arch/frv/kernel/sys_frv.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/frv/kernel/sys_frv.c	2006-08-27 21:36:52.000000000 +0200
@@ -212,3 +212,19 @@
 		return -ENOSYS;
 	}
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register unsigned long __scnum __asm__ ("gr7") = __NR_execve;
+	register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) filename;
+	register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) argv;
+	register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) envp;
+	__asm__ __volatile__ ("tira gr0,#0"
+			      : "+r" (__sc0)
+			      : "r" (__scnum), "r" (__sc1), "r" (__sc2));
+	return __sc0;
+}
Index: linux-cg/arch/h8300/kernel/sys_h8300.c
===================================================================
--- linux-cg.orig/arch/h8300/kernel/sys_h8300.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/h8300/kernel/sys_h8300.c	2006-08-27 21:36:52.000000000 +0200
@@ -280,3 +280,26 @@
                ((regs->pc)&0xffffff)-2,regs->orig_er0,regs->er1,regs->er2,regs->er3,regs->er0);
 }
 #endif
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register long res __asm__("er0");
+	register const char * _a __asm__("er1") = filename;
+	register void *_b __asm__("er2") = argv;
+	register void *_c __asm__("er3") = envp;
+	__asm__ __volatile__ ("mov.l %1,er0\n\t"
+			"trapa	#0\n\t"
+			: "=r" (res)
+			: "g" (__NR_execve),
+			  "g" (_a),
+			  "g" (_b),
+			  "g" (_c)
+			: "cc", "memory");
+	return res;
+}
+
+
Index: linux-cg/arch/i386/kernel/sys_i386.c
===================================================================
--- linux-cg.orig/arch/i386/kernel/sys_i386.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/i386/kernel/sys_i386.c	2006-08-27 21:36:52.000000000 +0200
@@ -243,3 +243,17 @@
 
 	return error;
 }
+
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	long __res;
+	asm volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx"
+	: "=a" (__res)
+	: "0" (__NR_execve),"ri" (filename),"c" (argv), "d" (envp) : "memory");
+	return __res;
+}
Index: linux-cg/arch/m32r/kernel/sys_m32r.c
===================================================================
--- linux-cg.orig/arch/m32r/kernel/sys_m32r.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/m32r/kernel/sys_m32r.c	2006-08-27 21:36:52.000000000 +0200
@@ -25,6 +25,8 @@
 #include <asm/cachectl.h>
 #include <asm/cacheflush.h>
 #include <asm/ipc.h>
+#include <asm/syscall.h>
+#include <asm/unistd.h>
 
 /*
  * sys_tas() - test-and-set
@@ -223,3 +225,21 @@
 	return -ENOSYS;
 }
 
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register long __scno __asm__ ("r7") = __NR_execve;
+	register long __arg3 __asm__ ("r2") = (long)(envp);
+	register long __arg2 __asm__ ("r1") = (long)(argv);
+	register long __res __asm__ ("r0") = (long)(filename);
+	__asm__ __volatile__ (
+		"trap #" SYSCALL_VECTOR "|| nop"
+		: "=r" (__res)
+		: "r" (__scno), "0" (__res), "r" (__arg2),
+			"r" (__arg3)
+		: "memory");
+	return __res;
+}
Index: linux-cg/arch/m68k/kernel/sys_m68k.c
===================================================================
--- linux-cg.orig/arch/m68k/kernel/sys_m68k.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/m68k/kernel/sys_m68k.c	2006-08-27 21:36:52.000000000 +0200
@@ -663,3 +663,18 @@
 {
 	return PAGE_SIZE;
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register long __res asm ("%d0") = __NR_execve;
+	register long __a asm ("%d1") = (long)(filename);
+	register long __b asm ("%d2") = (long)(argv);
+	register long __c asm ("%d3") = (long)(envp);
+	asm volatile ("trap  #0" : "+d" (__res)
+			: "d" (__a), "d" (__b), "d" (__c));
+	return __res;
+}
Index: linux-cg/arch/m68knommu/kernel/sys_m68k.c
===================================================================
--- linux-cg.orig/arch/m68knommu/kernel/sys_m68k.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/m68knommu/kernel/sys_m68k.c	2006-08-27 21:36:52.000000000 +0200
@@ -206,3 +206,17 @@
 	return PAGE_SIZE;
 }
 
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register long __res asm ("%d0") = __NR_execve;
+	register long __a asm ("%d1") = (long)(filename);
+	register long __b asm ("%d2") = (long)(argv);
+	register long __c asm ("%d3") = (long)(envp);
+	asm volatile ("trap  #0" : "+d" (__res)
+			: "d" (__a), "d" (__b), "d" (__c));
+	return __res;
+}
Index: linux-cg/arch/mips/kernel/syscall.c
===================================================================
--- linux-cg.orig/arch/mips/kernel/syscall.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/mips/kernel/syscall.c	2006-08-27 21:36:52.000000000 +0200
@@ -399,3 +399,27 @@
 {
 	do_exit(SIGSEGV);
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register unsigned long __a0 asm("$4") = (unsigned long) filename;
+	register unsigned long __a1 asm("$5") = (unsigned long) argv;
+	register unsigned long __a2 asm("$6") = (unsigned long) envp;
+	register unsigned long __a3 asm("$7");
+	unsigned long __v0;
+	__asm__ volatile (
+	".set\tnoreorder\n\t"
+	"li\t$2, %5\t\t\t# " #name "\n\t"
+	"syscall\n\t"
+	"move\t%0, $2\n\t"
+	".set\treorder"
+	: "=&r" (__v0), "=r" (__a3)
+	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve)
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24",
+	  "memory");
+	return __v0;
+}
Index: linux-cg/arch/s390/kernel/sys_s390.c
===================================================================
--- linux-cg.orig/arch/s390/kernel/sys_s390.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/s390/kernel/sys_s390.c	2006-08-27 21:36:52.000000000 +0200
@@ -266,3 +266,21 @@
 	return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
 }
 
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register const char *__arg1 asm("2") = filename;
+	register void *__arg2 asm("3") = argv;
+	register void *__arg3 asm("4") = envp;
+	register long __svcres asm("2");
+	asm volatile ("svc %b1"
+		: "=d" (__svcres)
+		: "i" (__NR_execve),
+		  "0" (__arg1),
+		  "d" (__arg2),
+		  "d" (__arg3) : "1", "cc", "memory");
+	return __svcres;
+}
Index: linux-cg/arch/sh/kernel/sys_sh.c
===================================================================
--- linux-cg.orig/arch/sh/kernel/sys_sh.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/sh/kernel/sys_sh.c	2006-08-27 21:36:52.000000000 +0200
@@ -295,3 +295,19 @@
 				(u64)len0 << 32 | len1,	advice);
 #endif
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register long __sc0 __asm__ ("r3") = __NR_execve;
+	register long __sc4 __asm__ ("r4") = (long) filename;
+	register long __sc5 __asm__ ("r5") = (long) argv;
+	register long __sc6 __asm__ ("r6") = (long) envp;
+	__asm__ __volatile__ ("trapa	#0x13" : "=z" (__sc0)
+			: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6)
+			: "memory");
+	return __sc0;
+}
Index: linux-cg/arch/sh64/kernel/sys_sh64.c
===================================================================
--- linux-cg.orig/arch/sh64/kernel/sys_sh64.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/sh64/kernel/sys_sh64.c	2006-08-27 21:36:52.000000000 +0200
@@ -283,3 +283,21 @@
 	up_read(&uts_sem);
 	return err?-EFAULT:0;
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve);
+	register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename;
+	register unsigned long __sc3 __asm__ ("r3") = (unsigned long) argv;
+	register unsigned long __sc4 __asm__ ("r4") = (unsigned long) envp;
+	__asm__ __volatile__ ("trapa	%1 !\t\t\t execve(%2,%3,%4)"
+	: "=r" (__sc0)
+	: "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) );
+	__asm__ __volatile__ ("!dummy	%0 %1 %2 %3"
+	: : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) : "memory");
+	return __sc0;
+}
Index: linux-cg/arch/sparc/kernel/sys_sparc.c
===================================================================
--- linux-cg.orig/arch/sparc/kernel/sys_sparc.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/sparc/kernel/sys_sparc.c	2006-08-27 21:36:52.000000000 +0200
@@ -483,3 +483,25 @@
 	up_read(&uts_sem);
 	return err;
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	long __res;
+	register long __g1 __asm__ ("g1") = __NR_execve;
+	register long __o0 __asm__ ("o0") = (long)(filename);
+	register long __o1 __asm__ ("o1") = (long)(argv);
+	register long __o2 __asm__ ("o2") = (long)(envp);
+	asm volatile ("t 0x10\n\t"
+		      "bcc 1f\n\t"
+		      "mov %%o0, %0\n\t"
+		      "sub %%g0, %%o0, %0\n\t"
+		      "1:\n\t"
+		      : "=r" (__res), "=&r" (__o0)
+		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1)
+		      : "cc");
+	return __res;
+}
Index: linux-cg/arch/sparc64/kernel/sys_sparc.c
===================================================================
--- linux-cg.orig/arch/sparc64/kernel/sys_sparc.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/sparc64/kernel/sys_sparc.c	2006-08-27 21:36:52.000000000 +0200
@@ -957,3 +957,23 @@
 	};
 	return err;
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	long __res;
+	register long __g1 __asm__ ("g1") = __NR_execve;
+	register long __o0 __asm__ ("o0") = (long)(filename);
+	register long __o1 __asm__ ("o1") = (long)(argv);
+	register long __o2 __asm__ ("o2") = (long)(envp);
+	asm volatile ("t 0x6d\n\t"
+		      "sub %%g0, %%o0, %0\n\t"
+		      "movcc %%xcc, %%o0, %0\n\t"
+		      : "=r" (__res), "=&r" (__o0)
+		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1)
+		      : "cc");
+	return __res;
+}
Index: linux-cg/arch/v850/kernel/syscalls.c
===================================================================
--- linux-cg.orig/arch/v850/kernel/syscalls.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/v850/kernel/syscalls.c	2006-08-27 21:36:52.000000000 +0200
@@ -194,3 +194,22 @@
 out:
 	return err;
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register char *__a __asm__ ("r6") = filename;
+	register void *__b __asm__ ("r7") = argv;
+	register void *__c __asm__ ("r8") = envp;
+	register unsigned long __syscall __asm__ ("r12") = __NR_execve;
+	register unsigned long __ret __asm__ ("r10");
+	__asm__ __volatile__ ("trap 0"
+			: "=r" (__ret), "=r" (__syscall)
+			: "1" (__syscall), "r" (__a), "r" (__b), "r" (__c)
+			: "r1", "r5", "r11", "r13", "r14",
+			  "r15", "r16", "r17", "r18", "r19");
+	return __ret;
+}
Index: linux-cg/arch/xtensa/kernel/syscalls.c
===================================================================
--- linux-cg.orig/arch/xtensa/kernel/syscalls.c	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/arch/xtensa/kernel/syscalls.c	2006-08-27 21:36:52.000000000 +0200
@@ -266,3 +266,23 @@
 	regs->areg[2] = res;
 	do_syscall_trace();
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	long __res;
+	asm volatile (
+		"  mov   a5, %2 \n"
+		"  mov   a4, %4 \n"
+		"  mov   a3, %3 \n"
+		"  movi  a2, %1 \n"
+		"  syscall      \n"
+		"  mov   %0, a2 \n"
+		: "=a" (__res)
+		: "i" (__NR_execve), "a" (filename), "a" (argv), "a" (envp)
+		: "a2", "a3", "a4", "a5");
+	return __res;
+}

--


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

* [PATCH 4/7] Remove the use of _syscallX macros in UML
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
  2006-08-27 21:47 ` [PATCH 2/7] rename the provided execve functions to kernel_execve Arnd Bergmann
  2006-08-27 21:47 ` [PATCH 3/7] provide kernel_execve on all architectures Arnd Bergmann
@ 2006-08-27 21:47 ` Arnd Bergmann
  2006-08-28  9:25   ` Andreas Schwab
  2006-08-30  5:41   ` H. Peter Anvin
  2006-08-27 21:47 ` [PATCH 6/7] remove all remaining _syscallX macros Arnd Bergmann
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-27 21:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty

[-- Attachment #1: uml-syscalls.diff --]
[-- Type: text/plain, Size: 4679 bytes --]

User mode linux uses _syscallX() to call into the host kernel.
The recommended way to do this is to use the syscall() function
from libc.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/arch/um/os-Linux/process.c
===================================================================
--- linux-cg.orig/arch/um/os-Linux/process.c	2006-08-16 12:08:06.000000000 +0200
+++ linux-cg/arch/um/os-Linux/process.c	2006-08-27 21:51:06.000000000 +0200
@@ -12,6 +12,7 @@
 #include <sys/mman.h>
 #include <sys/wait.h>
 #include <sys/mman.h>
+#include <sys/syscall.h>
 #include "ptrace_user.h"
 #include "os.h"
 #include "user.h"
@@ -141,11 +142,9 @@
  * syscalls, and also breaks with clone(), which does not unshare the TLS.
  */
 
-inline _syscall0(pid_t, getpid)
-
 int os_getpid(void)
 {
-	return(getpid());
+	return(syscall(__NR_getpid));
 }
 
 int os_getpgrp(void)
Index: linux-cg/arch/um/os-Linux/sys-i386/tls.c
===================================================================
--- linux-cg.orig/arch/um/os-Linux/sys-i386/tls.c	2006-04-14 13:18:17.000000000 +0200
+++ linux-cg/arch/um/os-Linux/sys-i386/tls.c	2006-08-27 21:51:21.000000000 +0200
@@ -1,10 +1,9 @@
 #include <errno.h>
 #include <linux/unistd.h>
+#include <sys/syscall.h>
 #include "sysdep/tls.h"
 #include "user_util.h"
 
-static _syscall1(int, get_thread_area, user_desc_t *, u_info);
-
 /* Checks whether host supports TLS, and sets *tls_min according to the value
  * valid on the host.
  * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
@@ -17,7 +16,7 @@
 		user_desc_t info;
 		info.entry_number = val[i];
 
-		if (get_thread_area(&info) == 0) {
+		if (syscall(__NR_get_thread_area, &info) == 0) {
 			*tls_min = val[i];
 			*supports_tls = 1;
 			return;
Index: linux-cg/arch/um/os-Linux/tls.c
===================================================================
--- linux-cg.orig/arch/um/os-Linux/tls.c	2006-04-02 23:16:55.000000000 +0200
+++ linux-cg/arch/um/os-Linux/tls.c	2006-08-27 21:52:23.000000000 +0200
@@ -1,5 +1,6 @@
 #include <errno.h>
 #include <sys/ptrace.h>
+#include <sys/syscall.h>
 #include <asm/ldt.h>
 #include "sysdep/tls.h"
 #include "uml-config.h"
@@ -48,14 +49,11 @@
 #ifdef UML_CONFIG_MODE_TT
 #include "linux/unistd.h"
 
-static _syscall1(int, get_thread_area, user_desc_t *, u_info);
-static _syscall1(int, set_thread_area, user_desc_t *, u_info);
-
 int do_set_thread_area_tt(user_desc_t *info)
 {
 	int ret;
 
-	ret = set_thread_area(info);
+	ret = syscall(__NR_set_thread_area,info);
 	if (ret < 0) {
 		ret = -errno;
 	}
@@ -66,7 +64,7 @@
 {
 	int ret;
 
-	ret = get_thread_area(info);
+	ret = syscall(__NR_get_thread_area,info);
 	if (ret < 0) {
 		ret = -errno;
 	}
Index: linux-cg/arch/um/sys-i386/unmap.c
===================================================================
--- linux-cg.orig/arch/um/sys-i386/unmap.c	2005-11-05 01:59:23.000000000 +0100
+++ linux-cg/arch/um/sys-i386/unmap.c	2006-08-27 21:50:44.000000000 +0200
@@ -5,20 +5,17 @@
 
 #include <linux/mman.h>
 #include <asm/unistd.h>
+#include <sys/syscall.h>
 
-static int errno;
-
-static inline _syscall2(int,munmap,void *,start,size_t,len)
-static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
 int switcheroo(int fd, int prot, void *from, void *to, int size)
 {
-	if(munmap(to, size) < 0){
+	if (syscall(__NR_munmap, to, size) < 0){
 		return(-1);
 	}
-	if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
+	if (syscall(__NR_mmap2, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
 		return(-1);
 	}
-	if(munmap(from, size) < 0){
+	if (syscall(__NR_munmap, from, size) < 0){
 		return(-1);
 	}
 	return(0);
Index: linux-cg/arch/um/sys-x86_64/unmap.c
===================================================================
--- linux-cg.orig/arch/um/sys-x86_64/unmap.c	2005-11-05 01:59:23.000000000 +0100
+++ linux-cg/arch/um/sys-x86_64/unmap.c	2006-08-27 21:54:04.000000000 +0200
@@ -5,20 +5,17 @@
 
 #include <linux/mman.h>
 #include <asm/unistd.h>
+#include <sys/syscall.h>
 
-static int errno;
-
-static inline _syscall2(int,munmap,void *,start,size_t,len)
-static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
 int switcheroo(int fd, int prot, void *from, void *to, int size)
 {
-	if(munmap(to, size) < 0){
+	if (syscall(munmap, to, size) < 0){
 		return(-1);
 	}
-	if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
+	if (syscall(mmap, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
 		return(-1);
 	}
-	if(munmap(from, size) < 0){
+	if (syscall(munmap, from, size) < 0){
 		return(-1);
 	}
 	return(0);

--


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

* [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
                   ` (2 preceding siblings ...)
  2006-08-27 21:47 ` [PATCH 4/7] Remove the use of _syscallX macros in UML Arnd Bergmann
@ 2006-08-27 21:47 ` Arnd Bergmann
  2006-08-28  7:35   ` Andi Kleen
  2006-08-27 21:47 ` [PATCH 7/7] remove the global errno from the kernel Arnd Bergmann
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-27 21:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty

[-- Attachment #1: kernel-execve-2.5.diff --]
[-- Type: text/plain, Size: 98273 bytes --]

The _syscallX macros were originally used by libc implementations,
but now there is no libc that can be built against an up-to-date
kernel an relies on them.
The only users of these macros are the __KERNEL_SYSCALLS_, which
are now gone as well, after execve has been removed from the
kernel.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/include/asm-cris/unistd.h
===================================================================
--- linux-cg.orig/include/asm-cris/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-cris/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -324,67 +324,6 @@
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #endif
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/linkage.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static inline _syscall0(pid_t,setsid)
-static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
-static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static inline _syscall1(int,dup,int,fd)
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
-static inline _syscall1(int,close,int,fd)
-
-struct pt_regs;
-asmlinkage long sys_mmap2(
-			unsigned long addr, unsigned long len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long pgoff);
-asmlinkage int sys_execve(const char *fname, char **argv, char **envp,
-			long r13, long mof, long srp, struct pt_regs *regs);
-asmlinkage int sys_clone(unsigned long newusp, unsigned long flags,
-			int* parent_tid, int* child_tid, long mof, long srp,
-			struct pt_regs *regs);
-asmlinkage int sys_fork(long r10, long r11, long r12, long r13,
-			long mof, long srp, struct pt_regs *regs);
-asmlinkage int sys_vfork(long r10, long r11, long r12, long r13,
-			long mof, long srp, struct pt_regs *regs);
-asmlinkage int sys_pipe(unsigned long __user *fildes);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-/*
- * Since we define it "external", it collides with the built-in
- * definition, which has the "noreturn" attribute and will cause
- * complaints.  We don't want to use -fno-builtin, so just use a
- * different name when in the kernel.
- */
-#define _exit kernel_syscall_exit
-static inline _syscall1(int,_exit,int,exitcode)
-static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-#endif /* __KERNEL_SYSCALLS__ */
-
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-frv/unistd.h
===================================================================
--- linux-cg.orig/include/asm-frv/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-frv/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -321,149 +321,6 @@
 
 #define NR_syscalls 310
 
-/*
- * process the return value of a syscall, consigning it to one of two possible fates
- * - user-visible error numbers are in the range -1 - -4095: see <asm-frv/errno.h>
- */
-#undef __syscall_return
-#define __syscall_return(type, res)					\
-do {									\
-        unsigned long __sr2 = (res);					\
-	if (__builtin_expect(__sr2 >= (unsigned long)(-4095), 0)) {	\
-		errno = (-__sr2);					\
-		__sr2 = ~0UL;						\
-	}								\
-	return (type) __sr2;						\
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-
-#undef _syscall0
-#define _syscall0(type,name)						\
-type name(void)								\
-{									\
-	register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);	\
-	register unsigned long __sc0 __asm__ ("gr8");			\
-	__asm__ __volatile__ ("tira gr0,#0"				\
-			      : "=r" (__sc0)				\
-			      : "r" (__scnum));				\
-	__syscall_return(type, __sc0);					\
-}
-
-#undef _syscall1
-#define _syscall1(type,name,type1,arg1)						\
-type name(type1 arg1)								\
-{										\
-	register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		\
-	register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	\
-	__asm__ __volatile__ ("tira gr0,#0"					\
-			      : "+r" (__sc0)					\
-			      : "r" (__scnum));					\
-	__syscall_return(type, __sc0);						\
-}
-
-#undef _syscall2
-#define _syscall2(type,name,type1,arg1,type2,arg2)				\
-type name(type1 arg1,type2 arg2)						\
-{										\
-	register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		\
-	register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	\
-	register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;	\
-	__asm__ __volatile__ ("tira gr0,#0"					\
-			      : "+r" (__sc0)					\
-			      : "r" (__scnum), "r" (__sc1));			\
-	__syscall_return(type, __sc0);						\
-}
-
-#undef _syscall3
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)			\
-type name(type1 arg1,type2 arg2,type3 arg3)					\
-{										\
-	register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);		\
-	register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;	\
-	register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;	\
-	register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;	\
-	__asm__ __volatile__ ("tira gr0,#0"					\
-			      : "+r" (__sc0)					\
-			      : "r" (__scnum), "r" (__sc1), "r" (__sc2));	\
-	__syscall_return(type, __sc0);						\
-}
-
-#undef _syscall4
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4)		\
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4)				\
-{											\
-	register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);			\
-	register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;		\
-	register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;		\
-	register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;		\
-	register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;		\
-	__asm__ __volatile__ ("tira gr0,#0"						\
-			      : "+r" (__sc0)						\
-			      : "r" (__scnum), "r" (__sc1), "r" (__sc2), "r" (__sc3));	\
-	__syscall_return(type, __sc0);							\
-}
-
-#undef _syscall5
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5)	\
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)			\
-{											\
-	register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);			\
-	register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;		\
-	register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;		\
-	register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;		\
-	register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;		\
-	register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5;		\
-	__asm__ __volatile__ ("tira gr0,#0"						\
-			      : "+r" (__sc0)						\
-			      : "r" (__scnum), "r" (__sc1), "r" (__sc2),		\
-			      "r" (__sc3), "r" (__sc4));				\
-	__syscall_return(type, __sc0);							\
-}
-
-#undef _syscall6
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6)		 \
-{												 \
-	register unsigned long __scnum __asm__ ("gr7") = (__NR_##name);				 \
-	register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) arg1;			 \
-	register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) arg2;			 \
-	register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) arg3;			 \
-	register unsigned long __sc3 __asm__ ("gr11") = (unsigned long) arg4;			 \
-	register unsigned long __sc4 __asm__ ("gr12") = (unsigned long) arg5;			 \
-	register unsigned long __sc5 __asm__ ("gr13") = (unsigned long) arg6;			 \
-	__asm__ __volatile__ ("tira gr0,#0"							 \
-			      : "+r" (__sc0)							 \
-			      : "r" (__scnum), "r" (__sc1), "r" (__sc2),			 \
-			      "r" (__sc3), "r" (__sc4), "r" (__sc5));				 \
-	__syscall_return(type, __sc0);								 \
-}
-
-
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/linkage.h>
-#include <asm/ptrace.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 /* #define __ARCH_WANT_OLD_READDIR */
 #define __ARCH_WANT_OLD_STAT
Index: linux-cg/include/asm-h8300/unistd.h
===================================================================
--- linux-cg.orig/include/asm-h8300/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-h8300/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -296,172 +296,6 @@
 
 #define NR_syscalls 289
 
-
-/* user-visible error numbers are in the range -1 - -122: see
-   <asm-m68k/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
-	/* avoid using res which is declared to be in register d0; \
-	   errno might expand to a function call and clobber it.  */ \
-		int __err = -(res); \
-		errno = __err; \
-		res = -1; \
-	} \
-	return (type) (res); \
-} while (0)
-
-#define _syscall0(type, name)				\
-type name(void)						\
-{							\
-  register long __res __asm__("er0");			\
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"		\
-                        "trapa	#0\n\t"			\
-			: "=r" (__res)			\
-			: "g" (__NR_##name)		\
-			: "cc", "memory");		\
-  __syscall_return(type, __res);			\
-}
-
-#define _syscall1(type, name, atype, a)			\
-type name(atype a)					\
-{							\
-  register long __res __asm__("er0");			\
-  register long _a __asm__("er1");			\
-  _a = (long)a;						\
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"		\
-                        "trapa	#0\n\t"			\
-			: "=r" (__res)			\
-			: "g" (__NR_##name),		\
-			  "g" (_a)			\
-			: "cc", "memory");	 	\
-  __syscall_return(type, __res);			\
-}
-
-#define _syscall2(type, name, atype, a, btype, b)	\
-type name(atype a, btype b)				\
-{							\
-  register long __res __asm__("er0");			\
-  register long _a __asm__("er1");			\
-  register long _b __asm__("er2");			\
-  _a = (long)a;						\
-  _b = (long)b;						\
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"		\
-                        "trapa	#0\n\t"			\
-			: "=r" (__res)			\
-			: "g" (__NR_##name),		\
-			  "g" (_a),			\
-			  "g" (_b)			\
-			: "cc", "memory");	 	\
-  __syscall_return(type, __res);			\
-}
-
-#define _syscall3(type, name, atype, a, btype, b, ctype, c)	\
-type name(atype a, btype b, ctype c)			\
-{							\
-  register long __res __asm__("er0");			\
-  register long _a __asm__("er1");			\
-  register long _b __asm__("er2");			\
-  register long _c __asm__("er3");			\
-  _a = (long)a;						\
-  _b = (long)b;						\
-  _c = (long)c;						\
-  __asm__ __volatile__ ("mov.l %1,er0\n\t"		\
-                        "trapa	#0\n\t"			\
-			: "=r" (__res)			\
-			: "g" (__NR_##name),		\
-			  "g" (_a),			\
-			  "g" (_b),			\
-			  "g" (_c)			\
-			: "cc", "memory");		\
-  __syscall_return(type, __res);			\
-}
-
-#define _syscall4(type, name, atype, a, btype, b,	\
-                  ctype, c, dtype, d)			\
-type name(atype a, btype b, ctype c, dtype d)		\
-{							\
-  register long __res __asm__("er0");			\
-  register long _a __asm__("er1");			\
-  register long _b __asm__("er2");			\
-  register long _c __asm__("er3");			\
-  register long _d __asm__("er4");			\
-  _a = (long)a;						\
-  _b = (long)b;						\
-  _c = (long)c;						\
-  _d = (long)d;						\
-  __asm__ __volatile__ ("mov.l	%1,er0\n\t"		\
-                        "trapa	#0\n\t"			\
-			: "=r" (__res)			\
-			: "g" (__NR_##name),		\
-			  "g" (_a),			\
-			  "g" (_b),			\
-			  "g" (_c),			\
-			  "g" (_d)			\
-			: "cc", "memory");		\
-  __syscall_return(type, __res);			\
-}
-
-#define _syscall5(type, name, atype, a, btype, b,	\
-                  ctype, c, dtype, d, etype, e)		\
-type name(atype a, btype b, ctype c, dtype d, etype e)	\
-{							\
-  register long __res __asm__("er0");			\
-  register long _a __asm__("er1");			\
-  register long _b __asm__("er2");			\
-  register long _c __asm__("er3");			\
-  register long _d __asm__("er4");			\
-  register long _e __asm__("er5");			\
-  _a = (long)a;                                       	\
-  _b = (long)b;                                       	\
-  _c = (long)c;                                       	\
-  _d = (long)d;                                       	\
-  _e = (long)e;                                       	\
-  __asm__ __volatile__ ("mov.l	%1,er0\n\t"		\
-                        "trapa	#0\n\t"			\
-			: "=r" (__res)			\
-			: "g" (__NR_##name),		\
-			  "g" (_a),			\
-			  "g" (_b),			\
-			  "g" (_c),			\
-			  "g" (_d),			\
-			  "g" (_e)			\
-			: "cc", "memory");		\
-  __syscall_return(type, __res);			\
-}
-
-#define _syscall6(type, name, atype, a, btype, b,	\
-                  ctype, c, dtype, d, etype, e, ftype, f)	\
-type name(atype a, btype b, ctype c, dtype d, etype e, ftype f)	\
-{							\
-  register long __res __asm__("er0");			\
-  register long _a __asm__("er1");			\
-  register long _b __asm__("er2");			\
-  register long _c __asm__("er3");			\
-  register long _d __asm__("er4");			\
-  register long _e __asm__("er5");			\
-  register long _f __asm__("er6");			\
-  _a = (long)a;                                       	\
-  _b = (long)b;                                       	\
-  _c = (long)c;                                       	\
-  _d = (long)d;                                       	\
-  _e = (long)e;                                       	\
-  _f = (long)f;                                       	\
-  __asm__ __volatile__ ("mov.l	%1,er0\n\t"		\
-                        "trapa	#0\n\t"			\
-			: "=r" (__res)			\
-			: "g" (__NR_##name),		\
-			  "g" (_a),			\
-			  "g" (_b),			\
-			  "g" (_c),			\
-			  "g" (_d),			\
-			  "g" (_e)			\
-			  "g" (_f)			\
-			: "cc", "memory");		\
-  __syscall_return(type, __res);			\
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
@@ -485,57 +319,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static inline _syscall0(int,pause)
-static inline _syscall0(int,sync)
-static inline _syscall0(pid_t,setsid)
-static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
-static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static inline _syscall1(int,dup,int,fd)
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
-static inline _syscall1(int,close,int,fd)
-static inline _syscall1(int,_exit,int,exitcode)
-static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-static inline _syscall1(int,delete_module,const char *,name)
-
-static inline pid_t wait(int * wait_stat)
-{
-	return waitpid(-1,wait_stat,0);
-}
-
-asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long pgoff);
-asmlinkage int sys_execve(char *name, char **argv, char **envp,
-			int dummy, ...);
-asmlinkage int sys_pipe(unsigned long *fildes);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  */
Index: linux-cg/include/asm-i386/unistd.h
===================================================================
--- linux-cg.orig/include/asm-i386/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-i386/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -328,103 +328,6 @@
 
 #define NR_syscalls 318
 
-/*
- * user-visible error numbers are in the range -1 - -128: see
- * <asm-i386/errno.h>
- */
-#define __syscall_return(type, res) \
-do { \
-	if ((unsigned long)(res) >= (unsigned long)(-(128 + 1))) { \
-		errno = -(res); \
-		res = -1; \
-	} \
-	return (type) (res); \
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-__asm__ volatile ("int $0x80" \
-	: "=a" (__res) \
-	: "0" (__NR_##name)); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
-		  "d" ((long)(arg3)) : "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
-	: "=a" (__res) \
-	: "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
-	  "d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
-__syscall_return(type,__res); \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	  type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
-                  "int $0x80 ; pop %%ebx" \
-	: "=a" (__res) \
-	: "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
-	  "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	  type5,arg5,type6,arg6) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
-{ \
-long __res; \
-  struct { long __a1; long __a6; } __s = { (long)arg1, (long)arg6 }; \
-__asm__ volatile ("push %%ebp ; push %%ebx ; movl 4(%2),%%ebp ; " \
-                  "movl 0(%2),%%ebx ; movl %1,%%eax ; int $0x80 ; " \
-                  "pop %%ebx ;  pop %%ebp" \
-	: "=a" (__res) \
-	: "i" (__NR_##name),"0" ((long)(&__s)),"c" ((long)(arg2)), \
-	  "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
@@ -449,45 +352,6 @@
 #define __ARCH_WANT_SYS_RT_SIGACTION
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/linkage.h>
-#include <asm/ptrace.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-
-asmlinkage int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount);
-asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long pgoff);
-asmlinkage int sys_execve(struct pt_regs regs);
-asmlinkage int sys_clone(struct pt_regs regs);
-asmlinkage int sys_fork(struct pt_regs regs);
-asmlinkage int sys_vfork(struct pt_regs regs);
-asmlinkage int sys_pipe(unsigned long __user *fildes);
-asmlinkage long sys_iopl(unsigned long unused);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-m32r/unistd.h
===================================================================
--- linux-cg.orig/include/asm-m32r/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-m32r/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -299,114 +299,6 @@
 
 #define NR_syscalls 285
 
-/* user-visible error numbers are in the range -1 - -124: see
- * <asm-m32r/errno.h>
- */
-
-#define __syscall_return(type, res) \
-do { \
-	if ((unsigned long)(res) >= (unsigned long)(-(124 + 1))) { \
-	/* Avoid using "res" which is declared to be in register r0; \
-	   errno might expand to a function call and clobber it.  */ \
-		int __err = -(res); \
-		errno = __err; \
-		res = -1; \
-	} \
-	return (type) (res); \
-} while (0)
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __res __asm__("r0"); \
-__asm__ __volatile__ (\
-	"trap #" SYSCALL_VECTOR "|| nop"\
-	: "=r" (__res) \
-	: "r" (__scno) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-	"trap #" SYSCALL_VECTOR "|| nop"\
-	: "=r" (__res) \
-	: "r" (__scno), "0" (__res) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __arg2 __asm__ ("r1") = (long)(arg2); \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-	"trap #" SYSCALL_VECTOR "|| nop"\
-	: "=r" (__res) \
-	: "r" (__scno), "0" (__res), "r" (__arg2) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __arg3 __asm__ ("r2") = (long)(arg3); \
-register long __arg2 __asm__ ("r1") = (long)(arg2); \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-	"trap #" SYSCALL_VECTOR "|| nop"\
-	: "=r" (__res) \
-	: "r" (__scno), "0" (__res), "r" (__arg2), \
-		"r" (__arg3) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __arg4 __asm__ ("r3") = (long)(arg4); \
-register long __arg3 __asm__ ("r2") = (long)(arg3); \
-register long __arg2 __asm__ ("r1") = (long)(arg2); \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-	"trap #" SYSCALL_VECTOR "|| nop"\
-	: "=r" (__res) \
-	: "r" (__scno), "0" (__res), "r" (__arg2), \
-		"r" (__arg3), "r" (__arg4) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	type5,arg5) \
-type name(type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-register long __scno __asm__ ("r7") = __NR_##name; \
-register long __arg5 __asm__ ("r4") = (long)(arg5); \
-register long __arg4 __asm__ ("r3") = (long)(arg4); \
-register long __arg3 __asm__ ("r2") = (long)(arg3); \
-register long __arg2 __asm__ ("r1") = (long)(arg2); \
-register long __res __asm__ ("r0") = (long)(arg1); \
-__asm__ __volatile__ (\
-	"trap #" SYSCALL_VECTOR "|| nop"\
-	: "=r" (__res) \
-	: "r" (__scno), "0" (__res), "r" (__arg2), \
-		"r" (__arg3), "r" (__arg4), "r" (__arg5) \
-	: "memory"); \
-__syscall_return(type,__res); \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_STAT64
 #define __ARCH_WANT_SYS_ALARM
@@ -423,43 +315,6 @@
 #define __ARCH_WANT_SYS_OLDUMOUNT
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/linkage.h>
-#include <asm/ptrace.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-static __inline__ _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-
-asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
-			  unsigned long prot, unsigned long flags,
-			  unsigned long fd, unsigned long pgoff);
-asmlinkage int sys_execve(struct pt_regs regs);
-asmlinkage int sys_clone(struct pt_regs regs);
-asmlinkage int sys_fork(struct pt_regs regs);
-asmlinkage int sys_vfork(struct pt_regs regs);
-asmlinkage int sys_pipe(unsigned long __user *fildes);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				 const struct sigaction __user *act,
-				 struct sigaction __user *oact,
-				 size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-m68k/unistd.h
===================================================================
--- linux-cg.orig/include/asm-m68k/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-m68k/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -289,102 +289,6 @@
 
 #define NR_syscalls		282
 
-/* user-visible error numbers are in the range -1 - -124: see
-   <asm-m68k/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
-	/* avoid using res which is declared to be in register d0; \
-	   errno might expand to a function call and clobber it.  */ \
-		int __err = -(res); \
-		errno = __err; \
-		res = -1; \
-	} \
-	return (type) (res); \
-} while (0)
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-__asm__ __volatile__ ("trap  #0" \
-                      : "+d" (__res) ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,atype,a) \
-type name(atype a) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "+d" (__res) \
-		      : "d" (__a)  ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,atype,a,btype,b) \
-type name(atype a,btype b) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "+d" (__res) \
-                      : "d" (__a), "d" (__b) \
-		     ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
-type name(atype a,btype b,ctype c) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "+d" (__res) \
-                      : "d" (__a), "d" (__b), \
-			"d" (__c) \
-		     ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
-type name (atype a, btype b, ctype c, dtype d) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-__asm__ __volatile__ ("trap  #0" \
-                      : "+d" (__res) \
-                      : "d" (__a), "d" (__b), \
-			"d" (__c), "d" (__d)  \
-		     ); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name (atype a,btype b,ctype c,dtype d,etype e) \
-{ \
-register long __res __asm__ ("%d0") = __NR_##name; \
-register long __a __asm__ ("%d1") = (long)(a); \
-register long __b __asm__ ("%d2") = (long)(b); \
-register long __c __asm__ ("%d3") = (long)(c); \
-register long __d __asm__ ("%d4") = (long)(d); \
-register long __e __asm__ ("%d5") = (long)(e); \
-__asm__ __volatile__ ("trap  #0" \
-		      : "+d" (__res) \
-		      : "d" (__a), "d" (__b), \
-			"d" (__c), "d" (__d), "d" (__e)  \
-                     ); \
-__syscall_return(type,__res); \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
@@ -408,12 +312,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-#ifdef __KERNEL_SYSCALLS__
-
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-m68knommu/unistd.h
===================================================================
--- linux-cg.orig/include/asm-m68knommu/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-m68knommu/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -290,155 +290,6 @@
 
 #define NR_syscalls		282
 
-/* user-visible error numbers are in the range -1 - -122: see
-   <asm-m68k/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
-	/* avoid using res which is declared to be in register d0; \
-	   errno might expand to a function call and clobber it.  */ \
-		int __err = -(res); \
-		errno = __err; \
-		res = -1; \
-	} \
-	return (type) (res); \
-} while (0)
-
-#define _syscall0(type, name)							\
-type name(void)									\
-{										\
-  long __res;									\
-  __asm__ __volatile__ ("movel	%1, %%d0\n\t"					\
-  			"trap	#0\n\t"						\
-  			"movel	%%d0, %0"					\
-			: "=g" (__res)						\
-			: "i" (__NR_##name)					\
-			: "cc", "%d0");						\
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {				\
-    errno = -__res;								\
-    __res = -1;									\
-  }										\
-  return (type)__res;								\
-}
-
-#define _syscall1(type, name, atype, a)						\
-type name(atype a)								\
-{										\
-  long __res;									\
-  __asm__ __volatile__ ("movel	%2, %%d1\n\t"					\
-  			"movel	%1, %%d0\n\t"					\
-  			"trap	#0\n\t"						\
-  			"movel	%%d0, %0"					\
-			: "=g" (__res)						\
-			: "i" (__NR_##name),					\
-			  "g" ((long)a)						\
-			: "cc", "%d0", "%d1");					\
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {				\
-    errno = -__res;								\
-    __res = -1;									\
-  }										\
-  return (type)__res;								\
-}
-
-#define _syscall2(type, name, atype, a, btype, b)				\
-type name(atype a, btype b)							\
-{										\
-  long __res;									\
-  __asm__ __volatile__ ("movel	%3, %%d2\n\t"					\
-  			"movel	%2, %%d1\n\t"					\
-			"movel	%1, %%d0\n\t"					\
-  			"trap	#0\n\t"						\
-  			"movel	%%d0, %0"					\
-			: "=g" (__res)						\
-			: "i" (__NR_##name),					\
-			  "a" ((long)a),					\
-			  "g" ((long)b)						\
-			: "cc", "%d0", "%d1", "%d2");				\
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {				\
-    errno = -__res;								\
-    __res = -1;									\
-  }										\
-  return (type)__res;								\
-}
-
-#define _syscall3(type, name, atype, a, btype, b, ctype, c)			\
-type name(atype a, btype b, ctype c)						\
-{										\
-  long __res;									\
-  __asm__ __volatile__ ("movel	%4, %%d3\n\t"					\
-			"movel	%3, %%d2\n\t"					\
-  			"movel	%2, %%d1\n\t"					\
-			"movel	%1, %%d0\n\t"					\
-  			"trap	#0\n\t"						\
-  			"movel	%%d0, %0"					\
-			: "=g" (__res)						\
-			: "i" (__NR_##name),					\
-			  "a" ((long)a),					\
-			  "a" ((long)b),					\
-			  "g" ((long)c)						\
-			: "cc", "%d0", "%d1", "%d2", "%d3");			\
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {				\
-    errno = -__res;								\
-    __res = -1;									\
-  }										\
-  return (type)__res;								\
-}
-
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)		\
-type name(atype a, btype b, ctype c, dtype d)					\
-{										\
-  long __res;									\
-  __asm__ __volatile__ ("movel	%5, %%d4\n\t"					\
-			"movel	%4, %%d3\n\t"					\
-			"movel	%3, %%d2\n\t"					\
-  			"movel	%2, %%d1\n\t"					\
-			"movel	%1, %%d0\n\t"					\
-  			"trap	#0\n\t"						\
-  			"movel	%%d0, %0"					\
-			: "=g" (__res)						\
-			: "i" (__NR_##name),					\
-			  "a" ((long)a),					\
-			  "a" ((long)b),					\
-			  "a" ((long)c),					\
-			  "g" ((long)d)						\
-			: "cc", "%d0", "%d1", "%d2", "%d3",			\
-			  "%d4");						\
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {				\
-    errno = -__res;								\
-    __res = -1;									\
-  }										\
-  return (type)__res;								\
-}
-
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)	\
-type name(atype a, btype b, ctype c, dtype d, etype e)				\
-{										\
-  long __res;									\
-  __asm__ __volatile__ ("movel	%6, %%d5\n\t"					\
-			"movel	%5, %%d4\n\t"					\
-			"movel	%4, %%d3\n\t"					\
-			"movel	%3, %%d2\n\t"					\
-  			"movel	%2, %%d1\n\t"					\
-			"movel	%1, %%d0\n\t"					\
-  			"trap	#0\n\t"						\
-  			"movel	%%d0, %0"					\
-			: "=g" (__res)						\
-			: "i" (__NR_##name),					\
-			  "a" ((long)a),					\
-			  "a" ((long)b),					\
-			  "a" ((long)c),					\
-			  "a" ((long)d),					\
-			  "g" ((long)e)						\
-			: "cc", "%d0", "%d1", "%d2", "%d3",			\
-			  "%d4", "%d5");					\
-  if ((unsigned long)(__res) >= (unsigned long)(-125)) {				\
-    errno = -__res;								\
-    __res = -1;									\
-  }										\
-  return (type)__res;								\
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
@@ -462,61 +313,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/interrupt.h>
-#include <linux/types.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static inline _syscall0(int,pause)
-static inline _syscall0(int,sync)
-static inline _syscall0(pid_t,setsid)
-static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
-static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static inline _syscall1(int,dup,int,fd)
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
-static inline _syscall1(int,close,int,fd)
-static inline _syscall1(int,_exit,int,exitcode)
-static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-static inline _syscall1(int,delete_module,const char *,name)
-
-static inline pid_t wait(int * wait_stat)
-{
-	return waitpid(-1,wait_stat,0);
-}
-asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long pgoff);
-asmlinkage int sys_execve(char *name, char **argv, char **envp);
-asmlinkage int sys_pipe(unsigned long *fildes);
-struct pt_regs;
-int sys_request_irq(unsigned int,
-			irqreturn_t (*)(int, void *, struct pt_regs *),
-			unsigned long, const char *, void *);
-void sys_free_irq(unsigned int, void *);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-mips/unistd.h
===================================================================
--- linux-cg.orig/include/asm-mips/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-mips/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -918,268 +918,6 @@
 
 #ifndef __ASSEMBLY__
 
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-	register unsigned long __a3 asm("$7"); \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"li\t$2, %2\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "=r" (__a3) \
-	: "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-/*
- * DANGER: This macro isn't usable for the pipe(2) call
- * which has a unusual return convention.
- */
-#define _syscall1(type,name,atype,a) \
-type name(atype a) \
-{ \
-	register unsigned long __a0 asm("$4") = (unsigned long) a; \
-	register unsigned long __a3 asm("$7"); \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"li\t$2, %3\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "=r" (__a3) \
-	: "r" (__a0), "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-#define _syscall2(type,name,atype,a,btype,b) \
-type name(atype a, btype b) \
-{ \
-	register unsigned long __a0 asm("$4") = (unsigned long) a; \
-	register unsigned long __a1 asm("$5") = (unsigned long) b; \
-	register unsigned long __a3 asm("$7"); \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"li\t$2, %4\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "=r" (__a3) \
-	: "r" (__a0), "r" (__a1), "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-#define _syscall3(type,name,atype,a,btype,b,ctype,c) \
-type name(atype a, btype b, ctype c) \
-{ \
-	register unsigned long __a0 asm("$4") = (unsigned long) a; \
-	register unsigned long __a1 asm("$5") = (unsigned long) b; \
-	register unsigned long __a2 asm("$6") = (unsigned long) c; \
-	register unsigned long __a3 asm("$7"); \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"li\t$2, %5\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "=r" (__a3) \
-	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-#define _syscall4(type,name,atype,a,btype,b,ctype,c,dtype,d) \
-type name(atype a, btype b, ctype c, dtype d) \
-{ \
-	register unsigned long __a0 asm("$4") = (unsigned long) a; \
-	register unsigned long __a1 asm("$5") = (unsigned long) b; \
-	register unsigned long __a2 asm("$6") = (unsigned long) c; \
-	register unsigned long __a3 asm("$7") = (unsigned long) d; \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"li\t$2, %5\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "+r" (__a3) \
-	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-#if (_MIPS_SIM == _MIPS_SIM_ABI32)
-
-/*
- * Using those means your brain needs more than an oil change ;-)
- */
-
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name(atype a, btype b, ctype c, dtype d, etype e) \
-{ \
-	register unsigned long __a0 asm("$4") = (unsigned long) a; \
-	register unsigned long __a1 asm("$5") = (unsigned long) b; \
-	register unsigned long __a2 asm("$6") = (unsigned long) c; \
-	register unsigned long __a3 asm("$7") = (unsigned long) d; \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"lw\t$2, %6\n\t" \
-	"subu\t$29, 32\n\t" \
-	"sw\t$2, 16($29)\n\t" \
-	"li\t$2, %5\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	"addiu\t$29, 32\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "+r" (__a3) \
-	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
-	  "m" ((unsigned long)e) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
-type name(atype a, btype b, ctype c, dtype d, etype e, ftype f) \
-{ \
-	register unsigned long __a0 asm("$4") = (unsigned long) a; \
-	register unsigned long __a1 asm("$5") = (unsigned long) b; \
-	register unsigned long __a2 asm("$6") = (unsigned long) c; \
-	register unsigned long __a3 asm("$7") = (unsigned long) d; \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"lw\t$2, %6\n\t" \
-	"lw\t$8, %7\n\t" \
-	"subu\t$29, 32\n\t" \
-	"sw\t$2, 16($29)\n\t" \
-	"sw\t$8, 20($29)\n\t" \
-	"li\t$2, %5\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	"addiu\t$29, 32\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "+r" (__a3) \
-	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_##name), \
-	  "m" ((unsigned long)e), "m" ((unsigned long)f) \
-	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-#endif /* (_MIPS_SIM == _MIPS_SIM_ABI32) */
-
-#if (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64)
-
-#define _syscall5(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e) \
-type name (atype a,btype b,ctype c,dtype d,etype e) \
-{ \
-	register unsigned long __a0 asm("$4") = (unsigned long) a; \
-	register unsigned long __a1 asm("$5") = (unsigned long) b; \
-	register unsigned long __a2 asm("$6") = (unsigned long) c; \
-	register unsigned long __a3 asm("$7") = (unsigned long) d; \
-	register unsigned long __a4 asm("$8") = (unsigned long) e; \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"li\t$2, %6\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "+r" (__a3) \
-	: "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "i" (__NR_##name) \
-	: "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-#define _syscall6(type,name,atype,a,btype,b,ctype,c,dtype,d,etype,e,ftype,f) \
-type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
-{ \
-	register unsigned long __a0 asm("$4") = (unsigned long) a; \
-	register unsigned long __a1 asm("$5") = (unsigned long) b; \
-	register unsigned long __a2 asm("$6") = (unsigned long) c; \
-	register unsigned long __a3 asm("$7") = (unsigned long) d; \
-	register unsigned long __a4 asm("$8") = (unsigned long) e; \
-	register unsigned long __a5 asm("$9") = (unsigned long) f; \
-	unsigned long __v0; \
-	\
-	__asm__ volatile ( \
-	".set\tnoreorder\n\t" \
-	"li\t$2, %7\t\t\t# " #name "\n\t" \
-	"syscall\n\t" \
-	"move\t%0, $2\n\t" \
-	".set\treorder" \
-	: "=&r" (__v0), "+r" (__a3) \
-	: "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), "r" (__a5), \
-	  "i" (__NR_##name) \
-	: "$2", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24", \
-	  "memory"); \
-	\
-	if (__a3 == 0) \
-		return (type) __v0; \
-	errno = __v0; \
-	return (type) -1; \
-}
-
-#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
-
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_SYS_ALARM
@@ -1206,45 +944,6 @@
 #  define __ARCH_WANT_COMPAT_SYS_TIME
 # endif
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/linkage.h>
-#include <asm/ptrace.h>
-#include <asm/sim.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-
-asmlinkage unsigned long sys_mmap(
-				unsigned long addr, size_t len,
-				int prot, int flags,
-				int fd, off_t offset);
-asmlinkage long sys_mmap2(
-			unsigned long addr, unsigned long len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long pgoff);
-asmlinkage int sys_execve(nabi_no_regargs struct pt_regs regs);
-asmlinkage int sys_pipe(nabi_no_regargs struct pt_regs regs);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
 #endif /* !__ASSEMBLY__ */
 
 /*
Index: linux-cg/include/asm-s390/unistd.h
===================================================================
--- linux-cg.orig/include/asm-s390/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-s390/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -394,158 +394,6 @@
 
 #ifdef __KERNEL__
 
-#define __syscall_return(type, res)			     \
-do {							     \
-	if ((unsigned long)(res) >= (unsigned long)(-4095)) {\
-		errno = -(res);				     \
-		res = -1;				     \
-	}						     \
-	return (type) (res);				     \
-} while (0)
-
-#define _svc_clobber "1", "cc", "memory"
-
-#define _syscall0(type,name)				     \
-type name(void) {					     \
-	register long __svcres asm("2");		     \
-	long __res;					     \
-	__asm__ __volatile__ (				     \
-		"    .if %1 < 256\n"			     \
-		"    svc %b1\n"				     \
-		"    .else\n"				     \
-		"    la  %%r1,%1\n"			     \
-		"    svc 0\n"				     \
-		"    .endif"				     \
-		: "=d" (__svcres)			     \
-		: "i" (__NR_##name)			     \
-		: _svc_clobber );			     \
-	__res = __svcres;				     \
-	__syscall_return(type,__res);			     \
-}
-
-#define _syscall1(type,name,type1,arg1)			     \
-type name(type1 arg1) {					     \
-	register type1 __arg1 asm("2") = arg1;		     \
-	register long __svcres asm("2");		     \
-	long __res;					     \
-	__asm__ __volatile__ (				     \
-		"    .if %1 < 256\n"			     \
-		"    svc %b1\n"				     \
-		"    .else\n"				     \
-		"    la  %%r1,%1\n"			     \
-		"    svc 0\n"				     \
-		"    .endif"				     \
-		: "=d" (__svcres)			     \
-		: "i" (__NR_##name),			     \
-		  "0" (__arg1)				     \
-		: _svc_clobber );			     \
-	__res = __svcres;				     \
-	__syscall_return(type,__res);			     \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2)	     \
-type name(type1 arg1, type2 arg2) {			     \
-	register type1 __arg1 asm("2") = arg1;		     \
-	register type2 __arg2 asm("3") = arg2;		     \
-	register long __svcres asm("2");		     \
-	long __res;					     \
-	__asm__ __volatile__ (				     \
-		"    .if %1 < 256\n"			     \
-		"    svc %b1\n"				     \
-		"    .else\n"				     \
-		"    la %%r1,%1\n"			     \
-		"    svc 0\n"				     \
-		"    .endif"				     \
-		: "=d" (__svcres)			     \
-		: "i" (__NR_##name),			     \
-		  "0" (__arg1),				     \
-		  "d" (__arg2)				     \
-		: _svc_clobber );			     \
-	__res = __svcres;				     \
-	__syscall_return(type,__res);			     \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)\
-type name(type1 arg1, type2 arg2, type3 arg3) {		     \
-	register type1 __arg1 asm("2") = arg1;		     \
-	register type2 __arg2 asm("3") = arg2;		     \
-	register type3 __arg3 asm("4") = arg3;		     \
-	register long __svcres asm("2");		     \
-	long __res;					     \
-	__asm__ __volatile__ (				     \
-		"    .if %1 < 256\n"			     \
-		"    svc %b1\n"				     \
-		"    .else\n"				     \
-		"    la  %%r1,%1\n"			     \
-		"    svc 0\n"				     \
-		"    .endif"				     \
-		: "=d" (__svcres)			     \
-		: "i" (__NR_##name),			     \
-		  "0" (__arg1),				     \
-		  "d" (__arg2),				     \
-		  "d" (__arg3)				     \
-		: _svc_clobber );			     \
-	__res = __svcres;				     \
-	__syscall_return(type,__res);			     \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,\
-		  type4,name4)				     \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) {  \
-	register type1 __arg1 asm("2") = arg1;		     \
-	register type2 __arg2 asm("3") = arg2;		     \
-	register type3 __arg3 asm("4") = arg3;		     \
-	register type4 __arg4 asm("5") = arg4;		     \
-	register long __svcres asm("2");		     \
-	long __res;					     \
-	__asm__ __volatile__ (				     \
-		"    .if %1 < 256\n"			     \
-		"    svc %b1\n"				     \
-		"    .else\n"				     \
-		"    la  %%r1,%1\n"			     \
-		"    svc 0\n"				     \
-		"    .endif"				     \
-		: "=d" (__svcres)			     \
-		: "i" (__NR_##name),			     \
-		  "0" (__arg1),				     \
-		  "d" (__arg2),				     \
-		  "d" (__arg3),				     \
-		  "d" (__arg4)				     \
-		: _svc_clobber );			     \
-	__res = __svcres;				     \
-	__syscall_return(type,__res);			     \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,\
-		  type4,name4,type5,name5)		     \
-type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,    \
-	  type5 arg5) {					     \
-	register type1 __arg1 asm("2") = arg1;		     \
-	register type2 __arg2 asm("3") = arg2;		     \
-	register type3 __arg3 asm("4") = arg3;		     \
-	register type4 __arg4 asm("5") = arg4;		     \
-	register type5 __arg5 asm("6") = arg5;		     \
-	register long __svcres asm("2");		     \
-	long __res;					     \
-	__asm__ __volatile__ (				     \
-		"    .if %1 < 256\n"			     \
-		"    svc %b1\n"				     \
-		"    .else\n"				     \
-		"    la  %%r1,%1\n"			     \
-		"    svc 0\n"				     \
-		"    .endif"				     \
-		: "=d" (__svcres)			     \
-		: "i" (__NR_##name),			     \
-		  "0" (__arg1),				     \
-		  "d" (__arg2),				     \
-		  "d" (__arg3),				     \
-		  "d" (__arg4),				     \
-		  "d" (__arg5)				     \
-		: _svc_clobber );			     \
-	__res = __svcres;				     \
-	__syscall_return(type,__res);			     \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_SYS_ALARM
@@ -573,57 +421,6 @@
 #   define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
 # endif
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <asm/ptrace.h>
-#include <asm/stat.h>
-#include <linux/syscalls.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static inline _syscall0(pid_t,setsid)
-static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
-static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static inline _syscall1(int,dup,int,fd)
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
-static inline _syscall1(int,close,int,fd)
-static inline _syscall2(long,stat,char *,filename,struct stat *,statbuf)
-
-static inline pid_t waitpid(int pid, int *wait_stat, int flags)
-{
-	return sys_wait4(pid, wait_stat, flags, NULL);
-}
-struct mmap_arg_struct;
-asmlinkage long sys_mmap2(struct mmap_arg_struct __user *arg);
-
-asmlinkage long sys_execve(struct pt_regs regs);
-asmlinkage long sys_clone(struct pt_regs regs);
-asmlinkage long sys_fork(struct pt_regs regs);
-asmlinkage long sys_vfork(struct pt_regs regs);
-asmlinkage long sys_pipe(unsigned long __user *fildes);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-sh/unistd.h
===================================================================
--- linux-cg.orig/include/asm-sh/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-sh/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -306,122 +306,6 @@
 
 #ifdef __KERNEL__
 
-/* user-visible error numbers are in the range -1 - -124: see <asm-sh/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-	if ((unsigned long)(res) >= (unsigned long)(-124)) { \
-	/* Avoid using "res" which is declared to be in register r0; \
-	   errno might expand to a function call and clobber it.  */ \
-		int __err = -(res); \
-		errno = __err; \
-		res = -1; \
-	} \
-	return (type) (res); \
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-__asm__ __volatile__ ("trapa	#0x10" \
-	: "=z" (__sc0) \
-	: "0" (__sc0) \
-	: "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-__asm__ __volatile__ ("trapa	#0x11" \
-	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4) \
-	: "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-__asm__ __volatile__ ("trapa	#0x12" \
-	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5) \
-	: "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-__asm__ __volatile__ ("trapa	#0x13" \
-	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6) \
-	: "memory"); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-register long __sc0 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-__asm__ __volatile__ ("trapa	#0x14" \
-	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6),  \
-	  "r" (__sc7) \
-	: "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
-register long __sc3 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-register long __sc0 __asm__ ("r0") = (long) arg5; \
-__asm__ __volatile__ ("trapa	#0x15" \
-	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7),  \
-	  "r" (__sc3) \
-	: "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
-register long __sc3 __asm__ ("r3") = __NR_##name; \
-register long __sc4 __asm__ ("r4") = (long) arg1; \
-register long __sc5 __asm__ ("r5") = (long) arg2; \
-register long __sc6 __asm__ ("r6") = (long) arg3; \
-register long __sc7 __asm__ ("r7") = (long) arg4; \
-register long __sc0 __asm__ ("r0") = (long) arg5; \
-register long __sc1 __asm__ ("r1") = (long) arg6; \
-__asm__ __volatile__ ("trapa	#0x16" \
-	: "=z" (__sc0) \
-	: "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6), "r" (__sc7),  \
-	  "r" (__sc3), "r" (__sc1) \
-	: "memory" ); \
-__syscall_return(type,__sc0); \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
@@ -445,76 +329,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <linux/linkage.h>
-#include <asm/ptrace.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static __inline__ _syscall0(int,pause)
-static __inline__ _syscall0(int,sync)
-static __inline__ _syscall0(pid_t,setsid)
-static __inline__ _syscall3(int,write,int,fd,const char *,buf,off_t,count)
-static __inline__ _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static __inline__ _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static __inline__ _syscall1(int,dup,int,fd)
-static __inline__ _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-static __inline__ _syscall3(int,open,const char *,file,int,flag,int,mode)
-static __inline__ _syscall1(int,close,int,fd)
-static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-static __inline__ _syscall1(int,delete_module,const char *,name)
-
-static __inline__ pid_t wait(int * wait_stat)
-{
-	return waitpid(-1,wait_stat,0);
-}
-
-asmlinkage long sys_mmap2(
-			unsigned long addr, unsigned long len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long pgoff);
-asmlinkage int sys_execve(char *ufilename, char **uargv,
-			char **uenvp, unsigned long r7,
-			struct pt_regs regs);
-asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
-			unsigned long parent_tidptr,
-			unsigned long child_tidptr,
-			struct pt_regs regs);
-asmlinkage int sys_fork(unsigned long r4, unsigned long r5,
-			unsigned long r6, unsigned long r7,
-			struct pt_regs regs);
-asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
-			unsigned long r6, unsigned long r7,
-			struct pt_regs regs);
-asmlinkage int sys_pipe(unsigned long r4, unsigned long r5,
-			unsigned long r6, unsigned long r7,
-			struct pt_regs regs);
-asmlinkage ssize_t sys_pread_wrapper(unsigned int fd, char *buf,
-				size_t count, long dummy, loff_t pos);
-asmlinkage ssize_t sys_pwrite_wrapper(unsigned int fd, const char *buf,
-				size_t count, long dummy, loff_t pos);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-sh64/unistd.h
===================================================================
--- linux-cg.orig/include/asm-sh64/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-sh64/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -348,72 +348,6 @@
 
 #define NR_syscalls 321
 
-/* user-visible error numbers are in the range -1 - -125: see <asm-sh64/errno.h> */
-
-#define __syscall_return(type, res) \
-do { \
-	/* Note: when returning from kernel the return value is in r9	    \
-	**       This prevents conflicts between return value and arg1      \
-	**       when dispatching signal handler, in other words makes	    \
-	**       life easier in the system call epilogue (see entry.S)      \
-	*/								    \
-        register unsigned long __sr2 __asm__ ("r2") = res;		    \
-	if ((unsigned long)(res) >= (unsigned long)(-125)) { \
-		errno = -(res);						    \
-		__sr2 = -1; 						    \
-	} \
-	return (type) (__sr2); 						    \
-} while (0)
-
-/* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x10 << 16) | __NR_##name); \
-__asm__ __volatile__ ("trapa	%1 !\t\t\t" #name "()"			    \
-	: "=r" (__sc0) 							    \
-	: "r" (__sc0) ); 						    \
-__syscall_return(type,__sc0); 						    \
-}
-
-	/*
-	 * The apparent spurious "dummy" assembler comment is *needed*,
-	 * as without it, the compiler treats the arg<n> variables
-	 * as no longer live just before the asm. The compiler can
-	 * then optimize the storage into any registers it wishes.
-	 * The additional dummy statement forces the compiler to put
-	 * the arguments into the correct registers before the TRAPA.
-	 */
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x11 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;	    \
-__asm__ __volatile__ ("trapa	%1 !\t\t\t" #name "(%2)"		    \
-	: "=r" (__sc0) 							    \
-	: "r" (__sc0), "r" (__sc2));					    \
-__asm__ __volatile__ ("!dummy	%0 %1"				   	    \
-	:								    \
-	: "r" (__sc0), "r" (__sc2));					    \
-__syscall_return(type,__sc0); 						    \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x12 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;	    \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;	    \
-__asm__ __volatile__ ("trapa	%1 !\t\t\t" #name "(%2,%3)"		    \
-	: "=r" (__sc0) 							    \
-	: "r" (__sc0), "r" (__sc2), "r" (__sc3) );			    \
-__asm__ __volatile__ ("!dummy	%0 %1 %2"			   	    \
-	:								    \
-	: "r" (__sc0), "r" (__sc2), "r" (__sc3) );			    \
-__syscall_return(type,__sc0); 						    \
-}
-
 #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
 type name(type1 arg1,type2 arg2,type3 arg3) \
 { \
@@ -430,64 +364,6 @@
 __syscall_return(type,__sc0); 						    \
 }
 
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x14 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;	    \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;	    \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3;	    \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4;	    \
-__asm__ __volatile__ ("trapa	%1 !\t\t\t" #name "(%2,%3,%4,%5)"	    \
-	: "=r" (__sc0) 							    \
-	: "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
-__asm__ __volatile__ ("!dummy	%0 %1 %2 %3 %4"			   	    \
-	:								    \
-	: "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5) );\
-__syscall_return(type,__sc0); 						    \
-}
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x15 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;	    \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;	    \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3;	    \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4;	    \
-register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5;	    \
-__asm__ __volatile__ ("trapa	%1 !\t\t\t" #name "(%2,%3,%4,%5,%6)"	    \
-	: "=r" (__sc0) 							    \
-	: "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5),  \
-	  "r" (__sc6));							    \
-__asm__ __volatile__ ("!dummy	%0 %1 %2 %3 %4 %5"		   	    \
-	:								    \
-	: "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5),  \
-	  "r" (__sc6));							    \
-__syscall_return(type,__sc0); 						    \
-}
-
-#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5, type6, arg6) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
-{ \
-register unsigned long __sc0 __asm__ ("r9") = ((0x16 << 16) | __NR_##name); \
-register unsigned long __sc2 __asm__ ("r2") = (unsigned long) arg1;	    \
-register unsigned long __sc3 __asm__ ("r3") = (unsigned long) arg2;	    \
-register unsigned long __sc4 __asm__ ("r4") = (unsigned long) arg3;	    \
-register unsigned long __sc5 __asm__ ("r5") = (unsigned long) arg4;	    \
-register unsigned long __sc6 __asm__ ("r6") = (unsigned long) arg5;	    \
-register unsigned long __sc7 __asm__ ("r7") = (unsigned long) arg6;	    \
-__asm__ __volatile__ ("trapa	%1 !\t\t\t" #name "(%2,%3,%4,%5,%6,%7)"	    \
-	: "=r" (__sc0) 							    \
-	: "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5),  \
-	  "r" (__sc6), "r" (__sc7));					    \
-__asm__ __volatile__ ("!dummy	%0 %1 %2 %3 %4 %5 %6"		   	    \
-	:								    \
-	: "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4), "r" (__sc5),  \
-	  "r" (__sc6), "r" (__sc7));					    \
-__syscall_return(type,__sc0); 						    \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_OLD_STAT
@@ -511,47 +387,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-#ifdef __KERNEL_SYSCALLS__
-
-/* Copy from sh */
-#include <linux/compiler.h>
-#include <linux/types.h>
-#include <asm/ptrace.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static inline _syscall0(int,pause)
-static inline _syscall1(int,setup,int,magic)
-static inline _syscall0(int,sync)
-static inline _syscall0(pid_t,setsid)
-static inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
-static inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static inline _syscall1(int,dup,int,fd)
-static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-static inline _syscall3(int,open,const char *,file,int,flag,int,mode)
-static inline _syscall1(int,close,int,fd)
-static inline _syscall1(int,_exit,int,exitcode)
-static inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-static inline _syscall1(int,delete_module,const char *,name)
-
-static inline pid_t wait(int * wait_stat)
-{
-	return waitpid(-1,wait_stat,0);
-}
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-sparc/unistd.h
===================================================================
--- linux-cg.orig/include/asm-sparc/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-sparc/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -326,136 +326,6 @@
  *          find a free slot in the 0-301 range.
  */
 
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-__asm__ __volatile__ ("t 0x10\n\t" \
-		      "bcc 1f\n\t" \
-		      "mov %%o0, %0\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "1:\n\t" \
-		      : "=r" (__res)\
-		      : "r" (__g1) \
-		      : "o0", "cc"); \
-if (__res < -255 || __res >= 0) \
-    return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-		      "bcc 1f\n\t" \
-		      "mov %%o0, %0\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "1:\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__g1) \
-		      : "cc"); \
-if (__res < -255 || __res >= 0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-		      "bcc 1f\n\t" \
-		      "mov %%o0, %0\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "1:\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__o1), "r" (__g1) \
-		      : "cc"); \
-if (__res < -255 || __res >= 0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-		      "bcc 1f\n\t" \
-		      "mov %%o0, %0\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "1:\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
-		      : "cc"); \
-if (__res < -255 || __res>=0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-		      "bcc 1f\n\t" \
-		      "mov %%o0, %0\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "1:\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
-		      : "cc"); \
-if (__res < -255 || __res>=0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	  type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-register long __o4 __asm__ ("o4") = (long)(arg5); \
-__asm__ __volatile__ ("t 0x10\n\t" \
-		      "bcc 1f\n\t" \
-		      "mov %%o0, %0\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "1:\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
-		      : "cc"); \
-if (__res < -255 || __res>=0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
@@ -478,53 +348,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGSUSPEND
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static __inline__ _syscall0(pid_t,setsid)
-static __inline__ _syscall3(int,write,int,fd,__const__ char *,buf,off_t,count)
-static __inline__ _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static __inline__ _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static __inline__ _syscall1(int,dup,int,fd)
-static __inline__ _syscall3(int,execve,__const__ char *,file,char **,argv,char **,envp)
-static __inline__ _syscall3(int,open,__const__ char *,file,int,flag,int,mode)
-static __inline__ _syscall1(int,close,int,fd)
-static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-
-#include <linux/linkage.h>
-
-asmlinkage unsigned long sys_mmap(
-				unsigned long addr, unsigned long len,
-				unsigned long prot, unsigned long flags,
-				unsigned long fd, unsigned long off);
-asmlinkage unsigned long sys_mmap2(
-				unsigned long addr, unsigned long len,
-				unsigned long prot, unsigned long flags,
-				unsigned long fd, unsigned long pgoff);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				void __user *restorer,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  *
Index: linux-cg/include/asm-sparc64/unistd.h
===================================================================
--- linux-cg.orig/include/asm-sparc64/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-sparc64/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -328,166 +328,6 @@
  *          find a free slot in the 0-301 range.
  */
 
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "movcc %%xcc, %%o0, %0\n\t" \
-		      : "=r" (__res)\
-		      : "r" (__g1) \
-		      : "o0", "cc"); \
-if (__res >= 0) \
-    return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall1(type,name,type1,arg1) \
-type name(type1 arg1) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "movcc %%xcc, %%o0, %0\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__g1) \
-		      : "cc"); \
-if (__res >= 0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall2(type,name,type1,arg1,type2,arg2) \
-type name(type1 arg1,type2 arg2) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "movcc %%xcc, %%o0, %0\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__o1), "r" (__g1) \
-		      : "cc"); \
-if (__res >= 0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
-type name(type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "movcc %%xcc, %%o0, %0\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
-		      : "cc"); \
-if (__res>=0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-
-#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "movcc %%xcc, %%o0, %0\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
-		      : "cc"); \
-if (__res>=0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-} 
-
-#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
-	  type5,arg5) \
-type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-register long __g1 __asm__ ("g1") = __NR_##name; \
-register long __o0 __asm__ ("o0") = (long)(arg1); \
-register long __o1 __asm__ ("o1") = (long)(arg2); \
-register long __o2 __asm__ ("o2") = (long)(arg3); \
-register long __o3 __asm__ ("o3") = (long)(arg4); \
-register long __o4 __asm__ ("o4") = (long)(arg5); \
-__asm__ __volatile__ ("t 0x6d\n\t" \
-		      "sub %%g0, %%o0, %0\n\t" \
-		      "movcc %%xcc, %%o0, %0\n\t" \
-		      : "=r" (__res), "=&r" (__o0) \
-		      : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
-		      : "cc"); \
-if (__res>=0) \
-	return (type) __res; \
-errno = -__res; \
-return -1; \
-}
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-static __inline__ _syscall0(pid_t,setsid)
-static __inline__ _syscall3(int,write,int,fd,__const__ char *,buf,off_t,count)
-static __inline__ _syscall3(int,read,int,fd,char *,buf,off_t,count)
-static __inline__ _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-static __inline__ _syscall1(int,dup,int,fd)
-static __inline__ _syscall3(int,execve,__const__ char *,file,char **,argv,char **,envp)
-static __inline__ _syscall3(int,open,__const__ char *,file,int,flag,int,mode)
-static __inline__ _syscall1(int,close,int,fd)
-static __inline__ _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-
-#include <linux/linkage.h>
-
-asmlinkage unsigned long sys_mmap(
-				unsigned long addr, unsigned long len,
-				unsigned long prot, unsigned long flags,
-				unsigned long fd, unsigned long off);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				void __user *restorer,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /* sysconf options, for SunOS compatibility */
 #define   _SC_ARG_MAX             1
 #define   _SC_CHILD_MAX           2
Index: linux-cg/include/asm-v850/unistd.h
===================================================================
--- linux-cg.orig/include/asm-v850/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-v850/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -237,134 +237,6 @@
 
 #ifdef __KERNEL__
 
-#include <asm/clinkage.h>
-
-#define __syscall_return(type, res)					      \
-  do {									      \
-	  /* user-visible error numbers are in the range -1 - -124:	      \
-	     see <asm-v850/errno.h> */					      \
-	  if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-125), 0)) { \
-		  errno = -(res);					      \
-		  res = -1;						      \
-	  }								      \
-	  return (type) (res);						      \
-  } while (0)
-
-
-#define _syscall0(type, name)						      \
-type name (void)							      \
-{									      \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;	      \
-  register unsigned long __ret __asm__ (SYSCALL_RET);			      \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP			      \
-			: "=r" (__ret), "=r" (__syscall)	 	      \
-			: "1" (__syscall)				      \
-			: SYSCALL_SHORT_CLOBBERS);			      \
-  __syscall_return (type, __ret);					      \
-}
-
-#define _syscall1(type, name, atype, a)					      \
-type name (atype a)							      \
-{									      \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;			      \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;	      \
-  register unsigned long __ret __asm__ (SYSCALL_RET);			      \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP			      \
-			: "=r" (__ret), "=r" (__syscall)		      \
-			: "1" (__syscall), "r" (__a)			      \
-			: SYSCALL_SHORT_CLOBBERS);			      \
-  __syscall_return (type, __ret);					      \
-}
-
-#define _syscall2(type, name, atype, a, btype, b)			      \
-type name (atype a, btype b)						      \
-{									      \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;			      \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;			      \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;	      \
-  register unsigned long __ret __asm__ (SYSCALL_RET);			      \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP			      \
-			: "=r" (__ret), "=r" (__syscall)		      \
-			: "1" (__syscall), "r" (__a), "r" (__b)		      \
-			: SYSCALL_SHORT_CLOBBERS);			      \
-  __syscall_return (type, __ret);					      \
-}
-
-#define _syscall3(type, name, atype, a, btype, b, ctype, c)		      \
-type name (atype a, btype b, ctype c)					      \
-{									      \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;			      \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;			      \
-  register ctype __c __asm__ (SYSCALL_ARG2) = c;			      \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;	      \
-  register unsigned long __ret __asm__ (SYSCALL_RET);			      \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP			      \
-			: "=r" (__ret), "=r" (__syscall)		      \
-			: "1" (__syscall), "r" (__a), "r" (__b), "r" (__c)    \
-			: SYSCALL_SHORT_CLOBBERS);			      \
-  __syscall_return (type, __ret);					      \
-}
-
-#define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)	      \
-type name (atype a, btype b, ctype c, dtype d)				      \
-{									      \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;			      \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;			      \
-  register ctype __c __asm__ (SYSCALL_ARG2) = c;			      \
-  register dtype __d __asm__ (SYSCALL_ARG3) = d;			      \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;	      \
-  register unsigned long __ret __asm__ (SYSCALL_RET);			      \
-  __asm__ __volatile__ ("trap " SYSCALL_SHORT_TRAP			      \
-			: "=r" (__ret), "=r" (__syscall)		      \
-			: "1" (__syscall),				      \
-			"r" (__a), "r" (__b), "r" (__c), "r" (__d)	      \
-			: SYSCALL_SHORT_CLOBBERS);			      \
-  __syscall_return (type, __ret);					      \
-}
-
-#define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype,e)\
-type name (atype a, btype b, ctype c, dtype d, etype e)			      \
-{									      \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;			      \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;			      \
-  register ctype __c __asm__ (SYSCALL_ARG2) = c;			      \
-  register dtype __d __asm__ (SYSCALL_ARG3) = d;			      \
-  register etype __e __asm__ (SYSCALL_ARG4) = e;			      \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;	      \
-  register unsigned long __ret __asm__ (SYSCALL_RET);			      \
-  __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP			      \
-			: "=r" (__ret), "=r" (__syscall), "=r" (__e)	      \
-			: "1" (__syscall),				      \
-			"r" (__a), "r" (__b), "r" (__c), "r" (__d), "2" (__e) \
-			: SYSCALL_CLOBBERS);				      \
-  __syscall_return (type, __ret);					      \
-}
-
-#define __SYSCALL6_TRAP(syscall, ret, a, b, c, d, e, f)			      \
-  __asm__ __volatile__ ("trap " SYSCALL_LONG_TRAP			      \
-			: "=r" (ret), "=r" (syscall),			      \
- 			"=r" (e), "=r" (f)				      \
-			: "1" (syscall),				      \
-			"r" (a), "r" (b), "r" (c), "r" (d),		      \
-			"2" (e), "3" (f)				      \
-			: SYSCALL_CLOBBERS);
-
-#define _syscall6(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e, ftype, f) \
-type name (atype a, btype b, ctype c, dtype d, etype e, ftype f)	      \
-{									      \
-  register atype __a __asm__ (SYSCALL_ARG0) = a;			      \
-  register btype __b __asm__ (SYSCALL_ARG1) = b;			      \
-  register ctype __c __asm__ (SYSCALL_ARG2) = c;			      \
-  register dtype __d __asm__ (SYSCALL_ARG3) = d;			      \
-  register etype __e __asm__ (SYSCALL_ARG4) = e;			      \
-  register etype __f __asm__ (SYSCALL_ARG5) = f;			      \
-  register unsigned long __syscall __asm__ (SYSCALL_NUM) = __NR_##name;	      \
-  register unsigned long __ret __asm__ (SYSCALL_RET);			      \
-  __SYSCALL6_TRAP(__syscall, __ret, __a, __b, __c, __d, __e, __f);	      \
-  __syscall_return (type, __ret);					      \
-}
-		
-
 #define __ARCH_WANT_IPC_PARSE_VERSION
 #define __ARCH_WANT_OLD_READDIR
 #define __ARCH_WANT_STAT64
@@ -386,57 +258,6 @@
 #define __ARCH_WANT_SYS_SIGPROCMASK
 #define __ARCH_WANT_SYS_RT_SIGACTION
 
-#ifdef __KERNEL_SYSCALLS__
-
-#include <linux/compiler.h>
-#include <linux/types.h>
-
-/*
- * we need this inline - forking from kernel space will result
- * in NO COPY ON WRITE (!!!), until an execve is executed. This
- * is no problem, but for the stack. This is handled by not letting
- * main() use the stack at all after fork(). Thus, no function
- * calls - which means inline code for fork too, as otherwise we
- * would use the stack upon exit from 'fork()'.
- *
- * Actually only pause and fork are needed inline, so that there
- * won't be any messing with the stack from main(), but we define
- * some others too.
- */
-#define __NR__exit __NR_exit
-extern inline _syscall0(pid_t,setsid)
-extern inline _syscall3(int,write,int,fd,const char *,buf,off_t,count)
-extern inline _syscall3(int,read,int,fd,char *,buf,off_t,count)
-extern inline _syscall3(off_t,lseek,int,fd,off_t,offset,int,count)
-extern inline _syscall1(int,dup,int,fd)
-extern inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp)
-extern inline _syscall3(int,open,const char *,file,int,flag,int,mode)
-extern inline _syscall1(int,close,int,fd)
-extern inline _syscall1(int,_exit,int,exitcode)
-extern inline _syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options)
-
-extern inline pid_t wait(int * wait_stat)
-{
-	return waitpid (-1, wait_stat, 0);
-}
-
-unsigned long sys_mmap(unsigned long addr, size_t len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, off_t offset);
-unsigned long sys_mmap2(unsigned long addr, size_t len,
-			unsigned long prot, unsigned long flags,
-			unsigned long fd, unsigned long pgoff);
-struct pt_regs;
-int sys_execve (char *name, char **argv, char **envp, struct pt_regs *regs);
-int sys_pipe (int *fildes);
-struct sigaction;
-asmlinkage long sys_rt_sigaction(int sig,
-				const struct sigaction __user *act,
-				struct sigaction __user *oact,
-				size_t sigsetsize);
-
-#endif /* __KERNEL_SYSCALLS__ */
-
 /*
  * "Conditional" syscalls
  */
Index: linux-cg/include/asm-xtensa/unistd.h
===================================================================
--- linux-cg.orig/include/asm-xtensa/unistd.h	2006-08-27 21:36:06.000000000 +0200
+++ linux-cg/include/asm-xtensa/unistd.h	2006-08-27 21:36:52.000000000 +0200
@@ -207,9 +207,6 @@
 /* Keep this last; should always equal the last valid call number. */
 #define __NR_Linux_syscalls     220
 
-/* user-visible error numbers are in the range -1 - -125: see
- * <asm-xtensa/errno.h> */
-
 #define SYSXTENSA_RESERVED	   0	/* don't use this */
 #define SYSXTENSA_ATOMIC_SET	   1	/* set variable */
 #define SYSXTENSA_ATOMIC_EXG_ADD   2	/* exchange memory and add */
@@ -219,194 +216,6 @@
 #define SYSXTENSA_COUNT		   5	/* count of syscall0 functions*/
 
 #ifdef __KERNEL__
-#include <linux/linkage.h>
-
-#define __syscall_return(type, res) return ((type)(res))
-
-/* Tensilica's xt-xcc compiler is much more agressive at code
- * optimization than gcc.  Multiple __asm__ statements are
- * insufficient for xt-xcc because subsequent optimization passes
- * (beyond the front-end that knows of __asm__ statements and other
- * such GNU Extensions to C) can modify the register selection for
- * containment of C variables.
- *
- * xt-xcc cannot modify the contents of a single __asm__ statement, so
- * we create single-asm versions of the syscall macros that are
- * suitable and optimal for both xt-xcc and gcc.
- *
- * Linux takes system-call arguments in registers.  The following
- * design is optimized for user-land apps (e.g., glibc) which
- * typically have a function wrapper around the "syscall" assembly
- * instruction.  It satisfies the Xtensa ABI while minizing argument
- * shifting.
- *
- * The Xtensa ABI and software conventions require the system-call
- * number in a2.  If an argument exists in a2, we move it to the next
- * available register.  Note that for improved efficiency, we do NOT
- * shift all parameters down one register to maintain the original
- * order.
- *
- * At best case (zero arguments), we just write the syscall number to
- * a2.  At worst case (1 to 6 arguments), we move the argument in a2
- * to the next available register, then write the syscall number to
- * a2.
- *
- * For clarity, the following truth table enumerates all possibilities.
- *
- * arguments	syscall number	arg0, arg1, arg2, arg3, arg4, arg5
- * ---------	--------------	----------------------------------
- *	0	      a2
- *	1	      a2	a3
- *	2	      a2	a4,   a3
- *	3	      a2	a5,   a3,   a4
- *	4	      a2	a6,   a3,   a4,   a5
- *	5	      a2	a7,   a3,   a4,   a5,   a6
- *	6	      a2	a8,   a3,   a4,   a5,   a6,   a7
- */
-
-#define _syscall0(type,name) \
-type name(void) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-	"  movi  a2, %1 \n" \
-	"  syscall      \n" \
-	"  mov   %0, a2 \n" \
-	: "=a" (__res) \
-	: "i" (__NR_##name) \
-	: "a2" \
-	); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall1(type,name,type0,arg0) \
-type name(type0 arg0) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-	"  mov   a3, %2 \n" \
-	"  movi  a2, %1 \n" \
-	"  syscall      \n" \
-	"  mov   %0, a2 \n" \
-	: "=a" (__res) \
-	: "i" (__NR_##name), "a" (arg0) \
-	: "a2", "a3" \
-	); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall2(type,name,type0,arg0,type1,arg1) \
-type name(type0 arg0,type1 arg1) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-	"  mov   a4, %2 \n" \
-	"  mov   a3, %3 \n" \
-	"  movi  a2, %1 \n" \
-	"  syscall      \n" \
-	"  mov   %0, a2 \n" \
-	: "=a" (__res) \
-	: "i" (__NR_##name), "a" (arg0), "a" (arg1) \
-	: "a2", "a3", "a4" \
-	); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall3(type,name,type0,arg0,type1,arg1,type2,arg2) \
-type name(type0 arg0,type1 arg1,type2 arg2) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-	"  mov   a5, %2 \n" \
-	"  mov   a4, %4 \n" \
-	"  mov   a3, %3 \n" \
-	"  movi  a2, %1 \n" \
-	"  syscall      \n" \
-	"  mov   %0, a2 \n" \
-	: "=a" (__res) \
-	: "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2) \
-	: "a2", "a3", "a4", "a5" \
-	); \
-__syscall_return(type,__res); \
-}
-
-#define _syscall4(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3) \
-type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-	"  mov   a6, %2 \n" \
-	"  mov   a5, %5 \n" \
-	"  mov   a4, %4 \n" \
-	"  mov   a3, %3 \n" \
-	"  movi  a2, %1 \n" \
-	"  syscall      \n" \
-	"  mov   %0, a2 \n" \
-	: "=a" (__res) \
-	: "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), "a" (arg3) \
-	: "a2", "a3", "a4", "a5", "a6" \
-	); \
-__syscall_return(type,__res); \
-}
-
-/* Note that we save and restore the a7 frame pointer.
- * Including a7 in the clobber list doesn't do what you'd expect.
- */
-#define _syscall5(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
-type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-	"  mov   a9, a7 \n" \
-	"  mov   a7, %2 \n" \
-	"  mov   a6, %6 \n" \
-	"  mov   a5, %5 \n" \
-	"  mov   a4, %4 \n" \
-	"  mov   a3, %3 \n" \
-	"  movi  a2, %1 \n" \
-	"  syscall      \n" \
-	"  mov   a7, a9 \n" \
-	"  mov   %0, a2 \n" \
-	: "=a" (__res) \
-	: "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
-                             "a" (arg3), "a" (arg4) \
-	: "a2", "a3", "a4", "a5", "a6", "a9" \
-	); \
-__syscall_return(type,__res); \
-}
-
-/* Note that we save and restore the a7 frame pointer.
- * Including a7 in the clobber list doesn't do what you'd expect.
- */
-#define _syscall6(type,name,type0,arg0,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
-type name(type0 arg0,type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
-{ \
-long __res; \
-__asm__ __volatile__ ( \
-	"  mov   a9, a7 \n" \
-	"  mov   a8, %2 \n" \
-	"  mov   a7, %7 \n" \
-	"  mov   a6, %6 \n" \
-	"  mov   a5, %5 \n" \
-	"  mov   a4, %4 \n" \
-	"  mov   a3, %3 \n" \
-	"  movi  a2, %1 \n" \
-	"  syscall      \n" \
-	"  mov   a7, a9 \n" \
-	"  mov   %0, a2 \n" \
-	: "=a" (__res) \
-	: "i" (__NR_##name), "a" (arg0), "a" (arg1), "a" (arg2), \
-                             "a" (arg3), "a" (arg4), "a" (arg5)  \
-	: "a2", "a3", "a4", "a5", "a6", "a8", "a9" \
-	); \
-__syscall_return(type,__res); \
-}
-
-
-#ifdef __KERNEL_SYSCALLS__
-static __inline__ _syscall3(int,execve,const char*,file,char**,argv,char**,envp)
-#endif
-
 /*
  * "Conditional" syscalls
  *

--


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

* [PATCH 7/7] remove the global errno from the kernel
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
                   ` (3 preceding siblings ...)
  2006-08-27 21:47 ` [PATCH 6/7] remove all remaining _syscallX macros Arnd Bergmann
@ 2006-08-27 21:47 ` Arnd Bergmann
  2006-08-27 22:00 ` [PATCH 5/7] sh64: remove the use of kernel syscalls Arnd Bergmann
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-27 21:47 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty

[-- Attachment #1: kernel_execve3.diff --]
[-- Type: text/plain, Size: 3891 bytes --]

The last in-kernel user of errno is gone, so we should
remove the definition and everything referring to it.
This also removes the now-unused lib/execve.c file
that was introduced earlier.

Also remove a few bogus definitions of __KERNEL_SYSCALLS__
that were already unused.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/lib/Makefile
===================================================================
--- linux-cg.orig/lib/Makefile	2006-08-27 23:44:35.000000000 +0200
+++ linux-cg/lib/Makefile	2006-08-27 23:44:38.000000000 +0200
@@ -2,7 +2,7 @@
 # Makefile for some libs needed in the kernel.
 #
 
-lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
+lib-y := ctype.o string.o vsprintf.o cmdline.o \
 	 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
 	 idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \
 	 sha1.o
Index: linux-cg/lib/execve.c
===================================================================
--- linux-cg.orig/lib/execve.c	2006-08-27 23:44:35.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,23 +0,0 @@
-#include <asm/bug.h>
-#include <asm/uaccess.h>
-
-#define __KERNEL_SYSCALLS__
-static int errno __attribute__((unused));
-#include <asm/unistd.h>
-
-#ifdef _syscall3
-int kernel_execve (const char *filename, char *const argv[], char *const envp[])
-								__attribute__((__weak__));
-int kernel_execve (const char *filename, char *const argv[], char *const envp[])
-{
-	mm_segment_t fs = get_fs();
-	int ret;
-
-	WARN_ON(segment_eq(fs, USER_DS));
-	ret = execve(filename, (char **)argv, (char **)envp);
-	if (ret)
-		ret = -errno;
-
-	return ret;
-}
-#endif
Index: linux-cg/include/linux/unistd.h
===================================================================
--- linux-cg.orig/include/linux/unistd.h	2006-08-27 23:41:34.000000000 +0200
+++ linux-cg/include/linux/unistd.h	2006-08-27 23:44:38.000000000 +0200
@@ -1,12 +1,8 @@
 #ifndef _LINUX_UNISTD_H_
 #define _LINUX_UNISTD_H_
 
-#ifdef __KERNEL__
-extern int errno;
-#endif
-
 /*
- * Include machine specific syscallX macros
+ * Include machine specific syscall numbers
  */
 #include <asm/unistd.h>
 
Index: linux-cg/lib/errno.c
===================================================================
--- linux-cg.orig/lib/errno.c	2006-08-27 23:41:34.000000000 +0200
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,7 +0,0 @@
-/*
- *  linux/lib/errno.c
- *
- *  Copyright (C) 1991, 1992  Linus Torvalds
- */
-
-int errno;
Index: linux-cg/arch/ia64/kernel/process.c
===================================================================
--- linux-cg.orig/arch/ia64/kernel/process.c	2006-08-27 23:44:53.000000000 +0200
+++ linux-cg/arch/ia64/kernel/process.c	2006-08-27 23:44:54.000000000 +0200
@@ -8,8 +8,6 @@
  * 2005-10-07 Keith Owens <kaos@sgi.com>
  *	      Add notify_die() hooks.
  */
-#define __KERNEL_SYSCALLS__	/* see <asm/unistd.h> */
-
 #include <linux/cpu.h>
 #include <linux/pm.h>
 #include <linux/elf.h>
Index: linux-cg/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
===================================================================
--- linux-cg.orig/drivers/media/dvb/dvb-core/dvb_ringbuffer.c	2006-08-27 23:44:53.000000000 +0200
+++ linux-cg/drivers/media/dvb/dvb-core/dvb_ringbuffer.c	2006-08-27 23:44:54.000000000 +0200
@@ -26,7 +26,6 @@
 
 
 
-#define __KERNEL_SYSCALLS__
 #include <linux/errno.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
Index: linux-cg/drivers/net/wireless/ipw2100.c
===================================================================
--- linux-cg.orig/drivers/net/wireless/ipw2100.c	2006-08-27 23:44:53.000000000 +0200
+++ linux-cg/drivers/net/wireless/ipw2100.c	2006-08-27 23:44:54.000000000 +0200
@@ -150,7 +150,6 @@
 #include <linux/skbuff.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
-#define __KERNEL_SYSCALLS__
 #include <linux/fs.h>
 #include <linux/mm.h>
 #include <linux/slab.h>

--


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

* [PATCH 5/7] sh64: remove the use of kernel syscalls
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
                   ` (4 preceding siblings ...)
  2006-08-27 21:47 ` [PATCH 7/7] remove the global errno from the kernel Arnd Bergmann
@ 2006-08-27 22:00 ` Arnd Bergmann
  2006-08-28  8:05   ` Paul Mundt
  2006-08-27 22:01 ` [PATCH 1/7] introduce kernel_execve Arnd Bergmann
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-27 22:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty,
	linuxsh-shmedia-dev, lethal, rc

sh64 is using system call macros to call some functions
from the kernel. Remove those so we can get rid of
kernel syscalls.

This is probably not the best implementation and may
need to be redone.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/arch/sh64/kernel/process.c
===================================================================
--- linux-cg.orig/arch/sh64/kernel/process.c	2006-08-27 23:36:34.000000000 +0200
+++ linux-cg/arch/sh64/kernel/process.c	2006-08-27 23:40:13.000000000 +0200
@@ -32,7 +32,6 @@
 #undef IDLE_TRACE
 /* Temporary flags/tests. All to be removed/undefined. END */
 
-#define __KERNEL_SYSCALLS__
 #include <stdarg.h>
 
 #include <linux/kernel.h>
@@ -230,13 +229,10 @@
 void idle_trace(void)
 {
 
-	_syscall0(int, getpid)
-	_syscall1(int, getpgid, int, pid)
-
 	if (!once) {
         	/* VM allocation/deallocation simple test */
 		test_VM();
-		pid = getpid();
+		pid = sys_getpid();
 
         	printk("Got all through to Idle !!\n");
         	printk("I'm now going to loop forever ...\n");
@@ -268,7 +264,7 @@
 		}
 		old_jiffies = jiffies;
 	}
-	pgid = getpgid(pid);
+	pgid = sys_getpgid(pid);
 	printk(".");
 }
 #else
@@ -628,18 +624,23 @@
  * a system call from a "real" process, but the process memory space will
  * not be free'd until both the parent and the child have exited.
  */
+#error please implement a working kernel_thread function like the other architectures
+/* _syscallN() does not work any more. this probably needs to call
+ * do_fork directly */
 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
 {
-	/* A bit less processor dependent than older sh ... */
-	unsigned int reply;
-
-static __inline__ _syscall2(int,clone,unsigned long,flags,unsigned long,newsp)
-static __inline__ _syscall1(int,exit,int,ret)
+	register unsigned long reply asm ("r9") = ((0x13 << 16) | __NR_clone);
+	register unsigned long __flags asm ("r2") = flags | CLONE_VM;
+	register unsigned long __newsp asm ("r3") = 0;
+
+	__asm__ __volatile__ ("trapa	%1 !\t\t\t clone(%2,%3)"
+	: "=r" (__sc0) : "r" (__sc0), "r" (__sc2), "r" (__sc3));
+	__asm__ __volatile__ ("!dummy	%0 %1"
+	: : "r" (__sc0), "r" (__sc2), "r" (__sc3) : "memory");
 
-	reply = clone(flags | CLONE_VM, 0);
 	if (!reply) {
 		/* Child */
-		reply = exit(fn(arg));
+		reply = sys_exit(fn(arg));
 	}
 
 	return reply;

--


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

* [PATCH 1/7] introduce kernel_execve
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
                   ` (5 preceding siblings ...)
  2006-08-27 22:00 ` [PATCH 5/7] sh64: remove the use of kernel syscalls Arnd Bergmann
@ 2006-08-27 22:01 ` Arnd Bergmann
  2006-08-29  9:12 ` [PATCH 0/7] kill __KERNEL_SYSCALLS__ David Howells
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-27 22:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty

The use of execve() in the kernel is dubious, since it relies
on the __KERNEL_SYSCALLS__ mechanism that stores the result in
a global errno variable. As a first step of getting rid of
this, change all users to a global kernel_execve function that
returns a proper error code.

This function is a terrible hack, and a later patch removes
it again after the kernel syscalls are gone.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Index: linux-cg/init/do_mounts_initrd.c
===================================================================
--- linux-cg.orig/init/do_mounts_initrd.c	2006-08-27 23:17:58.000000000 +0200
+++ linux-cg/init/do_mounts_initrd.c	2006-08-27 23:18:58.000000000 +0200
@@ -1,4 +1,3 @@
-#define __KERNEL_SYSCALLS__
 #include <linux/unistd.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
@@ -35,7 +34,7 @@
 	(void) sys_open("/dev/console",O_RDWR,0);
 	(void) sys_dup(0);
 	(void) sys_dup(0);
-	return execve(shell, argv, envp_init);
+	return kernel_execve(shell, argv, envp_init);
 }
 
 static void __init handle_initrd(void)
Index: linux-cg/kernel/kmod.c
===================================================================
--- linux-cg.orig/kernel/kmod.c	2006-08-27 23:17:58.000000000 +0200
+++ linux-cg/kernel/kmod.c	2006-08-27 23:18:58.000000000 +0200
@@ -18,8 +18,6 @@
 	call_usermodehelper wait flag, and remove exec_usermodehelper.
 	Rusty Russell <rusty@rustcorp.com.au>  Jan 2003
 */
-#define __KERNEL_SYSCALLS__
-
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/syscalls.h>
@@ -150,7 +148,8 @@
 
 	retval = -EPERM;
 	if (current->fs->root)
-		retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
+		retval = kernel_execve(sub_info->path,
+				sub_info->argv, sub_info->envp);
 
 	/* Exec failed? */
 	sub_info->retval = retval;
Index: linux-cg/lib/Makefile
===================================================================
--- linux-cg.orig/lib/Makefile	2006-08-27 23:17:58.000000000 +0200
+++ linux-cg/lib/Makefile	2006-08-27 23:18:58.000000000 +0200
@@ -33,6 +33,8 @@
   lib-y += dec_and_lock.o
 endif
 
+lib-y += execve.o
+
 obj-$(CONFIG_CRC_CCITT)	+= crc-ccitt.o
 obj-$(CONFIG_CRC16)	+= crc16.o
 obj-$(CONFIG_CRC32)	+= crc32.o
Index: linux-cg/lib/execve.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-cg/lib/execve.c	2006-08-27 23:18:58.000000000 +0200
@@ -0,0 +1,23 @@
+#include <asm/bug.h>
+#include <asm/uaccess.h>
+
+#define __KERNEL_SYSCALLS__
+static int errno __attribute__((unused));
+#include <asm/unistd.h>
+
+#ifdef _syscall3
+int kernel_execve (const char *filename, char *const argv[], char *const envp[])
+								__attribute__((__weak__));
+int kernel_execve (const char *filename, char *const argv[], char *const envp[])
+{
+	mm_segment_t fs = get_fs();
+	int ret;
+
+	WARN_ON(segment_eq(fs, USER_DS));
+	ret = execve(filename, (char **)argv, (char **)envp);
+	if (ret)
+		ret = -errno;
+
+	return ret;
+}
+#endif
Index: linux-cg/init/main.c
===================================================================
--- linux-cg.orig/init/main.c	2006-08-27 23:17:58.000000000 +0200
+++ linux-cg/init/main.c	2006-08-27 23:18:58.000000000 +0200
@@ -9,8 +9,6 @@
  *  Simplified starting of init:  Michael A. Griffith <grif@acm.org> 
  */
 
-#define __KERNEL_SYSCALLS__
-
 #include <linux/types.h>
 #include <linux/module.h>
 #include <linux/proc_fs.h>
@@ -679,7 +677,7 @@
 static void run_init_process(char *init_filename)
 {
 	argv_init[0] = init_filename;
-	execve(init_filename, argv_init, envp_init);
+	kernel_execve(init_filename, argv_init, envp_init);
 }
 
 static int init(void * unused)
Index: linux-cg/arch/sparc64/kernel/power.c
===================================================================
--- linux-cg.orig/arch/sparc64/kernel/power.c	2006-08-27 23:18:53.000000000 +0200
+++ linux-cg/arch/sparc64/kernel/power.c	2006-08-27 23:19:04.000000000 +0200
@@ -4,8 +4,6 @@
  * Copyright (C) 1999 David S. Miller (davem@redhat.com)
  */
 
-#define __KERNEL_SYSCALLS__
-
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/init.h>
@@ -14,6 +12,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/pm.h>
+#include <linux/syscalls.h>
 
 #include <asm/system.h>
 #include <asm/auxio.h>
@@ -98,7 +97,7 @@
 
 	/* Ok, down we go... */
 	button_pressed = 0;
-	if (execve("/sbin/shutdown", argv, envp) < 0) {
+	if (kernel_execve("/sbin/shutdown", argv, envp) < 0) {
 		printk("powerd: shutdown execution failed\n");
 		add_wait_queue(&powerd_wait, &wait);
 		goto again;

--


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

* Re: [PATCH 2/7] rename the provided execve functions to kernel_execve
  2006-08-27 21:47 ` [PATCH 2/7] rename the provided execve functions to kernel_execve Arnd Bergmann
@ 2006-08-28  2:20   ` Randy.Dunlap
  2006-08-28  7:44     ` Arnd Bergmann
  0 siblings, 1 reply; 45+ messages in thread
From: Randy.Dunlap @ 2006-08-28  2:20 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

On Sun, 27 Aug 2006 23:47:36 +0200 Arnd Bergmann wrote:

> --- linux-cg.orig/drivers/sbus/char/envctrl.c	2006-08-27 23:36:36.000000000 +0200
> +++ linux-cg/drivers/sbus/char/envctrl.c	2006-08-27 23:36:42.000000000 +0200
> @@ -19,9 +19,6 @@
>   *              Daniele Bellucci <bellucda@tiscali.it>
>   */
>  
> -#define __KERNEL_SYSCALLS__
> -static int errno;
> -
>  #include <linux/module.h>
>  #include <linux/sched.h>
>  #include <linux/kthread.h>
> @@ -982,7 +979,7 @@
>  
>  	inprog = 1;
>  	printk(KERN_CRIT "kenvctrld: WARNING: Shutting down the system now.\n");
> -	if (0 > execve("/sbin/shutdown", argv, envp)) {
> +	if (0 > kernel_execve("/sbin/shutdown", argv, envp)) {
>  		printk(KERN_CRIT "kenvctrld: WARNING: system shutdown failed!\n"); 
>  		inprog = 0;  /* unlikely to succeed, but we could try again */
>  	}

Linux just educated the git mailing list (yesterday) about ordering
of comparisons, so while here, please change the order inside the if()
to be like the others:
	if (kernel_execv(...) < 0)


> Index: linux-cg/include/linux/syscalls.h
> ===================================================================
> --- linux-cg.orig/include/linux/syscalls.h	2006-08-27 23:36:36.000000000 +0200
> +++ linux-cg/include/linux/syscalls.h	2006-08-27 23:36:42.000000000 +0200
> @@ -597,4 +597,6 @@
>  asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
>  				    size_t len);
>  
> +int kernel_execve(const char *filename, char *const argv[], char *const envp[]);
> +
>  #endif

Question:
All other syscalls (in syscalls.h) return long or unsigned long
or ssize_t etc.  I.e., none of them return int.  Does this one
return int because it's strictly an inside-the-kernel "syscall",
not exposed to userspace?


---
~Randy

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-27 21:47 ` [PATCH 6/7] remove all remaining _syscallX macros Arnd Bergmann
@ 2006-08-28  7:35   ` Andi Kleen
  2006-08-28  7:41     ` Arnd Bergmann
  0 siblings, 1 reply; 45+ messages in thread
From: Andi Kleen @ 2006-08-28  7:35 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty, linux-kernel

Arnd Bergmann <arnd@arndb.de> writes:

> The _syscallX macros were originally used by libc implementations,
> but now there is no libc that can be built against an up-to-date
> kernel an relies on them.
> The only users of these macros are the __KERNEL_SYSCALLS_, which
> are now gone as well, after execve has been removed from the
> kernel.

I would prefer to keep them on i386/x86-64 at least because
a lot of my test programs are using them.

-Andi

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  7:35   ` Andi Kleen
@ 2006-08-28  7:41     ` Arnd Bergmann
  2006-08-28  7:46       ` Arjan van de Ven
  2006-08-28  7:50       ` Andi Kleen
  0 siblings, 2 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-28  7:41 UTC (permalink / raw)
  To: Andi Kleen
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty, linux-kernel

On Monday 28 August 2006 09:35, Andi Kleen wrote:
> I would prefer to keep them on i386/x86-64 at least because
> a lot of my test programs are using them.
> 
Hmm, maybe we should have an asm-generic/unistd.h then
containing something like

#ifndef __KERNEL__
#include <sys/syscall.h>
#define _syscall0(type,name) \
type name(type1 arg1) \
{ \
	return syscall(__NR_ ## name); \
}
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
	return syscall(__NR_ ## name, arg1); \
}
#define _syscall1(type,name,type1,arg1,type2,arg2) \
type name(type1 arg1, type2 arg2) \
{ \
	return syscall(__NR_ ## name, arg1, arg2); \
}
// ...
#endif

	Arnd <><

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

* Re: [PATCH 2/7] rename the provided execve functions to kernel_execve
  2006-08-28  2:20   ` Randy.Dunlap
@ 2006-08-28  7:44     ` Arnd Bergmann
  0 siblings, 0 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-28  7:44 UTC (permalink / raw)
  To: Randy.Dunlap
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

On Monday 28 August 2006 04:20, Randy.Dunlap wrote:
> Question:
> All other syscalls (in syscalls.h) return long or unsigned long
> or ssize_t etc.  I.e., none of them return int.  Does this one
> return int because it's strictly an inside-the-kernel "syscall",
> not exposed to userspace?

Well, it's not really a system call in the first place, but
I could not find any other place where it would fit.
The prototype of the kernel_execve function is the one from
the man execve page, and also similar to those that were
generated by the _syscall3() macro before.

	Arnd <><

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  7:41     ` Arnd Bergmann
@ 2006-08-28  7:46       ` Arjan van de Ven
  2006-08-28  8:09         ` Arnd Bergmann
  2006-08-28  7:50       ` Andi Kleen
  1 sibling, 1 reply; 45+ messages in thread
From: Arjan van de Ven @ 2006-08-28  7:46 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Andi Kleen, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Chase Venters, Andrew Morton, Russell King, rusty, linux-kernel

On Mon, 2006-08-28 at 09:41 +0200, Arnd Bergmann wrote:
> On Monday 28 August 2006 09:35, Andi Kleen wrote:
> > I would prefer to keep them on i386/x86-64 at least because
> > a lot of my test programs are using them.
> > 
> Hmm, maybe we should have an asm-generic/unistd.h then
> containing something like


we or the (g)libc headers ?




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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  7:41     ` Arnd Bergmann
  2006-08-28  7:46       ` Arjan van de Ven
@ 2006-08-28  7:50       ` Andi Kleen
  2006-08-28  8:01         ` Arnd Bergmann
  1 sibling, 1 reply; 45+ messages in thread
From: Andi Kleen @ 2006-08-28  7:50 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty, linux-kernel

On Monday 28 August 2006 09:41, Arnd Bergmann wrote:
> On Monday 28 August 2006 09:35, Andi Kleen wrote:
> > I would prefer to keep them on i386/x86-64 at least because
> > a lot of my test programs are using them.
> > 
> Hmm, maybe we should have an asm-generic/unistd.h then
> containing something like

Or just keep the current ones that work fine? 

(some older glibc implementations also get some cases wrong)

-Andi


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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  7:50       ` Andi Kleen
@ 2006-08-28  8:01         ` Arnd Bergmann
  2006-08-28  8:03           ` Andi Kleen
  0 siblings, 1 reply; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-28  8:01 UTC (permalink / raw)
  To: Andi Kleen
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty, linux-kernel,
	David Woodhouse

On Monday 28 August 2006 09:50, Andi Kleen wrote:
> Or just keep the current ones that work fine? 
> 

Are you sure they do? Since dwmw2 did the changeset 
56142536868a2be34f261ed8fdca1610f8a73fbd, they are all inside
#ifdef __KERNEL__. You may argue that merging that patch was
wrong and it should be reverted, but now that we have it, the 
code is not relevant for user space anymore.

	Arnd <><

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  8:01         ` Arnd Bergmann
@ 2006-08-28  8:03           ` Andi Kleen
  2006-08-28  8:09             ` David Miller
  0 siblings, 1 reply; 45+ messages in thread
From: Andi Kleen @ 2006-08-28  8:03 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arch, Jeff Dike, Bjoern Steinbrink, Arjan van de Ven,
	Chase Venters, Andrew Morton, Russell King, rusty, linux-kernel,
	David Woodhouse

On Monday 28 August 2006 10:01, Arnd Bergmann wrote:
> On Monday 28 August 2006 09:50, Andi Kleen wrote:
> > Or just keep the current ones that work fine? 
> > 
> 
> Are you sure they do? Since dwmw2 did the changeset 
> 56142536868a2be34f261ed8fdca1610f8a73fbd, they are all inside
> #ifdef __KERNEL__. You may argue that merging that patch was
> wrong and it should be reverted, but now that we have it, the 
> code is not relevant for user space anymore.

Thanks for brining it to my attention. I indeed think think the patch was 
wrong.

-Andi

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

* Re: [PATCH 5/7] sh64: remove the use of kernel syscalls
  2006-08-27 22:00 ` [PATCH 5/7] sh64: remove the use of kernel syscalls Arnd Bergmann
@ 2006-08-28  8:05   ` Paul Mundt
  0 siblings, 0 replies; 45+ messages in thread
From: Paul Mundt @ 2006-08-28  8:05 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty, linuxsh-shmedia-dev, rc

On Mon, Aug 28, 2006 at 12:00:49AM +0200, Arnd Bergmann wrote:
> sh64 is using system call macros to call some functions
> from the kernel. Remove those so we can get rid of
> kernel syscalls.
> 
It makes more sense to just rip out the old debug code, since we don't
really have that much of a need for it anymore, it was mostly something
that was handy during the initial bringup. This also brings us closer to
something that looks like readable code again..

I also added a sane kernel_thread() implementation that gets away from
this, so that should take care of sh64 at least.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

diff --git a/arch/sh64/kernel/process.c b/arch/sh64/kernel/process.c
index dba8e14..525d0ec 100644
--- a/arch/sh64/kernel/process.c
+++ b/arch/sh64/kernel/process.c
@@ -20,261 +20,16 @@
 /*
  * This file handles the architecture-dependent parts of process handling..
  */
-
-/* Temporary flags/tests. All to be removed/undefined. BEGIN */
-#define IDLE_TRACE
-#define VM_SHOW_TABLES
-#define VM_TEST_FAULT
-#define VM_TEST_RTLBMISS
-#define VM_TEST_WTLBMISS
-
-#undef VM_SHOW_TABLES
-#undef IDLE_TRACE
-/* Temporary flags/tests. All to be removed/undefined. END */
-
-#define __KERNEL_SYSCALLS__
-#include <stdarg.h>
-
-#include <linux/kernel.h>
-#include <linux/rwsem.h>
 #include <linux/mm.h>
-#include <linux/smp.h>
-#include <linux/smp_lock.h>
 #include <linux/ptrace.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/user.h>
-#include <linux/a.out.h>
-#include <linux/interrupt.h>
-#include <linux/unistd.h>
-#include <linux/delay.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
-
+#include <linux/module.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/processor.h>		/* includes also <asm/registers.h> */
-#include <asm/mmu_context.h>
-#include <asm/elf.h>
-#include <asm/page.h>
-
-#include <linux/irq.h>
 
 struct task_struct *last_task_used_math = NULL;
 
-#ifdef IDLE_TRACE
-#ifdef VM_SHOW_TABLES
-/* For testing */
-static void print_PTE(long base)
-{
-	int i, skip=0;
-	long long x, y, *p = (long long *) base;
-
-	for (i=0; i< 512; i++, p++){
-		if (*p == 0) {
-			if (!skip) {
-				skip++;
-				printk("(0s) ");
-			}
-		} else {
-			skip=0;
-			x = (*p) >> 32;
-			y = (*p) & 0xffffffff;
-			printk("%08Lx%08Lx ", x, y);
-			if (!((i+1)&0x3)) printk("\n");
-		}
-	}
-}
-
-/* For testing */
-static void print_DIR(long base)
-{
-	int i, skip=0;
-	long *p = (long *) base;
-
-	for (i=0; i< 512; i++, p++){
-		if (*p == 0) {
-			if (!skip) {
-				skip++;
-				printk("(0s) ");
-			}
-		} else {
-			skip=0;
-			printk("%08lx ", *p);
-			if (!((i+1)&0x7)) printk("\n");
-		}
-	}
-}
-
-/* For testing */
-static void print_vmalloc_first_tables(void)
-{
-
-#define PRESENT	0x800	/* Bit 11 */
-
-	/*
-	 * Do it really dirty by looking at raw addresses,
-         * raw offsets, no types. If we used pgtable/pgalloc
-	 * macros/definitions we could hide potential bugs.
-	 *
-	 * Note that pointers are 32-bit for CDC.
-	 */
-	long pgdt, pmdt, ptet;
-
-	pgdt = (long) &swapper_pg_dir;
-	printk("-->PGD (0x%08lx):\n", pgdt);
-	print_DIR(pgdt);
-	printk("\n");
-
-	/* VMALLOC pool is mapped at 0xc0000000, second (pointer) entry in PGD */
-	pgdt += 4;
-	pmdt = (long) (* (long *) pgdt);
-	if (!(pmdt & PRESENT)) {
-		printk("No PMD\n");
-		return;
-	} else pmdt &= 0xfffff000;
-
-	printk("-->PMD (0x%08lx):\n", pmdt);
-	print_DIR(pmdt);
-	printk("\n");
-
-	/* Get the pmdt displacement for 0xc0000000 */
-	pmdt += 2048;
-
-	/* just look at first two address ranges ... */
-        /* ... 0xc0000000 ... */
-	ptet = (long) (* (long *) pmdt);
-	if (!(ptet & PRESENT)) {
-		printk("No PTE0\n");
-		return;
-	} else ptet &= 0xfffff000;
-
-	printk("-->PTE0 (0x%08lx):\n", ptet);
-	print_PTE(ptet);
-	printk("\n");
-
-        /* ... 0xc0001000 ... */
-	ptet += 4;
-	if (!(ptet & PRESENT)) {
-		printk("No PTE1\n");
-		return;
-	} else ptet &= 0xfffff000;
-	printk("-->PTE1 (0x%08lx):\n", ptet);
-	print_PTE(ptet);
-	printk("\n");
-}
-#else
-#define print_vmalloc_first_tables()
-#endif	/* VM_SHOW_TABLES */
-
-static void test_VM(void)
-{
-	void *a, *b, *c;
-
-#ifdef VM_SHOW_TABLES
-	printk("Initial PGD/PMD/PTE\n");
-#endif
-        print_vmalloc_first_tables();
-
-	printk("Allocating 2 bytes\n");
-	a = vmalloc(2);
-        print_vmalloc_first_tables();
-
-	printk("Allocating 4100 bytes\n");
-	b = vmalloc(4100);
-        print_vmalloc_first_tables();
-
-	printk("Allocating 20234 bytes\n");
-	c = vmalloc(20234);
-        print_vmalloc_first_tables();
-
-#ifdef VM_TEST_FAULT
-	/* Here you may want to fault ! */
-
-#ifdef VM_TEST_RTLBMISS
-	printk("Ready to fault upon read.\n");
-	if (* (char *) a) {
-		printk("RTLBMISSed on area a !\n");
-	}
-	printk("RTLBMISSed on area a !\n");
-#endif
-
-#ifdef VM_TEST_WTLBMISS
-	printk("Ready to fault upon write.\n");
-	*((char *) b) = 'L';
-	printk("WTLBMISSed on area b !\n");
-#endif
-
-#endif	/* VM_TEST_FAULT */
-
-	printk("Deallocating the 4100 byte chunk\n");
-	vfree(b);
-        print_vmalloc_first_tables();
-
-	printk("Deallocating the 2 byte chunk\n");
-	vfree(a);
-        print_vmalloc_first_tables();
-
-	printk("Deallocating the last chunk\n");
-	vfree(c);
-        print_vmalloc_first_tables();
-}
-
-extern unsigned long volatile jiffies;
-int once = 0;
-unsigned long old_jiffies;
-int pid = -1, pgid = -1;
-
-void idle_trace(void)
-{
-
-	_syscall0(int, getpid)
-	_syscall1(int, getpgid, int, pid)
-
-	if (!once) {
-        	/* VM allocation/deallocation simple test */
-		test_VM();
-		pid = getpid();
-
-        	printk("Got all through to Idle !!\n");
-        	printk("I'm now going to loop forever ...\n");
-        	printk("Any ! below is a timer tick.\n");
-		printk("Any . below is a getpgid system call from pid = %d.\n", pid);
-
-
-        	old_jiffies = jiffies;
-		once++;
-	}
-
-	if (old_jiffies != jiffies) {
-		old_jiffies = jiffies - old_jiffies;
-		switch (old_jiffies) {
-		case 1:
-			printk("!");
-			break;
-		case 2:
-			printk("!!");
-			break;
-		case 3:
-			printk("!!!");
-			break;
-		case 4:
-			printk("!!!!");
-			break;
-		default:
-			printk("(%d!)", (int) old_jiffies);
-		}
-		old_jiffies = jiffies;
-	}
-	pgid = getpgid(pid);
-	printk(".");
-}
-#else
-#define idle_trace()	do { } while (0)
-#endif	/* IDLE_TRACE */
-
 static int hlt_counter = 1;
 
 #define HARD_IDLE_TIMEOUT (HZ / 3)
@@ -323,7 +78,6 @@ void cpu_idle(void)
 			local_irq_disable();
 			while (!need_resched()) {
 				local_irq_enable();
-				idle_trace();
 				hlt();
 				local_irq_disable();
 			}
@@ -619,6 +376,10 @@ void free_task_struct(struct task_struct
 /*
  * Create a kernel thread
  */
+ATTRIB_NORET void kernel_thread_helper(void *arg, int (*fn)(void *))
+{
+	do_exit(fn(arg));
+}
 
 /*
  * This is the mechanism for creating a new kernel thread.
@@ -630,19 +391,17 @@ void free_task_struct(struct task_struct
  */
 int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
 {
-	/* A bit less processor dependent than older sh ... */
-	unsigned int reply;
+	struct pt_regs regs;
 
-static __inline__ _syscall2(int,clone,unsigned long,flags,unsigned long,newsp)
-static __inline__ _syscall1(int,exit,int,ret)
+	memset(&regs, 0, sizeof(regs));
+	regs.regs[2] = (unsigned long)arg;
+	regs.regs[3] = (unsigned long)fn;
 
-	reply = clone(flags | CLONE_VM, 0);
-	if (!reply) {
-		/* Child */
-		reply = exit(fn(arg));
-	}
+	regs.pc = (unsigned long)kernel_thread_helper;
+	regs.sr = (1 << 30);
 
-	return reply;
+	return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
+		       &regs, 0, NULL, NULL);
 }
 
 /*

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  7:46       ` Arjan van de Ven
@ 2006-08-28  8:09         ` Arnd Bergmann
  0 siblings, 0 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-28  8:09 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: Andi Kleen, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Chase Venters, Andrew Morton, Russell King, rusty, linux-kernel

On Monday 28 August 2006 09:46, Arjan van de Ven wrote:
> we or the (g)libc headers ?
> 
I don't think having libc do it. In order to use these macros,
you always had to #include <linux/unistd.h> or <asm/unistd.h>.

Putting the headers into a libc file means that user code
would need to change its includes, when it really should
just use <sys/syscall.h>.

Changing the libc copy of asm/unistd.h is against our current
plan to get to a point where `make headers_install' gets
you a working tree. _If_ we want to have it in there, it needs
to be in the kernel source.

	Arnd <><

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  8:03           ` Andi Kleen
@ 2006-08-28  8:09             ` David Miller
  2006-08-28  8:15               ` Andi Kleen
  0 siblings, 1 reply; 45+ messages in thread
From: David Miller @ 2006-08-28  8:09 UTC (permalink / raw)
  To: ak
  Cc: arnd, linux-arch, jdike, B.Steinbrink, arjan, chase.venters,
	akpm, rmk+lkml, rusty, linux-kernel, dwmw2

From: Andi Kleen <ak@suse.de>
Date: Mon, 28 Aug 2006 10:03:02 +0200

> Thanks for brining it to my attention. I indeed think think the
> patch was wrong.

I disagree, this stuff really doesn't have a strong argument
for existence.

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  8:09             ` David Miller
@ 2006-08-28  8:15               ` Andi Kleen
  2006-08-28  8:19                 ` David Miller
  0 siblings, 1 reply; 45+ messages in thread
From: Andi Kleen @ 2006-08-28  8:15 UTC (permalink / raw)
  To: David Miller
  Cc: arnd, linux-arch, jdike, B.Steinbrink, arjan, chase.venters,
	akpm, rmk+lkml, rusty, linux-kernel, dwmw2

On Monday 28 August 2006 10:09, David Miller wrote:
> From: Andi Kleen <ak@suse.de>
> Date: Mon, 28 Aug 2006 10:03:02 +0200
> 
> > Thanks for brining it to my attention. I indeed think think the
> > patch was wrong.
> 
> I disagree, this stuff really doesn't have a strong argument
> for existence.

I see it as the reference implementation of the kernel system call ABI

-Andi

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  8:15               ` Andi Kleen
@ 2006-08-28  8:19                 ` David Miller
  2006-08-28  8:28                   ` Andi Kleen
  0 siblings, 1 reply; 45+ messages in thread
From: David Miller @ 2006-08-28  8:19 UTC (permalink / raw)
  To: ak
  Cc: arnd, linux-arch, jdike, B.Steinbrink, arjan, chase.venters,
	akpm, rmk+lkml, rusty, linux-kernel, dwmw2

From: Andi Kleen <ak@suse.de>
Date: Mon, 28 Aug 2006 10:15:38 +0200

> I see it as the reference implementation of the kernel system call
> ABI

I see it as duplication because the person who writes the
kernel is the one who ends up writing the libc syscall
bits or explains to the libc person for that arch how
things work.  And once one libc implmenetation of this
exists, it can be used as a reference for other libc
variants.

Finally, once it's done, it's done, and that's it.

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  8:19                 ` David Miller
@ 2006-08-28  8:28                   ` Andi Kleen
  2006-08-28  8:40                     ` David Woodhouse
  0 siblings, 1 reply; 45+ messages in thread
From: Andi Kleen @ 2006-08-28  8:28 UTC (permalink / raw)
  To: David Miller
  Cc: arnd, linux-arch, jdike, B.Steinbrink, arjan, chase.venters,
	akpm, rmk+lkml, rusty, linux-kernel, dwmw2

On Monday 28 August 2006 10:19, David Miller wrote:

> I see it as duplication because the person who writes the
> kernel is the one who ends up writing the libc syscall
> bits or explains to the libc person for that arch how
> things work.  

And the way to explain it is to write the reference code.

> And once one libc implmenetation of this 
> exists, it can be used as a reference for other libc
> variants.

At least on x86-64 various glibc versions had quite buggy
syscall()s, that is why I never trusted it very much.
 
> Finally, once it's done, it's done, and that's it.

Except if you still have to deal with old user land.

-Andi

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  8:28                   ` Andi Kleen
@ 2006-08-28  8:40                     ` David Woodhouse
  2006-08-28  8:53                       ` Andi Kleen
  0 siblings, 1 reply; 45+ messages in thread
From: David Woodhouse @ 2006-08-28  8:40 UTC (permalink / raw)
  To: Andi Kleen
  Cc: David Miller, arnd, linux-arch, jdike, B.Steinbrink, arjan,
	chase.venters, akpm, rmk+lkml, rusty, linux-kernel

On Mon, 2006-08-28 at 10:28 +0200, Andi Kleen wrote:
> On Monday 28 August 2006 10:19, David Miller wrote:
> 
> > I see it as duplication because the person who writes the
> > kernel is the one who ends up writing the libc syscall
> > bits or explains to the libc person for that arch how
> > things work.  
> 
> And the way to explain it is to write the reference code.

That's a new and interesting thing to add to the list of things
that /usr/include/linux is _not_:

/usr/include/linux is _not_ a place to dump "reference code" in lieu of
documentation on using kernel interfaces.

Besides, the _syscallX implementations in the kernel were generally
unsuitable for use in that way anyway -- I'd be much more inclined to
rely on the libc version. The kernel version would do strange things
like break with PIC code by using an unavailable register (i386),
misalign 64-bit syscall arguments on 32-bit machines (MIPS), etc. 

> > And once one libc implmenetation of this 
> > exists, it can be used as a reference for other libc
> > variants.
> 
> At least on x86-64 various glibc versions had quite buggy
> syscall()s, that is why I never trusted it very much.

I assume these were very _early_ glibc in when the port was new? 

> > Finally, once it's done, it's done, and that's it.
> 
> Except if you still have to deal with old user land.

The limited subset of old userland which elected to use _syscallX()
instead of libc's syscall(), and which can be fixed fairly easily.

-- 
dwmw2


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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  8:40                     ` David Woodhouse
@ 2006-08-28  8:53                       ` Andi Kleen
  2006-08-28 10:00                         ` David Woodhouse
  0 siblings, 1 reply; 45+ messages in thread
From: Andi Kleen @ 2006-08-28  8:53 UTC (permalink / raw)
  To: David Woodhouse
  Cc: David Miller, arnd, linux-arch, jdike, B.Steinbrink, arjan,
	chase.venters, akpm, rmk+lkml, rusty, linux-kernel



> /usr/include/linux is _not_ a place to dump "reference code" in lieu of
> documentation on using kernel interfaces.

At least for the system call interface it was always. It is not
my fault you're trying to suddenly redefine it to be something else.

> 
> Besides, the _syscallX implementations in the kernel were generally
> unsuitable for use 

I disagree. I used them and they worked great for me.

> in that way anyway -- I'd be much more inclined to 
> rely on the libc version. The kernel version would do strange things
> like break with PIC code by using an unavailable register (i386),
> misalign 64-bit syscall arguments on 32-bit machines (MIPS), etc. 

The glibc versions would do similar things. Just try to use a 6 argument
call on i386 for once.

-Andi

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

* Re: [PATCH 4/7] Remove the use of _syscallX macros in UML
  2006-08-27 21:47 ` [PATCH 4/7] Remove the use of _syscallX macros in UML Arnd Bergmann
@ 2006-08-28  9:25   ` Andreas Schwab
  2006-08-30  5:41   ` H. Peter Anvin
  1 sibling, 0 replies; 45+ messages in thread
From: Andreas Schwab @ 2006-08-28  9:25 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

Arnd Bergmann <arnd@arndb.de> writes:

>  int switcheroo(int fd, int prot, void *from, void *to, int size)
>  {
> -	if(munmap(to, size) < 0){
> +	if (syscall(munmap, to, size) < 0){

s/unmap/__NR_unmap/

>  		return(-1);
>  	}
> -	if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
> +	if (syscall(mmap, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){

s/mmap/__NR_mmap/

>  		return(-1);
>  	}
> -	if(munmap(from, size) < 0){
> +	if (syscall(munmap, from, size) < 0){

s/unmap/__NR_unmap/

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28  8:53                       ` Andi Kleen
@ 2006-08-28 10:00                         ` David Woodhouse
  2006-08-28 10:37                           ` Arjan van de Ven
  2006-08-28 14:05                           ` Arnd Bergmann
  0 siblings, 2 replies; 45+ messages in thread
From: David Woodhouse @ 2006-08-28 10:00 UTC (permalink / raw)
  To: Andi Kleen
  Cc: David Miller, arnd, linux-arch, jdike, B.Steinbrink, arjan,
	chase.venters, akpm, rmk+lkml, rusty, linux-kernel

On Mon, 2006-08-28 at 10:53 +0200, Andi Kleen wrote:
> 
> > /usr/include/linux is _not_ a place to dump "reference code" in lieu of
> > documentation on using kernel interfaces.
> 
> At least for the system call interface it was always. It is not
> my fault you're trying to suddenly redefine it to be something else.

I'm trying to 'suddenly redefine' kernel headers as something that
_isn't_ just a library of random crap for people to abuse in userspace
as they see fit, then whine when something breaks even though it was
never really guaranteed to work when abused in that way anyway.

So far, you're just reminding me why that needed to be done.

> > Besides, the _syscallX implementations in the kernel were generally
> > unsuitable for use [as a reference implementation]
> 
> I disagree. I used them and they worked great for me.

Really? You used them as a reference implementation? Didn't you already
know how x86_64 syscalls work?

Or were you saying you just happened to use the x86_64 implementation of
_syscallX stuff in some userspace hacks, and it happened to work? In
which case go and line up behind the guy who said that about atomic.h on
i386 and only ever tested it on UP. The doctor will get to you later.

-- 
dwmw2


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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 10:00                         ` David Woodhouse
@ 2006-08-28 10:37                           ` Arjan van de Ven
  2006-08-28 10:58                             ` Andi Kleen
  2006-08-28 14:05                           ` Arnd Bergmann
  1 sibling, 1 reply; 45+ messages in thread
From: Arjan van de Ven @ 2006-08-28 10:37 UTC (permalink / raw)
  To: David Woodhouse
  Cc: linux-kernel, rusty, rmk+lkml, akpm, chase.venters, B.Steinbrink,
	jdike, linux-arch, arnd, David Miller, Andi Kleen

On Mon, 2006-08-28 at 11:00 +0100, David Woodhouse wrote:
> On Mon, 2006-08-28 at 10:53 +0200, Andi Kleen wrote:
> > 
> > > /usr/include/linux is _not_ a place to dump "reference code" in lieu of
> > > documentation on using kernel interfaces.
> > 
> > At least for the system call interface it was always. It is not
> > my fault you're trying to suddenly redefine it to be something else.
> 
> I'm trying to 'suddenly redefine' kernel headers as something that
> _isn't_ just a library of random crap for people to abuse in userspace
> as they see fit, then whine when something breaks even though it was
> never really guaranteed to work when abused in that way anyway.
> 
> So far, you're just reminding me why that needed to be done.
> 
> > > Besides, the _syscallX implementations in the kernel were generally
> > > unsuitable for use [as a reference implementation]
> > 
> > I disagree. I used them and they worked great for me.

the x86_64 macros use the VDSO page? great! I didn't know that.
But that would make them unusable for kernel use I suspect...


-- 
if you want to mail me at work (you don't), use arjan (at) linux.intel.com


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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 10:37                           ` Arjan van de Ven
@ 2006-08-28 10:58                             ` Andi Kleen
  0 siblings, 0 replies; 45+ messages in thread
From: Andi Kleen @ 2006-08-28 10:58 UTC (permalink / raw)
  To: Arjan van de Ven
  Cc: David Woodhouse, linux-kernel, rusty, rmk+lkml, akpm,
	chase.venters, B.Steinbrink, jdike, linux-arch, arnd,
	David Miller


> the x86_64 macros use the VDSO page? great! I didn't know that.
> But that would make them unusable for kernel use I suspect...

Not sure what you're talking about. x86-64 64bit system calls don't go
through a vDSO

-Andi (who is out of the thread which seems to be full of unconstructive
polemics now)


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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 10:00                         ` David Woodhouse
  2006-08-28 10:37                           ` Arjan van de Ven
@ 2006-08-28 14:05                           ` Arnd Bergmann
  2006-08-28 14:42                             ` Andi Kleen
  1 sibling, 1 reply; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-28 14:05 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Andi Kleen, David Miller, linux-arch, jdike, B.Steinbrink, arjan,
	chase.venters, akpm, rmk+lkml, rusty, linux-kernel

On Monday 28 August 2006 12:00, David Woodhouse wrote:
> I'm trying to 'suddenly redefine' kernel headers as something that
> _isn't_ just a library of random crap for people to abuse in userspace
> as they see fit, then whine when something breaks even though it was
> never really guaranteed to work when abused in that way anyway.

Well, there are two points to consider here:

1. There is user space source code out that that used these macros
   in the past, without feeling ashamed of it. It's fairly well-documented
   and seems to be a common way for inexperienced people to use syscalls
   before they get formal libc support.

2. There is a long history of bugs with these calls. The version with more
   than 5 arguments is missing on some platforms, the assembly constraints
   break if your gcc is too old or too new, it doesn't work at all on
   non-gcc compiles, and libc and kernel are normally out of sync.
   Expect any platform other than x86 to be broken ;-).

The patch below should address both these issues, as long as the libc
has a working implementation of syscall(2).

Of course, if Andi prefers, we can do this for all architectures except
x86 and let him keep the old code.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Index: linux-cg/include/asm-alpha/unistd.h
===================================================================
--- linux-cg.orig/include/asm-alpha/unistd.h	2006-08-28 11:08:52.000000000 +0200
+++ linux-cg/include/asm-alpha/unistd.h	2006-08-28 15:41:56.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ALPHA_UNISTD_H
 #define _ALPHA_UNISTD_H
 
+#include <asm-generic/unistd.h>
+
 #define __NR_osf_syscall	  0	/* not implemented */
 #define __NR_exit		  1
 #define __NR_fork		  2
Index: linux-cg/include/asm-arm/unistd.h
===================================================================
--- linux-cg.orig/include/asm-arm/unistd.h	2006-08-28 11:08:52.000000000 +0200
+++ linux-cg/include/asm-arm/unistd.h	2006-08-28 15:42:04.000000000 +0200
@@ -13,6 +13,8 @@
 #ifndef __ASM_ARM_UNISTD_H
 #define __ASM_ARM_UNISTD_H
 
+#include <asm-generic/unistd.h>
+
 #define __NR_OABI_SYSCALL_BASE	0x900000
 
 #if defined(__thumb__) || defined(__ARM_EABI__)
Index: linux-cg/include/asm-arm26/unistd.h
===================================================================
--- linux-cg.orig/include/asm-arm26/unistd.h	2006-08-28 11:08:52.000000000 +0200
+++ linux-cg/include/asm-arm26/unistd.h	2006-08-28 15:42:09.000000000 +0200
@@ -14,6 +14,8 @@
 #ifndef __ASM_ARM_UNISTD_H
 #define __ASM_ARM_UNISTD_H
 
+#include <asm-generic/unistd.h>
+
 #define __NR_SYSCALL_BASE	0x900000
 
 /*
Index: linux-cg/include/asm-cris/unistd.h
===================================================================
--- linux-cg.orig/include/asm-cris/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-cris/unistd.h	2006-08-28 15:42:20.000000000 +0200
@@ -1,6 +1,7 @@
 #ifndef _ASM_CRIS_UNISTD_H_
 #define _ASM_CRIS_UNISTD_H_
 
+#include <asm-generic/unistd.h>
 #include <asm/arch/unistd.h>
 
 /*
Index: linux-cg/include/asm-frv/unistd.h
===================================================================
--- linux-cg.orig/include/asm-frv/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-frv/unistd.h	2006-08-28 15:42:26.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ASM_UNISTD_H_
 #define _ASM_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file contains the system call numbers.
  */
Index: linux-cg/include/asm-generic/Kbuild
===================================================================
--- linux-cg.orig/include/asm-generic/Kbuild	2006-08-28 15:39:39.000000000 +0200
+++ linux-cg/include/asm-generic/Kbuild	2006-08-28 15:39:52.000000000 +0200
@@ -1,3 +1,3 @@
 header-y += atomic.h errno-base.h errno.h fcntl.h ioctl.h ipc.h mman.h \
-	signal.h statfs.h
+	signal.h statfs.h unistd.h
 unifdef-y := resource.h siginfo.h
Index: linux-cg/include/asm-generic/unistd.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux-cg/include/asm-generic/unistd.h	2006-08-28 15:58:37.000000000 +0200
@@ -0,0 +1,76 @@
+#ifndef __ASM_GENERIC_UNISTD_H
+#define __ASM_GENERIC_UNISTD_H
+
+#ifndef __KERNEL__
+#include <sys/syscall.h>
+
+/*
+ * Applications should never rely on these macros, but instead
+ * use the syscall(2) function from libc.
+ *
+ * The purpose of the _syscallX() function is to generate a
+ * gcc warning about this.
+ */
+#ifdef __GNUC__
+static inline void __attribute__((deprecated)) _syscallX(void) { }
+#else
+static inline void _syscallX(void) { }
+#endif
+
+#define _syscall0(type, name)						\
+type name(void)								\
+{									\
+	_syscallX();							\
+	return (type)syscall(__NR_ ## name);				\
+}
+
+#define _syscall1(type, name, type1, arg1)				\
+type name(type1 arg1)							\
+{									\
+	_syscallX();							\
+	return (type)syscall(__NR_ ## name, arg1);			\
+}
+
+#define _syscall2(type, name, type1, arg1, type2, arg2)			\
+type name(type1 arg1, type2 arg2)					\
+{									\
+	_syscallX();							\
+	return (type)syscall(__NR_ ## name, arg1, arg2);		\
+}
+
+#define _syscall3(type, name, type1, arg1, type2, arg2, type3, arg3)	\
+type name(type1 arg1, type2 arg2, type3 arg3)				\
+{									\
+	_syscallX();							\
+	return (type)syscall(__NR_ ## name, arg1, arg2, arg3);		\
+}
+
+#define _syscall4(type, name, type1, arg1, type2, arg2, type3, arg3,	\
+			      type4, arg4)				\
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4)		\
+{									\
+	_syscallX();							\
+	return (type)syscall(__NR_ ## name, arg1, arg2, arg3, arg4)	\
+}
+
+#define _syscall5(type, name, type1, arg1, type2, arg2, type3, arg3,	\
+			      type4, arg4, type5, arg5)			\
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5)	\
+{									\
+	_syscallX();							\
+	return (type)syscall(__NR_ ## name, arg1, arg2, arg3,		\
+					    arg4, arg5);		\
+}
+
+#define _syscall6(type, name, type1, arg1, type2, arg2, type3, arg3,	\
+			      type4, arg4, type5, arg5, type6, arg6)	\
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5,	\
+							  type6 arg6)	\
+{									\
+	_syscallX();							\
+	return (type)syscall(__NR_ ## name, arg1, arg2, arg3,		\
+					    arg4, arg5, arg6);		\
+}
+
+#endif
+#endif
Index: linux-cg/include/asm-h8300/unistd.h
===================================================================
--- linux-cg.orig/include/asm-h8300/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-h8300/unistd.h	2006-08-28 15:42:34.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ASM_H8300_UNISTD_H_
 #define _ASM_H8300_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file contains the system call numbers.
  */
Index: linux-cg/include/asm-i386/unistd.h
===================================================================
--- linux-cg.orig/include/asm-i386/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-i386/unistd.h	2006-08-28 15:42:37.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ASM_I386_UNISTD_H_
 #define _ASM_I386_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file contains the system call numbers.
  */
Index: linux-cg/include/asm-ia64/unistd.h
===================================================================
--- linux-cg.orig/include/asm-ia64/unistd.h	2006-08-28 11:08:53.000000000 +0200
+++ linux-cg/include/asm-ia64/unistd.h	2006-08-28 15:42:46.000000000 +0200
@@ -9,6 +9,7 @@
  */
 
 #include <asm/break.h>
+#include <asm-generic/unistd.h>
 
 #define __BREAK_SYSCALL			__IA64_BREAK_SYSCALL
 
Index: linux-cg/include/asm-m32r/unistd.h
===================================================================
--- linux-cg.orig/include/asm-m32r/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-m32r/unistd.h	2006-08-28 15:42:55.000000000 +0200
@@ -4,6 +4,7 @@
 /* $Id$ */
 
 #include <asm/syscall.h>	/* SYSCALL_* */
+#include <asm-generic/unistd.h>
 
 /*
  * This file contains the system call numbers.
Index: linux-cg/include/asm-m68k/unistd.h
===================================================================
--- linux-cg.orig/include/asm-m68k/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-m68k/unistd.h	2006-08-28 15:42:59.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ASM_M68K_UNISTD_H_
 #define _ASM_M68K_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file contains the system call numbers.
  */
Index: linux-cg/include/asm-m68knommu/unistd.h
===================================================================
--- linux-cg.orig/include/asm-m68knommu/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-m68knommu/unistd.h	2006-08-28 15:43:02.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ASM_M68K_UNISTD_H_
 #define _ASM_M68K_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file contains the system call numbers.
  */
Index: linux-cg/include/asm-mips/unistd.h
===================================================================
--- linux-cg.orig/include/asm-mips/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-mips/unistd.h	2006-08-28 15:43:08.000000000 +0200
@@ -13,6 +13,7 @@
 #define _ASM_UNISTD_H
 
 #include <asm/sgidefs.h>
+#include <asm-generic/unistd.h>
 
 #if _MIPS_SIM == _MIPS_SIM_ABI32
 
Index: linux-cg/include/asm-parisc/unistd.h
===================================================================
--- linux-cg.orig/include/asm-parisc/unistd.h	2006-08-28 11:08:52.000000000 +0200
+++ linux-cg/include/asm-parisc/unistd.h	2006-08-28 15:43:12.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ASM_PARISC_UNISTD_H_
 #define _ASM_PARISC_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file contains the system call numbers.
  */
Index: linux-cg/include/asm-powerpc/unistd.h
===================================================================
--- linux-cg.orig/include/asm-powerpc/unistd.h	2006-08-28 11:08:52.000000000 +0200
+++ linux-cg/include/asm-powerpc/unistd.h	2006-08-28 15:43:14.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ASM_PPC_UNISTD_H_
 #define _ASM_PPC_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file contains the system call numbers.
  *
Index: linux-cg/include/asm-s390/unistd.h
===================================================================
--- linux-cg.orig/include/asm-s390/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-s390/unistd.h	2006-08-28 15:43:19.000000000 +0200
@@ -9,6 +9,8 @@
 #ifndef _ASM_S390_UNISTD_H_
 #define _ASM_S390_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file contains the system call numbers.
  */
Index: linux-cg/include/asm-sh/unistd.h
===================================================================
--- linux-cg.orig/include/asm-sh/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-sh/unistd.h	2006-08-28 15:43:23.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef __ASM_SH_UNISTD_H
 #define __ASM_SH_UNISTD_H
 
+#include <asm-generic/unistd.h>
+
 /*
  * Copyright (C) 1999  Niibe Yutaka
  */
Index: linux-cg/include/asm-sh64/unistd.h
===================================================================
--- linux-cg.orig/include/asm-sh64/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-sh64/unistd.h	2006-08-28 15:43:27.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef __ASM_SH64_UNISTD_H
 #define __ASM_SH64_UNISTD_H
 
+#include <asm-generic/unistd.h>
+
 /*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
Index: linux-cg/include/asm-sparc/unistd.h
===================================================================
--- linux-cg.orig/include/asm-sparc/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-sparc/unistd.h	2006-08-28 15:43:31.000000000 +0200
@@ -2,6 +2,8 @@
 #ifndef _SPARC_UNISTD_H
 #define _SPARC_UNISTD_H
 
+#include <asm-generic/unistd.h>
+
 /*
  * System calls under the Sparc.
  *
Index: linux-cg/include/asm-sparc64/unistd.h
===================================================================
--- linux-cg.orig/include/asm-sparc64/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-sparc64/unistd.h	2006-08-28 15:43:34.000000000 +0200
@@ -2,6 +2,8 @@
 #ifndef _SPARC64_UNISTD_H
 #define _SPARC64_UNISTD_H
 
+#include <asm-generic/unistd.h>
+
 /*
  * System calls under the Sparc.
  *
Index: linux-cg/include/asm-v850/unistd.h
===================================================================
--- linux-cg.orig/include/asm-v850/unistd.h	2006-08-28 15:21:50.000000000 +0200
+++ linux-cg/include/asm-v850/unistd.h	2006-08-28 15:44:07.000000000 +0200
@@ -14,6 +14,8 @@
 #ifndef __V850_UNISTD_H__
 #define __V850_UNISTD_H__
 
+#include <asm-generic/unistd.h>
+
 #define __NR_restart_syscall	  0
 #define __NR_exit		  1
 #define __NR_fork		  2
Index: linux-cg/include/asm-x86_64/unistd.h
===================================================================
--- linux-cg.orig/include/asm-x86_64/unistd.h	2006-08-28 11:08:52.000000000 +0200
+++ linux-cg/include/asm-x86_64/unistd.h	2006-08-28 15:44:11.000000000 +0200
@@ -1,6 +1,8 @@
 #ifndef _ASM_X86_64_UNISTD_H_
 #define _ASM_X86_64_UNISTD_H_
 
+#include <asm-generic/unistd.h>
+
 #ifndef __SYSCALL
 #define __SYSCALL(a,b) 
 #endif
Index: linux-cg/include/asm-xtensa/unistd.h
===================================================================
--- linux-cg.orig/include/asm-xtensa/unistd.h	2006-08-28 15:21:51.000000000 +0200
+++ linux-cg/include/asm-xtensa/unistd.h	2006-08-28 15:44:15.000000000 +0200
@@ -11,6 +11,8 @@
 #ifndef _XTENSA_UNISTD_H
 #define _XTENSA_UNISTD_H
 
+#include <asm-generic/unistd.h>
+
 #define __NR_spill		  0
 #define __NR_exit		  1
 #define __NR_read		  3

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 14:05                           ` Arnd Bergmann
@ 2006-08-28 14:42                             ` Andi Kleen
  2006-08-28 15:46                               ` Adrian Bunk
                                                 ` (2 more replies)
  0 siblings, 3 replies; 45+ messages in thread
From: Andi Kleen @ 2006-08-28 14:42 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David Woodhouse, David Miller, linux-arch, jdike, B.Steinbrink,
	arjan, chase.venters, akpm, rmk+lkml, rusty, linux-kernel

On Monday 28 August 2006 16:05, Arnd Bergmann wrote:

> The patch below should address both these issues, as long as the libc
> has a working implementation of syscall(2).

I would prefer the _syscall() macros to stay independent of the 
actual glibc version. Or what do you do otherwise on a system
with old glibc? Upgrading glibc is normally a major PITA.

-Andi

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 14:42                             ` Andi Kleen
@ 2006-08-28 15:46                               ` Adrian Bunk
  2006-08-28 17:00                                 ` Andi Kleen
  2006-08-28 20:20                               ` Horst H. von Brand
  2006-08-30  5:44                               ` H. Peter Anvin
  2 siblings, 1 reply; 45+ messages in thread
From: Adrian Bunk @ 2006-08-28 15:46 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Arnd Bergmann, David Woodhouse, David Miller, linux-arch, jdike,
	B.Steinbrink, arjan, chase.venters, akpm, rmk+lkml, rusty,
	linux-kernel

On Mon, Aug 28, 2006 at 04:42:21PM +0200, Andi Kleen wrote:
> On Monday 28 August 2006 16:05, Arnd Bergmann wrote:
> 
> > The patch below should address both these issues, as long as the libc
> > has a working implementation of syscall(2).
> 
> I would prefer the _syscall() macros to stay independent of the 
> actual glibc version. Or what do you do otherwise on a system
> with old glibc? Upgrading glibc is normally a major PITA.

This would only be required if you'd upgrade the userspace kernel 
headers on this system to a version not matching the ones glibc was 
built against - and this has never been considered a good idea
(it should work in theory, but not with our current header mess).

> -Andi

cu
Adrian

-- 

    Gentoo kernels are 42 times more popular than SUSE kernels among
    KLive users  (a service by SUSE contractor Andrea Arcangeli that
    gathers data about kernels from many users worldwide).

       There are three kinds of lies: Lies, Damn Lies, and Statistics.
                                                    Benjamin Disraeli


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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 15:46                               ` Adrian Bunk
@ 2006-08-28 17:00                                 ` Andi Kleen
  2006-08-30 17:45                                   ` Adrian Bunk
  0 siblings, 1 reply; 45+ messages in thread
From: Andi Kleen @ 2006-08-28 17:00 UTC (permalink / raw)
  To: Adrian Bunk
  Cc: Arnd Bergmann, David Woodhouse, David Miller, linux-arch, jdike,
	B.Steinbrink, arjan, chase.venters, akpm, rmk+lkml, rusty,
	linux-kernel


> This would only be required if you'd upgrade the userspace kernel
> headers on this system to a version not matching the ones glibc was
> built against - and this has never been considered a good idea
> (it should work in theory, but not with our current header mess).

Sorry, but that's just utterly wrong. It has always worked. The kernel ABI
is stable on this level.

-Andi

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 14:42                             ` Andi Kleen
  2006-08-28 15:46                               ` Adrian Bunk
@ 2006-08-28 20:20                               ` Horst H. von Brand
  2006-08-28 21:23                                 ` Arnd Bergmann
  2006-08-30  5:44                               ` H. Peter Anvin
  2 siblings, 1 reply; 45+ messages in thread
From: Horst H. von Brand @ 2006-08-28 20:20 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Arnd Bergmann, David Woodhouse, David Miller, linux-arch, jdike,
	B.Steinbrink, arjan, chase.venters, akpm, rmk+lkml, rusty,
	linux-kernel

Andi Kleen <ak@suse.de> wrote:
> On Monday 28 August 2006 16:05, Arnd Bergmann wrote:
> 
> > The patch below should address both these issues, as long as the libc
> > has a working implementation of syscall(2).

> I would prefer the _syscall() macros to stay independent of the 
> actual glibc version. Or what do you do otherwise on a system
> with old glibc? Upgrading glibc is normally a major PITA.

Could just this macro layer be explicitly BSD (or at least LGPL) licensed? 
If not, it looks like a SCOX-whining-over-errno.h thing in the making in
case somebody wants to build a non-GPL libc on top...
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513


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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 20:20                               ` Horst H. von Brand
@ 2006-08-28 21:23                                 ` Arnd Bergmann
  0 siblings, 0 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-28 21:23 UTC (permalink / raw)
  To: Horst H. von Brand
  Cc: Andi Kleen, David Woodhouse, David Miller, linux-arch, jdike,
	B.Steinbrink, arjan, chase.venters, akpm, rmk+lkml, rusty,
	linux-kernel

Am Monday 28 August 2006 22:20 schrieb Horst H. von Brand:
> Could just this macro layer be explicitly BSD (or at least LGPL) licensed?
> If not, it looks like a SCOX-whining-over-errno.h thing in the making in
> case somebody wants to build a non-GPL libc on top...

klibc comes with a BSD licensed version of these macros.

	Arnd <><

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

* Re: [PATCH 3/7] provide kernel_execve on all architectures
  2006-08-27 21:47 ` [PATCH 3/7] provide kernel_execve on all architectures Arnd Bergmann
@ 2006-08-29  2:22   ` Ralf Baechle
  0 siblings, 0 replies; 45+ messages in thread
From: Ralf Baechle @ 2006-08-29  2:22 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

On Sun, Aug 27, 2006 at 11:47:37PM +0200, Arnd Bergmann wrote:

> This adds the new kernel_execve function on all architectures
> that were using _syscall3() to implement execve.
> 
> The implementation uses code from the _syscall3 macros provided
> in the unistd.h header file. I don't have cross-compilers for
> any of these architectures, so the patch is untested with the
> exception of i386.
> 
> Most architectures can probably implement this in a nicer way
> in assembly or by combining it with the sys_execve implementation
> itself, but this should do it for now.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Two bugs in your MIPS version of kernel_execve(); the inline asm which
was copying from _syscall3 macro was still using the #stringify
operation.  It also didn't get the result return in case of errors
right - $a3 = 1 indicates an error in which case $v0 will contain the
positive error number.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 0721314..b73b26c 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -399,3 +399,32 @@ asmlinkage void bad_stack(void)
 {
 	do_exit(SIGSEGV);
 }
+
+/*
+ * Do a system call from kernel instead of calling sys_execve so we
+ * end up with proper pt_regs.
+ */
+int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+{
+	register unsigned long __a0 asm("$4") = (unsigned long) filename;
+	register unsigned long __a1 asm("$5") = (unsigned long) argv;
+	register unsigned long __a2 asm("$6") = (unsigned long) envp;
+	register unsigned long __a3 asm("$7");
+	unsigned long __v0;
+
+	__asm__ volatile ("					\n"
+	"	.set	noreorder				\n"
+	"	li	$2, %5		# __NR_execve		\n"
+	"	syscall						\n"
+	"	move	%0, $2					\n"
+	"	.set	reorder					\n"
+	: "=&r" (__v0), "=r" (__a3)
+	: "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve)
+	: "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24",
+	  "memory");
+
+	if (__a3 == 0)
+		return __v0;
+
+	return -__v0;
+}

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

* Re: [PATCH 0/7] kill __KERNEL_SYSCALLS__
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
                   ` (6 preceding siblings ...)
  2006-08-27 22:01 ` [PATCH 1/7] introduce kernel_execve Arnd Bergmann
@ 2006-08-29  9:12 ` David Howells
  2006-08-29  9:37   ` Arnd Bergmann
  2006-08-29  9:38   ` Haavard Skinnemoen
  2006-08-29 17:21 ` [PATCH 3/7] provide kernel_execve on all architectures David Howells
  2006-08-29 17:23 ` [PATCH 7/7] remove the global errno from the kernel David Howells
  9 siblings, 2 replies; 45+ messages in thread
From: David Howells @ 2006-08-29  9:12 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

Arnd Bergmann <arnd@arndb.de> wrote:

> Ok, next try. This time a full series that tries to kill
> off __KERNEL_SYSCALLS__, _syscallX() and the global errno
> for good.

Have you checked uClibc?  Does that use _syscallX()?

David

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

* Re: [PATCH 0/7] kill __KERNEL_SYSCALLS__
  2006-08-29  9:12 ` [PATCH 0/7] kill __KERNEL_SYSCALLS__ David Howells
@ 2006-08-29  9:37   ` Arnd Bergmann
  2006-08-29  9:38   ` Haavard Skinnemoen
  1 sibling, 0 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-29  9:37 UTC (permalink / raw)
  To: David Howells
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

On Tuesday 29 August 2006 11:12, David Howells wrote:
> > Ok, next try. This time a full series that tries to kill
> > off __KERNEL_SYSCALLS__, _syscallX() and the global errno
> > for good.
> 
> Have you checked uClibc?  Does that use _syscallX()?

uClibc has its own copy of these macros.

	Arnd <><

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

* Re: [PATCH 0/7] kill __KERNEL_SYSCALLS__
  2006-08-29  9:12 ` [PATCH 0/7] kill __KERNEL_SYSCALLS__ David Howells
  2006-08-29  9:37   ` Arnd Bergmann
@ 2006-08-29  9:38   ` Haavard Skinnemoen
  1 sibling, 0 replies; 45+ messages in thread
From: Haavard Skinnemoen @ 2006-08-29  9:38 UTC (permalink / raw)
  To: David Howells
  Cc: Arnd Bergmann, linux-kernel, linux-arch, Jeff Dike,
	Bjoern Steinbrink, Arjan van de Ven, Chase Venters,
	Andrew Morton, Russell King, rusty

On 8/29/06, David Howells <dhowells@redhat.com> wrote:
> Arnd Bergmann <arnd@arndb.de> wrote:
>
> > Ok, next try. This time a full series that tries to kill
> > off __KERNEL_SYSCALLS__, _syscallX() and the global errno
> > for good.
>
> Have you checked uClibc?  Does that use _syscallX()?

At least the latest version provides its own set of _syscallX()
macros. I removed _syscallX() from the AVR32 kernel a few weeks ago as
suggested by David Woodhouse, and uClibc doesn't seem to have a
problem with it.

Haavard

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

* Re: [PATCH 3/7] provide kernel_execve on all architectures
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
                   ` (7 preceding siblings ...)
  2006-08-29  9:12 ` [PATCH 0/7] kill __KERNEL_SYSCALLS__ David Howells
@ 2006-08-29 17:21 ` David Howells
  2006-08-29 17:23 ` [PATCH 7/7] remove the global errno from the kernel David Howells
  9 siblings, 0 replies; 45+ messages in thread
From: David Howells @ 2006-08-29 17:21 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

Arnd Bergmann <arnd@arndb.de> wrote:

> Most architectures can probably implement this in a nicer way
> in assembly or by combining it with the sys_execve implementation
> itself, but this should do it for now.

Try applying the attached delta for FRV.  Note that you didn't #include
asm/unistd.h in your original patch.

Signed-Off-By: David Howells <dhowells@redhat.com>

---
diff --git a/arch/frv/kernel/Makefile b/arch/frv/kernel/Makefile
index 91d380a..7bf175c 100644
--- a/arch/frv/kernel/Makefile
+++ b/arch/frv/kernel/Makefile
@@ -8,7 +8,7 @@ heads-$(CONFIG_MMU)		:= head-mmu-fr451.o
 extra-y:= head.o init_task.o vmlinux.lds
 
 obj-y := $(heads-y) entry.o entry-table.o break.o switch_to.o kernel_thread.o \
-	 process.o traps.o ptrace.o signal.o dma.o \
+	 kernel_execve.o process.o traps.o ptrace.o signal.o dma.o \
 	 sys_frv.o time.o semaphore.o setup.o frv_ksyms.o \
 	 debug-stub.o irq.o irq-routing.o sleep.o uaccess.o atomic-ops.o
 
diff --git a/arch/frv/kernel/sys_frv.c b/arch/frv/kernel/sys_frv.c
index 944aab2..c4d4348 100644
--- a/arch/frv/kernel/sys_frv.c
+++ b/arch/frv/kernel/sys_frv.c
@@ -212,19 +212,3 @@ asmlinkage long sys_ipc(unsigned long ca
 		return -ENOSYS;
 	}
 }
-
-/*
- * Do a system call from kernel instead of calling sys_execve so we
- * end up with proper pt_regs.
- */
-int kernel_execve(const char *filename, char *const argv[], char *const envp[])
-{
-	register unsigned long __scnum __asm__ ("gr7") = __NR_execve;
-	register unsigned long __sc0 __asm__ ("gr8") = (unsigned long) filename;
-	register unsigned long __sc1 __asm__ ("gr9") = (unsigned long) argv;
-	register unsigned long __sc2 __asm__ ("gr10") = (unsigned long) envp;
-	__asm__ __volatile__ ("tira gr0,#0"
-			      : "+r" (__sc0)
-			      : "r" (__scnum), "r" (__sc1), "r" (__sc2));
-	return __sc0;
-}
diff --git a/arch/frv/kernel/kernel_execve.S b/arch/frv/kernel/kernel_execve.S
new file mode 100644
index 0000000..9b074a1
--- /dev/null
+++ b/arch/frv/kernel/kernel_execve.S
@@ -0,0 +1,33 @@
+/* in-kernel program execution
+ *
+ * Copyright (C) 2006 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/linkage.h>
+#include <asm/unistd.h>
+
+###############################################################################
+#
+# Do a system call from kernel instead of calling sys_execve so we end up with
+# proper pt_regs.
+#
+# int kernel_execve(const char *filename, char *const argv[], char *const envp[])
+#
+# On entry: GR8/GR9/GR10: arguments to function
+# On return: GR8: syscall return.
+#
+###############################################################################
+	.globl		kernel_execve
+	.type		kernel_execve,@function
+kernel_execve:
+	setlos		__NR_execve,gr7
+	tira		gr0,#0
+	bralr
+
+	.size		kernel_execve,.-kernel_execve

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

* Re: [PATCH 7/7] remove the global errno from the kernel
  2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
                   ` (8 preceding siblings ...)
  2006-08-29 17:21 ` [PATCH 3/7] provide kernel_execve on all architectures David Howells
@ 2006-08-29 17:23 ` David Howells
  9 siblings, 0 replies; 45+ messages in thread
From: David Howells @ 2006-08-29 17:23 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

Arnd Bergmann <arnd@arndb.de> wrote:

> The last in-kernel user of errno is gone, so we should
> remove the definition and everything referring to it.
> This also removes the now-unused lib/execve.c file
> that was introduced earlier.

	  CC      lib/execve.o
	frv-linux-gnu-gcc: lib/execve.c: No such file or directory
	frv-linux-gnu-gcc: no input files

You perchance forgot to remove something added in patch 1/7.

David

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

* Re: [PATCH 4/7] Remove the use of _syscallX macros in UML
  2006-08-27 21:47 ` [PATCH 4/7] Remove the use of _syscallX macros in UML Arnd Bergmann
  2006-08-28  9:25   ` Andreas Schwab
@ 2006-08-30  5:41   ` H. Peter Anvin
  2006-08-30 12:38     ` Arnd Bergmann
  1 sibling, 1 reply; 45+ messages in thread
From: H. Peter Anvin @ 2006-08-30  5:41 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

Arnd Bergmann wrote:
> User mode linux uses _syscallX() to call into the host kernel.
> The recommended way to do this is to use the syscall() function
> from libc.

Not really.

syscall() is a horrible botch; it is in fact unimplementable (without 
enormous switch statements) on a number of architectures.

	-hpa

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 14:42                             ` Andi Kleen
  2006-08-28 15:46                               ` Adrian Bunk
  2006-08-28 20:20                               ` Horst H. von Brand
@ 2006-08-30  5:44                               ` H. Peter Anvin
  2006-08-30  7:22                                 ` Andi Kleen
  2 siblings, 1 reply; 45+ messages in thread
From: H. Peter Anvin @ 2006-08-30  5:44 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Arnd Bergmann, David Woodhouse, David Miller, linux-arch, jdike,
	B.Steinbrink, arjan, chase.venters, akpm, rmk+lkml, rusty,
	linux-kernel

Andi Kleen wrote:
> On Monday 28 August 2006 16:05, Arnd Bergmann wrote:
> 
>> The patch below should address both these issues, as long as the libc
>> has a working implementation of syscall(2).
> 
> I would prefer the _syscall() macros to stay independent of the 
> actual glibc version. Or what do you do otherwise on a system
> with old glibc? Upgrading glibc is normally a major PITA.
> 

Why don't you just have a private version of the macros?

syscall(2) is, again, a horrible botch -- on architectures which 
requires alignment for register pairs, the extra register buggers up the 
alignment.  One *can* work around it by making the syscall number 64 
bits, but I think it's safe to say that no libc does that currently.

	-hpa

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-30  5:44                               ` H. Peter Anvin
@ 2006-08-30  7:22                                 ` Andi Kleen
  0 siblings, 0 replies; 45+ messages in thread
From: Andi Kleen @ 2006-08-30  7:22 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Arnd Bergmann, David Woodhouse, David Miller, linux-arch, jdike,
	B.Steinbrink, arjan, chase.venters, akpm, rmk+lkml, rusty,
	linux-kernel


> Why don't you just have a private version of the macros?

Because I don't write a libc, just test programs, preferably
without a huge amount of cut'n'pasted code

-Andi

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

* Re: [PATCH 4/7] Remove the use of _syscallX macros in UML
  2006-08-30  5:41   ` H. Peter Anvin
@ 2006-08-30 12:38     ` Arnd Bergmann
  0 siblings, 0 replies; 45+ messages in thread
From: Arnd Bergmann @ 2006-08-30 12:38 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: linux-kernel, linux-arch, Jeff Dike, Bjoern Steinbrink,
	Arjan van de Ven, Chase Venters, Andrew Morton, Russell King,
	rusty

On Wednesday 30 August 2006 07:41, H. Peter Anvin wrote:
> syscall() is a horrible botch; it is in fact unimplementable (without 
> enormous switch statements) on a number of architectures.
> 
Ok, good point. I'll leave the _syscallX() macros in for now and only
remove the kernel syscalls in my next submission, so we get at least
the non-controversial part done.

	Arnd <><

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

* Re: [PATCH 6/7] remove all remaining _syscallX macros
  2006-08-28 17:00                                 ` Andi Kleen
@ 2006-08-30 17:45                                   ` Adrian Bunk
  0 siblings, 0 replies; 45+ messages in thread
From: Adrian Bunk @ 2006-08-30 17:45 UTC (permalink / raw)
  To: Andi Kleen
  Cc: Arnd Bergmann, David Woodhouse, David Miller, linux-arch, jdike,
	B.Steinbrink, arjan, chase.venters, akpm, rmk+lkml, rusty,
	linux-kernel

On Mon, Aug 28, 2006 at 07:00:09PM +0200, Andi Kleen wrote:
> 
> > This would only be required if you'd upgrade the userspace kernel
> > headers on this system to a version not matching the ones glibc was
> > built against - and this has never been considered a good idea
> > (it should work in theory, but not with our current header mess).
> 
> Sorry, but that's just utterly wrong. It has always worked. The kernel ABI
> is stable on this level.

In this area, the ABI is much more stable than the API.

Try compiling glibc-2.0.1 with 2.6.17 kernel headers...

> -Andi

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


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

end of thread, other threads:[~2006-08-30 17:45 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-27 21:47 [PATCH 0/7] kill __KERNEL_SYSCALLS__ Arnd Bergmann
2006-08-27 21:47 ` [PATCH 2/7] rename the provided execve functions to kernel_execve Arnd Bergmann
2006-08-28  2:20   ` Randy.Dunlap
2006-08-28  7:44     ` Arnd Bergmann
2006-08-27 21:47 ` [PATCH 3/7] provide kernel_execve on all architectures Arnd Bergmann
2006-08-29  2:22   ` Ralf Baechle
2006-08-27 21:47 ` [PATCH 4/7] Remove the use of _syscallX macros in UML Arnd Bergmann
2006-08-28  9:25   ` Andreas Schwab
2006-08-30  5:41   ` H. Peter Anvin
2006-08-30 12:38     ` Arnd Bergmann
2006-08-27 21:47 ` [PATCH 6/7] remove all remaining _syscallX macros Arnd Bergmann
2006-08-28  7:35   ` Andi Kleen
2006-08-28  7:41     ` Arnd Bergmann
2006-08-28  7:46       ` Arjan van de Ven
2006-08-28  8:09         ` Arnd Bergmann
2006-08-28  7:50       ` Andi Kleen
2006-08-28  8:01         ` Arnd Bergmann
2006-08-28  8:03           ` Andi Kleen
2006-08-28  8:09             ` David Miller
2006-08-28  8:15               ` Andi Kleen
2006-08-28  8:19                 ` David Miller
2006-08-28  8:28                   ` Andi Kleen
2006-08-28  8:40                     ` David Woodhouse
2006-08-28  8:53                       ` Andi Kleen
2006-08-28 10:00                         ` David Woodhouse
2006-08-28 10:37                           ` Arjan van de Ven
2006-08-28 10:58                             ` Andi Kleen
2006-08-28 14:05                           ` Arnd Bergmann
2006-08-28 14:42                             ` Andi Kleen
2006-08-28 15:46                               ` Adrian Bunk
2006-08-28 17:00                                 ` Andi Kleen
2006-08-30 17:45                                   ` Adrian Bunk
2006-08-28 20:20                               ` Horst H. von Brand
2006-08-28 21:23                                 ` Arnd Bergmann
2006-08-30  5:44                               ` H. Peter Anvin
2006-08-30  7:22                                 ` Andi Kleen
2006-08-27 21:47 ` [PATCH 7/7] remove the global errno from the kernel Arnd Bergmann
2006-08-27 22:00 ` [PATCH 5/7] sh64: remove the use of kernel syscalls Arnd Bergmann
2006-08-28  8:05   ` Paul Mundt
2006-08-27 22:01 ` [PATCH 1/7] introduce kernel_execve Arnd Bergmann
2006-08-29  9:12 ` [PATCH 0/7] kill __KERNEL_SYSCALLS__ David Howells
2006-08-29  9:37   ` Arnd Bergmann
2006-08-29  9:38   ` Haavard Skinnemoen
2006-08-29 17:21 ` [PATCH 3/7] provide kernel_execve on all architectures David Howells
2006-08-29 17:23 ` [PATCH 7/7] remove the global errno from the kernel David Howells

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