All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix some system calls with long long arguments
@ 2007-03-06 15:39 Atsushi Nemoto
  2007-03-07 14:14 ` Atsushi Nemoto
  0 siblings, 1 reply; 10+ messages in thread
From: Atsushi Nemoto @ 2007-03-06 15:39 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf, kraj

fadvise64(), readahead(), sync_file_range() have long long argument(s)
but glibc passes it by hi/lo pair without padding, on both O32 and
N32.

Also wire up fadvise64_64() and fixup confusion of it with
fadvise64().

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 arch/mips/kernel/linux32.c     |   16 ----------------
 arch/mips/kernel/scall32-o32.S |    7 ++++---
 arch/mips/kernel/scall64-n32.S |    5 +++--
 arch/mips/kernel/scall64-o32.S |    3 ++-
 arch/mips/kernel/syscall.c     |   33 +++++++++++++++++++++++++++++++++
 include/asm-mips/unistd.h      |   10 ++++++----
 6 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 30d433f..71e1524 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -528,22 +528,6 @@ asmlinkage int sys32_sendfile(int out_fd
 	return ret;
 }
 
-asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3,
-                                   size_t count)
-{
-	return sys_readahead(fd, merge_64(a2, a3), count);
-}
-
-asmlinkage long sys32_sync_file_range(int fd, int __pad,
-	unsigned long a2, unsigned long a3,
-	unsigned long a4, unsigned long a5,
-	int flags)
-{
-	return sys_sync_file_range(fd,
-			merge_64(a2, a3), merge_64(a4, a5),
-			flags);
-}
-
 save_static_function(sys32_clone);
 __attribute_used__ noinline static int
 _sys32_clone(nabi_no_regargs struct pt_regs regs)
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 7c0b393..b898a7c 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -554,7 +554,7 @@ einval:	li	v0, -EINVAL
 	sys	sys_fcntl64		3	/* 4220 */
 	sys	sys_ni_syscall		0
 	sys	sys_gettid		0
-	sys	sys_readahead		5
+	sys	sys32_readahead		4
 	sys	sys_setxattr		5
 	sys	sys_lsetxattr		5	/* 4225 */
 	sys	sys_fsetxattr		5
@@ -596,7 +596,7 @@ einval:	li	v0, -EINVAL
 	sys	sys_remap_file_pages	5
 	sys	sys_set_tid_address	1
 	sys	sys_restart_syscall	0
-	sys	sys_fadvise64_64	7
+	sys	sys32_fadvise64		5
 	sys	sys_statfs64		3	/* 4255 */
 	sys	sys_fstatfs64		2
 	sys	sys_timer_create	3
@@ -647,7 +647,7 @@ einval:	li	v0, -EINVAL
 	sys	sys_ppoll		5
 	sys	sys_unshare		1
 	sys	sys_splice		4
-	sys	sys_sync_file_range	7	/* 4305 */
+	sys	sys32_sync_file_range	6	/* 4305 */
 	sys	sys_tee			4
 	sys	sys_vmsplice		4
 	sys	sys_move_pages		6
@@ -656,6 +656,7 @@ einval:	li	v0, -EINVAL
 	sys	sys_kexec_load		4
 	sys	sys_getcpu		3
 	sys	sys_epoll_pwait		6
+	sys	sys32_fadvise64_64	6
 	.endm
 
 	/* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index f17e31e..c554f28 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -336,7 +336,7 @@ EXPORT(sysn32_call_table)
 	PTR	sys_set_tid_address
 	PTR	sys_restart_syscall
 	PTR	compat_sys_semtimedop			/* 6215 */
-	PTR	sys_fadvise64_64
+	PTR	sys32_fadvise64
 	PTR	compat_sys_statfs64
 	PTR	compat_sys_fstatfs64
 	PTR	sys_sendfile64
@@ -388,7 +388,7 @@ EXPORT(sysn32_call_table)
 	PTR	sys_ppoll			/* 6265 */
 	PTR	sys_unshare
 	PTR	sys_splice
-	PTR	sys_sync_file_range
+	PTR	sys32_sync_file_range
 	PTR	sys_tee
 	PTR	sys_vmsplice			/* 6270 */
 	PTR	sys_move_pages
@@ -397,3 +397,4 @@ EXPORT(sysn32_call_table)
 	PTR	compat_sys_kexec_load
 	PTR	sys_getcpu
 	PTR	compat_sys_epoll_pwait
+	PTR	sys32_fadvise64_64
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 142c9b7..5b7ca00 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -459,7 +459,7 @@ sys_call_table:
 	PTR	sys_remap_file_pages
 	PTR	sys_set_tid_address
 	PTR	sys_restart_syscall
-	PTR	sys_fadvise64_64
+	PTR	sys32_fadvise64
 	PTR	compat_sys_statfs64		/* 4255 */
 	PTR	compat_sys_fstatfs64
 	PTR	compat_sys_timer_create
@@ -519,4 +519,5 @@ sys_call_table:
 	PTR	compat_sys_kexec_load
 	PTR	sys_getcpu
 	PTR	compat_sys_epoll_pwait
+	PTR	sys32_fadvise64_64
 	.size	sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 26e1a7e..6e107fc 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -435,3 +435,36 @@ int kernel_execve(const char *filename,
 
 	return -__v0;
 }
+
+#if defined(CONFIG_32BIT) || defined(CONFIG_MIPS32_COMPAT)
+#ifdef __BIG_ENDIAN
+#define merge_64(r1,r2)	(((u64)(r1) << 32) + ((u32)(r2)))
+#else
+#define merge_64(r1,r2)	(((u64)(r2) << 32) + ((u32)(r1)))
+#endif
+asmlinkage long sys32_fadvise64_64(int fd, long a1, long a2, long a3, long a4,
+	int advice)
+{
+	return sys_fadvise64_64(fd, merge_64(a1, a2), merge_64(a3, a4),
+				advice);
+}
+
+asmlinkage long sys32_fadvise64(int fd, long a1, long a2, size_t len,
+	int advice)
+{
+	return sys_fadvise64_64(fd, merge_64(a1, a2), len, advice);
+}
+
+asmlinkage ssize_t sys32_readahead(int fd, long a1, long a2, size_t count)
+{
+	return sys_readahead(fd, merge_64(a1, a2), count);
+}
+
+asmlinkage long sys32_sync_file_range(int fd, long a1, long a2,
+	long a3, long a4, unsigned int flags)
+{
+	return sys_sync_file_range(fd, merge_64(a1, a2), merge_64(a3, a4),
+				   flags);
+}
+
+#endif
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index 696cff3..949e956 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -334,16 +334,17 @@
 #define __NR_kexec_load			(__NR_Linux + 311)
 #define __NR_getcpu			(__NR_Linux + 312)
 #define __NR_epoll_pwait		(__NR_Linux + 313)
+#define __NR_fadvise64_64		(__NR_Linux + 314)
 
 /*
  * Offset of the last Linux o32 flavoured syscall
  */
-#define __NR_Linux_syscalls		313
+#define __NR_Linux_syscalls		314
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
 
 #define __NR_O32_Linux			4000
-#define __NR_O32_Linux_syscalls		313
+#define __NR_O32_Linux_syscalls		314
 
 #if _MIPS_SIM == _MIPS_SIM_ABI64
 
@@ -918,16 +919,17 @@
 #define __NR_kexec_load			(__NR_Linux + 274)
 #define __NR_getcpu			(__NR_Linux + 275)
 #define __NR_epoll_pwait		(__NR_Linux + 276)
+#define __NR_fadvise64_64		(__NR_Linux + 277)
 
 /*
  * Offset of the last N32 flavoured syscall
  */
-#define __NR_Linux_syscalls		276
+#define __NR_Linux_syscalls		277
 
 #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
 
 #define __NR_N32_Linux			6000
-#define __NR_N32_Linux_syscalls		276
+#define __NR_N32_Linux_syscalls		277
 
 #ifdef __KERNEL__
 

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-03-06 15:39 [PATCH] Fix some system calls with long long arguments Atsushi Nemoto
@ 2007-03-07 14:14 ` Atsushi Nemoto
  2007-03-08 15:37   ` Atsushi Nemoto
  0 siblings, 1 reply; 10+ messages in thread
From: Atsushi Nemoto @ 2007-03-07 14:14 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf, kraj

Revised, renumbering __NR_fadvise64_64.


Subject: [PATCH] Fix some system calls with long long arguments

fadvise64(), readahead(), sync_file_range() have long long argument(s)
but glibc passes it by hi/lo pair without padding, on both O32 and
N32.

Also wire up fadvise64_64() and fixup confusion of it with
fadvise64().

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 arch/mips/kernel/linux32.c     |   16 ----------------
 arch/mips/kernel/scall32-o32.S |    7 ++++---
 arch/mips/kernel/scall64-n32.S |    5 +++--
 arch/mips/kernel/scall64-o32.S |    3 ++-
 arch/mips/kernel/syscall.c     |   33 +++++++++++++++++++++++++++++++++
 include/asm-mips/unistd.h      |   10 ++++++----
 6 files changed, 48 insertions(+), 26 deletions(-)

diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 30d433f..71e1524 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -528,22 +528,6 @@ asmlinkage int sys32_sendfile(int out_fd
 	return ret;
 }
 
-asmlinkage ssize_t sys32_readahead(int fd, u32 pad0, u64 a2, u64 a3,
-                                   size_t count)
-{
-	return sys_readahead(fd, merge_64(a2, a3), count);
-}
-
-asmlinkage long sys32_sync_file_range(int fd, int __pad,
-	unsigned long a2, unsigned long a3,
-	unsigned long a4, unsigned long a5,
-	int flags)
-{
-	return sys_sync_file_range(fd,
-			merge_64(a2, a3), merge_64(a4, a5),
-			flags);
-}
-
 save_static_function(sys32_clone);
 __attribute_used__ noinline static int
 _sys32_clone(nabi_no_regargs struct pt_regs regs)
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 0c9a9ff..aa02a68 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -554,7 +554,7 @@ einval:	li	v0, -EINVAL
 	sys	sys_fcntl64		3	/* 4220 */
 	sys	sys_ni_syscall		0
 	sys	sys_gettid		0
-	sys	sys_readahead		5
+	sys	sys32_readahead		4
 	sys	sys_setxattr		5
 	sys	sys_lsetxattr		5	/* 4225 */
 	sys	sys_fsetxattr		5
@@ -596,7 +596,7 @@ einval:	li	v0, -EINVAL
 	sys	sys_remap_file_pages	5
 	sys	sys_set_tid_address	1
 	sys	sys_restart_syscall	0
-	sys	sys_fadvise64_64	7
+	sys	sys32_fadvise64		5
 	sys	sys_statfs64		3	/* 4255 */
 	sys	sys_fstatfs64		2
 	sys	sys_timer_create	3
@@ -647,7 +647,7 @@ einval:	li	v0, -EINVAL
 	sys	sys_ppoll		5
 	sys	sys_unshare		1
 	sys	sys_splice		4
-	sys	sys_sync_file_range	7	/* 4305 */
+	sys	sys32_sync_file_range	6	/* 4305 */
 	sys	sys_tee			4
 	sys	sys_vmsplice		4
 	sys	sys_move_pages		6
@@ -658,6 +658,7 @@ einval:	li	v0, -EINVAL
 	sys	sys_epoll_pwait		6
 	sys	sys_ioprio_set		3
 	sys	sys_ioprio_get		2
+	sys	sys32_fadvise64_64	6
 	.endm
 
 	/* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 6eac283..e65dbf6 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -336,7 +336,7 @@ EXPORT(sysn32_call_table)
 	PTR	sys_set_tid_address
 	PTR	sys_restart_syscall
 	PTR	compat_sys_semtimedop			/* 6215 */
-	PTR	sys_fadvise64_64
+	PTR	sys32_fadvise64
 	PTR	compat_sys_statfs64
 	PTR	compat_sys_fstatfs64
 	PTR	sys_sendfile64
@@ -388,7 +388,7 @@ EXPORT(sysn32_call_table)
 	PTR	sys_ppoll			/* 6265 */
 	PTR	sys_unshare
 	PTR	sys_splice
-	PTR	sys_sync_file_range
+	PTR	sys32_sync_file_range
 	PTR	sys_tee
 	PTR	sys_vmsplice			/* 6270 */
 	PTR	sys_move_pages
@@ -399,4 +399,5 @@ EXPORT(sysn32_call_table)
 	PTR	compat_sys_epoll_pwait
 	PTR	sys_ioprio_set
 	PTR	sys_ioprio_get
+	PTR	sys32_fadvise64_64
 	.size	sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 7e74b41..7d797da 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -459,7 +459,7 @@ sys_call_table:
 	PTR	sys_remap_file_pages
 	PTR	sys_set_tid_address
 	PTR	sys_restart_syscall
-	PTR	sys_fadvise64_64
+	PTR	sys32_fadvise64
 	PTR	compat_sys_statfs64		/* 4255 */
 	PTR	compat_sys_fstatfs64
 	PTR	compat_sys_timer_create
@@ -521,4 +521,5 @@ sys_call_table:
 	PTR	compat_sys_epoll_pwait
 	PTR	sys_ioprio_set
 	PTR	sys_ioprio_get			/* 4315 */
+	PTR	sys32_fadvise64_64
 	.size	sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 26e1a7e..6e107fc 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -435,3 +435,36 @@ int kernel_execve(const char *filename,
 
 	return -__v0;
 }
+
+#if defined(CONFIG_32BIT) || defined(CONFIG_MIPS32_COMPAT)
+#ifdef __BIG_ENDIAN
+#define merge_64(r1,r2)	(((u64)(r1) << 32) + ((u32)(r2)))
+#else
+#define merge_64(r1,r2)	(((u64)(r2) << 32) + ((u32)(r1)))
+#endif
+asmlinkage long sys32_fadvise64_64(int fd, long a1, long a2, long a3, long a4,
+	int advice)
+{
+	return sys_fadvise64_64(fd, merge_64(a1, a2), merge_64(a3, a4),
+				advice);
+}
+
+asmlinkage long sys32_fadvise64(int fd, long a1, long a2, size_t len,
+	int advice)
+{
+	return sys_fadvise64_64(fd, merge_64(a1, a2), len, advice);
+}
+
+asmlinkage ssize_t sys32_readahead(int fd, long a1, long a2, size_t count)
+{
+	return sys_readahead(fd, merge_64(a1, a2), count);
+}
+
+asmlinkage long sys32_sync_file_range(int fd, long a1, long a2,
+	long a3, long a4, unsigned int flags)
+{
+	return sys_sync_file_range(fd, merge_64(a1, a2), merge_64(a3, a4),
+				   flags);
+}
+
+#endif
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index 2f1087b..93b17ac 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -336,16 +336,17 @@
 #define __NR_epoll_pwait		(__NR_Linux + 313)
 #define __NR_ioprio_set			(__NR_Linux + 314)
 #define __NR_ioprio_get			(__NR_Linux + 315)
+#define __NR_fadvise64_64		(__NR_Linux + 316)
 
 /*
  * Offset of the last Linux o32 flavoured syscall
  */
-#define __NR_Linux_syscalls		315
+#define __NR_Linux_syscalls		316
 
 #endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
 
 #define __NR_O32_Linux			4000
-#define __NR_O32_Linux_syscalls		315
+#define __NR_O32_Linux_syscalls		316
 
 #if _MIPS_SIM == _MIPS_SIM_ABI64
 
@@ -924,16 +925,17 @@
 #define __NR_epoll_pwait		(__NR_Linux + 276)
 #define __NR_ioprio_set			(__NR_Linux + 277)
 #define __NR_ioprio_get			(__NR_Linux + 278)
+#define __NR_fadvise64_64		(__NR_Linux + 279)
 
 /*
  * Offset of the last N32 flavoured syscall
  */
-#define __NR_Linux_syscalls		278
+#define __NR_Linux_syscalls		279
 
 #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
 
 #define __NR_N32_Linux			6000
-#define __NR_N32_Linux_syscalls		278
+#define __NR_N32_Linux_syscalls		279
 
 #ifdef __KERNEL__
 

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-03-07 14:14 ` Atsushi Nemoto
@ 2007-03-08 15:37   ` Atsushi Nemoto
  2007-03-15  1:35     ` Atsushi Nemoto
  0 siblings, 1 reply; 10+ messages in thread
