public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] consolidate asm/ipc.h
@ 2005-03-23  4:01 Stephen Rothwell
  2005-03-23  4:12 ` David S. Miller
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Stephen Rothwell @ 2005-03-23  4:01 UTC (permalink / raw)
  To: linux-arch

[-- Attachment #1: Type: text/plain, Size: 20229 bytes --]

Hi all,

All the asm*/ipc.h files are basically the same (for things that are used)
so I have consolidated them all into asm-generic/ipc.h

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Built and booted on ppc64, built on ppc.

Diffstat looks like this:
 arch/x86_64/ia32/sys_ia32.c     |    1
 arch/x86_64/kernel/sys_x86_64.c |    1
 include/asm-arm/ipc.h           |   30 -----------------------------
 include/asm-arm26/ipc.h         |   29 ----------------------------
 include/asm-cris/ipc.h          |   36 -----------------------------------
 include/asm-frv/ipc.h           |   34 ---------------------------------
 include/asm-generic/ipc.h       |   31 ++++++++++++++++++++++++++++++
 include/asm-h8300/ipc.h         |   32 -------------------------------
 include/asm-i386/ipc.h          |   33 --------------------------------
 include/asm-m32r/ipc.h          |   36 -----------------------------------
 include/asm-m68k/ipc.h          |   32 -------------------------------
 include/asm-m68knommu/ipc.h     |    2 -
 include/asm-mips/ipc.h          |   34 ---------------------------------
 include/asm-ppc/ipc.h           |   30 -----------------------------
 include/asm-ppc64/ipc.h         |   35 ----------------------------------
 include/asm-s390/ipc.h          |   41 ----------------------------------------
 include/asm-sh/ipc.h            |   33 --------------------------------
 include/asm-sh64/ipc.h          |    7 ------
 include/asm-sparc/ipc.h         |   33 --------------------------------
 include/asm-sparc64/ipc.h       |   34 ---------------------------------
 include/asm-v850/ipc.h          |   32 -------------------------------
 include/asm-x86_64/ipc.h        |    6 -----
 22 files changed, 49 insertions(+), 533 deletions(-)

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN linus/arch/x86_64/ia32/sys_ia32.c linus-compat_sys_ipc.1/arch/x86_64/ia32/sys_ia32.c
--- linus/arch/x86_64/ia32/sys_ia32.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.1/arch/x86_64/ia32/sys_ia32.c	2005-03-23 12:16:30.000000000 +1100
@@ -65,7 +65,6 @@
 #include <asm/types.h>
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
-#include <asm/ipc.h>
 #include <asm/atomic.h>
 #include <asm/ldt.h>
 
diff -ruN linus/arch/x86_64/kernel/sys_x86_64.c linus-compat_sys_ipc.1/arch/x86_64/kernel/sys_x86_64.c
--- linus/arch/x86_64/kernel/sys_x86_64.c	2004-05-31 19:02:00.000000000 +1000
+++ linus-compat_sys_ipc.1/arch/x86_64/kernel/sys_x86_64.c	2005-03-23 12:17:49.000000000 +1100
@@ -18,7 +18,6 @@
 #include <linux/personality.h>
 
 #include <asm/uaccess.h>
-#include <asm/ipc.h>
 #include <asm/ia32.h>
 
 /*
diff -ruN linus/include/asm-arm/ipc.h linus-compat_sys_ipc.1/include/asm-arm/ipc.h
--- linus/include/asm-arm/ipc.h	2005-03-17 14:08:05.000000000 +1100
+++ linus-compat_sys_ipc.1/include/asm-arm/ipc.h	2005-03-23 11:46:12.000000000 +1100
@@ -1,29 +1 @@
-#ifndef __ASMARM_IPC_H
-#define __ASMARM_IPC_H
-
-/* 
- * These are used to wrap system calls on ARM.
- *
- * See arch/arm/kernel/sys-arm.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-arm26/ipc.h linus-compat_sys_ipc.1/include/asm-arm26/ipc.h
--- linus/include/asm-arm26/ipc.h	2003-06-04 21:14:10.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-arm26/ipc.h	2005-03-23 11:46:36.000000000 +1100
@@ -1,28 +1 @@
-#ifndef __ASMARM_IPC_H
-#define __ASMARM_IPC_H
-
-/* 
- * These are used to wrap system calls on ARM.
- *
- * See arch/arm/kernel/sys-arm.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-cris/ipc.h linus-compat_sys_ipc.1/include/asm-cris/ipc.h
--- linus/include/asm-cris/ipc.h	2003-07-11 10:41:26.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-cris/ipc.h	2005-03-23 11:47:00.000000000 +1100
@@ -1,35 +1 @@
-#ifndef __CRIS_IPC_H__
-#define __CRIS_IPC_H__
-
-/* 
- * These are used to wrap system calls on CRIS.
- *
- * See arch/cris/kernel/sys_cris.c for ugly details..
- *
- * Same as x86 version.
- *
- */
-struct ipc_kludge {
-	struct msgbuf *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC            25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-frv/ipc.h linus-compat_sys_ipc.1/include/asm-frv/ipc.h
--- linus/include/asm-frv/ipc.h	2005-01-05 13:48:06.000000000 +1100
+++ linus-compat_sys_ipc.1/include/asm-frv/ipc.h	2005-03-23 11:47:24.000000000 +1100
@@ -1,33 +1 @@
-#ifndef __ASM_IPC_H__
-#define __ASM_IPC_H__
-
-/*
- * These are used to wrap system calls on FR-V
- *
- * See arch/frv/kernel/sys_frv.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC		25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
-
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-generic/ipc.h linus-compat_sys_ipc.1/include/asm-generic/ipc.h
--- linus/include/asm-generic/ipc.h	1970-01-01 10:00:00.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-generic/ipc.h	2005-03-23 11:44:17.000000000 +1100
@@ -0,0 +1,31 @@
+#ifndef _ASM_GENERIC_IPC_H
+#define _ASM_GENERIC_IPC_H
+/*
+ * These are used to wrap system calls.
+ *
+ * See architecture code for ugly details..
+ */
+struct ipc_kludge {
+	struct msgbuf __user *msgp;
+	long msgtyp;
+};
+
+#define SEMOP		 1
+#define SEMGET		 2
+#define SEMCTL		 3
+#define SEMTIMEDOP	 4
+#define MSGSND		11
+#define MSGRCV		12
+#define MSGGET		13
+#define MSGCTL		14
+#define SHMAT		21
+#define SHMDT		22
+#define SHMGET		23
+#define SHMCTL		24
+
+/* Used by the DIPC package, try and avoid reusing it */
+#define DIPC            25
+
+#define IPCCALL(version,op)	((version)<<16 | (op))
+
+#endif	/* _ASM_GENERIC_IPC_H */
diff -ruN linus/include/asm-h8300/ipc.h linus-compat_sys_ipc.1/include/asm-h8300/ipc.h
--- linus/include/asm-h8300/ipc.h	2003-02-17 11:01:58.000000000 +1100
+++ linus-compat_sys_ipc.1/include/asm-h8300/ipc.h	2005-03-23 12:04:22.000000000 +1100
@@ -1,31 +1 @@
-#ifndef __H8300_IPC_H__
-#define __H8300_IPC_H__
-
-/* 
- * These are used to wrap system calls on H8/300.
- *
- * See arch/h8300/kernel/sys_h8300.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC		25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-i386/ipc.h linus-compat_sys_ipc.1/include/asm-i386/ipc.h
--- linus/include/asm-i386/ipc.h	2003-05-10 14:11:11.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-i386/ipc.h	2005-03-23 12:04:47.000000000 +1100
@@ -1,32 +1 @@
-#ifndef __i386_IPC_H__
-#define __i386_IPC_H__
-
-/* 
- * These are used to wrap system calls on x86.
- *
- * See arch/i386/kernel/sys_i386.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC            25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-m32r/ipc.h linus-compat_sys_ipc.1/include/asm-m32r/ipc.h
--- linus/include/asm-m32r/ipc.h	2004-09-17 17:06:56.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-m32r/ipc.h	2005-03-23 12:05:13.000000000 +1100
@@ -1,35 +1 @@
-#ifndef __M32R_IPC_H__
-#define __M32R_IPC_H__
-
-/* orig : i386/ipc.h 2.6.0-test3 */
-
-/*
- * These are used to wrap system calls on x86.
- *
- * See arch/i386/kernel/sys_i386.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC            25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif	/* __M32R_IPC_H__ */
-
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-m68k/ipc.h linus-compat_sys_ipc.1/include/asm-m68k/ipc.h
--- linus/include/asm-m68k/ipc.h	2004-05-12 07:28:09.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-m68k/ipc.h	2005-03-23 12:05:29.000000000 +1100
@@ -1,31 +1 @@
-#ifndef __m68k_IPC_H__
-#define __m68k_IPC_H__
-
-/*
- * These are used to wrap system calls on m68k.
- *
- * See arch/m68k/kernel/sys_m68k.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC		25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-m68knommu/ipc.h linus-compat_sys_ipc.1/include/asm-m68knommu/ipc.h
--- linus/include/asm-m68knommu/ipc.h	2002-11-02 03:37:46.000000000 +1100
+++ linus-compat_sys_ipc.1/include/asm-m68knommu/ipc.h	2005-03-23 12:05:44.000000000 +1100
@@ -1 +1 @@
-#include <asm-m68k/ipc.h>
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-mips/ipc.h linus-compat_sys_ipc.1/include/asm-mips/ipc.h
--- linus/include/asm-mips/ipc.h	2003-08-02 09:37:34.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-mips/ipc.h	2005-03-23 12:06:00.000000000 +1100
@@ -1,33 +1 @@
-#ifndef _ASM_IPC_H
-#define _ASM_IPC_H
-
-/*
- * These are used to wrap system calls on MIPS.
- *
- * See arch/mips/kernel/sysmips.c for ugly details..
- * FIXME: split up into ordinary syscalls ...
- */
-struct ipc_kludge {
-	struct msgbuf *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC		25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif /* _ASM_IPC_H */
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-ppc/ipc.h linus-compat_sys_ipc.1/include/asm-ppc/ipc.h
--- linus/include/asm-ppc/ipc.h	2003-09-24 10:56:02.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-ppc/ipc.h	2005-03-23 12:06:13.000000000 +1100
@@ -1,29 +1 @@
-#ifndef __PPC_IPC_H__
-#define __PPC_IPC_H__
-
-/*
- * These are used to wrap system calls on PowerPC.
- *
- * See arch/ppc/kernel/syscalls.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif /* __PPC_IPC_H__ */
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-ppc64/ipc.h linus-compat_sys_ipc.1/include/asm-ppc64/ipc.h
--- linus/include/asm-ppc64/ipc.h	2004-05-30 11:50:26.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-ppc64/ipc.h	2005-03-23 12:06:27.000000000 +1100
@@ -1,34 +1 @@
-#ifndef __PPC64_IPC_H__
-#define __PPC64_IPC_H__
-
-/* 
- * These are used to wrap system calls on PowerPC.
- *
- * See arch/ppc64/kernel/syscalls.c for ugly details..
- *
- * 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.
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif /* __PPC64_IPC_H__ */
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-s390/ipc.h linus-compat_sys_ipc.1/include/asm-s390/ipc.h
--- linus/include/asm-s390/ipc.h	2004-06-15 08:15:08.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-s390/ipc.h	2005-03-23 12:06:43.000000000 +1100
@@ -1,40 +1 @@
-/*
- *  include/asm-s390/ipc.h
- *
- *  S390 version
- *
- *  Derived from "include/asm-i386/ipc.h"
- */
-
-#ifndef __s390_IPC_H__
-#define __s390_IPC_H__
-
-/* 
- * These are used to wrap system calls on S390.
- *
- * See arch/s390/kernel/sys_s390.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC            25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-sh/ipc.h linus-compat_sys_ipc.1/include/asm-sh/ipc.h
--- linus/include/asm-sh/ipc.h	2004-01-20 08:20:27.000000000 +1100
+++ linus-compat_sys_ipc.1/include/asm-sh/ipc.h	2005-03-23 12:06:55.000000000 +1100
@@ -1,32 +1 @@
-#ifndef __ASM_SH_IPC_H
-#define __ASM_SH_IPC_H
-
-/* 
- * These are used to wrap system calls on x86.
- *
- * See arch/i386/kernel/sys_i386.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC            25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif /* __ASM_SH_IPC_H */
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-sh64/ipc.h linus-compat_sys_ipc.1/include/asm-sh64/ipc.h
--- linus/include/asm-sh64/ipc.h	2004-06-30 00:44:46.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-sh64/ipc.h	2005-03-23 12:07:06.000000000 +1100
@@ -1,6 +1 @@
-#ifndef __ASM_SH64_IPC_H
-#define __ASM_SH64_IPC_H
-
-#include <asm-sh/ipc.h>
-
-#endif /* __ASM_SH64_IPC_H */
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-sparc/ipc.h linus-compat_sys_ipc.1/include/asm-sparc/ipc.h
--- linus/include/asm-sparc/ipc.h	2004-06-02 07:45:40.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-sparc/ipc.h	2005-03-23 12:07:18.000000000 +1100
@@ -1,32 +1 @@
-#ifndef __SPARC_IPC_H__
-#define __SPARC_IPC_H__
-
-/* 
- * These are used to wrap system calls on the sparc.
- *
- * See arch/sparc/kernel/sys_sparc.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf __user *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC            25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-sparc64/ipc.h linus-compat_sys_ipc.1/include/asm-sparc64/ipc.h
--- linus/include/asm-sparc64/ipc.h	2003-07-14 13:14:56.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-sparc64/ipc.h	2005-03-23 13:18:11.000000000 +1100
@@ -1,33 +1 @@
-#ifndef __SPARC64_IPC_H__
-#define __SPARC64_IPC_H__
-
-/* 
- * These are used to wrap system calls on the sparc.
- *
- * See arch/sparc64/kernel/sys_sparc32.c for ugly details..
- */
-struct ipc_kludge {
-	u32 msgp;
-	s32 msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define SEMTIMEDOP	 4
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC            25
-
-/* We don't need to maintain backward compatibility on 64bit, we've started fresh */
-#define IPCCALL(version,op)	(op)
-
-#endif
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-v850/ipc.h linus-compat_sys_ipc.1/include/asm-v850/ipc.h
--- linus/include/asm-v850/ipc.h	2002-11-02 03:38:12.000000000 +1100
+++ linus-compat_sys_ipc.1/include/asm-v850/ipc.h	2005-03-23 12:08:09.000000000 +1100
@@ -1,31 +1 @@
-#ifndef __V850_IPC_H__
-#define __V850_IPC_H__
-
-/* 
- * These are used to wrap system calls on v850.
- *
- * See arch/v850/kernel/syscalls.c for ugly details..
- */
-struct ipc_kludge {
-	struct msgbuf *msgp;
-	long msgtyp;
-};
-
-#define SEMOP		 1
-#define SEMGET		 2
-#define SEMCTL		 3
-#define MSGSND		11
-#define MSGRCV		12
-#define MSGGET		13
-#define MSGCTL		14
-#define SHMAT		21
-#define SHMDT		22
-#define SHMGET		23
-#define SHMCTL		24
-
-/* Used by the DIPC package, try and avoid reusing it */
-#define DIPC		25
-
-#define IPCCALL(version,op)	((version)<<16 | (op))
-
-#endif /* __V850_IPC_H__ */
+#include <asm-generic/ipc.h>
diff -ruN linus/include/asm-x86_64/ipc.h linus-compat_sys_ipc.1/include/asm-x86_64/ipc.h
--- linus/include/asm-x86_64/ipc.h	2002-10-17 23:29:20.000000000 +1000
+++ linus-compat_sys_ipc.1/include/asm-x86_64/ipc.h	1970-01-01 10:00:00.000000000 +1000
@@ -1,6 +0,0 @@
-#ifndef __x8664_IPC_H__
-#define __x8664_IPC_H__
-
-/* dummy */
-
-#endif

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] consolidate asm/ipc.h
  2005-03-23  4:01 [PATCH] consolidate asm/ipc.h Stephen Rothwell
@ 2005-03-23  4:12 ` David S. Miller
  2005-03-23  6:48 ` [PATCH] consolidate shmat usage Stephen Rothwell
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: David S. Miller @ 2005-03-23  4:12 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-arch

On Wed, 23 Mar 2005 15:01:23 +1100
Stephen Rothwell <sfr@canb.auug.org.au> wrote:

> All the asm*/ipc.h files are basically the same (for things that are used)
> so I have consolidated them all into asm-generic/ipc.h
> 
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

Looks good to me.

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

* [PATCH] consolidate shmat usage
  2005-03-23  4:01 [PATCH] consolidate asm/ipc.h Stephen Rothwell
  2005-03-23  4:12 ` David S. Miller
