fix shmat
Subsystems (9)
A message that is not in the archive (sent off-list or not yet received): [email protected]
From the bitkeeper commit message queue:
Quoted 5 lines
sys_shmat()need to be declared asmlinkage. This causes breakage when we actually get the proper prototypes into caller's scope.
Why? sys_shmat is not a system call. Or at least there is a comment just before the implementation that this is not a syscall. I think either the asmlinkage or the comment are wrong:
/*
* Fix shmaddr, allocate descriptor, map shm, add attach descriptor to lists.
*
* NOTE! Despite the name, this is NOT a direct system call entrypoint. The
Quoted 9 lines
* "raddr" thing points to kernel space, and there has to be a wrapper around
* this.
*/(quoted diff) +1
-1-long sys_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr) +asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr){ struct shmid_kernel *shp; unsigned long addr;
I'd propose to remove the asmlinkage and to move the prototype (without asmlinkage) back from syscalls.h to shm.h - what do you think? --
Manfred
On Mon, 23 Feb 2004 19:15:04 +0100 Manfred Spraul <[email protected]> wrote:
| From the bitkeeper commit message queue:
|
| >
| > sys_shmat() need to be declared asmlinkage. This causes breakage when we
| > actually get the proper prototypes into caller's scope.
| >
| >
| Why? sys_shmat is not a system call. Or at least there is a comment just
| before the implementation that this is not a syscall.
| I think either the asmlinkage or the comment are wrong:
| /*
| * Fix shmaddr, allocate descriptor, map shm, add attach descriptor to
| lists.
| *
| * NOTE! Despite the name, this is NOT a direct system call entrypoint. The
|
| > * "raddr" thing points to kernel space, and there has to be a wrapper around
| > * this.
| > */
| >-long sys_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
| >+asmlinkage long sys_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr)
| > {
| > struct shmid_kernel *shp;
| > unsigned long addr;
| >
|
| I'd propose to remove the asmlinkage and to move the prototype (without
| asmlinkage) back from syscalls.h to shm.h - what do you think?It's not a syscall AFAICT.
It's not listed in any .S files, like most syscalls are. However, it is listed in kernel/sys.c as a "cond_syscall", which I'm guessing is incorrect.
I'd like to rename it so that it doesn't begin with "sys_".
--
~Randy
Quoted 3 lines · Manfred Spraul
I'd propose to remove the asmlinkage and to move the prototype (without asmlinkage) back from
syscalls.htoshm.h- what do you think?
Please. Maybe it might even be worth-while renaming it to "do_sys_shmat()" to make it clear that it's not a "sys_xxx()" at all.
Linus
Quoted 4 lines · Linus Torvalds
Please. Maybe it might even be worth-while renaming it to "
do_sys_shmat()" to make it clear that it's not a "sys_xxx()" at all.
Below is a patch that renames sys_shmat to do_shmat. Additionally, I've replaced the cond_syscall with a conditional inline function.
It touches all archs - only i386 is tested.
The patch is against 2.6.3-bk5 (latest slapshot)
--
Manfred
<<<<
arch/alpha/kernel/osf_sys.c +1 -1
@@ -464,7 +464,7 @@unsigned long raddr;long err; - err =sys_shmat (shmid, shmaddr, shmflg, &raddr); + err =do_shmat (shmid, shmaddr, shmflg, &raddr);/* * This works because all user-level addresses are
arch/arm/kernel/sys_arm.c +2 -2
@@ -210,7 +210,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char *) ptr, second, &raddr); + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)return ret;return put_user (raddr, (ulong *) third);
@@ -218,7 +218,7 @@case 1 :/* iBCS2 emulator entry point */ if (!segment_eq (get_fs (),get_ds ()))return -EINVAL ; -return sys_shmat (first, (char *) ptr, +return do_shmat (first, (char *) ptr, second, (ulong *) third); }case SHMDT :
arch/arm26/kernel/sys_arm.c +2 -2
@@ -211,7 +211,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char *) ptr, second, &raddr); + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)return ret;return put_user (raddr, (ulong *) third);
@@ -219,7 +219,7 @@case 1 :/* iBCS2 emulator entry point */ if (!segment_eq (get_fs (),get_ds ()))return -EINVAL ; -return sys_shmat (first, (char *) ptr, +return do_shmat (first, (char *) ptr, second, (ulong *) third); }case SHMDT :
arch/cris/kernel/sys_cris.c +1 -1
@@ -155,7 +155,7 @@case SHMAT : {ulong raddr; - ret =sys_shmat (first, (char __user *) ptr, second, &raddr); + ret =do_shmat (first, (char __user *) ptr, second, &raddr);if (ret)return ret;return put_user (raddr, (ulong __user *) third);
arch/h8300/kernel/sys_h8300.c +1 -1
@@ -240,7 +240,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char *) ptr, + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)return ret;
arch/i386/kernel/sys_i386.c +2 -2
@@ -186,7 +186,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char __user *) ptr, second, &raddr); + ret =do_shmat (first, (char __user *) ptr, second, &raddr);if (ret)return ret;return put_user (raddr, (ulong __user *) third);
@@ -195,7 +195,7 @@if (!segment_eq (get_fs (),get_ds ()))return -EINVAL ;/* The "(ulong *) third" is valid _only_ because of the kernel segment thing */ -return sys_shmat (first, (char __user *) ptr, second, (ulong *) third); +return do_shmat (first, (char __user *) ptr, second, (ulong *) third); }case SHMDT :return sys_shmdt ((char __user *)ptr);
arch/ia64/ia32/sys_ia32.c +1 -1
@@ -1447,7 +1447,7 @@if (version ==1 )return -EINVAL ;/* iBCS2 emulator entry point: unsupported */ - err =sys_shmat (first, uptr, second, &raddr); + err =do_shmat (first, uptr, second, &raddr);if (err)return err;return put_user (raddr, uaddr);
arch/ia64/kernel/sys_ia64.c +1 -1
@@ -98,7 +98,7 @@unsigned long raddr;int retval; - retval =sys_shmat (shmid, shmaddr, shmflg, &raddr); + retval =do_shmat (shmid, shmaddr, shmflg, &raddr);if (retval <0 )return retval;
arch/m68k/kernel/sys_m68k.c +1 -1
@@ -241,7 +241,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char *) ptr, + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)return ret;
arch/mips/kernel/linux32.c +1 -1
@@ -1460,7 +1460,7 @@if (version ==1 )return err; - err =sys_shmat (first, uptr, second, &raddr); + err =do_shmat (first, uptr, second, &raddr);if (err)return err; err =put_user (raddr, uaddr);
arch/mips/kernel/syscall.c +2 -2
@@ -342,7 +342,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char *) ptr, second, &raddr); + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)return ret;return put_user (raddr, (ulong *) third);
@@ -350,7 +350,7 @@case 1 :/* iBCS2 emulator entry point */ if (!segment_eq (get_fs (),get_ds ()))return -EINVAL ; -return sys_shmat (first, (char *) ptr, second, (ulong *) third); +return do_shmat (first, (char *) ptr, second, (ulong *) third); }case SHMDT :return sys_shmdt ((char *)ptr);
arch/mips/kernel/sysirix.c +1 -1
@@ -968,7 +968,7 @@ {switch (opcode) {case 0 : -return sys_shmat ((int ) arg0, (char *)arg1, (int ) arg2, +return do_shmat ((int ) arg0, (char *)arg1, (int ) arg2, (unsigned long *) arg3);case 1 :return sys_shmctl ((int )arg0, (int )arg1, (struct shmid_ds *)arg2);
arch/parisc/kernel/sys_parisc.c +1 -1
@@ -173,7 +173,7 @@unsigned long raddr;int r; - r =sys_shmat (shmid, shmaddr, shmflag, &raddr); + r =do_shmat (shmid, shmaddr, shmflag, &raddr);if (r <0 )return r;return raddr;
arch/ppc/kernel/syscalls.c +1 -1
@@ -119,7 +119,7 @@if ((ret =verify_area (VERIFY_WRITE , (ulong __user *) third,sizeof (ulong))))break ; - ret =sys_shmat (first, (char __user *) ptr, second, &raddr); + ret =do_shmat (first, (char __user *) ptr, second, &raddr);if (ret)break ; ret =put_user (raddr, (ulong __user *) third);
arch/ppc64/kernel/syscalls.c +2 -2
@@ -122,7 +122,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char *) ptr, second, &raddr); + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)break ; ret =put_user (raddr, (ulong *) third);
@@ -132,7 +132,7 @@ ret = -EINVAL ;if (!segment_eq (get_fs (),get_ds ()))break ; - ret =sys_shmat (first, (char *) ptr, second, + ret =do_shmat (first, (char *) ptr, second, (ulong *) third);break ; }
arch/ppc64/kernel/sys_ppc32.c +1 -1
@@ -1649,7 +1649,7 @@if (version ==1 )return err; - err =sys_shmat (first, uptr, second, &raddr); + err =do_shmat (first, uptr, second, &raddr);if (err)return err; err =put_user (raddr, uaddr);
arch/s390/kernel/compat_linux.c +1 -1
@@ -721,7 +721,7 @@if (version ==1 ) goto out; - err =sys_shmat (first, uptr, second, &raddr); + err =do_shmat (first, uptr, second, &raddr);if (err) goto out; err =put_user (raddr, uaddr);
arch/s390/kernel/sys_s390.c +1 -1
@@ -225,7 +225,7 @@case SHMAT : {ulong raddr; - ret =sys_shmat (first, (char *) ptr, second, &raddr); + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)return ret;return put_user (raddr, (ulong *) third);
arch/sh/kernel/sys_sh.c +2 -2
@@ -200,7 +200,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char __user *) ptr, + ret =do_shmat (first, (char __user *) ptr, second, &raddr);if (ret)return ret;
@@ -209,7 +209,7 @@case 1 :/* iBCS2 emulator entry point */ if (!segment_eq (get_fs (),get_ds ()))return -EINVAL ; -return sys_shmat (first, (char __user *) ptr, +return do_shmat (first, (char __user *) ptr, second, (ulong *) third); }case SHMDT :
arch/sparc/kernel/sys_sparc.c +2 -2
@@ -185,7 +185,7 @@switch (version) {case 0 :default : {ulong raddr; - err =sys_shmat (first, (char __user *) ptr, second, &raddr); + err =do_shmat (first, (char __user *) ptr, second, &raddr);if (err) goto out; err = -EFAULT ;
@@ -195,7 +195,7 @@ goto out; }case 1 :/* iBCS2 emulator entry point */ - err =sys_shmat (first, (char __user *) ptr, second, (ulong __user *) third); + err =do_shmat (first, (char __user *) ptr, second, (ulong __user *) third); goto out; }case SHMDT :
arch/sparc/kernel/sys_sunos.c +2 -2
@@ -1006,8 +1006,8 @@switch (op) {case 0 : -/* sys_shmat(): attach a shared memory area */ - rval =sys_shmat ((int )arg1,(char *)arg2,(int )arg3,&raddr); +/* do_shmat(): attach a shared memory area */ + rval =do_shmat ((int )arg1,(char *)arg2,(int )arg3,&raddr);if (!rval) rval = (int ) raddr;break ;
arch/sparc64/kernel/sys_sparc32.c +1 -1
@@ -642,7 +642,7 @@if (version ==1 ) goto out; - err =sys_shmat (first, uptr, second, &raddr); + err =do_shmat (first, uptr, second, &raddr);if (err) goto out; err =put_user (raddr, uaddr);
arch/sparc64/kernel/sys_sparc.c +1 -1
@@ -254,7 +254,7 @@switch (call) {case SHMAT : {ulong raddr; - err =sys_shmat (first, (char *) ptr, second, &raddr); + err =do_shmat (first, (char *) ptr, second, &raddr);if (!err) {if (put_user (raddr, (ulong __user *) third)) err = -EFAULT ;
arch/sparc64/kernel/sys_sunos32.c +2 -2
@@ -1139,8 +1139,8 @@switch (op) {case 0 : -/* sys_shmat(): attach a shared memory area */ - rval =sys_shmat ((int )arg1,(char *)A (arg2),(int )arg3,&raddr); +/* do_shmat(): attach a shared memory area */ + rval =do_shmat ((int )arg1,(char *)A (arg2),(int )arg3,&raddr);if (!rval) rval = (int ) raddr;break ;
arch/um/kernel/syscall_kern.c +2 -2
@@ -235,7 +235,7 @@switch (version) {default : {ulong raddr; - ret =sys_shmat (first, (char *) ptr, second, &raddr); + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)return ret;return put_user (raddr, (ulong *) third);
@@ -243,7 +243,7 @@case 1 :/* iBCS2 emulator entry point */ if (!segment_eq (get_fs (),get_ds ()))return -EINVAL ; -return sys_shmat (first, (char *) ptr, second, (ulong *) third); +return do_shmat (first, (char *) ptr, second, (ulong *) third); }case SHMDT :return sys_shmdt ((char *)ptr);
arch/v850/kernel/syscalls.c +2 -2
@@ -106,7 +106,7 @@if ((ret =verify_area (VERIFY_WRITE , (ulong *) third,sizeof (ulong))))break ; - ret =sys_shmat (first, (char *) ptr, second, &raddr); + ret =do_shmat (first, (char *) ptr, second, &raddr);if (ret)break ; ret =put_user (raddr, (ulong *) third);
@@ -115,7 +115,7 @@case 1 :/* iBCS2 emulator entry point */ if (!segment_eq (get_fs (),get_ds ()))break ; - ret =sys_shmat (first, (char *) ptr, second, + ret =do_shmat (first, (char *) ptr, second, (ulong *) third);break ; }
arch/x86_64/ia32/ipc32.c +1 -1
@@ -457,7 +457,7 @@if (version ==1 )return -EINVAL ;/* iBCS2 emulator entry point: unsupported */ - err =sys_shmat (first, uptr, second, &raddr); + err =do_shmat (first, uptr, second, &raddr);if (err)return err;return put_user (raddr, uaddr);
arch/x86_64/kernel/sys_x86_64.c +1 -1
@@ -155,7 +155,7 @@asmlinkage long wrap_sys_shmat (int shmid,char *shmaddr,int shmflg) {unsigned long raddr; -return sys_shmat (shmid,shmaddr,shmflg,&raddr) ?: (long )raddr; +return do_shmat (shmid,shmaddr,shmflg,&raddr) ?: (long )raddr; }asmlinkage long sys_time64 (long * tloc)
include/linux/shm.h +8 -1
@@ -90,7 +90,14 @@#define SHM_LOCKED 02000/* segment will not be swapped */ #define SHM_HUGETLB 04000/* segment will use huge TLB pages */ -long sys_shmat (int shmid,char __user *shmaddr,int shmflg,unsigned long *addr); +#ifdef CONFIG_SYSVIPC +long do_shmat (int shmid,char __user *shmaddr,int shmflg,unsigned long *addr); +#else +inline long do_shmat (int shmid,char __user *shmaddr,int shmflg,unsigned long *addr) +{ +return -ENOSYS ; +} +#endif 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);
Only in build-2.6/ipc: .Makefile.swp
ipc/shm.c +1 -1
@@ -635,7 +635,7 @@* "raddr" thing points to kernel space, and there has to be a wrapper around * this. */ -asmlinkage long sys_shmat (int shmid,char __user *shmaddr,int shmflg,ulong *raddr) +long do_shmat (int shmid,char __user *shmaddr,int shmflg,ulong *raddr) {struct shmid_kernel *shp;unsigned long addr;
kernel/sys.c +0 -1
@@ -258,7 +258,6 @@ cond_syscall(sys_msgrcv) cond_syscall(sys_msgctl) cond_syscall(sys_shmget) -cond_syscall(sys_shmat) cond_syscall(sys_shmdt) cond_syscall(sys_shmctl)
Quoted 9 lines · Manfred Spraul
Quoted 4 lines · Linus Torvalds
Please. Maybe it might even be worth-while renaming it to "
do_sys_shmat()" to make it clear that it's not a "sys_xxx()" at all.Below is a patch that renames
sys_shmattodo_shmat. Additionally, I've replaced thecond_syscallwith a conditional inline function.
It doesn't update arch/mips/kernel/scall64-64.S and arch/mips/kernel/scall64-n32.S?
I'd be inclined to leave it as sys_shmat(). It is logically a syscall, and the fact that everyone except mips (and ia64) sticks a multiplexer in front of it is a sad historical note.
It's simply a matter of getting the appropriate prototype in scope for all the C callers. For now, I'd be inclined to bung the prototype in kernel.h, because Randy's syscalls.h patches will fix all this for real in a week or two.
Quoted 4 lines
I'd be inclined to leave it as
sys_shmat(). It is logically a syscall, and the fact that everyone except mips (and ia64) sticks a multiplexer in front of it is a sad historical note.
I still live in hope that we break it back out into syscalls on ppc32/64 one day.
Anton
Quoted 3 lines · Manfred Spraul
Why?
sys_shmatis not a system call. Or at least there is a comment just before the implementation that this is not a syscall.
I think either the asmlinkage or the comment are wrong:
On 64bit mips kernels it's a syscall. On parics, too but they use a wrapper neverless.