From: Atsushi Nemoto @ 2007-03-08 15:37 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf, kraj, libc-ports

On Wed, 07 Mar 2007 23:14:10 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> fadvise64(), readahead(), sync_file_range() have long long argument(s)
> but glibc passes it by hi/lo pair without padding, on both O32 and
> N32.
> 
> Also wire up fadvise64_64() and fixup confusion of it with
> fadvise64().

If best performance was preferred, the O32 readahead and
sync_file_range should not changed and libc should provide MIPS
specific syscall wrappers, like pread64.  The N32 can also use
standard sys_readahead(), etc. and libc should provide wrappers, too.

Anyway fadvice64() needs to be fixed.

Any comments from libc side?  Original patch is here:
http://www.linux-mips.org/archives/linux-mips/2007-03/msg00092.html

---
Atsushi Nemoto

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-03-08 15:37   ` Atsushi Nemoto
@ 2007-03-15  1:35     ` Atsushi Nemoto
  2007-03-15 16:33       ` Atsushi Nemoto
  2007-03-15 16:53       ` Atsushi Nemoto
  0 siblings, 2 replies; 10+ messages in thread
From: Atsushi Nemoto @ 2007-03-15  1:35 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf, kraj, libc-ports

On Fri, 09 Mar 2007 00:37:49 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> > fadvise64(), readahead(), sync_file_range() have long long argument(s)
> > but glibc passes it by hi/lo pair without padding, on both O32 and
> > N32.
> > 
> > Also wire up fadvise64_64() and fixup confusion of it with
> > fadvise64().
> 
> If best performance was preferred, the O32 readahead and
> sync_file_range should not changed and libc should provide MIPS
> specific syscall wrappers, like pread64.  The N32 can also use
> standard sys_readahead(), etc. and libc should provide wrappers, too.
> 
> Anyway fadvice64() needs to be fixed.
> 
> Any comments from libc side?  Original patch is here:
> http://www.linux-mips.org/archives/linux-mips/2007-03/msg00092.html