@ 2005-03-23  6:48 ` Stephen Rothwell
  2005-03-23 10:54   ` David Howells
                     ` (2 more replies)
  2005-03-23  8:06 ` [PATCH] consolidate asm/ipc.h Andi Kleen
  2005-03-23 10:49 ` David Howells
  3 siblings, 3 replies; 21+ messages in thread
From: Stephen Rothwell @ 2005-03-23  6:48 UTC (permalink / raw)
  To: linux-arch

[-- Attachment #1: Type: text/plain, Size: 29143 bytes --]

This patch creates sys_shmat and sys_smhatcall and uses them wherever possible - this tidies up sys_ipc a bit in most cases.  I have not touched um arch.

I am eventually aiming at consolidating (as much as possible of) sys_ipc
and doing compat_sys_ipc.

I suspetc the conditional compilation of sys_shmat{,call} is a bit much
and have no problem with removing the conditionals.

It builds on ppc64 and ppc.

diffstat looks like this:
 arch/alpha/Kconfig              |    3 +++
 arch/alpha/kernel/osf_sys.c     |   11 +----------
 arch/arm/Kconfig                |    3 +++
 arch/arm/kernel/sys_arm.c       |   22 +++-------------------
 arch/arm26/Kconfig              |    3 +++
 arch/arm26/kernel/sys_arm.c     |   10 +++-------
 arch/cris/Kconfig               |    3 +++
 arch/cris/kernel/sys_cris.c     |   10 +++-------
 arch/frv/Kconfig                |    3 +++
 arch/frv/kernel/sys_frv.c       |   10 +++-------
 arch/h8300/Kconfig              |    3 +++
 arch/h8300/kernel/sys_h8300.c   |   12 ++----------
 arch/i386/Kconfig               |    3 +++
 arch/i386/kernel/sys_i386.c     |   10 +++-------
 arch/m32r/Kconfig               |    3 +++
 arch/m32r/kernel/sys_m32r.c     |   14 +++-----------
 arch/m68k/Kconfig               |    3 +++
 arch/m68k/kernel/sys_m68k.c     |   12 ++----------
 arch/mips/Kconfig               |    3 +++
 arch/mips/kernel/syscall.c      |   26 +++-----------------------
 arch/parisc/Kconfig             |    3 +++
 arch/parisc/kernel/sys_parisc.c |    8 +-------
 arch/ppc/Kconfig                |    3 +++
 arch/ppc/kernel/syscalls.c      |   14 +++-----------
 arch/ppc64/Kconfig              |    3 +++
 arch/ppc64/kernel/syscalls.c    |   11 +++--------
 arch/s390/Kconfig               |    3 +++
 arch/s390/kernel/sys_s390.c     |   12 +++---------
 arch/sh/Kconfig                 |    3 +++
 arch/sh/kernel/sys_sh.c         |   11 +++--------
 arch/sh64/Kconfig               |    6 ++++++
 arch/sh64/kernel/sys_sh64.c     |   26 +++-----------------------
 arch/sparc/Kconfig              |    3 +++
 arch/sparc/kernel/sys_sparc.c   |   13 +++----------
 arch/sparc64/Kconfig            |    3 +++
 arch/sparc64/kernel/sys_sparc.c |   11 +++--------
 arch/v850/Kconfig               |    2 ++
 arch/v850/kernel/syscalls.c     |   14 +++-----------
 arch/x86_64/Kconfig             |    3 +++
 arch/x86_64/kernel/sys_x86_64.c |    3 +--
 include/linux/syscalls.h        |    1 +
 ipc/shm.c                       |   35 +++++++++++++++++++++++++++++++++++
 42 files changed, 150 insertions(+), 208 deletions(-)

Comments?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruN linus-compat_sys_ipc.1/arch/alpha/Kconfig linus-compat_sys_ipc.2/arch/alpha/Kconfig
--- linus-compat_sys_ipc.1/arch/alpha/Kconfig	2005-01-09 10:05:38.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/alpha/Kconfig	2005-03-23 17:12:34.000000000 +1100
@@ -21,6 +21,9 @@
 config UID16
 	bool
 
+config SYS_SHMATCALL
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 
diff -ruN linus-compat_sys_ipc.1/arch/alpha/kernel/osf_sys.c linus-compat_sys_ipc.2/arch/alpha/kernel/osf_sys.c
--- linus-compat_sys_ipc.1/arch/alpha/kernel/osf_sys.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/alpha/kernel/osf_sys.c	2005-03-23 16:16:25.000000000 +1100
@@ -460,16 +460,7 @@
 asmlinkage long
 osf_shmat(int shmid, void __user *shmaddr, int shmflg)
 {
-	unsigned long raddr;
-	long err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-
-	/*
-	 * This works because all user-level addresses are
-	 * non-negative longs!
-	 */
-	return err ? err : (long)raddr;
+	return sys_shmatcall(shmid, shmaddr, shmflg);
 }
 
 
diff -ruN linus-compat_sys_ipc.1/arch/arm/Kconfig linus-compat_sys_ipc.2/arch/arm/Kconfig
--- linus-compat_sys_ipc.1/arch/arm/Kconfig	2005-03-05 12:06:14.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/arm/Kconfig	2005-03-23 17:12:45.000000000 +1100
@@ -50,6 +50,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/arm/kernel/sys_arm.c linus-compat_sys_ipc.2/arch/arm/kernel/sys_arm.c
--- linus-compat_sys_ipc.1/arch/arm/kernel/sys_arm.c	2005-03-17 14:08:05.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/arm/kernel/sys_arm.c	2005-03-23 16:22:00.000000000 +1100
@@ -212,13 +212,9 @@
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat(first, (char __user *)ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user(raddr, (ulong __user *)third);
-		}
+		default:
+			return sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1: /* Of course, we don't support iBCS2! */
 			return -EINVAL;
 		}
@@ -234,18 +230,6 @@
 	}
 }
 
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg,
-			  unsigned long __user *addr)
-{
-	unsigned long ret;
-	long err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &ret);
-	if (err == 0)
-		err = put_user(ret, addr);
-	return err;
-}
-
 /* Fork a new task - this creates a new program thread.
  * This is called indirectly via a small wrapper
  */
diff -ruN linus-compat_sys_ipc.1/arch/arm26/Kconfig linus-compat_sys_ipc.2/arch/arm26/Kconfig
--- linus-compat_sys_ipc.1/arch/arm26/Kconfig	2005-01-16 11:05:29.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/arm26/Kconfig	2005-03-23 17:12:54.000000000 +1100
@@ -38,6 +38,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/arm26/kernel/sys_arm.c linus-compat_sys_ipc.2/arch/arm26/kernel/sys_arm.c
--- linus-compat_sys_ipc.1/arch/arm26/kernel/sys_arm.c	2005-01-04 17:05:27.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/arm26/kernel/sys_arm.c	2005-03-23 16:25:43.000000000 +1100
@@ -210,13 +210,9 @@
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong *) third);
-		}
+		default:
+			return sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruN linus-compat_sys_ipc.1/arch/cris/Kconfig linus-compat_sys_ipc.2/arch/cris/Kconfig
--- linus-compat_sys_ipc.1/arch/cris/Kconfig	2005-01-05 17:06:06.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/cris/Kconfig	2005-03-23 17:13:10.000000000 +1100
@@ -13,6 +13,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/cris/kernel/sys_cris.c linus-compat_sys_ipc.2/arch/cris/kernel/sys_cris.c
--- linus-compat_sys_ipc.1/arch/cris/kernel/sys_cris.c	2004-06-04 07:19:00.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/cris/kernel/sys_cris.c	2005-03-23 16:28:01.000000000 +1100
@@ -154,13 +154,9 @@
 	case MSGCTL:
 		return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
 
-	case SHMAT: {
-                ulong raddr;
-                ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-                if (ret)
-                        return ret;
-                return put_user (raddr, (ulong __user *) third);
-        }
+	case SHMAT:
+		return sys_shmat(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT: 
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruN linus-compat_sys_ipc.1/arch/frv/Kconfig linus-compat_sys_ipc.2/arch/frv/Kconfig
--- linus-compat_sys_ipc.1/arch/frv/Kconfig	2005-01-05 13:48:10.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/frv/Kconfig	2005-03-23 17:11:16.000000000 +1100
@@ -10,6 +10,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/frv/kernel/sys_frv.c linus-compat_sys_ipc.2/arch/frv/kernel/sys_frv.c
--- linus-compat_sys_ipc.1/arch/frv/kernel/sys_frv.c	2005-01-06 12:05:05.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/frv/kernel/sys_frv.c	2005-03-23 17:10:43.000000000 +1100
@@ -188,13 +188,9 @@
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong __user *) third);
-		}
+		default:
+			return sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruN linus-compat_sys_ipc.1/arch/h8300/Kconfig linus-compat_sys_ipc.2/arch/h8300/Kconfig
--- linus-compat_sys_ipc.1/arch/h8300/Kconfig	2005-01-05 17:06:06.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/h8300/Kconfig	2005-03-23 17:13:31.000000000 +1100
@@ -25,6 +25,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/h8300/kernel/sys_h8300.c linus-compat_sys_ipc.2/arch/h8300/kernel/sys_h8300.c
--- linus-compat_sys_ipc.1/arch/h8300/kernel/sys_h8300.c	2004-03-16 08:12:17.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/h8300/kernel/sys_h8300.c	2005-03-23 16:30:23.000000000 +1100
@@ -236,16 +236,8 @@
 	if (call <= SHMCTL) 
 		switch (call) {
 		case SHMAT:
-			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong *) third);
-			}
-			}
+			return sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case SHMDT: 
 			return sys_shmdt ((char *)ptr);
 		case SHMGET:
diff -ruN linus-compat_sys_ipc.1/arch/i386/Kconfig linus-compat_sys_ipc.2/arch/i386/Kconfig
--- linus-compat_sys_ipc.1/arch/i386/Kconfig	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/i386/Kconfig	2005-03-23 17:13:49.000000000 +1100
@@ -25,6 +25,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config GENERIC_ISA_DMA
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/i386/kernel/sys_i386.c linus-compat_sys_ipc.2/arch/i386/kernel/sys_i386.c
--- linus-compat_sys_ipc.1/arch/i386/kernel/sys_i386.c	2004-07-26 05:20:35.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/i386/kernel/sys_i386.c	2005-03-23 16:32:42.000000000 +1100
@@ -183,13 +183,9 @@
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong __user *) third);
-		}
+		default:
+			return sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruN linus-compat_sys_ipc.1/arch/m32r/Kconfig linus-compat_sys_ipc.2/arch/m32r/Kconfig
--- linus-compat_sys_ipc.1/arch/m32r/Kconfig	2005-01-12 06:07:52.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/m32r/Kconfig	2005-03-23 17:09:57.000000000 +1100
@@ -16,6 +16,9 @@
 	bool
 	default n
 
+config SYS_SHMAT
+	def_bool y
+
 config GENERIC_ISA_DMA
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/m32r/kernel/sys_m32r.c linus-compat_sys_ipc.2/arch/m32r/kernel/sys_m32r.c
--- linus-compat_sys_ipc.1/arch/m32r/kernel/sys_m32r.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/m32r/kernel/sys_m32r.c	2005-03-23 17:09:15.000000000 +1100
@@ -168,17 +168,9 @@
 	case MSGCTL:
 		return sys_msgctl (first, second,
 				   (struct msqid_ds __user *) ptr);
-	case SHMAT: {
-		ulong raddr;
-
-		if (!access_ok(VERIFY_WRITE, (ulong __user *) third,
-				      sizeof(ulong)))
-			return -EFAULT;
-		ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-		if (ret)
-			return ret;
-		return put_user (raddr, (ulong __user *) third);
-		}
+	case SHMAT:
+		return sys_shmat(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT:
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruN linus-compat_sys_ipc.1/arch/m68k/Kconfig linus-compat_sys_ipc.2/arch/m68k/Kconfig
--- linus-compat_sys_ipc.1/arch/m68k/Kconfig	2005-01-16 11:05:29.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/m68k/Kconfig	2005-03-23 17:14:13.000000000 +1100
@@ -14,6 +14,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/m68k/kernel/sys_m68k.c linus-compat_sys_ipc.2/arch/m68k/kernel/sys_m68k.c
--- linus-compat_sys_ipc.1/arch/m68k/kernel/sys_m68k.c	2004-05-12 07:28:08.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/m68k/kernel/sys_m68k.c	2005-03-23 16:35:35.000000000 +1100
@@ -237,16 +237,8 @@
 	if (call <= SHMCTL)
 		switch (call) {
 		case SHMAT:
-			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong *) third);
-			}
-			}
+			return sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case SHMDT:
 			return sys_shmdt ((char *)ptr);
 		case SHMGET:
diff -ruN linus-compat_sys_ipc.1/arch/mips/Kconfig linus-compat_sys_ipc.2/arch/mips/Kconfig
--- linus-compat_sys_ipc.1/arch/mips/Kconfig	2005-03-06 07:08:24.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/mips/Kconfig	2005-03-23 17:14:33.000000000 +1100
@@ -21,6 +21,9 @@
 	depends on MIPS64 = 'n'
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 mainmenu "Linux/MIPS Kernel Configuration"
 
 source "init/Kconfig"
diff -ruN linus-compat_sys_ipc.1/arch/mips/kernel/syscall.c linus-compat_sys_ipc.2/arch/mips/kernel/syscall.c
--- linus-compat_sys_ipc.1/arch/mips/kernel/syscall.c	2005-02-04 04:10:36.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/mips/kernel/syscall.c	2005-03-23 16:38:48.000000000 +1100
@@ -349,13 +349,9 @@
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong *) third);
-		}
+		default:
+			return sys_shmat(first, ptr, second,
+					(unsigned logn __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
@@ -374,22 +370,6 @@
 }
 
 /*
- * Native ABI that is O32 or N64 version
- */
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
-                          int shmflg, unsigned long *addr)
-{
-	unsigned long raddr;
-	int err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (err)
-		return err;
-
-	return put_user(raddr, addr);
-}
-
-/*
  * No implemented yet ...
  */
 asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
diff -ruN linus-compat_sys_ipc.1/arch/parisc/Kconfig linus-compat_sys_ipc.2/arch/parisc/Kconfig
--- linus-compat_sys_ipc.1/arch/parisc/Kconfig	2005-03-08 09:11:45.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/parisc/Kconfig	2005-03-23 16:43:18.000000000 +1100
@@ -22,6 +22,9 @@
 config UID16
 	bool
 
+config SYS_SHMATCALL
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	def_bool y
 
diff -ruN linus-compat_sys_ipc.1/arch/parisc/kernel/sys_parisc.c linus-compat_sys_ipc.2/arch/parisc/kernel/sys_parisc.c
--- linus-compat_sys_ipc.1/arch/parisc/kernel/sys_parisc.c	2005-03-10 04:08:58.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/parisc/kernel/sys_parisc.c	2005-03-23 16:41:53.000000000 +1100
@@ -163,13 +163,7 @@
 
 long sys_shmat_wrapper(int shmid, char __user *shmaddr, int shmflag)
 {
-	unsigned long raddr;
-	int r;
-
-	r = do_shmat(shmid, shmaddr, shmflag, &raddr);
-	if (r < 0)
-		return r;
-	return raddr;
+	return sys_shmatcall(shmid, shmaddr, shmflag);
 }
 
 /* Fucking broken ABI */
diff -ruN linus-compat_sys_ipc.1/arch/ppc/Kconfig linus-compat_sys_ipc.2/arch/ppc/Kconfig
--- linus-compat_sys_ipc.1/arch/ppc/Kconfig	2005-03-19 10:05:48.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/ppc/Kconfig	2005-03-23 16:45:18.000000000 +1100
@@ -11,6 +11,9 @@
 config UID16
 	bool
 
+config SYS_SHMAT
+	def_bool y
+
 config GENERIC_HARDIRQS
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/ppc/kernel/syscalls.c linus-compat_sys_ipc.2/arch/ppc/kernel/syscalls.c
--- linus-compat_sys_ipc.1/arch/ppc/kernel/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/ppc/kernel/syscalls.c	2005-03-23 16:44:39.000000000 +1100
@@ -114,18 +114,10 @@
 	case MSGCTL:
 		ret = sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
 		break;
-	case SHMAT: {
-		ulong raddr;
-
-		if ((ret = access_ok(VERIFY_WRITE, (ulong __user *) third,
-				       sizeof(ulong)) ? 0 : -EFAULT))
-			break;
-		ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-		if (ret)
-			break;
-		ret = put_user (raddr, (ulong __user *) third);
+	case SHMAT:
+		ret = sys_shmat(first, ptr, second,
+				(unsigned long __user *)third);
 		break;
-		}
 	case SHMDT:
 		ret = sys_shmdt ((char __user *)ptr);
 		break;
diff -ruN linus-compat_sys_ipc.1/arch/ppc64/Kconfig linus-compat_sys_ipc.2/arch/ppc64/Kconfig
--- linus-compat_sys_ipc.1/arch/ppc64/Kconfig	2005-03-19 10:05:48.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/ppc64/Kconfig	2005-03-23 17:16:50.000000000 +1100
@@ -13,6 +13,9 @@
 config UID16
 	bool
 
+config SYS_SHMAT
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 
diff -ruN linus-compat_sys_ipc.1/arch/ppc64/kernel/syscalls.c linus-compat_sys_ipc.2/arch/ppc64/kernel/syscalls.c
--- linus-compat_sys_ipc.1/arch/ppc64/kernel/syscalls.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/ppc64/kernel/syscalls.c	2005-03-23 16:46:22.000000000 +1100
@@ -125,15 +125,10 @@
 		break;
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat(first, (char __user *) ptr,
-					(int)second, &raddr);
-			if (ret)
-				break;
-			ret = put_user (raddr, (ulong __user *) third);
+		default:
+			ret = sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 			break;
-		}
 		case 1:	/* iBCS2 emulator entry point */
 			ret = -EINVAL;
 			if (!segment_eq(get_fs(), get_ds()))
diff -ruN linus-compat_sys_ipc.1/arch/s390/Kconfig linus-compat_sys_ipc.2/arch/s390/Kconfig
--- linus-compat_sys_ipc.1/arch/s390/Kconfig	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/s390/Kconfig	2005-03-23 16:49:18.000000000 +1100
@@ -32,6 +32,9 @@
 	default y
 	depends on ARCH_S390X = 'n'
 
+config SYS_SHMAT
+	def_bool y
+
 source "init/Kconfig"
 
 menu "Base setup"
diff -ruN linus-compat_sys_ipc.1/arch/s390/kernel/sys_s390.c linus-compat_sys_ipc.2/arch/s390/kernel/sys_s390.c
--- linus-compat_sys_ipc.1/arch/s390/kernel/sys_s390.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/s390/kernel/sys_s390.c	2005-03-23 16:48:24.000000000 +1100
@@ -187,15 +187,9 @@
                 return sys_msgctl(first, (int)second,
 				   (struct msqid_ds __user *)ptr);
 
-	case SHMAT: {
-		ulong raddr;
-		ret = do_shmat(first, (char __user *)ptr,
-				(int)second, &raddr);
-		if (ret)
-			return ret;
-		return put_user (raddr, (ulong __user *) third);
-		break;
-        }
+	case SHMAT:
+		return sys_shmat(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT:
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruN linus-compat_sys_ipc.1/arch/sh/Kconfig linus-compat_sys_ipc.2/arch/sh/Kconfig
--- linus-compat_sys_ipc.1/arch/sh/Kconfig	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sh/Kconfig	2005-03-23 16:50:48.000000000 +1100
@@ -18,6 +18,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/sh/kernel/sys_sh.c linus-compat_sys_ipc.2/arch/sh/kernel/sys_sh.c
--- linus-compat_sys_ipc.1/arch/sh/kernel/sys_sh.c	2004-03-25 08:30:37.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sh/kernel/sys_sh.c	2005-03-23 16:50:15.000000000 +1100
@@ -225,14 +225,9 @@
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char __user *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong __user *) third);
-			}
+			default:
+				return sys_shmat(first, ptr, second,
+						(unsigned long __user *)third);
 			case 1:	/* iBCS2 emulator entry point */
 				if (!segment_eq(get_fs(), get_ds()))
 					return -EINVAL;
diff -ruN linus-compat_sys_ipc.1/arch/sh64/Kconfig linus-compat_sys_ipc.2/arch/sh64/Kconfig
--- linus-compat_sys_ipc.1/arch/sh64/Kconfig	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sh64/Kconfig	2005-03-23 17:17:01.000000000 +1100
@@ -21,6 +21,12 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
+config SYS_SHMATCALL
+	def_boot y
+
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/sh64/kernel/sys_sh64.c linus-compat_sys_ipc.2/arch/sh64/kernel/sys_sh64.c
--- linus-compat_sys_ipc.1/arch/sh64/kernel/sys_sh64.c	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sh64/kernel/sys_sh64.c	2005-03-23 17:07:07.000000000 +1100
@@ -245,14 +245,9 @@
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char __user *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong __user *) third);
-			}
+			default:
+				return sys_shmat(first, ptr, second,
+						(unsigned long __user *)third);
 			case 1:	/* iBCS2 emulator entry point */
 				if (!segment_eq(get_fs(), get_ds()))
 					return -EINVAL;
@@ -283,18 +278,3 @@
 	up_read(&uts_sem);
 	return err?-EFAULT:0;
 }
-
-/* Copy from mips version */
-asmlinkage long sys_shmatcall(int shmid, char __user *shmaddr,
-		int shmflg)
-{
-	unsigned long raddr;
-	int err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (err)
-		return err;
-
-	err = raddr;
-	return err;
-}
diff -ruN linus-compat_sys_ipc.1/arch/sparc/Kconfig linus-compat_sys_ipc.2/arch/sparc/Kconfig
--- linus-compat_sys_ipc.1/arch/sparc/Kconfig	2005-01-23 18:05:20.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sparc/Kconfig	2005-03-23 17:16:56.000000000 +1100
@@ -13,6 +13,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 config HIGHMEM
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/sparc/kernel/sys_sparc.c linus-compat_sys_ipc.2/arch/sparc/kernel/sys_sparc.c
--- linus-compat_sys_ipc.1/arch/sparc/kernel/sys_sparc.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sparc/kernel/sys_sparc.c	2005-03-23 16:54:22.000000000 +1100
@@ -185,17 +185,10 @@
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			case 0: default: {
-				ulong raddr;
-				err = do_shmat (first, (char __user *) ptr, second, &raddr);
-				if (err)
-					goto out;
-				err = -EFAULT;
-				if (put_user (raddr, (ulong __user *) third))
-					goto out;
-				err = 0;
+			case 0: default:
+				err = sys_shmat(first, ptr, second,
+						(unsigned long __user *)third);
 				goto out;
-				}
 			case 1:	/* iBCS2 emulator entry point */
 				err = -EINVAL;
 				goto out;
diff -ruN linus-compat_sys_ipc.1/arch/sparc64/Kconfig linus-compat_sys_ipc.2/arch/sparc64/Kconfig
--- linus-compat_sys_ipc.1/arch/sparc64/Kconfig	2005-02-19 07:06:16.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sparc64/Kconfig	2005-03-23 16:57:31.000000000 +1100
@@ -16,6 +16,9 @@
 	bool
 	default y
 
+config SYS_SHMAT
+	def_bool y
+
 source "init/Kconfig"
 
 config SYSVIPC_COMPAT
diff -ruN linus-compat_sys_ipc.1/arch/sparc64/kernel/sys_sparc.c linus-compat_sys_ipc.2/arch/sparc64/kernel/sys_sparc.c
--- linus-compat_sys_ipc.1/arch/sparc64/kernel/sys_sparc.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sparc64/kernel/sys_sparc.c	2005-03-23 16:56:46.000000000 +1100
@@ -259,14 +259,9 @@
 	}
 	if (call <= SHMCTL) {
 		switch (call) {
-		case SHMAT: {
-			ulong raddr;
-			err = do_shmat(first, ptr, (int)second, &raddr);
-			if (!err) {
-				if (put_user(raddr,
-					     (ulong __user *) third))
-					err = -EFAULT;
-			}
+		case SHMAT:
+			err = sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 			goto out;
 		}
 		case SHMDT:
diff -ruN linus-compat_sys_ipc.1/arch/v850/Kconfig linus-compat_sys_ipc.2/arch/v850/Kconfig
--- linus-compat_sys_ipc.1/arch/v850/Kconfig	2005-01-05 17:06:07.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/v850/Kconfig	2005-03-23 17:03:41.000000000 +1100
@@ -13,6 +13,8 @@
 config UID16
 	bool
 	default n
+config SYS_SHMAT
+	def_bool n
 config RWSEM_GENERIC_SPINLOCK
 	bool
 	default y
diff -ruN linus-compat_sys_ipc.1/arch/v850/kernel/syscalls.c linus-compat_sys_ipc.2/arch/v850/kernel/syscalls.c
--- linus-compat_sys_ipc.1/arch/v850/kernel/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/v850/kernel/syscalls.c	2005-03-23 17:02:45.000000000 +1100
@@ -101,18 +101,10 @@
 		break;
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-
-			if ((ret = access_ok(VERIFY_WRITE, (ulong*) third,
-					       sizeof(ulong)) ? 0 : -EFAULT))
-				break;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				break;
-			ret = put_user (raddr, (ulong *) third);
+		default:
+			ret = sys_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 			break;
-			}
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				break;
diff -ruN linus-compat_sys_ipc.1/arch/x86_64/Kconfig linus-compat_sys_ipc.2/arch/x86_64/Kconfig
--- linus-compat_sys_ipc.1/arch/x86_64/Kconfig	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/x86_64/Kconfig	2005-03-23 17:06:10.000000000 +1100
@@ -78,6 +78,9 @@
 	bool
 	default y
 
+config SYS_SHMATCALL
+	def_bool y
+
 source "init/Kconfig"
 
 
diff -ruN linus-compat_sys_ipc.1/arch/x86_64/kernel/sys_x86_64.c linus-compat_sys_ipc.2/arch/x86_64/kernel/sys_x86_64.c
--- linus-compat_sys_ipc.1/arch/x86_64/kernel/sys_x86_64.c	2005-03-23 12:17:49.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/x86_64/kernel/sys_x86_64.c	2005-03-23 17:04:33.000000000 +1100
@@ -154,8 +154,7 @@
 
 asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg)
 {
-	unsigned long raddr;
-	return do_shmat(shmid,shmaddr,shmflg,&raddr) ?: (long)raddr;
+	return sys_shmatcall(shmid, shmaddr, shmflg);
 }
 
 asmlinkage long sys_time64(long __user * tloc)
diff -ruN linus-compat_sys_ipc.1/include/linux/syscalls.h linus-compat_sys_ipc.2/include/linux/syscalls.h
--- linus-compat_sys_ipc.1/include/linux/syscalls.h	2005-01-05 17:06:08.000000000 +1100
+++ linus-compat_sys_ipc.2/include/linux/syscalls.h	2005-03-23 16:11:15.000000000 +1100
@@ -458,6 +458,7 @@
 				const struct timespec __user *timeout);
 asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
 				int shmflg, unsigned long __user *addr);
+asmlinkage long sys_shmatcall(int shmid, char __user *shmaddr, int shmflg);
 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
 asmlinkage long sys_shmdt(char __user *shmaddr);
 asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
diff -ruN linus-compat_sys_ipc.1/ipc/shm.c linus-compat_sys_ipc.2/ipc/shm.c
--- linus-compat_sys_ipc.1/ipc/shm.c	2005-03-18 04:08:16.000000000 +1100
+++ linus-compat_sys_ipc.2/ipc/shm.c	2005-03-23 17:18:28.000000000 +1100
@@ -771,6 +771,41 @@
 	return err;
 }
 
+#ifdef CONFIG_SYS_SHMAT
+/*
+ * Attach a shared memory segment.  This version of the system
+ * call returns the attached address through the last parameter.
+ */
+asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg,
+		unsigned long __user *addr)
+{
+	ulong raddr;
+	long ret;
+
+	if (!access_ok(VERIFY_WRITE, addr, sizeof(*addr)))
+		return -EFAULT;
+	ret = do_shmat(shmid, shmaddr, shmflg, &raddr);
+	if (ret == 0)
+		ret = __put_user(raddr, addr);
+	return ret;
+}
+#endif
+
+#ifdef CONFIG_SYS_SHMATCALL
+/*
+ * Attach a shared memory segment.  This version of the system
+ * call returns the attached address as its return value
+ */
+asmlinkage long sys_shmatcall(int shmid, char __user *shmaddr, int shmflg)
+{
+	ulong raddr;
+	long ret;
+
+	ret = do_shmat(shmid, shmaddr, shmflg, &raddr);
+	return ret ? ret : raddr;
+}
+#endif
+
 /*
  * detach and kill segment if marked destroyed.
  * The work is done in shm_close.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] consolidate asm/ipc.h
  2005-03-23  4:01 [PATCH] consolidate asm/ipc.h Stephen Rothwell
  2005-03-23  4:12 ` David S. Miller
  2005-03-23  6:48 ` [PATCH] consolidate shmat usage Stephen Rothwell
@ 2005-03-23  8:06 ` Andi Kleen
  2005-03-24  0:30   ` Stephen Rothwell
  2005-03-23 10:49 ` David Howells
  3 siblings, 1 reply; 21+ messages in thread
From: Andi Kleen @ 2005-03-23  8:06 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-arch

> diff -ruN linus/include/asm-x86_64/ipc.h linus-compat_sys_ipc.1/include/asm-x86_64/ipc.h
> --- linus/include/asm-x86_64/ipc.h	2002-10-17 23:29:20.000000000 +1000
> +++ linus-compat_sys_ipc.1/include/asm-x86_64/ipc.h	1970-01-01 10:00:00.000000000 +1000
> @@ -1,6 +0,0 @@
> -#ifndef __x8664_IPC_H__
> -#define __x8664_IPC_H__
> -
> -/* dummy */
> -
> -#endif

The dummy was originally put in because someone actually included it.
That was in 2.4 days of course.

Can you do a allyesconfig build on x86-64 just to make sure it still builds?

-Andi

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

* Re: [PATCH] consolidate asm/ipc.h
  2005-03-23  4:01 [PATCH] consolidate asm/ipc.h Stephen Rothwell
                   ` (2 preceding siblings ...)
  2005-03-23  8:06 ` [PATCH] consolidate asm/ipc.h Andi Kleen
@ 2005-03-23 10:49 ` David Howells
  3 siblings, 0 replies; 21+ messages in thread
From: David Howells @ 2005-03-23 10:49 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-arch

Stephen Rothwell <sfr@canb.auug.org.au> wrote:

> All the asm*/ipc.h files are basically the same (for things that are used)
> so I have consolidated them all into asm-generic/ipc.h

The FRV bit looks okay to me.

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

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

* Re: [PATCH] consolidate shmat usage
  2005-03-23  6:48 ` [PATCH] consolidate shmat usage Stephen Rothwell
@ 2005-03-23 10:54   ` David Howells
  2005-04-05  8:02     ` Stephen Rothwell
  2005-03-23 14:51   ` Matthew Wilcox
  2005-04-05  8:05   ` [PATCH] consolidate shmat usage Stephen Rothwell
  2 siblings, 1 reply; 21+ messages in thread
From: David Howells @ 2005-03-23 10:54 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-arch

Stephen Rothwell <sfr@canb.auug.org.au> wrote:

> This patch creates sys_shmat and sys_smhatcall and uses them wherever
> possible - this tidies up sys_ipc a bit in most cases.  I have not touched
> um arch.
> 
> I am eventually aiming at consolidating (as much as possible of) sys_ipc
> and doing compat_sys_ipc.
> 
> I suspetc the conditional compilation of sys_shmat{,call} is a bit much
> and have no problem with removing the conditionals.

Looks okay to me; but the #ifdef haters are going to hate your guts and insist
that the sys_shmat and sys_shmatcall functions you added go in their own files
and get conditionally included by the Makefile.

David

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

* Re: [PATCH] consolidate shmat usage
  2005-03-23  6:48 ` [PATCH] consolidate shmat usage Stephen Rothwell
  2005-03-23 10:54   ` David Howells
@ 2005-03-23 14:51   ` Matthew Wilcox
  2005-04-05  8:01     ` Stephen Rothwell
  2005-04-05  8:05   ` [PATCH] consolidate shmat usage Stephen Rothwell
  2 siblings, 1 reply; 21+ messages in thread
From: Matthew Wilcox @ 2005-03-23 14:51 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linux-arch

On Wed, Mar 23, 2005 at 05:48:10PM +1100, Stephen Rothwell wrote:
> This patch creates sys_shmat and sys_smhatcall and uses them wherever possible - this tidies up sys_ipc a bit in most cases.  I have not touched um arch.

The concept is great, but I'd quibble over the details ...

> I am eventually aiming at consolidating (as much as possible of) sys_ipc
> and doing compat_sys_ipc.

Great, but please remember not all architectures have a sys_ipc (looks like
alpha, ia64, parisc and x86_64 according to a fairly recent version of glibc).

> +++ linus-compat_sys_ipc.2/arch/parisc/kernel/sys_parisc.c	2005-03-23 16:41:53.000000000 +1100
> @@ -163,13 +163,7 @@
>  
>  long sys_shmat_wrapper(int shmid, char __user *shmaddr, int shmflag)
>  {
> -	unsigned long raddr;
> -	int r;
> -
> -	r = do_shmat(shmid, shmaddr, shmflag, &raddr);
> -	if (r < 0)
> -		return r;
> -	return raddr;
> +	return sys_shmatcall(shmid, shmaddr, shmflag);
>  }

I don't see the need for a wrapper function in sys_parisc.c -- would
make sense to just call the sys_shmatcall() directly.  I suspect the same
goes for Alpha's osf_shmat() function.

> diff -ruN linus-compat_sys_ipc.1/ipc/shm.c linus-compat_sys_ipc.2/ipc/shm.c
> --- linus-compat_sys_ipc.1/ipc/shm.c	2005-03-18 04:08:16.000000000 +1100
> +++ linus-compat_sys_ipc.2/ipc/shm.c	2005-03-23 17:18:28.000000000 +1100
> +asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg,
> +		unsigned long __user *addr)
> +asmlinkage long sys_shmatcall(int shmid, char __user *shmaddr, int shmflg)
> +{
> +	ulong raddr;
> +	long ret;
> +
> +	ret = do_shmat(shmid, shmaddr, shmflg, &raddr);
> +	return ret ? ret : raddr;
> +}

I dislike the naming here.  The manpage for shmat is the three-argument
version.  The only reason we have the four-argument version is because
of the silly sys_ipc multiplexer.  So I think sys_shmat() should be
the three-argument form and we should rename the existing sys_shmat()
to something like ipc_shmat().  Does it need to be asmlinkage?

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

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

* Re: [PATCH] consolidate asm/ipc.h
  2005-03-23  8:06 ` [PATCH] consolidate asm/ipc.h Andi Kleen