Any comments?

I think this patch has less maintainance cost but a little bit slow.

These syscalls can be a little bit faster, but needs more works on
glibc (and uClibc, etc.) side.

Anyway we should take some action while current implementation is
broken (except N64).

Which is a way to go?

---
Atsushi Nemoto

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-03-15  1:35     ` Atsushi Nemoto
@ 2007-03-15 16:33       ` Atsushi Nemoto
  2007-03-15 16:53       ` Atsushi Nemoto
  1 sibling, 0 replies; 10+ messages in thread
From: Atsushi Nemoto @ 2007-03-15 16:33 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf, kraj, libc-ports

On Thu, 15 Mar 2007 10:35:11 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> > > fadvise64(), readahead(), sync_file_range() have long long argument(s)
> > > but glibc passes it by hi/lo pair without padding, on both O32 and
> > > N32.

BTW, I can not find sync_file_range symbol in my libc.so.  There is
sysdeps/unix/sysv/linux/sync_file_range.c but it seems not built into
library.

Is this a correct fix?

--- glibc-2.5.org/sysdeps/unix/sysv/linux/Makefile	2006-04-26 04:12:04.000000000 +0900
+++ glibc-2.5/sysdeps/unix/sysv/linux/Makefile	2007-03-16 01:25:28.654940581 +0900
@@ -13,7 +13,7 @@
 
 ifeq ($(subdir),misc)
 sysdep_routines += sysctl clone llseek umount umount2 readahead \
-		   setfsuid setfsgid makedev
+		   setfsuid setfsgid makedev sync_file_range
 
 CFLAGS-gethostid.c = -fexceptions
 

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-03-15  1:35     ` Atsushi Nemoto
  2007-03-15 16:33       ` Atsushi Nemoto
@ 2007-03-15 16:53       ` Atsushi Nemoto
  2007-05-17 15:46         ` Atsushi Nemoto
  1 sibling, 1 reply; 10+ messages in thread
From: Atsushi Nemoto @ 2007-03-15 16:53 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf, kraj, libc-ports

On Thu, 15 Mar 2007 10:35:11 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> I think this patch has less maintainance cost but a little bit slow.
> 
> These syscalls can be a little bit faster, but needs more works on
> glibc (and uClibc, etc.) side.
> 
> Anyway we should take some action while current implementation is
> broken (except N64).
> 
> Which is a way to go?

Here is a sample fix for N32 readahead and sync_file_range.

For kernel:
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -299,7 +299,7 @@ EXPORT(sysn32_call_table)
 	PTR	sys_ni_syscall			/* res. for afs_syscall */
 	PTR	sys_ni_syscall			/* res. for security */
 	PTR	sys_gettid
-	PTR	sys32_readahead
+	PTR	sys_readahead
 	PTR	sys_setxattr			/* 6180 */
 	PTR	sys_lsetxattr
 	PTR	sys_fsetxattr

For glibc:
--- glibc-ports-2.5.org/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list	1970-01-01 09:00:00.000000000 +0900
+++ glibc-ports-2.5/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list	2007-03-16 00:24:21.000000000 +0900
@@ -0,0 +1,4 @@
+# File name	Caller	Syscall name	# args	Strong name	Weak names
+
+readahead	-	readahead	i:iii	__readahead	readahead
+sync_file_range	-	sync_file_range	i:iiii	sync_file_range


Is this approach preferred?

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-03-15 16:53       ` Atsushi Nemoto
@ 2007-05-17 15:46         ` Atsushi Nemoto
  2007-05-17 15:47           ` Atsushi Nemoto
  0 siblings, 1 reply; 10+ messages in thread