@ 2005-03-24  0:30   ` Stephen Rothwell
  0 siblings, 0 replies; 21+ messages in thread
From: Stephen Rothwell @ 2005-03-24  0:30 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-arch

[-- Attachment #1: Type: text/plain, Size: 1313 bytes --]

On Wed, 23 Mar 2005 09:06:44 +0100 Andi Kleen <ak@suse.de> wrote:
>
> > diff -ruN linus/include/asm-x86_64/ipc.h linus-compat_sys_ipc.1/include/asm-x86_64/ipc.h
> > --- linus/include/asm-x86_64/ipc.h	2002-10-17 23:29:20.000000000 +1000
> > +++ linus-compat_sys_ipc.1/include/asm-x86_64/ipc.h	1970-01-01 10:00:00.000000000 +1000
> > @@ -1,6 +0,0 @@
> > -#ifndef __x8664_IPC_H__
> > -#define __x8664_IPC_H__
> > -
> > -/* dummy */
> > -
> > -#endif
> 
> The dummy was originally put in because someone actually included it.
> That was in 2.4 days of course.

I removed the only places in x86_64 that included it.

> Can you do a allyesconfig build on x86-64 just to make sure it still builds?

As well as ever I suspect :-)

  BUILD   arch/x86_64/boot/bzImage
Root device is (8, 5)
Boot sector 512 bytes.
Setup is 5422 bytes.
System is 11506 kB
System is too big. Try using modules.
make[1]: *** [arch/x86_64/boot/bzImage] Error 1
make: *** [bzImage] Error 2

but the vmlinux has built ok (I am impressed - 214MB vmlinux :-)).

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

P.S. I did notice this warning in particular:

arch/x86_64/lib/bitops.c:18: warning: `find_first_zero_bit' declared inline after being called

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] consolidate shmat usage
  2005-03-23 14:51   ` Matthew Wilcox
@ 2005-04-05  8:01     ` Stephen Rothwell
  2005-04-05 13:03       ` Matthew Wilcox
  0 siblings, 1 reply; 21+ messages in thread
From: Stephen Rothwell @ 2005-04-05  8:01 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-arch

[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]

On Wed, 23 Mar 2005 14:51:32 +0000 Matthew Wilcox <matthew@wil.cx> wrote:
>
> > I am eventually aiming at consolidating (as much as possible of)
> > sys_ipc and doing compat_sys_ipc.
> 
> Great, but please remember not all architectures have a sys_ipc (looks
> like alpha, ia64, parisc and x86_64 according to a fairly recent version
> of glibc).

Yes, I understand that.

> I don't see the need for a wrapper function in sys_parisc.c -- would
> make sense to just call the sys_shmatcall() directly.  I suspect the
> same goes for Alpha's osf_shmat() function.

I agree, I was just doing minimal changes first.

> I dislike the naming here.  The manpage for shmat is the three-argument
> version.  The only reason we have the four-argument version is because
> of the silly sys_ipc multiplexer.  So I think sys_shmat() should be
> the three-argument form and we should rename the existing sys_shmat()
> to something like ipc_shmat().  Does it need to be asmlinkage?

OK, I have changed sys_shmat to sys_shmat4 and sys_shmatcall to sys_shmat.
There are some architectures that use each of these directly as system
calls.

New version in following email.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] consolidate shmat usage
  2005-03-23 10:54   ` David Howells
@ 2005-04-05  8:02     ` Stephen Rothwell
  0 siblings, 0 replies; 21+ messages in thread
From: Stephen Rothwell @ 2005-04-05  8:02 UTC (permalink / raw)
  To: David Howells; +Cc: linux-arch

[-- Attachment #1: Type: text/plain, Size: 581 bytes --]

On Wed, 23 Mar 2005 10:54:28 +0000 David Howells <dhowells@redhat.com> wrote:
>
> Looks okay to me; but the #ifdef haters are going to hate your guts and insist
> that the sys_shmat and sys_shmatcall functions you added go in their own files
> and get conditionally included by the Makefile.

I am one of those, but couldn't be bothered.  I have removed the ifdefs in
the new version so everyone gets both these (very small) syscall stubs.

New version following.
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* [PATCH] consolidate shmat usage
  2005-03-23  6:48 ` [PATCH] consolidate shmat usage Stephen Rothwell
  2005-03-23 10:54   ` David Howells
  2005-03-23 14:51   ` Matthew Wilcox
@ 2005-04-05  8:05   ` Stephen Rothwell
  2 siblings, 0 replies; 21+ messages in thread
From: Stephen Rothwell @ 2005-04-05  8:05 UTC (permalink / raw)
  To: linux-arch

[-- Attachment #1: Type: text/plain, Size: 27380 bytes --]

This patch creates sys_shmat and sys_smhatcall and uses them wherever
possible - this tidies up sys_ipc a bit in most cases.

I am eventually aiming at consolidating (as much as possible of) sys_ipc
and doing compat_sys_ipc.

It has been built on i386, ppc64 and x86_64 with and without CONFIG_SYSVIPC.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruNp linus/arch/alpha/kernel/osf_sys.c linus-compat_sys_ipc.2/arch/alpha/kernel/osf_sys.c
--- linus/arch/alpha/kernel/osf_sys.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/alpha/kernel/osf_sys.c	2005-04-05 15:39:55.000000000 +1000
@@ -457,22 +457,6 @@ osf_getdomainname(char __user *name, int
 	return 0;
 }
 
-asmlinkage long
-osf_shmat(int shmid, void __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	long err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-
-	/*
-	 * This works because all user-level addresses are
-	 * non-negative longs!
-	 */
-	return err ? err : (long)raddr;
-}
-
-
 /*
  * The following stuff should move into a header file should it ever
  * be labeled "officially supported."  Right now, there is just enough
diff -ruNp linus/arch/alpha/kernel/systbls.S linus-compat_sys_ipc.2/arch/alpha/kernel/systbls.S
--- linus/arch/alpha/kernel/systbls.S	2004-09-16 21:51:57.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/alpha/kernel/systbls.S	2005-04-05 15:39:41.000000000 +1000
@@ -227,7 +227,7 @@ sys_call_table:
 	.quad sys_semop
 	.quad osf_utsname
 	.quad sys_lchown
-	.quad osf_shmat
+	.quad sys_shmat
 	.quad sys_shmctl			/* 210 */
 	.quad sys_shmdt
 	.quad sys_shmget
diff -ruNp linus/arch/arm/kernel/calls.S linus-compat_sys_ipc.2/arch/arm/kernel/calls.S
--- linus/arch/arm/kernel/calls.S	2005-03-17 14:08:05.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/arm/kernel/calls.S	2005-04-05 15:25:13.000000000 +1000
@@ -319,7 +319,7 @@ __syscall_start:
 		.long	sys_msgrcv
 		.long	sys_msgget
 		.long	sys_msgctl
-/* 305 */	.long	sys_shmat
+/* 305 */	.long	sys_shmat4
 		.long	sys_shmdt
 		.long	sys_shmget
 		.long	sys_shmctl
diff -ruNp linus/arch/arm/kernel/sys_arm.c linus-compat_sys_ipc.2/arch/arm/kernel/sys_arm.c
--- linus/arch/arm/kernel/sys_arm.c	2005-03-17 14:08:05.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/arm/kernel/sys_arm.c	2005-04-05 15:24:55.000000000 +1000
@@ -212,13 +212,9 @@ asmlinkage int sys_ipc(uint call, int fi
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat(first, (char __user *)ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user(raddr, (ulong __user *)third);
-		}
+		default:
+			return sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1: /* Of course, we don't support iBCS2! */
 			return -EINVAL;
 		}
@@ -234,18 +230,6 @@ asmlinkage int sys_ipc(uint call, int fi
 	}
 }
 
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg,
-			  unsigned long __user *addr)
-{
-	unsigned long ret;
-	long err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &ret);
-	if (err == 0)
-		err = put_user(ret, addr);
-	return err;
-}
-
 /* Fork a new task - this creates a new program thread.
  * This is called indirectly via a small wrapper
  */
diff -ruNp linus/arch/arm26/kernel/sys_arm.c linus-compat_sys_ipc.2/arch/arm26/kernel/sys_arm.c
--- linus/arch/arm26/kernel/sys_arm.c	2005-01-04 17:05:27.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/arm26/kernel/sys_arm.c	2005-04-05 15:25:25.000000000 +1000
@@ -210,13 +210,9 @@ asmlinkage int sys_ipc (uint call, int f
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong *) third);
-		}
+		default:
+			return sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruNp linus/arch/cris/kernel/sys_cris.c linus-compat_sys_ipc.2/arch/cris/kernel/sys_cris.c
--- linus/arch/cris/kernel/sys_cris.c	2004-06-04 07:19:00.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/cris/kernel/sys_cris.c	2005-04-05 15:25:43.000000000 +1000
@@ -154,13 +154,9 @@ asmlinkage int sys_ipc (uint call, int f
 	case MSGCTL:
 		return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
 
-	case SHMAT: {
-                ulong raddr;
-                ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-                if (ret)
-                        return ret;
-                return put_user (raddr, (ulong __user *) third);
-        }
+	case SHMAT:
+		return sys_shmat4(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT: 
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruNp linus/arch/frv/kernel/sys_frv.c linus-compat_sys_ipc.2/arch/frv/kernel/sys_frv.c
--- linus/arch/frv/kernel/sys_frv.c	2005-01-06 12:05:05.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/frv/kernel/sys_frv.c	2005-04-05 15:30:08.000000000 +1000
@@ -188,13 +188,9 @@ asmlinkage long sys_ipc(unsigned long ca
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong __user *) third);
-		}
+		default:
+			return sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruNp linus/arch/h8300/kernel/sys_h8300.c linus-compat_sys_ipc.2/arch/h8300/kernel/sys_h8300.c
--- linus/arch/h8300/kernel/sys_h8300.c	2004-03-16 08:12:17.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/h8300/kernel/sys_h8300.c	2005-04-05 15:26:03.000000000 +1000
@@ -236,16 +236,8 @@ asmlinkage int sys_ipc (uint call, int f
 	if (call <= SHMCTL) 
 		switch (call) {
 		case SHMAT:
-			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong *) third);
-			}
-			}
+			return sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 		case SHMDT: 
 			return sys_shmdt ((char *)ptr);
 		case SHMGET:
diff -ruNp linus/arch/i386/kernel/sys_i386.c linus-compat_sys_ipc.2/arch/i386/kernel/sys_i386.c
--- linus/arch/i386/kernel/sys_i386.c	2004-07-26 05:20:35.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/i386/kernel/sys_i386.c	2005-04-05 16:41:47.000000000 +1000
@@ -131,7 +131,7 @@ asmlinkage int old_select(struct sel_arg
 asmlinkage int sys_ipc (uint call, int first, int second,
 			int third, void __user *ptr, long fifth)
 {
-	int version, ret;
+	int version;
 
 	version = call >> 16; /* hack for backward compatibility */
 	call &= 0xffff;
@@ -183,13 +183,9 @@ asmlinkage int sys_ipc (uint call, int f
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong __user *) third);
-		}
+		default:
+			return sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruNp linus/arch/ia64/kernel/entry.S linus-compat_sys_ipc.2/arch/ia64/kernel/entry.S
--- linus/arch/ia64/kernel/entry.S	2005-02-04 04:10:36.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/ia64/kernel/entry.S	2005-04-05 16:15:31.000000000 +1000
@@ -1417,7 +1417,7 @@ sys_call_table:
 	data8 sys_msgrcv
 	data8 sys_msgctl
 	data8 sys_shmget
-	data8 ia64_shmat
+	data8 sys_shmat
 	data8 sys_shmdt				// 1115
 	data8 sys_shmctl
 	data8 sys_syslog
diff -ruNp linus/arch/ia64/kernel/sys_ia64.c linus-compat_sys_ipc.2/arch/ia64/kernel/sys_ia64.c
--- linus/arch/ia64/kernel/sys_ia64.c	2005-02-04 04:10:36.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/ia64/kernel/sys_ia64.c	2005-04-05 16:15:16.000000000 +1000
@@ -93,20 +93,6 @@ sys_getpagesize (void)
 }
 
 asmlinkage unsigned long
-ia64_shmat (int shmid, void __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	int retval;
-
-	retval = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (retval < 0)
-		return retval;
-
-	force_successful_syscall_return();
-	return raddr;
-}
-
-asmlinkage unsigned long
 ia64_brk (unsigned long brk)
 {
 	unsigned long rlim, retval, newbrk, oldbrk;
diff -ruNp linus/arch/m32r/kernel/sys_m32r.c linus-compat_sys_ipc.2/arch/m32r/kernel/sys_m32r.c
--- linus/arch/m32r/kernel/sys_m32r.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/m32r/kernel/sys_m32r.c	2005-04-05 15:29:47.000000000 +1000
@@ -168,17 +168,9 @@ asmlinkage int sys_ipc(uint call, int fi
 	case MSGCTL:
 		return sys_msgctl (first, second,
 				   (struct msqid_ds __user *) ptr);
-	case SHMAT: {
-		ulong raddr;
-
-		if (!access_ok(VERIFY_WRITE, (ulong __user *) third,
-				      sizeof(ulong)))
-			return -EFAULT;
-		ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-		if (ret)
-			return ret;
-		return put_user (raddr, (ulong __user *) third);
-		}
+	case SHMAT:
+		return sys_shmat4(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT:
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruNp linus/arch/m68k/kernel/sys_m68k.c linus-compat_sys_ipc.2/arch/m68k/kernel/sys_m68k.c
--- linus/arch/m68k/kernel/sys_m68k.c	2004-05-12 07:28:08.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/m68k/kernel/sys_m68k.c	2005-04-05 15:26:44.000000000 +1000
@@ -237,16 +237,8 @@ asmlinkage int sys_ipc (uint call, int f
 	if (call <= SHMCTL)
 		switch (call) {
 		case SHMAT:
-			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong *) third);
-			}
-			}
+			return sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 		case SHMDT:
 			return sys_shmdt ((char *)ptr);
 		case SHMGET:
diff -ruNp linus/arch/mips/kernel/scall64-64.S linus-compat_sys_ipc.2/arch/mips/kernel/scall64-64.S
--- linus/arch/mips/kernel/scall64-64.S	2005-02-04 04:10:36.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/mips/kernel/scall64-64.S	2005-04-05 15:27:04.000000000 +1000
@@ -236,7 +236,7 @@ sys_call_table:
 	PTR	sys_mincore
 	PTR	sys_madvise
 	PTR	sys_shmget
-	PTR	sys_shmat
+	PTR	sys_shmat4
 	PTR	sys_shmctl			/* 5030 */
 	PTR	sys_dup
 	PTR	sys_dup2
diff -ruNp linus/arch/mips/kernel/syscall.c linus-compat_sys_ipc.2/arch/mips/kernel/syscall.c
--- linus/arch/mips/kernel/syscall.c	2005-02-04 04:10:36.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/mips/kernel/syscall.c	2005-04-05 15:27:19.000000000 +1000
@@ -349,13 +349,9 @@ asmlinkage int sys_ipc (uint call, int f
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong *) third);
-		}
+		default:
+			return sys_shmat4(first, ptr, second,
+					(unsigned logn __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
@@ -374,22 +370,6 @@ asmlinkage int sys_ipc (uint call, int f
 }
 
 /*
- * Native ABI that is O32 or N64 version
- */
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
-                          int shmflg, unsigned long *addr)
-{
-	unsigned long raddr;
-	int err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (err)
-		return err;
-
-	return put_user(raddr, addr);
-}
-
-/*
  * No implemented yet ...
  */
 asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
diff -ruNp linus/arch/parisc/kernel/sys_parisc.c linus-compat_sys_ipc.2/arch/parisc/kernel/sys_parisc.c
--- linus/arch/parisc/kernel/sys_parisc.c	2005-03-10 04:08:58.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/parisc/kernel/sys_parisc.c	2005-04-05 15:41:29.000000000 +1000
@@ -161,17 +161,6 @@ asmlinkage unsigned long sys_mmap(unsign
 	}
 }
 
-long sys_shmat_wrapper(int shmid, char __user *shmaddr, int shmflag)
-{
-	unsigned long raddr;
-	int r;
-
-	r = do_shmat(shmid, shmaddr, shmflag, &raddr);
-	if (r < 0)
-		return r;
-	return raddr;
-}
-
 /* Fucking broken ABI */
 
 #ifdef CONFIG_64BIT
diff -ruNp linus/arch/parisc/kernel/syscall_table.S linus-compat_sys_ipc.2/arch/parisc/kernel/syscall_table.S
--- linus/arch/parisc/kernel/syscall_table.S	2005-01-16 07:07:51.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/parisc/kernel/syscall_table.S	2005-04-05 15:43:04.000000000 +1000
@@ -297,7 +297,7 @@
 	ENTRY_DIFF(msgrcv)
 	ENTRY_SAME(msgget)		/* 190 */
 	ENTRY_SAME(msgctl)
-	ENTRY_SAME(shmat_wrapper)
+	ENTRY_SAME(shmat)
 	ENTRY_SAME(shmdt)
 	ENTRY_SAME(shmget)
 	ENTRY_SAME(shmctl)		/* 195 */
diff -ruNp linus/arch/ppc/kernel/syscalls.c linus-compat_sys_ipc.2/arch/ppc/kernel/syscalls.c
--- linus/arch/ppc/kernel/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/ppc/kernel/syscalls.c	2005-04-05 15:27:36.000000000 +1000
@@ -114,18 +114,10 @@ sys_ipc (uint call, int first, int secon
 	case MSGCTL:
 		ret = sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
 		break;
-	case SHMAT: {
-		ulong raddr;
-
-		if ((ret = access_ok(VERIFY_WRITE, (ulong __user *) third,
-				       sizeof(ulong)) ? 0 : -EFAULT))
-			break;
-		ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-		if (ret)
-			break;
-		ret = put_user (raddr, (ulong __user *) third);
+	case SHMAT:
+		ret = sys_shmat4(first, ptr, second,
+				(unsigned long __user *)third);
 		break;
-		}
 	case SHMDT:
 		ret = sys_shmdt ((char __user *)ptr);
 		break;
diff -ruNp linus/arch/ppc64/kernel/syscalls.c linus-compat_sys_ipc.2/arch/ppc64/kernel/syscalls.c
--- linus/arch/ppc64/kernel/syscalls.c	2005-03-29 16:06:36.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/ppc64/kernel/syscalls.c	2005-04-05 15:27:50.000000000 +1000
@@ -125,15 +125,10 @@ sys_ipc (uint call, int first, unsigned 
 		break;
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat(first, (char __user *) ptr,
-					(int)second, &raddr);
-			if (ret)
-				break;
-			ret = put_user (raddr, (ulong __user *) third);
+		default:
+			ret = sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 			break;
-		}
 		case 1:	/* iBCS2 emulator entry point */
 			ret = -EINVAL;
 			if (!segment_eq(get_fs(), get_ds()))
diff -ruNp linus/arch/s390/kernel/sys_s390.c linus-compat_sys_ipc.2/arch/s390/kernel/sys_s390.c
--- linus/arch/s390/kernel/sys_s390.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/s390/kernel/sys_s390.c	2005-04-05 15:28:06.000000000 +1000
@@ -187,15 +187,9 @@ asmlinkage long sys_ipc(uint call, int f
                 return sys_msgctl(first, (int)second,
 				   (struct msqid_ds __user *)ptr);
 
-	case SHMAT: {
-		ulong raddr;
-		ret = do_shmat(first, (char __user *)ptr,
-				(int)second, &raddr);
-		if (ret)
-			return ret;
-		return put_user (raddr, (ulong __user *) third);
-		break;
-        }
+	case SHMAT:
+		return sys_shmat4(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT:
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruNp linus/arch/sh/kernel/sys_sh.c linus-compat_sys_ipc.2/arch/sh/kernel/sys_sh.c
--- linus/arch/sh/kernel/sys_sh.c	2004-03-25 08:30:37.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sh/kernel/sys_sh.c	2005-04-05 15:28:25.000000000 +1000
@@ -225,14 +225,9 @@ asmlinkage int sys_ipc(uint call, int fi
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char __user *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong __user *) third);
-			}
+			default:
+				return sys_shmat4(first, ptr, second,
+						(unsigned long __user *)third);
 			case 1:	/* iBCS2 emulator entry point */
 				if (!segment_eq(get_fs(), get_ds()))
 					return -EINVAL;
diff -ruNp linus/arch/sh64/kernel/sys_sh64.c linus-compat_sys_ipc.2/arch/sh64/kernel/sys_sh64.c
--- linus/arch/sh64/kernel/sys_sh64.c	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sh64/kernel/sys_sh64.c	2005-04-05 15:29:28.000000000 +1000
@@ -245,14 +245,9 @@ asmlinkage int sys_ipc(uint call, int fi
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char __user *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong __user *) third);
-			}
+			default:
+				return sys_shmat4(first, ptr, second,
+						(unsigned long __user *)third);
 			case 1:	/* iBCS2 emulator entry point */
 				if (!segment_eq(get_fs(), get_ds()))
 					return -EINVAL;
@@ -283,18 +278,3 @@ asmlinkage int sys_uname(struct old_utsn
 	up_read(&uts_sem);
 	return err?-EFAULT:0;
 }
-
-/* Copy from mips version */
-asmlinkage long sys_shmatcall(int shmid, char __user *shmaddr,
-		int shmflg)
-{
-	unsigned long raddr;
-	int err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (err)
-		return err;
-
-	err = raddr;
-	return err;
-}
diff -ruNp linus/arch/sh64/kernel/syscalls.S linus-compat_sys_ipc.2/arch/sh64/kernel/syscalls.S
--- linus/arch/sh64/kernel/syscalls.S	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sh64/kernel/syscalls.S	2005-04-05 15:34:10.000000000 +1000
@@ -268,7 +268,7 @@ sys_call_table:
 	.long sys_msgrcv
 	.long sys_msgget
 	.long sys_msgctl
-	.long sys_shmatcall
+	.long sys_shmat
 	.long sys_shmdt			/* 245 */
 	.long sys_shmget
 	.long sys_shmctl
diff -ruNp linus/arch/sparc/kernel/sys_sparc.c linus-compat_sys_ipc.2/arch/sparc/kernel/sys_sparc.c
--- linus/arch/sparc/kernel/sys_sparc.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sparc/kernel/sys_sparc.c	2005-04-05 15:28:39.000000000 +1000
@@ -185,17 +185,10 @@ asmlinkage int sys_ipc (uint call, int f
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			case 0: default: {
-				ulong raddr;
-				err = do_shmat (first, (char __user *) ptr, second, &raddr);
-				if (err)
-					goto out;
-				err = -EFAULT;
-				if (put_user (raddr, (ulong __user *) third))
-					goto out;
-				err = 0;
+			case 0: default:
+				err = sys_shmat4(first, ptr, second,
+						(unsigned long __user *)third);
 				goto out;
-				}
 			case 1:	/* iBCS2 emulator entry point */
 				err = -EINVAL;
 				goto out;
diff -ruNp linus/arch/sparc64/kernel/sys_sparc.c linus-compat_sys_ipc.2/arch/sparc64/kernel/sys_sparc.c
--- linus/arch/sparc64/kernel/sys_sparc.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/sparc64/kernel/sys_sparc.c	2005-04-05 15:28:54.000000000 +1000
@@ -259,14 +259,9 @@ asmlinkage long sys_ipc(unsigned int cal
 	}
 	if (call <= SHMCTL) {
 		switch (call) {
-		case SHMAT: {
-			ulong raddr;
-			err = do_shmat(first, ptr, (int)second, &raddr);
-			if (!err) {
-				if (put_user(raddr,
-					     (ulong __user *) third))
-					err = -EFAULT;
-			}
+		case SHMAT:
+			err = sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 			goto out;
 		}
 		case SHMDT:
diff -ruNp linus/arch/um/include/sysdep-x86_64/syscalls.h linus-compat_sys_ipc.2/arch/um/include/sysdep-x86_64/syscalls.h
--- linus/arch/um/include/sysdep-x86_64/syscalls.h	2005-04-01 05:09:16.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/um/include/sysdep-x86_64/syscalls.h	2005-04-05 15:44:11.000000000 +1000
@@ -26,7 +26,6 @@ extern syscall_handler_t *ia32_sys_call_
 extern long old_mmap(unsigned long addr, unsigned long len,
 		     unsigned long prot, unsigned long flags,
 		     unsigned long fd, unsigned long pgoff);
-extern syscall_handler_t wrap_sys_shmat;
 extern syscall_handler_t sys_modify_ldt;
 extern syscall_handler_t sys_arch_prctl;
 
@@ -36,7 +35,7 @@ extern syscall_handler_t sys_arch_prctl;
 	[ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
 	[ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
 	[ __NR_shmget ] = (syscall_handler_t *) sys_shmget, \
-	[ __NR_shmat ] = (syscall_handler_t *) wrap_sys_shmat, \
+	[ __NR_shmat ] = (syscall_handler_t *) sys_shmat, \
 	[ __NR_shmctl ] = (syscall_handler_t *) sys_shmctl, \
 	[ __NR_semop ] = (syscall_handler_t *) sys_semop, \
 	[ __NR_semget ] = (syscall_handler_t *) sys_semget, \
diff -ruNp linus/arch/um/sys-i386/syscalls.c linus-compat_sys_ipc.2/arch/um/sys-i386/syscalls.c
--- linus/arch/um/sys-i386/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/um/sys-i386/syscalls.c	2005-04-05 16:24:10.000000000 +1000
@@ -143,13 +143,9 @@ long sys_ipc (uint call, int first, int 
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong *) third);
-		}
+		default:
+			return sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruNp linus/arch/um/sys-x86_64/syscalls.c linus-compat_sys_ipc.2/arch/um/sys-x86_64/syscalls.c
--- linus/arch/um/sys-x86_64/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/um/sys-x86_64/syscalls.c	2005-04-05 15:45:51.000000000 +1000
@@ -14,13 +14,6 @@
 #include "asm/prctl.h" /* XXX This should get the constants from libc */
 #include "choose-mode.h"
 
-asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-
-	return do_shmat(shmid, shmaddr, shmflg, &raddr) ?: (long) raddr;
-}
-
 #ifdef CONFIG_MODE_TT
 extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
 
diff -ruNp linus/arch/v850/kernel/syscalls.c linus-compat_sys_ipc.2/arch/v850/kernel/syscalls.c
--- linus/arch/v850/kernel/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.2/arch/v850/kernel/syscalls.c	2005-04-05 15:29:12.000000000 +1000
@@ -101,18 +101,10 @@ sys_ipc (uint call, int first, int secon
 		break;
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-
-			if ((ret = access_ok(VERIFY_WRITE, (ulong*) third,
-					       sizeof(ulong)) ? 0 : -EFAULT))
-				break;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				break;
-			ret = put_user (raddr, (ulong *) third);
+		default:
+			ret = sys_shmat4(first, ptr, second,
+					(unsigned long __user *)third);
 			break;
-			}
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				break;
diff -ruNp linus/arch/x86_64/kernel/sys_x86_64.c linus-compat_sys_ipc.2/arch/x86_64/kernel/sys_x86_64.c
--- linus/arch/x86_64/kernel/sys_x86_64.c	2005-04-01 05:09:16.000000000 +1000
+++ linus-compat_sys_ipc.2/arch/x86_64/kernel/sys_x86_64.c	2005-04-05 15:46:08.000000000 +1000
@@ -152,12 +152,6 @@ asmlinkage long sys_uname(struct new_uts
 	return err ? -EFAULT : 0;
 }
 
-asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	return do_shmat(shmid,shmaddr,shmflg,&raddr) ?: (long)raddr;
-}
-
 asmlinkage long sys_time64(long __user * tloc)
 {
 	struct timeval now; 
diff -ruNp linus/include/asm-x86_64/unistd.h linus-compat_sys_ipc.2/include/asm-x86_64/unistd.h
--- linus/include/asm-x86_64/unistd.h	2005-04-01 05:09:17.000000000 +1000
+++ linus-compat_sys_ipc.2/include/asm-x86_64/unistd.h	2005-04-05 15:46:35.000000000 +1000
@@ -76,7 +76,7 @@ __SYSCALL(__NR_madvise, sys_madvise)
 #define __NR_shmget                             29
 __SYSCALL(__NR_shmget, sys_shmget)
 #define __NR_shmat                              30
-__SYSCALL(__NR_shmat, wrap_sys_shmat)
+__SYSCALL(__NR_shmat, sys_shmat)
 #define __NR_shmctl                             31
 __SYSCALL(__NR_shmctl, sys_shmctl)
 
diff -ruNp linus/include/linux/syscalls.h linus-compat_sys_ipc.2/include/linux/syscalls.h
--- linus/include/linux/syscalls.h	2005-01-05 17:06:08.000000000 +1100
+++ linus-compat_sys_ipc.2/include/linux/syscalls.h	2005-04-05 15:34:33.000000000 +1000
@@ -456,8 +456,9 @@ asmlinkage long sys_semctl(int semid, in
 asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
 				unsigned nsops,
 				const struct timespec __user *timeout);
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
+asmlinkage long sys_shmat4(int shmid, char __user *shmaddr,
 				int shmflg, unsigned long __user *addr);
+asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
 asmlinkage long sys_shmdt(char __user *shmaddr);
 asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
diff -ruNp linus/ipc/shm.c linus-compat_sys_ipc.2/ipc/shm.c
--- linus/ipc/shm.c	2005-03-18 04:08:16.000000000 +1100
+++ linus-compat_sys_ipc.2/ipc/shm.c	2005-04-05 16:14:58.000000000 +1000
@@ -28,6 +28,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/audit.h>
+#include <linux/ptrace.h>	/* for force_successful_syscall_return() */
 #include <asm/uaccess.h>
 
 #include "util.h"
@@ -772,6 +773,40 @@ out:
 }
 
 /*
+ * Attach a shared memory segment.  This version of the system
+ * call returns the attached address through the last parameter.
+ */
+asmlinkage long sys_shmat4(int shmid, char __user *shmaddr, int shmflg,
+		unsigned long __user *addr)
+{
+	ulong raddr;
+	long ret;
+
+	if (!access_ok(VERIFY_WRITE, addr, sizeof(*addr)))
+		return -EFAULT;
+	ret = do_shmat(shmid, shmaddr, shmflg, &raddr);
+	if (ret == 0)
+		ret = __put_user(raddr, addr);
+	return ret;
+}
+
+/*
+ * Attach a shared memory segment.  This version of the system
+ * call returns the attached address as its return value
+ */
+asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg)
+{
+	ulong raddr;
+	long ret;
+
+	ret = do_shmat(shmid, shmaddr, shmflg, &raddr);
+	if (ret < 0)
+		return ret;
+	force_successful_syscall_return();
+	return raddr;
+}
+
+/*
  * detach and kill segment if marked destroyed.
  * The work is done in shm_close.
  */
diff -ruNp linus/kernel/sys_ni.c linus-compat_sys_ipc.2/kernel/sys_ni.c
--- linus/kernel/sys_ni.c	2005-03-29 16:06:38.000000000 +1000
+++ linus-compat_sys_ipc.2/kernel/sys_ni.c	2005-04-05 16:34:41.000000000 +1000
@@ -76,6 +76,8 @@ cond_syscall(sys_request_key);
 cond_syscall(sys_keyctl);
 cond_syscall(compat_sys_keyctl);
 cond_syscall(compat_sys_socketcall);
+cond_syscall(sys_shmat);
+cond_syscall(sys_shmat4);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] consolidate shmat usage
  2005-04-05  8:01     ` Stephen Rothwell
@ 2005-04-05 13:03       ` Matthew Wilcox
  2005-04-05 20:00         ` Ralf Baechle
                           ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Matthew Wilcox @ 2005-04-05 13:03 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Matthew Wilcox, linux-arch, Russell King, ralf

On Tue, Apr 05, 2005 at 06:01:32PM +1000, Stephen Rothwell wrote:
> On Wed, 23 Mar 2005 14:51:32 +0000 Matthew Wilcox <matthew@wil.cx> wrote:
> > I dislike the naming here.  The manpage for shmat is the three-argument
> > version.  The only reason we have the four-argument version is because
> > of the silly sys_ipc multiplexer.  So I think sys_shmat() should be
> > the three-argument form and we should rename the existing sys_shmat()
> > to something like ipc_shmat().  Does it need to be asmlinkage?
> 
> OK, I have changed sys_shmat to sys_shmat4 and sys_shmatcall to sys_shmat.
> There are some architectures that use each of these directly as system
> calls.

Umm.  I think you've just discovered a bug in ARM and MIPS.  I don't see
any code in glibc for handling the 4-argument version of sys_shmat.
Russell, Ralf, could you comment?

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

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

* Re: [PATCH] consolidate shmat usage
  2005-04-05 13:03       ` Matthew Wilcox
@ 2005-04-05 20:00         ` Ralf Baechle
  2005-04-05 20:16         ` Russell King
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Ralf Baechle @ 2005-04-05 20:00 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Stephen Rothwell, linux-arch, Russell King

On Tue, Apr 05, 2005 at 02:03:12PM +0100, Matthew Wilcox wrote:

> On Tue, Apr 05, 2005 at 06:01:32PM +1000, Stephen Rothwell wrote:
> > On Wed, 23 Mar 2005 14:51:32 +0000 Matthew Wilcox <matthew@wil.cx> wrote:
> > > I dislike the naming here.  The manpage for shmat is the three-argument
> > > version.  The only reason we have the four-argument version is because
> > > of the silly sys_ipc multiplexer.  So I think sys_shmat() should be
> > > the three-argument form and we should rename the existing sys_shmat()
> > > to something like ipc_shmat().  Does it need to be asmlinkage?
> > 
> > OK, I have changed sys_shmat to sys_shmat4 and sys_shmatcall to sys_shmat.
> > There are some architectures that use each of these directly as system
> > calls.
> 
> Umm.  I think you've just discovered a bug in ARM and MIPS.  I don't see
> any code in glibc for handling the 4-argument version of sys_shmat.
> Russell, Ralf, could you comment?

On MIPS it affects only 64-bit systems running native code which few people
do.  Fixing it as I'm writing this,

  Ralf

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

* Re: [PATCH] consolidate shmat usage
  2005-04-05 13:03       ` Matthew Wilcox
  2005-04-05 20:00         ` Ralf Baechle
@ 2005-04-05 20:16         ` Russell King
  2005-04-05 20:20           ` Ralf Baechle
  2005-04-06 15:05         ` Stephen Rothwell
  2005-04-27  6:27         ` [PATCH] consolidate sys_shmat Stephen Rothwell
  3 siblings, 1 reply; 21+ messages in thread
From: Russell King @ 2005-04-05 20:16 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: Stephen Rothwell, linux-arch, ralf

On Tue, Apr 05, 2005 at 02:03:12PM +0100, Matthew Wilcox wrote:
> On Tue, Apr 05, 2005 at 06:01:32PM +1000, Stephen Rothwell wrote:
> > On Wed, 23 Mar 2005 14:51:32 +0000 Matthew Wilcox <matthew@wil.cx> wrote:
> > > I dislike the naming here.  The manpage for shmat is the three-argument
> > > version.  The only reason we have the four-argument version is because
> > > of the silly sys_ipc multiplexer.  So I think sys_shmat() should be
> > > the three-argument form and we should rename the existing sys_shmat()
> > > to something like ipc_shmat().  Does it need to be asmlinkage?
> > 
> > OK, I have changed sys_shmat to sys_shmat4 and sys_shmatcall to sys_shmat.
> > There are some architectures that use each of these directly as system
> > calls.
> 
> Umm.  I think you've just discovered a bug in ARM and MIPS.  I don't see
> any code in glibc for handling the 4-argument version of sys_shmat.
> Russell, Ralf, could you comment?

glibc probably doesn't use the new sys_shmat() syscall yet - it's a
relatively recent addition, so I think we have the opportunity to fix
it if needs be.

However, I don't know the glibc sources well enough to comment on the
state of play there.  And what's more, I don't know any active ARM
glibc folk to ask about it.  Sorry.

(For the record, I've never been interested in glibc myself, and I've
always hoped that there would be someone else to look after that side
of things.  However, it appears that this stance hasn't really resulted
in a long lasting ARM glibc effort.  Maybe I'm wrong, but I don't see
_any_ signs out there which indicate otherwise.)

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

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

* Re: [PATCH] consolidate shmat usage
  2005-04-05 20:16         ` Russell King