From: Atsushi Nemoto @ 2007-05-17 15:46 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf, kraj, libc-ports

On Fri, 16 Mar 2007 01:53:25 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> > Anyway we should take some action while current implementation is
> > broken (except N64).
> > 
> > Which is a way to go?
> 
> Here is a sample fix for N32 readahead and sync_file_range.

I fixed N32/O32 readahead, sync_file_range, fadvise, fadvise64
syscalls on both kernel and glibc side.

Here is a kernel side fixes.


Subject: [PATCH] Fix some system calls with long long arguments

* O32 fadvise64() pass long long arguments by register pairs.  Add
  sys32 version for 64 bit kernel.
* N32 readahead() can pass a long long argument by one register.  No
  need to use sys32_readahead.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
 arch/mips/kernel/linux32.c     |   10 ++++++++++
 arch/mips/kernel/scall64-n32.S |    2 +-
 arch/mips/kernel/scall64-o32.S |    2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 37849ed..06e04da 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -556,6 +556,16 @@ asmlinkage long sys32_sync_file_range(int fd, int __pad,
 			flags);
 }
 
+asmlinkage long sys32_fadvise64_64(int fd, int __pad,
+	unsigned long a2, unsigned long a3,
+	unsigned long a4, unsigned long a5,
+	int flags)
+{
+	return sys_fadvise64_64(fd,
+			merge_64(a2, a3), merge_64(a4, a5),
+			flags);
+}
+
 save_static_function(sys32_clone);
 __attribute_used__ noinline static int
 _sys32_clone(nabi_no_regargs struct pt_regs regs)
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 6eac283..1631035 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -299,7 +299,7 @@ EXPORT(sysn32_call_table)
 	PTR	sys_ni_syscall			/* res. for afs_syscall */
 	PTR	sys_ni_syscall			/* res. for security */
 	PTR	sys_gettid
-	PTR	sys32_readahead
+	PTR	sys_readahead
 	PTR	sys_setxattr			/* 6180 */
 	PTR	sys_lsetxattr
 	PTR	sys_fsetxattr
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 7e74b41..2aa9942 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -459,7 +459,7 @@ sys_call_table:
 	PTR	sys_remap_file_pages
 	PTR	sys_set_tid_address
 	PTR	sys_restart_syscall
-	PTR	sys_fadvise64_64
+	PTR	sys32_fadvise64_64
 	PTR	compat_sys_statfs64		/* 4255 */
 	PTR	compat_sys_fstatfs64
 	PTR	compat_sys_timer_create

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-05-17 15:46         ` Atsushi Nemoto
@ 2007-05-17 15:47           ` Atsushi Nemoto
  2007-05-21  4:38             ` Atsushi Nemoto
  2007-05-23 17:26             ` Daniel Jacobowitz
  0 siblings, 2 replies; 10+ messages in thread
From: Atsushi Nemoto @ 2007-05-17 15:47 UTC (permalink / raw)
  To: linux-mips; +Cc: ralf, kraj, libc-ports

On Fri, 18 May 2007 00:46:13 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> I fixed N32/O32 readahead, sync_file_range, fadvise, fadvise64
> syscalls on both kernel and glibc side.
> 
> Here is a kernel side fixes.

And here is glibc side fixes for posix_fadvise, posix_fadvise64,
readahead, sync_file_range.  For O32, add a padding before a long long
argument pair.  For N32, pass a long long value by one argument.  O32
readahead borrows ARM EABI implementation.  N32 posix_fadvise64 use C
implementation (instead of syscalls.list) for versioned symbols.


2007-05-18  Atsushi Nemoto  <anemo@mba.ocn.ne.jp>

	* sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c: New file.
	* sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise64.c: New file.
	* sysdeps/unix/sysv/linux/mips/mips32/readahead.c: New file.
	* sysdeps/unix/sysv/linux/mips/mips32/sync_file_range.c: New file.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fadvise64.c: New file.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list: New file.

diff -urNp glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c
--- glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c	1970-01-01 09:00:00.000000000 +0900
+++ glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c	2007-05-17 11:06:49.000000000 +0900
@@ -0,0 +1,42 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sysdep.h>
+
+/* Advice the system about the expected behaviour of the application with
+   respect to the file associated with FD.  */
+
+int
+posix_fadvise (int fd, off_t offset, off_t len, int advise)
+{
+/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
+#ifdef __NR_fadvise64
+  INTERNAL_SYSCALL_DECL (err);
+  int ret = INTERNAL_SYSCALL (fadvise64, err, 7, fd, 0,
+			      __LONG_LONG_PAIR (offset >> 31, offset),
+			      __LONG_LONG_PAIR (offset >> 31, len),
+			      advise);
+  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+    return INTERNAL_SYSCALL_ERRNO (ret, err);
+  return 0;
+#else
+  return ENOSYS;
+#endif
+}
diff -urNp glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise64.c glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise64.c
--- glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise64.c	1970-01-01 09:00:00.000000000 +0900
+++ glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise64.c	2007-05-17 13:05:31.000000000 +0900
@@ -0,0 +1,61 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sysdep.h>
+
+/* Advice the system about the expected behaviour of the application with
+   respect to the file associated with FD.  */
+
+int
+__posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
+{
+/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
+#ifdef __NR_fadvise64
+  INTERNAL_SYSCALL_DECL (err);
+  int ret = INTERNAL_SYSCALL (fadvise64, err, 7, fd, 0,
+			      __LONG_LONG_PAIR ((long) (offset >> 32),
+						(long) offset),
+			      __LONG_LONG_PAIR ((long) (len >> 32),
+						(long) len),
+			      advise);
+  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+    return INTERNAL_SYSCALL_ERRNO (ret, err);
+  return 0;
+#else
+  return ENOSYS;
+#endif
+}
+
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3)
+
+int
+attribute_compat_text_section
+__posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise)
+{
+  return __posix_fadvise64_l64 (fd, offset, len, advise);
+}
+
+versioned_symbol (libc, __posix_fadvise64_l64, posix_fadvise64, GLIBC_2_3_3);
+compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2);
+#else
+strong_alias (__posix_fadvise64_l64, posix_fadvise64);
+#endif
diff -urNp glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips32/readahead.c glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/readahead.c
--- glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips32/readahead.c	1970-01-01 09:00:00.000000000 +0900
+++ glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/readahead.c	2007-05-17 11:06:43.000000000 +0900
@@ -0,0 +1 @@
+#include <sysdeps/unix/sysv/linux/arm/eabi/readahead.c>
diff -urNp glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips32/sync_file_range.c glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/sync_file_range.c
--- glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips32/sync_file_range.c	1970-01-01 09:00:00.000000000 +0900
+++ glibc-ports/sysdeps/unix/sysv/linux/mips/mips32/sync_file_range.c	2007-05-17 11:06:37.000000000 +0900
@@ -0,0 +1,47 @@
+/* Selective file content synch'ing.
+   Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/types.h>
+
+#include <sysdep.h>
+#include <sys/syscall.h>
+
+
+#ifdef __NR_sync_file_range
+int
+sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags)
+{
+  return INLINE_SYSCALL (sync_file_range, 7, fd, 0,
+			 __LONG_LONG_PAIR ((long) (from >> 32), (long) from),
+			 __LONG_LONG_PAIR ((long) (to >> 32), (long) to),
+			 flags);
+}
+#else
+int
+sync_file_range (int fd, __off64_t from, __off64_t to, unsigned int flags)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (sync_file_range)
+
+# include <stub-tag.h>
+#endif
diff -urNp glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fadvise64.c glibc-ports/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fadvise64.c
--- glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fadvise64.c	1970-01-01 09:00:00.000000000 +0900
+++ glibc-ports/sysdeps/unix/sysv/linux/mips/mips64/n32/posix_fadvise64.c	2007-05-17 16:05:25.000000000 +0900
@@ -0,0 +1,56 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sysdep.h>
+
+/* Advice the system about the expected behaviour of the application with
+   respect to the file associated with FD.  */
+
+int
+__posix_fadvise64_l64 (int fd, off64_t offset, off64_t len, int advise)
+{
+/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
+#ifdef __NR_fadvise64
+  INTERNAL_SYSCALL_DECL (err);
+  int ret = INTERNAL_SYSCALL (fadvise64, err, 4, fd, offset, len, advise);
+  if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+    return INTERNAL_SYSCALL_ERRNO (ret, err);
+  return 0;
+#else
+  return ENOSYS;
+#endif
+}
+
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT(libc, GLIBC_2_2, GLIBC_2_3_3)
+
+int
+attribute_compat_text_section
+__posix_fadvise64_l32 (int fd, off64_t offset, size_t len, int advise)
+{
+  return __posix_fadvise64_l64 (fd, offset, len, advise);
+}
+
+versioned_symbol (libc, __posix_fadvise64_l64, posix_fadvise64, GLIBC_2_3_3);
+compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2);
+#else
+strong_alias (__posix_fadvise64_l64, posix_fadvise64);
+#endif
diff -urNp glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list glibc-ports/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list
--- glibc-ports.org/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list	1970-01-01 09:00:00.000000000 +0900
+++ glibc-ports/sysdeps/unix/sysv/linux/mips/mips64/n32/syscalls.list	2007-05-17 15:08:16.000000000 +0900
@@ -0,0 +1,5 @@
+# File name	Caller	Syscall name	# args	Strong name	Weak names
+
+readahead	-	readahead	i:iii	__readahead	readahead
+sync_file_range	-	sync_file_range	i:iiii	sync_file_range
+posix_fadvise	-	fadvise64	i:iiii	posix_fadvise

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-05-17 15:47           ` Atsushi Nemoto
@ 2007-05-21  4:38             ` Atsushi Nemoto
  2007-05-23 17:26             ` Daniel Jacobowitz
  1 sibling, 0 replies; 10+ messages in thread
From: Atsushi Nemoto @ 2007-05-21  4:38 UTC (permalink / raw)
  To: libc-ports; +Cc: linux-mips, ralf, kraj, drow

On Fri, 18 May 2007 00:47:59 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> And here is glibc side fixes for posix_fadvise, posix_fadvise64,
> readahead, sync_file_range.  For O32, add a padding before a long long
> argument pair.  For N32, pass a long long value by one argument.  O32
> readahead borrows ARM EABI implementation.  N32 posix_fadvise64 use C
> implementation (instead of syscalls.list) for versioned symbols.

I filed it at glibc bugzilla:

http://sources.redhat.com/bugzilla/show_bug.cgi?id=4526

---
Atsushi Nemoto

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

* Re: [PATCH] Fix some system calls with long long arguments
  2007-05-17 15:47           ` Atsushi Nemoto
  2007-05-21  4:38             ` Atsushi Nemoto
@ 2007-05-23 17:26             ` Daniel Jacobowitz
  1 sibling, 0 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2007-05-23 17:26 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips, ralf, kraj, libc-ports

On Fri, May 18, 2007 at 12:47:59AM +0900, Atsushi Nemoto wrote:
> On Fri, 18 May 2007 00:46:13 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> > I fixed N32/O32 readahead, sync_file_range, fadvise, fadvise64
> > syscalls on both kernel and glibc side.
> > 
> > Here is a kernel side fixes.
> 
> And here is glibc side fixes for posix_fadvise, posix_fadvise64,
> readahead, sync_file_range.  For O32, add a padding before a long long
> argument pair.  For N32, pass a long long value by one argument.  O32
> readahead borrows ARM EABI implementation.  N32 posix_fadvise64 use C
> implementation (instead of syscalls.list) for versioned symbols.

I see the kernel patch was already merged; I've added this to CVS.

-- 
Daniel Jacobowitz
CodeSourcery

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

end of thread, other threads:[~2007-05-23 17:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-06 15:39 [PATCH] Fix some system calls with long long arguments Atsushi Nemoto
2007-03-07 14:14 ` Atsushi Nemoto
2007-03-08 15:37   ` Atsushi Nemoto
2007-03-15  1:35     ` Atsushi Nemoto
2007-03-15 16:33       ` Atsushi Nemoto
2007-03-15 16:53       ` Atsushi Nemoto
2007-05-17 15:46         ` Atsushi Nemoto
2007-05-17 15:47           ` Atsushi Nemoto
2007-05-21  4:38             ` Atsushi Nemoto
2007-05-23 17:26             ` Daniel Jacobowitz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.