@ 2005-04-05 20:20           ` Ralf Baechle
  0 siblings, 0 replies; 21+ messages in thread
From: Ralf Baechle @ 2005-04-05 20:20 UTC (permalink / raw)
  To: Matthew Wilcox, Stephen Rothwell, linux-arch

On Tue, Apr 05, 2005 at 09:16:19PM +0100, Russell King wrote:

> glibc probably doesn't use the new sys_shmat() syscall yet - it's a
> relatively recent addition, so I think we have the opportunity to fix
> it if needs be.
> 
> However, I don't know the glibc sources well enough to comment on the
> state of play there.  And what's more, I don't know any active ARM
> glibc folk to ask about it.  Sorry.
> 
> (For the record, I've never been interested in glibc myself, and I've
> always hoped that there would be someone else to look after that side
> of things.  However, it appears that this stance hasn't really resulted
> in a long lasting ARM glibc effort.  Maybe I'm wrong, but I don't see
> _any_ signs out there which indicate otherwise.)

Since you already kept me on the cc list ;-) ARM libc seems to use the
good old wrapper syscall.

  Ralf

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

* Re: [PATCH] consolidate shmat usage
  2005-04-05 13:03       ` Matthew Wilcox
  2005-04-05 20:00         ` Ralf Baechle
  2005-04-05 20:16         ` Russell King
@ 2005-04-06 15:05         ` Stephen Rothwell
  2005-04-07  5:14           ` Stephen Rothwell
  2005-04-11 20:29           ` Russell King
  2005-04-27  6:27         ` [PATCH] consolidate sys_shmat Stephen Rothwell
  3 siblings, 2 replies; 21+ messages in thread
From: Stephen Rothwell @ 2005-04-06 15:05 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-arch, rmk, ralf

[-- Attachment #1: Type: text/plain, Size: 27214 bytes --]

On Tue, 5 Apr 2005 14:03:12 +0100 Matthew Wilcox <matthew@wil.cx> wrote:
>
> Umm.  I think you've just discovered a bug in ARM and MIPS.  I don't see
> any code in glibc for handling the 4-argument version of sys_shmat.
> Russell, Ralf, could you comment?

OK, assuming that using the 4 argument version of sys_shmat as a system
call, here is another version of the patch (not tested) for comment.

we now have sys_shmat, ipc_shmat and do_shmat :-)
-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruNp linus/arch/alpha/kernel/osf_sys.c linus-compat_sys_ipc.3/arch/alpha/kernel/osf_sys.c
--- linus/arch/alpha/kernel/osf_sys.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/alpha/kernel/osf_sys.c	2005-04-05 15:39:55.000000000 +1000
@@ -457,22 +457,6 @@ osf_getdomainname(char __user *name, int
 	return 0;
 }
 
-asmlinkage long
-osf_shmat(int shmid, void __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	long err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-
-	/*
-	 * This works because all user-level addresses are
-	 * non-negative longs!
-	 */
-	return err ? err : (long)raddr;
-}
-
-
 /*
  * The following stuff should move into a header file should it ever
  * be labeled "officially supported."  Right now, there is just enough
diff -ruNp linus/arch/alpha/kernel/systbls.S linus-compat_sys_ipc.3/arch/alpha/kernel/systbls.S
--- linus/arch/alpha/kernel/systbls.S	2004-09-16 21:51:57.000000000 +1000
+++ linus-compat_sys_ipc.3/arch/alpha/kernel/systbls.S	2005-04-05 15:39:41.000000000 +1000
@@ -227,7 +227,7 @@ sys_call_table:
 	.quad sys_semop
 	.quad osf_utsname
 	.quad sys_lchown
-	.quad osf_shmat
+	.quad sys_shmat
 	.quad sys_shmctl			/* 210 */
 	.quad sys_shmdt
 	.quad sys_shmget
diff -ruNp linus/arch/arm/kernel/sys_arm.c linus-compat_sys_ipc.3/arch/arm/kernel/sys_arm.c
--- linus/arch/arm/kernel/sys_arm.c	2005-03-17 14:08:05.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/arm/kernel/sys_arm.c	2005-04-06 13:35:51.000000000 +1000
@@ -212,13 +212,9 @@ asmlinkage int sys_ipc(uint call, int fi
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat(first, (char __user *)ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user(raddr, (ulong __user *)third);
-		}
+		default:
+			return ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1: /* Of course, we don't support iBCS2! */
 			return -EINVAL;
 		}
@@ -234,18 +230,6 @@ asmlinkage int sys_ipc(uint call, int fi
 	}
 }
 
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg,
-			  unsigned long __user *addr)
-{
-	unsigned long ret;
-	long err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &ret);
-	if (err == 0)
-		err = put_user(ret, addr);
-	return err;
-}
-
 /* Fork a new task - this creates a new program thread.
  * This is called indirectly via a small wrapper
  */
diff -ruNp linus/arch/arm26/kernel/sys_arm.c linus-compat_sys_ipc.3/arch/arm26/kernel/sys_arm.c
--- linus/arch/arm26/kernel/sys_arm.c	2005-01-04 17:05:27.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/arm26/kernel/sys_arm.c	2005-04-06 13:36:36.000000000 +1000
@@ -210,13 +210,9 @@ asmlinkage int sys_ipc (uint call, int f
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong *) third);
-		}
+		default:
+			return ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruNp linus/arch/cris/kernel/sys_cris.c linus-compat_sys_ipc.3/arch/cris/kernel/sys_cris.c
--- linus/arch/cris/kernel/sys_cris.c	2004-06-04 07:19:00.000000000 +1000
+++ linus-compat_sys_ipc.3/arch/cris/kernel/sys_cris.c	2005-04-06 13:36:47.000000000 +1000
@@ -154,13 +154,9 @@ asmlinkage int sys_ipc (uint call, int f
 	case MSGCTL:
 		return sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
 
-	case SHMAT: {
-                ulong raddr;
-                ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-                if (ret)
-                        return ret;
-                return put_user (raddr, (ulong __user *) third);
-        }
+	case SHMAT:
+		return ipc_shmat(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT: 
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruNp linus/arch/frv/kernel/sys_frv.c linus-compat_sys_ipc.3/arch/frv/kernel/sys_frv.c
--- linus/arch/frv/kernel/sys_frv.c	2005-01-06 12:05:05.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/frv/kernel/sys_frv.c	2005-04-06 13:38:50.000000000 +1000
@@ -188,13 +188,9 @@ asmlinkage long sys_ipc(unsigned long ca
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong __user *) third);
-		}
+		default:
+			return ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruNp linus/arch/h8300/kernel/sys_h8300.c linus-compat_sys_ipc.3/arch/h8300/kernel/sys_h8300.c
--- linus/arch/h8300/kernel/sys_h8300.c	2004-03-16 08:12:17.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/h8300/kernel/sys_h8300.c	2005-04-06 13:36:56.000000000 +1000
@@ -236,16 +236,8 @@ asmlinkage int sys_ipc (uint call, int f
 	if (call <= SHMCTL) 
 		switch (call) {
 		case SHMAT:
-			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong *) third);
-			}
-			}
+			return ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case SHMDT: 
 			return sys_shmdt ((char *)ptr);
 		case SHMGET:
diff -ruNp linus/arch/i386/kernel/sys_i386.c linus-compat_sys_ipc.3/arch/i386/kernel/sys_i386.c
--- linus/arch/i386/kernel/sys_i386.c	2004-07-26 05:20:35.000000000 +1000
+++ linus-compat_sys_ipc.3/arch/i386/kernel/sys_i386.c	2005-04-06 13:37:06.000000000 +1000
@@ -131,7 +131,7 @@ asmlinkage int old_select(struct sel_arg
 asmlinkage int sys_ipc (uint call, int first, int second,
 			int third, void __user *ptr, long fifth)
 {
-	int version, ret;
+	int version;
 
 	version = call >> 16; /* hack for backward compatibility */
 	call &= 0xffff;
@@ -183,13 +183,9 @@ asmlinkage int sys_ipc (uint call, int f
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong __user *) third);
-		}
+		default:
+			return ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruNp linus/arch/ia64/kernel/entry.S linus-compat_sys_ipc.3/arch/ia64/kernel/entry.S
--- linus/arch/ia64/kernel/entry.S	2005-02-04 04:10:36.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/ia64/kernel/entry.S	2005-04-05 16:15:31.000000000 +1000
@@ -1417,7 +1417,7 @@ sys_call_table:
 	data8 sys_msgrcv
 	data8 sys_msgctl
 	data8 sys_shmget
-	data8 ia64_shmat
+	data8 sys_shmat
 	data8 sys_shmdt				// 1115
 	data8 sys_shmctl
 	data8 sys_syslog
diff -ruNp linus/arch/ia64/kernel/sys_ia64.c linus-compat_sys_ipc.3/arch/ia64/kernel/sys_ia64.c
--- linus/arch/ia64/kernel/sys_ia64.c	2005-02-04 04:10:36.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/ia64/kernel/sys_ia64.c	2005-04-05 16:15:16.000000000 +1000
@@ -93,20 +93,6 @@ sys_getpagesize (void)
 }
 
 asmlinkage unsigned long
-ia64_shmat (int shmid, void __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	int retval;
-
-	retval = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (retval < 0)
-		return retval;
-
-	force_successful_syscall_return();
-	return raddr;
-}
-
-asmlinkage unsigned long
 ia64_brk (unsigned long brk)
 {
 	unsigned long rlim, retval, newbrk, oldbrk;
diff -ruNp linus/arch/m32r/kernel/sys_m32r.c linus-compat_sys_ipc.3/arch/m32r/kernel/sys_m32r.c
--- linus/arch/m32r/kernel/sys_m32r.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/m32r/kernel/sys_m32r.c	2005-04-06 13:38:46.000000000 +1000
@@ -168,17 +168,9 @@ asmlinkage int sys_ipc(uint call, int fi
 	case MSGCTL:
 		return sys_msgctl (first, second,
 				   (struct msqid_ds __user *) ptr);
-	case SHMAT: {
-		ulong raddr;
-
-		if (!access_ok(VERIFY_WRITE, (ulong __user *) third,
-				      sizeof(ulong)))
-			return -EFAULT;
-		ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-		if (ret)
-			return ret;
-		return put_user (raddr, (ulong __user *) third);
-		}
+	case SHMAT:
+		return ipc_shmat(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT:
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruNp linus/arch/m68k/kernel/sys_m68k.c linus-compat_sys_ipc.3/arch/m68k/kernel/sys_m68k.c
--- linus/arch/m68k/kernel/sys_m68k.c	2004-05-12 07:28:08.000000000 +1000
+++ linus-compat_sys_ipc.3/arch/m68k/kernel/sys_m68k.c	2005-04-06 13:37:11.000000000 +1000
@@ -237,16 +237,8 @@ asmlinkage int sys_ipc (uint call, int f
 	if (call <= SHMCTL)
 		switch (call) {
 		case SHMAT:
-			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong *) third);
-			}
-			}
+			return ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case SHMDT:
 			return sys_shmdt ((char *)ptr);
 		case SHMGET:
diff -ruNp linus/arch/mips/kernel/syscall.c linus-compat_sys_ipc.3/arch/mips/kernel/syscall.c
--- linus/arch/mips/kernel/syscall.c	2005-02-04 04:10:36.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/mips/kernel/syscall.c	2005-04-06 13:37:38.000000000 +1000
@@ -349,13 +349,9 @@ asmlinkage int sys_ipc (uint call, int f
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong *) third);
-		}
+		default:
+			return ipc_shmat(first, ptr, second,
+					(unsigned logn __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
@@ -374,22 +370,6 @@ asmlinkage int sys_ipc (uint call, int f
 }
 
 /*
- * Native ABI that is O32 or N64 version
- */
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
-                          int shmflg, unsigned long *addr)
-{
-	unsigned long raddr;
-	int err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (err)
-		return err;
-
-	return put_user(raddr, addr);
-}
-
-/*
  * No implemented yet ...
  */
 asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
diff -ruNp linus/arch/parisc/kernel/sys_parisc.c linus-compat_sys_ipc.3/arch/parisc/kernel/sys_parisc.c
--- linus/arch/parisc/kernel/sys_parisc.c	2005-03-10 04:08:58.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/parisc/kernel/sys_parisc.c	2005-04-05 15:41:29.000000000 +1000
@@ -161,17 +161,6 @@ asmlinkage unsigned long sys_mmap(unsign
 	}
 }
 
-long sys_shmat_wrapper(int shmid, char __user *shmaddr, int shmflag)
-{
-	unsigned long raddr;
-	int r;
-
-	r = do_shmat(shmid, shmaddr, shmflag, &raddr);
-	if (r < 0)
-		return r;
-	return raddr;
-}
-
 /* Fucking broken ABI */
 
 #ifdef CONFIG_64BIT
diff -ruNp linus/arch/parisc/kernel/syscall_table.S linus-compat_sys_ipc.3/arch/parisc/kernel/syscall_table.S
--- linus/arch/parisc/kernel/syscall_table.S	2005-01-16 07:07:51.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/parisc/kernel/syscall_table.S	2005-04-05 15:43:04.000000000 +1000
@@ -297,7 +297,7 @@
 	ENTRY_DIFF(msgrcv)
 	ENTRY_SAME(msgget)		/* 190 */
 	ENTRY_SAME(msgctl)
-	ENTRY_SAME(shmat_wrapper)
+	ENTRY_SAME(shmat)
 	ENTRY_SAME(shmdt)
 	ENTRY_SAME(shmget)
 	ENTRY_SAME(shmctl)		/* 195 */
diff -ruNp linus/arch/ppc/kernel/syscalls.c linus-compat_sys_ipc.3/arch/ppc/kernel/syscalls.c
--- linus/arch/ppc/kernel/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/ppc/kernel/syscalls.c	2005-04-06 13:37:44.000000000 +1000
@@ -114,18 +114,10 @@ sys_ipc (uint call, int first, int secon
 	case MSGCTL:
 		ret = sys_msgctl (first, second, (struct msqid_ds __user *) ptr);
 		break;
-	case SHMAT: {
-		ulong raddr;
-
-		if ((ret = access_ok(VERIFY_WRITE, (ulong __user *) third,
-				       sizeof(ulong)) ? 0 : -EFAULT))
-			break;
-		ret = do_shmat (first, (char __user *) ptr, second, &raddr);
-		if (ret)
-			break;
-		ret = put_user (raddr, (ulong __user *) third);
+	case SHMAT:
+		ret = ipc_shmat(first, ptr, second,
+				(unsigned long __user *)third);
 		break;
-		}
 	case SHMDT:
 		ret = sys_shmdt ((char __user *)ptr);
 		break;
diff -ruNp linus/arch/ppc64/kernel/syscalls.c linus-compat_sys_ipc.3/arch/ppc64/kernel/syscalls.c
--- linus/arch/ppc64/kernel/syscalls.c	2005-03-29 16:06:36.000000000 +1000
+++ linus-compat_sys_ipc.3/arch/ppc64/kernel/syscalls.c	2005-04-06 13:37:50.000000000 +1000
@@ -125,15 +125,10 @@ sys_ipc (uint call, int first, unsigned 
 		break;
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat(first, (char __user *) ptr,
-					(int)second, &raddr);
-			if (ret)
-				break;
-			ret = put_user (raddr, (ulong __user *) third);
+		default:
+			ret = ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 			break;
-		}
 		case 1:	/* iBCS2 emulator entry point */
 			ret = -EINVAL;
 			if (!segment_eq(get_fs(), get_ds()))
diff -ruNp linus/arch/s390/kernel/sys_s390.c linus-compat_sys_ipc.3/arch/s390/kernel/sys_s390.c
--- linus/arch/s390/kernel/sys_s390.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/s390/kernel/sys_s390.c	2005-04-06 13:37:55.000000000 +1000
@@ -187,15 +187,9 @@ asmlinkage long sys_ipc(uint call, int f
                 return sys_msgctl(first, (int)second,
 				   (struct msqid_ds __user *)ptr);
 
-	case SHMAT: {
-		ulong raddr;
-		ret = do_shmat(first, (char __user *)ptr,
-				(int)second, &raddr);
-		if (ret)
-			return ret;
-		return put_user (raddr, (ulong __user *) third);
-		break;
-        }
+	case SHMAT:
+		return ipc_shmat(first, ptr, second,
+				(unsigned long __user *)third);
 	case SHMDT:
 		return sys_shmdt ((char __user *)ptr);
 	case SHMGET:
diff -ruNp linus/arch/sh/kernel/sys_sh.c linus-compat_sys_ipc.3/arch/sh/kernel/sys_sh.c
--- linus/arch/sh/kernel/sys_sh.c	2004-03-25 08:30:37.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/sh/kernel/sys_sh.c	2005-04-06 13:38:03.000000000 +1000
@@ -225,14 +225,9 @@ asmlinkage int sys_ipc(uint call, int fi
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char __user *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong __user *) third);
-			}
+			default:
+				return ipc_shmat(first, ptr, second,
+						(unsigned long __user *)third);
 			case 1:	/* iBCS2 emulator entry point */
 				if (!segment_eq(get_fs(), get_ds()))
 					return -EINVAL;
diff -ruNp linus/arch/sh64/kernel/sys_sh64.c linus-compat_sys_ipc.3/arch/sh64/kernel/sys_sh64.c
--- linus/arch/sh64/kernel/sys_sh64.c	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/sh64/kernel/sys_sh64.c	2005-04-06 13:38:41.000000000 +1000
@@ -245,14 +245,9 @@ asmlinkage int sys_ipc(uint call, int fi
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			default: {
-				ulong raddr;
-				ret = do_shmat (first, (char __user *) ptr,
-						 second, &raddr);
-				if (ret)
-					return ret;
-				return put_user (raddr, (ulong __user *) third);
-			}
+			default:
+				return ipc_shmat(first, ptr, second,
+						(unsigned long __user *)third);
 			case 1:	/* iBCS2 emulator entry point */
 				if (!segment_eq(get_fs(), get_ds()))
 					return -EINVAL;
@@ -283,18 +278,3 @@ asmlinkage int sys_uname(struct old_utsn
 	up_read(&uts_sem);
 	return err?-EFAULT:0;
 }
-
-/* Copy from mips version */
-asmlinkage long sys_shmatcall(int shmid, char __user *shmaddr,
-		int shmflg)
-{
-	unsigned long raddr;
-	int err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (err)
-		return err;
-
-	err = raddr;
-	return err;
-}
diff -ruNp linus/arch/sh64/kernel/syscalls.S linus-compat_sys_ipc.3/arch/sh64/kernel/syscalls.S
--- linus/arch/sh64/kernel/syscalls.S	2005-03-09 06:08:28.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/sh64/kernel/syscalls.S	2005-04-05 15:34:10.000000000 +1000
@@ -268,7 +268,7 @@ sys_call_table:
 	.long sys_msgrcv
 	.long sys_msgget
 	.long sys_msgctl
-	.long sys_shmatcall
+	.long sys_shmat
 	.long sys_shmdt			/* 245 */
 	.long sys_shmget
 	.long sys_shmctl
diff -ruNp linus/arch/sparc/kernel/sys_sparc.c linus-compat_sys_ipc.3/arch/sparc/kernel/sys_sparc.c
--- linus/arch/sparc/kernel/sys_sparc.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/sparc/kernel/sys_sparc.c	2005-04-06 13:38:10.000000000 +1000
@@ -185,17 +185,10 @@ asmlinkage int sys_ipc (uint call, int f
 		switch (call) {
 		case SHMAT:
 			switch (version) {
-			case 0: default: {
-				ulong raddr;
-				err = do_shmat (first, (char __user *) ptr, second, &raddr);
-				if (err)
-					goto out;
-				err = -EFAULT;
-				if (put_user (raddr, (ulong __user *) third))
-					goto out;
-				err = 0;
+			case 0: default:
+				err = ipc_shmat(first, ptr, second,
+						(unsigned long __user *)third);
 				goto out;
-				}
 			case 1:	/* iBCS2 emulator entry point */
 				err = -EINVAL;
 				goto out;
diff -ruNp linus/arch/sparc64/kernel/sys_sparc.c linus-compat_sys_ipc.3/arch/sparc64/kernel/sys_sparc.c
--- linus/arch/sparc64/kernel/sys_sparc.c	2005-02-11 13:05:29.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/sparc64/kernel/sys_sparc.c	2005-04-06 13:38:14.000000000 +1000
@@ -259,14 +259,9 @@ asmlinkage long sys_ipc(unsigned int cal
 	}
 	if (call <= SHMCTL) {
 		switch (call) {
-		case SHMAT: {
-			ulong raddr;
-			err = do_shmat(first, ptr, (int)second, &raddr);
-			if (!err) {
-				if (put_user(raddr,
-					     (ulong __user *) third))
-					err = -EFAULT;
-			}
+		case SHMAT:
+			err = ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 			goto out;
 		}
 		case SHMDT:
diff -ruNp linus/arch/um/include/sysdep-x86_64/syscalls.h linus-compat_sys_ipc.3/arch/um/include/sysdep-x86_64/syscalls.h
--- linus/arch/um/include/sysdep-x86_64/syscalls.h	2005-04-01 05:09:16.000000000 +1000
+++ linus-compat_sys_ipc.3/arch/um/include/sysdep-x86_64/syscalls.h	2005-04-05 15:44:11.000000000 +1000
@@ -26,7 +26,6 @@ extern syscall_handler_t *ia32_sys_call_
 extern long old_mmap(unsigned long addr, unsigned long len,
 		     unsigned long prot, unsigned long flags,
 		     unsigned long fd, unsigned long pgoff);
-extern syscall_handler_t wrap_sys_shmat;
 extern syscall_handler_t sys_modify_ldt;
 extern syscall_handler_t sys_arch_prctl;
 
@@ -36,7 +35,7 @@ extern syscall_handler_t sys_arch_prctl;
 	[ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
 	[ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
 	[ __NR_shmget ] = (syscall_handler_t *) sys_shmget, \
-	[ __NR_shmat ] = (syscall_handler_t *) wrap_sys_shmat, \
+	[ __NR_shmat ] = (syscall_handler_t *) sys_shmat, \
 	[ __NR_shmctl ] = (syscall_handler_t *) sys_shmctl, \
 	[ __NR_semop ] = (syscall_handler_t *) sys_semop, \
 	[ __NR_semget ] = (syscall_handler_t *) sys_semget, \
diff -ruNp linus/arch/um/sys-i386/syscalls.c linus-compat_sys_ipc.3/arch/um/sys-i386/syscalls.c
--- linus/arch/um/sys-i386/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/um/sys-i386/syscalls.c	2005-04-06 13:38:22.000000000 +1000
@@ -143,13 +143,9 @@ long sys_ipc (uint call, int first, int 
 
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				return ret;
-			return put_user (raddr, (ulong *) third);
-		}
+		default:
+			return ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				return -EINVAL;
diff -ruNp linus/arch/um/sys-x86_64/syscalls.c linus-compat_sys_ipc.3/arch/um/sys-x86_64/syscalls.c
--- linus/arch/um/sys-x86_64/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/um/sys-x86_64/syscalls.c	2005-04-05 15:45:51.000000000 +1000
@@ -14,13 +14,6 @@
 #include "asm/prctl.h" /* XXX This should get the constants from libc */
 #include "choose-mode.h"
 
-asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-
-	return do_shmat(shmid, shmaddr, shmflg, &raddr) ?: (long) raddr;
-}
-
 #ifdef CONFIG_MODE_TT
 extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
 
diff -ruNp linus/arch/v850/kernel/syscalls.c linus-compat_sys_ipc.3/arch/v850/kernel/syscalls.c
--- linus/arch/v850/kernel/syscalls.c	2005-03-14 13:07:08.000000000 +1100
+++ linus-compat_sys_ipc.3/arch/v850/kernel/syscalls.c	2005-04-06 13:38:36.000000000 +1000
@@ -101,18 +101,10 @@ sys_ipc (uint call, int first, int secon
 		break;
 	case SHMAT:
 		switch (version) {
-		default: {
-			ulong raddr;
-
-			if ((ret = access_ok(VERIFY_WRITE, (ulong*) third,
-					       sizeof(ulong)) ? 0 : -EFAULT))
-				break;
-			ret = do_shmat (first, (char *) ptr, second, &raddr);
-			if (ret)
-				break;
-			ret = put_user (raddr, (ulong *) third);
+		default:
+			ret = ipc_shmat(first, ptr, second,
+					(unsigned long __user *)third);
 			break;
-			}
 		case 1:	/* iBCS2 emulator entry point */
 			if (!segment_eq(get_fs(), get_ds()))
 				break;
diff -ruNp linus/arch/x86_64/kernel/sys_x86_64.c linus-compat_sys_ipc.3/arch/x86_64/kernel/sys_x86_64.c
--- linus/arch/x86_64/kernel/sys_x86_64.c	2005-04-01 05:09:16.000000000 +1000
+++ linus-compat_sys_ipc.3/arch/x86_64/kernel/sys_x86_64.c	2005-04-05 15:46:08.000000000 +1000
@@ -152,12 +152,6 @@ asmlinkage long sys_uname(struct new_uts
 	return err ? -EFAULT : 0;
 }
 
-asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	return do_shmat(shmid,shmaddr,shmflg,&raddr) ?: (long)raddr;
-}
-
 asmlinkage long sys_time64(long __user * tloc)
 {
 	struct timeval now; 
diff -ruNp linus/include/asm-x86_64/unistd.h linus-compat_sys_ipc.3/include/asm-x86_64/unistd.h
--- linus/include/asm-x86_64/unistd.h	2005-04-01 05:09:17.000000000 +1000
+++ linus-compat_sys_ipc.3/include/asm-x86_64/unistd.h	2005-04-05 15:46:35.000000000 +1000
@@ -76,7 +76,7 @@ __SYSCALL(__NR_madvise, sys_madvise)
 #define __NR_shmget                             29
 __SYSCALL(__NR_shmget, sys_shmget)
 #define __NR_shmat                              30
-__SYSCALL(__NR_shmat, wrap_sys_shmat)
+__SYSCALL(__NR_shmat, sys_shmat)
 #define __NR_shmctl                             31
 __SYSCALL(__NR_shmctl, sys_shmctl)
 
diff -ruNp linus/include/linux/shm.h linus-compat_sys_ipc.3/include/linux/shm.h
--- linus/include/linux/shm.h	2004-08-25 07:48:22.000000000 +1000
+++ linus-compat_sys_ipc.3/include/linux/shm.h	2005-04-06 13:41:30.000000000 +1000
@@ -95,12 +95,20 @@ struct shmid_kernel /* private to the ke
 
 #ifdef CONFIG_SYSVIPC
 long do_shmat(int shmid, char __user *shmaddr, int shmflg, unsigned long *addr);
+long ipc_shmat(int shmid, char __user *shmaddr, int shmflg,
+		unsigned long __user *addr);
 #else
 static inline long do_shmat(int shmid, char __user *shmaddr,
 				int shmflg, unsigned long *addr)
 {
 	return -ENOSYS;
 }
+
+static inline long ipc_shmat(int shmid, char __user *shmaddr,
+				int shmflg, unsigned long __user *addr)
+{
+	return -ENOSYS;
+}
 #endif
 
 #endif /* __KERNEL__ */
diff -ruNp linus/include/linux/syscalls.h linus-compat_sys_ipc.3/include/linux/syscalls.h
--- linus/include/linux/syscalls.h	2005-01-05 17:06:08.000000000 +1100
+++ linus-compat_sys_ipc.3/include/linux/syscalls.h	2005-04-06 13:39:42.000000000 +1000
@@ -456,8 +456,7 @@ asmlinkage long sys_semctl(int semid, in
 asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
 				unsigned nsops,
 				const struct timespec __user *timeout);
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
-				int shmflg, unsigned long __user *addr);
+asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
 asmlinkage long sys_shmdt(char __user *shmaddr);
 asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
diff -ruNp linus/ipc/shm.c linus-compat_sys_ipc.3/ipc/shm.c
--- linus/ipc/shm.c	2005-03-18 04:08:16.000000000 +1100
+++ linus-compat_sys_ipc.3/ipc/shm.c	2005-04-06 13:42:38.000000000 +1000
@@ -28,6 +28,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/audit.h>
+#include <linux/ptrace.h>	/* for force_successful_syscall_return() */
 #include <asm/uaccess.h>
 
 #include "util.h"
@@ -772,6 +773,40 @@ out:
 }
 
 /*
+ * Attach a shared memory segment.  This version of the system
+ * call returns the attached address through the last parameter.
+ */
+long ipc_shmat(int shmid, char __user *shmaddr, int shmflg,
+		unsigned long __user *addr)
+{
+	ulong raddr;
+	long ret;
+
+	if (!access_ok(VERIFY_WRITE, addr, sizeof(*addr)))
+		return -EFAULT;
+	ret = do_shmat(shmid, shmaddr, shmflg, &raddr);
+	if (ret == 0)
+		ret = __put_user(raddr, addr);
+	return ret;
+}
+
+/*
+ * Attach a shared memory segment.  This version of the system
+ * call returns the attached address as its return value
+ */
+asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg)
+{
+	ulong raddr;
+	long ret;
+
+	ret = do_shmat(shmid, shmaddr, shmflg, &raddr);
+	if (ret < 0)
+		return ret;
+	force_successful_syscall_return();
+	return raddr;
+}
+
+/*
  * detach and kill segment if marked destroyed.
  * The work is done in shm_close.
  */
diff -ruNp linus/kernel/sys_ni.c linus-compat_sys_ipc.3/kernel/sys_ni.c
--- linus/kernel/sys_ni.c	2005-03-29 16:06:38.000000000 +1000
+++ linus-compat_sys_ipc.3/kernel/sys_ni.c	2005-04-06 13:43:03.000000000 +1000
@@ -52,6 +52,7 @@ cond_syscall(sys_msgsnd);
 cond_syscall(sys_msgrcv);
 cond_syscall(sys_msgctl);
 cond_syscall(sys_shmget);
+cond_syscall(sys_shmat);
 cond_syscall(sys_shmdt);
 cond_syscall(sys_shmctl);
 cond_syscall(sys_mq_open);

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] consolidate shmat usage
  2005-04-06 15:05         ` Stephen Rothwell
@ 2005-04-07  5:14           ` Stephen Rothwell
  2005-04-11 20:29           ` Russell King
  1 sibling, 0 replies; 21+ messages in thread
From: Stephen Rothwell @ 2005-04-07  5:14 UTC (permalink / raw)
  To: linux-arch; +Cc: matthew, rmk, ralf

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

On Thu, 7 Apr 2005 01:05:01 +1000 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> On Tue, 5 Apr 2005 14:03:12 +0100 Matthew Wilcox <matthew@wil.cx> wrote:
> >
> > Umm.  I think you've just discovered a bug in ARM and MIPS.  I don't see
> > any code in glibc for handling the 4-argument version of sys_shmat.
> > Russell, Ralf, could you comment?
> 
> OK, assuming that using the 4 argument version of sys_shmat as a system
> call, here is another version of the patch (not tested) for comment.

I have now built that patch on ppc64, i386 and x86_64 with and without
CONFIG_SYSVIPC and booted it on ppc64.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] consolidate shmat usage
  2005-04-06 15:05         ` Stephen Rothwell
  2005-04-07  5:14           ` Stephen Rothwell
@ 2005-04-11 20:29           ` Russell King
  1 sibling, 0 replies; 21+ messages in thread
From: Russell King @ 2005-04-11 20:29 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Matthew Wilcox, linux-arch, ralf

On Thu, Apr 07, 2005 at 01:05:01AM +1000, Stephen Rothwell wrote:
> On Tue, 5 Apr 2005 14:03:12 +0100 Matthew Wilcox <matthew@wil.cx> wrote:
> >
> > Umm.  I think you've just discovered a bug in ARM and MIPS.  I don't see
> > any code in glibc for handling the 4-argument version of sys_shmat.
> > Russell, Ralf, could you comment?
> 
> OK, assuming that using the 4 argument version of sys_shmat as a system
> call, here is another version of the patch (not tested) for comment.

I suspect you mean "assuming that using the 4 argument version of
sys_shmat as a system call is wrong" because that seems to be what
you've implemented.

This patch converts ARM sys_shmat from the 4 arg to the 3 arg version.
I'm mostly happy with that, except for one exception - the effect of
running a glibc with sys_shmat support against an older kernel with
the 4 argument version will be inherently problematic - the system
call will appear to succeed, but not as one would expect.

Since sys_shmat was added to ARM on 2 March 2005, it means that the 4
argument version is in both 2.6.12-rc1 and 2.6.12-rc2, but not 2.6.11.
I guess that means we can fix the API now, before 2.6.12 happens.  This
would mean that we don't expect the kernel API to be stable for new
features until the following non-rc release?

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core

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

* [PATCH] consolidate sys_shmat
  2005-04-05 13:03       ` Matthew Wilcox
                           ` (2 preceding siblings ...)
  2005-04-06 15:05         ` Stephen Rothwell
@ 2005-04-27  6:27         ` Stephen Rothwell
  2005-04-27 12:50           ` Ralf Baechle
  3 siblings, 1 reply; 21+ messages in thread
From: Stephen Rothwell @ 2005-04-27  6:27 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-arch, rmk, ralf

[-- Attachment #1: Type: text/plain, Size: 13290 bytes --]

Hi all,

I have minimised this patch a bit.  It now just consolidates sys_shmat and
in doing so, "fixes" the ABIs for MIPS(64) and ARM.  ARM glibc does not
use the sys_shmnat syscall directly so far (as far as I can see) and on
MIPS64, the ABI that glibc seems to expect (I am pretty much guessing) is
the fixed one.

I would like to get this to Andrew (and Linus) pretty soon as it would be
best if we don't have a "release" kernel with the incorrect ABI in it.

If everyone is happy, I will send this to Andrew tomorrow (or so).

diffstat look like this:

 arch/alpha/kernel/osf_sys.c              |   16 ----------------
 arch/alpha/kernel/systbls.S              |    2 +-
 arch/arm/kernel/sys_arm.c                |   12 ------------
 arch/ia64/kernel/entry.S                 |    2 +-
 arch/ia64/kernel/sys_ia64.c              |   14 --------------
 arch/mips/kernel/syscall.c               |   16 ----------------
 arch/parisc/kernel/sys_parisc.c          |   11 -----------
 arch/parisc/kernel/syscall_table.S       |    2 +-
 arch/sh64/kernel/sys_sh64.c              |   15 ---------------
 arch/sh64/kernel/syscalls.S              |    2 +-
 arch/um/include/sysdep-x86_64/syscalls.h |    3 +--
 arch/um/sys-x86_64/syscalls.c            |    7 -------
 arch/x86_64/kernel/sys_x86_64.c          |    6 ------
 include/asm-x86_64/unistd.h              |    2 +-
 include/linux/syscalls.h                 |    3 +--
 ipc/shm.c                                |   14 ++++++++++++++
 kernel/sys_ni.c                          |    1 +
 17 files changed, 22 insertions(+), 106 deletions(-)

I have built this on PPC64 (which doesn't use sys_shmat) and X86_64 (which
does) both with and without CONFIG_SYSVIPC.

One slight downside is that there is now a sys_shmat defined even on those
architectures that don't use it (it is a very small function) - but maybe
we should be deprecating the use of sys_ipc anyway :-)

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

diff -ruNp linus/arch/alpha/kernel/osf_sys.c linus-sys_shmat.1/arch/alpha/kernel/osf_sys.c
--- linus/arch/alpha/kernel/osf_sys.c	2005-04-26 15:37:54.000000000 +1000
+++ linus-sys_shmat.1/arch/alpha/kernel/osf_sys.c	2005-04-27 12:13:13.000000000 +1000
@@ -457,22 +457,6 @@ osf_getdomainname(char __user *name, int
 	return 0;
 }
 
-asmlinkage long
-osf_shmat(int shmid, void __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	long err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-
-	/*
-	 * This works because all user-level addresses are
-	 * non-negative longs!
-	 */
-	return err ? err : (long)raddr;
-}
-
-
 /*
  * The following stuff should move into a header file should it ever
  * be labeled "officially supported."  Right now, there is just enough
diff -ruNp linus/arch/alpha/kernel/systbls.S linus-sys_shmat.1/arch/alpha/kernel/systbls.S
--- linus/arch/alpha/kernel/systbls.S	2005-04-26 15:37:54.000000000 +1000
+++ linus-sys_shmat.1/arch/alpha/kernel/systbls.S	2005-04-27 12:13:01.000000000 +1000
@@ -227,7 +227,7 @@ sys_call_table:
 	.quad sys_semop
 	.quad osf_utsname
 	.quad sys_lchown
-	.quad osf_shmat
+	.quad sys_shmat
 	.quad sys_shmctl			/* 210 */
 	.quad sys_shmdt
 	.quad sys_shmget
diff -ruNp linus/arch/arm/kernel/sys_arm.c linus-sys_shmat.1/arch/arm/kernel/sys_arm.c
--- linus/arch/arm/kernel/sys_arm.c	2005-04-26 15:37:54.000000000 +1000
+++ linus-sys_shmat.1/arch/arm/kernel/sys_arm.c	2005-04-27 13:01:21.000000000 +1000
@@ -227,18 +227,6 @@ asmlinkage int sys_ipc(uint call, int fi
 	}
 }
 
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg,
-			  unsigned long __user *addr)
-{
-	unsigned long ret;
-	long err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &ret);
-	if (err == 0)
-		err = put_user(ret, addr);
-	return err;
-}
-
 /* Fork a new task - this creates a new program thread.
  * This is called indirectly via a small wrapper
  */
diff -ruNp linus/arch/ia64/kernel/entry.S linus-sys_shmat.1/arch/ia64/kernel/entry.S
--- linus/arch/ia64/kernel/entry.S	2005-04-26 15:37:54.000000000 +1000
+++ linus-sys_shmat.1/arch/ia64/kernel/entry.S	2005-04-27 13:02:53.000000000 +1000
@@ -1417,7 +1417,7 @@ sys_call_table:
 	data8 sys_msgrcv
 	data8 sys_msgctl
 	data8 sys_shmget
-	data8 ia64_shmat
+	data8 sys_shmat
 	data8 sys_shmdt				// 1115
 	data8 sys_shmctl
 	data8 sys_syslog
diff -ruNp linus/arch/ia64/kernel/sys_ia64.c linus-sys_shmat.1/arch/ia64/kernel/sys_ia64.c
--- linus/arch/ia64/kernel/sys_ia64.c	2005-04-26 15:37:54.000000000 +1000
+++ linus-sys_shmat.1/arch/ia64/kernel/sys_ia64.c	2005-04-27 13:05:40.000000000 +1000
@@ -93,20 +93,6 @@ sys_getpagesize (void)
 }
 
 asmlinkage unsigned long
-ia64_shmat (int shmid, void __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	int retval;
-
-	retval = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (retval < 0)
-		return retval;
-
-	force_successful_syscall_return();
-	return raddr;
-}
-
-asmlinkage unsigned long
 ia64_brk (unsigned long brk)
 {
 	unsigned long rlim, retval, newbrk, oldbrk;
diff -ruNp linus/arch/mips/kernel/syscall.c linus-sys_shmat.1/arch/mips/kernel/syscall.c
--- linus/arch/mips/kernel/syscall.c	2005-04-26 15:37:55.000000000 +1000
+++ linus-sys_shmat.1/arch/mips/kernel/syscall.c	2005-04-27 13:06:51.000000000 +1000
@@ -374,22 +374,6 @@ asmlinkage int sys_ipc (uint call, int f
 }
 
 /*
- * Native ABI that is O32 or N64 version
- */
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
-                          int shmflg, unsigned long *addr)
-{
-	unsigned long raddr;
-	int err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (err)
-		return err;
-
-	return put_user(raddr, addr);
-}
-
-/*
  * No implemented yet ...
  */
 asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
diff -ruNp linus/arch/parisc/kernel/sys_parisc.c linus-sys_shmat.1/arch/parisc/kernel/sys_parisc.c
--- linus/arch/parisc/kernel/sys_parisc.c	2005-04-26 15:37:55.000000000 +1000
+++ linus-sys_shmat.1/arch/parisc/kernel/sys_parisc.c	2005-04-27 13:07:40.000000000 +1000
@@ -161,17 +161,6 @@ asmlinkage unsigned long sys_mmap(unsign
 	}
 }
 
-long sys_shmat_wrapper(int shmid, char __user *shmaddr, int shmflag)
-{
-	unsigned long raddr;
-	int r;
-
-	r = do_shmat(shmid, shmaddr, shmflag, &raddr);
-	if (r < 0)
-		return r;
-	return raddr;
-}
-
 /* Fucking broken ABI */
 
 #ifdef CONFIG_64BIT
diff -ruNp linus/arch/parisc/kernel/syscall_table.S linus-sys_shmat.1/arch/parisc/kernel/syscall_table.S
--- linus/arch/parisc/kernel/syscall_table.S	2005-04-26 15:37:55.000000000 +1000
+++ linus-sys_shmat.1/arch/parisc/kernel/syscall_table.S	2005-04-27 13:07:58.000000000 +1000
@@ -297,7 +297,7 @@
 	ENTRY_DIFF(msgrcv)
 	ENTRY_SAME(msgget)		/* 190 */
 	ENTRY_SAME(msgctl)
-	ENTRY_SAME(shmat_wrapper)
+	ENTRY_SAME(shmat)
 	ENTRY_SAME(shmdt)
 	ENTRY_SAME(shmget)
 	ENTRY_SAME(shmctl)		/* 195 */
diff -ruNp linus/arch/sh64/kernel/sys_sh64.c linus-sys_shmat.1/arch/sh64/kernel/sys_sh64.c
--- linus/arch/sh64/kernel/sys_sh64.c	2005-04-26 15:37:55.000000000 +1000
+++ linus-sys_shmat.1/arch/sh64/kernel/sys_sh64.c	2005-04-27 13:11:39.000000000 +1000
@@ -283,18 +283,3 @@ asmlinkage int sys_uname(struct old_utsn
 	up_read(&uts_sem);
 	return err?-EFAULT:0;
 }
-
-/* Copy from mips version */
-asmlinkage long sys_shmatcall(int shmid, char __user *shmaddr,
-		int shmflg)
-{
-	unsigned long raddr;
-	int err;
-
-	err = do_shmat(shmid, shmaddr, shmflg, &raddr);
-	if (err)
-		return err;
-
-	err = raddr;
-	return err;
-}
diff -ruNp linus/arch/sh64/kernel/syscalls.S linus-sys_shmat.1/arch/sh64/kernel/syscalls.S
--- linus/arch/sh64/kernel/syscalls.S	2005-04-26 15:37:55.000000000 +1000
+++ linus-sys_shmat.1/arch/sh64/kernel/syscalls.S	2005-04-27 13:11:54.000000000 +1000
@@ -268,7 +268,7 @@ sys_call_table:
 	.long sys_msgrcv
 	.long sys_msgget
 	.long sys_msgctl
-	.long sys_shmatcall
+	.long sys_shmat
 	.long sys_shmdt			/* 245 */
 	.long sys_shmget
 	.long sys_shmctl
diff -ruNp linus/arch/um/include/sysdep-x86_64/syscalls.h linus-sys_shmat.1/arch/um/include/sysdep-x86_64/syscalls.h
--- linus/arch/um/include/sysdep-x86_64/syscalls.h	2005-04-26 15:37:56.000000000 +1000
+++ linus-sys_shmat.1/arch/um/include/sysdep-x86_64/syscalls.h	2005-04-27 13:10:09.000000000 +1000
@@ -26,7 +26,6 @@ extern syscall_handler_t *ia32_sys_call_
 extern long old_mmap(unsigned long addr, unsigned long len,
 		     unsigned long prot, unsigned long flags,
 		     unsigned long fd, unsigned long pgoff);
-extern syscall_handler_t wrap_sys_shmat;
 extern syscall_handler_t sys_modify_ldt;
 extern syscall_handler_t sys_arch_prctl;
 
@@ -36,7 +35,7 @@ extern syscall_handler_t sys_arch_prctl;
 	[ __NR_mincore ] = (syscall_handler_t *) sys_mincore, \
 	[ __NR_madvise ] = (syscall_handler_t *) sys_madvise, \
 	[ __NR_shmget ] = (syscall_handler_t *) sys_shmget, \
-	[ __NR_shmat ] = (syscall_handler_t *) wrap_sys_shmat, \
+	[ __NR_shmat ] = (syscall_handler_t *) sys_shmat, \
 	[ __NR_shmctl ] = (syscall_handler_t *) sys_shmctl, \
 	[ __NR_semop ] = (syscall_handler_t *) sys_semop, \
 	[ __NR_semget ] = (syscall_handler_t *) sys_semget, \
diff -ruNp linus/arch/um/sys-x86_64/syscalls.c linus-sys_shmat.1/arch/um/sys-x86_64/syscalls.c
--- linus/arch/um/sys-x86_64/syscalls.c	2005-04-26 15:37:56.000000000 +1000
+++ linus-sys_shmat.1/arch/um/sys-x86_64/syscalls.c	2005-04-27 13:10:44.000000000 +1000
@@ -14,13 +14,6 @@
 #include "asm/prctl.h" /* XXX This should get the constants from libc */
 #include "choose-mode.h"
 
-asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-
-	return do_shmat(shmid, shmaddr, shmflg, &raddr) ?: (long) raddr;
-}
-
 #ifdef CONFIG_MODE_TT
 extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
 
diff -ruNp linus/arch/x86_64/kernel/sys_x86_64.c linus-sys_shmat.1/arch/x86_64/kernel/sys_x86_64.c
--- linus/arch/x86_64/kernel/sys_x86_64.c	2005-04-26 15:37:56.000000000 +1000
+++ linus-sys_shmat.1/arch/x86_64/kernel/sys_x86_64.c	2005-04-27 13:11:09.000000000 +1000
@@ -152,12 +152,6 @@ asmlinkage long sys_uname(struct new_uts
 	return err ? -EFAULT : 0;
 }
 
-asmlinkage long wrap_sys_shmat(int shmid, char __user *shmaddr, int shmflg)
-{
-	unsigned long raddr;
-	return do_shmat(shmid,shmaddr,shmflg,&raddr) ?: (long)raddr;
-}
-
 asmlinkage long sys_time64(long __user * tloc)
 {
 	struct timeval now; 
diff -ruNp linus/include/asm-x86_64/unistd.h linus-sys_shmat.1/include/asm-x86_64/unistd.h
--- linus/include/asm-x86_64/unistd.h	2005-04-26 15:38:02.000000000 +1000
+++ linus-sys_shmat.1/include/asm-x86_64/unistd.h	2005-04-27 13:12:58.000000000 +1000
@@ -76,7 +76,7 @@ __SYSCALL(__NR_madvise, sys_madvise)
 #define __NR_shmget                             29
 __SYSCALL(__NR_shmget, sys_shmget)
 #define __NR_shmat                              30
-__SYSCALL(__NR_shmat, wrap_sys_shmat)
+__SYSCALL(__NR_shmat, sys_shmat)
 #define __NR_shmctl                             31
 __SYSCALL(__NR_shmctl, sys_shmctl)
 
diff -ruNp linus/include/linux/syscalls.h linus-sys_shmat.1/include/linux/syscalls.h
--- linus/include/linux/syscalls.h	2005-04-26 15:38:02.000000000 +1000
+++ linus-sys_shmat.1/include/linux/syscalls.h	2005-04-27 11:44:01.000000000 +1000
@@ -456,8 +456,7 @@ asmlinkage long sys_semctl(int semid, in
 asmlinkage long sys_semtimedop(int semid, struct sembuf __user *sops,
 				unsigned nsops,
 				const struct timespec __user *timeout);
-asmlinkage long sys_shmat(int shmid, char __user *shmaddr,
-				int shmflg, unsigned long __user *addr);
+asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg);
 asmlinkage long sys_shmget(key_t key, size_t size, int flag);
 asmlinkage long sys_shmdt(char __user *shmaddr);
 asmlinkage long sys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
diff -ruNp linus/ipc/shm.c linus-sys_shmat.1/ipc/shm.c
--- linus/ipc/shm.c	2005-04-26 15:38:03.000000000 +1000
+++ linus-sys_shmat.1/ipc/shm.c	2005-04-27 13:50:58.000000000 +1000
@@ -28,6 +28,8 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/audit.h>
+#include <linux/ptrace.h>
+
 #include <asm/uaccess.h>
 
 #include "util.h"
@@ -771,6 +773,18 @@ out:
 	return err;
 }
 
+asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg)
+{
+	unsigned long ret;
+	long err;
+
+	err = do_shmat(shmid, shmaddr, shmflg, &ret);
+	if (err)
+		return err;
+	force_successful_syscall_return();
+	return (long)ret;
+}
+
 /*
  * detach and kill segment if marked destroyed.
  * The work is done in shm_close.
diff -ruNp linus/kernel/sys_ni.c linus-sys_shmat.1/kernel/sys_ni.c
--- linus/kernel/sys_ni.c	2005-04-26 15:38:03.000000000 +1000
+++ linus-sys_shmat.1/kernel/sys_ni.c	2005-04-27 13:23:04.000000000 +1000
@@ -52,6 +52,7 @@ cond_syscall(sys_msgsnd);
 cond_syscall(sys_msgrcv);
 cond_syscall(sys_msgctl);
 cond_syscall(sys_shmget);
+cond_syscall(sys_shmat);
 cond_syscall(sys_shmdt);
 cond_syscall(sys_shmctl);
 cond_syscall(sys_mq_open);

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: [PATCH] consolidate sys_shmat
  2005-04-27  6:27         ` [PATCH] consolidate sys_shmat Stephen Rothwell
@ 2005-04-27 12:50           ` Ralf Baechle
  2005-04-27 14:36             ` Stephen Rothwell
  0 siblings, 1 reply; 21+ messages in thread
From: Ralf Baechle @ 2005-04-27 12:50 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: Matthew Wilcox, linux-arch, rmk

On Wed, Apr 27, 2005 at 04:27:09PM +1000, Stephen Rothwell wrote:

> I have minimised this patch a bit.  It now just consolidates sys_shmat and
> in doing so, "fixes" the ABIs for MIPS(64) and ARM.  ARM glibc does not
> use the sys_shmnat syscall directly so far (as far as I can see) and on
> MIPS64, the ABI that glibc seems to expect (I am pretty much guessing) is
> the fixed one.

Correct, so the patch is looking ok.

  Ralf

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

* Re: [PATCH] consolidate sys_shmat
  2005-04-27 12:50           ` Ralf Baechle
@ 2005-04-27 14:36             ` Stephen Rothwell
  0 siblings, 0 replies; 21+ messages in thread
From: Stephen Rothwell @ 2005-04-27 14:36 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: matthew, linux-arch, rmk

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

On Wed, 27 Apr 2005 13:50:15 +0100 Ralf Baechle <ralf@linux-mips.org> wrote:
>
> On Wed, Apr 27, 2005 at 04:27:09PM +1000, Stephen Rothwell wrote:
> 
> > I have minimised this patch a bit.  It now just consolidates sys_shmat and
> > in doing so, "fixes" the ABIs for MIPS(64) and ARM.  ARM glibc does not
> > use the sys_shmnat syscall directly so far (as far as I can see) and on
> > MIPS64, the ABI that glibc seems to expect (I am pretty much guessing) is
> > the fixed one.
> 
> Correct, so the patch is looking ok.

Good, thanks.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2005-04-27 14:36 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-23  4:01 [PATCH] consolidate asm/ipc.h Stephen Rothwell
2005-03-23  4:12 ` David S. Miller
2005-03-23  6:48 ` [PATCH] consolidate shmat usage Stephen Rothwell
2005-03-23 10:54   ` David Howells
2005-04-05  8:02     ` Stephen Rothwell
2005-03-23 14:51   ` Matthew Wilcox
2005-04-05  8:01     ` Stephen Rothwell
2005-04-05 13:03       ` Matthew Wilcox
2005-04-05 20:00         ` Ralf Baechle
2005-04-05 20:16         ` Russell King
2005-04-05 20:20           ` Ralf Baechle
2005-04-06 15:05         ` Stephen Rothwell
2005-04-07  5:14           ` Stephen Rothwell
2005-04-11 20:29           ` Russell King
2005-04-27  6:27         ` [PATCH] consolidate sys_shmat Stephen Rothwell
2005-04-27 12:50           ` Ralf Baechle
2005-04-27 14:36             ` Stephen Rothwell
2005-04-05  8:05   ` [PATCH] consolidate shmat usage Stephen Rothwell
2005-03-23  8:06 ` [PATCH] consolidate asm/ipc.h Andi Kleen
2005-03-24  0:30   ` Stephen Rothwell
2005-03-23 10:49 ` David Howells

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox