Linux MIPS Architecture development
 help / color / mirror / Atom feed
* mmap is broken for MIPS64 n32 and o32 abis
@ 2008-09-19  6:31 Dinar Temirbulatov
  2008-09-19 10:14 ` Sergei Shtylyov
  2008-09-19 12:33 ` Maciej W. Rozycki
  0 siblings, 2 replies; 8+ messages in thread
From: Dinar Temirbulatov @ 2008-09-19  6:31 UTC (permalink / raw)
  To: linux-mips

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

Hi,
I noticed that mmap is not working properly under n32, o32 abis in
MIPS64, for example if we want to map 0xb6000000 address to the
userland under those abis we call  mmap and because the last argument
in old_mmap is off_t and this type is 64-bits wide for MIPS64, we end
up having for example 0xffffffffb6000000 address value. I am sure that
this is not a glibc issue. Following patch adds 32-bit version of mmap
and also it adds mmap64 support for n32 abi since mmap64 was
implemented correctly for n32 too.
                                          thanks, Dinar.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: mmap.patch --]
[-- Type: text/x-patch; name=mmap.patch, Size: 2682 bytes --]

diff -ruNp linux-2.6.27-rc6/arch/mips/kernel/scall64-n32.S linux-2.6.27-rc6-fix/arch/mips/kernel/scall64-n32.S
--- linux-2.6.27-rc6/arch/mips/kernel/scall64-n32.S	2008-09-19 09:34:42.000000000 +0400
+++ linux-2.6.27-rc6-fix/arch/mips/kernel/scall64-n32.S	2008-09-19 09:47:13.000000000 +0400
@@ -129,7 +129,7 @@ EXPORT(sysn32_call_table)
 	PTR	sys_newlstat
 	PTR	sys_poll
 	PTR	sys_lseek
-	PTR	old_mmap
+	PTR	sys32_mmap
 	PTR	sys_mprotect			/* 6010 */
 	PTR	sys_munmap
 	PTR	sys_brk
@@ -413,4 +413,5 @@ EXPORT(sysn32_call_table)
 	PTR	sys_dup3			/* 5290 */
 	PTR	sys_pipe2
 	PTR	sys_inotify_init1
+        PTR	sys32_mmap2
 	.size	sysn32_call_table,.-sysn32_call_table
diff -ruNp linux-2.6.27-rc6/arch/mips/kernel/scall64-o32.S linux-2.6.27-rc6-fix/arch/mips/kernel/scall64-o32.S
--- linux-2.6.27-rc6/arch/mips/kernel/scall64-o32.S	2008-09-19 09:34:42.000000000 +0400
+++ linux-2.6.27-rc6-fix/arch/mips/kernel/scall64-o32.S	2008-09-19 09:47:22.000000000 +0400
@@ -295,7 +295,7 @@ sys_call_table:
 	PTR	sys_swapon
 	PTR	sys_reboot
 	PTR	compat_sys_old_readdir
-	PTR	old_mmap			/* 4090 */
+	PTR	sys32_mmap			/* 4090 */
 	PTR	sys_munmap
 	PTR	sys_truncate
 	PTR	sys_ftruncate
diff -ruNp linux-2.6.27-rc6/arch/mips/kernel/syscall.c linux-2.6.27-rc6-fix/arch/mips/kernel/syscall.c
--- linux-2.6.27-rc6/arch/mips/kernel/syscall.c	2008-09-19 09:34:42.000000000 +0400
+++ linux-2.6.27-rc6-fix/arch/mips/kernel/syscall.c	2008-09-19 09:46:52.000000000 +0400
@@ -170,6 +170,22 @@ out:
 }
 
 asmlinkage unsigned long
+sys32_mmap(unsigned long addr, unsigned long len, int prot,
+        int flags, int fd, unsigned int offset offset)
+{
+        unsigned long result;
+
+        result = -EINVAL;
+        if (offset & ~PAGE_MASK)
+                goto out;
+
+        result = do_mmap2(addr, len, prot, flags, fd, (unsigned long) offset >> PAGE_SHIFT);
+
+out:
+        return result;
+}
+
+asmlinkage unsigned long
 sys_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
           unsigned long flags, unsigned long fd, unsigned long pgoff)
 {
diff -ruNp linux-2.6.27-rc6/include/asm-mips/unistd.h linux-2.6.27-rc6-fix/include/asm-mips/unistd.h
--- linux-2.6.27-rc6/include/asm-mips/unistd.h	2008-09-19 09:34:43.000000000 +0400
+++ linux-2.6.27-rc6-fix/include/asm-mips/unistd.h	2008-09-19 09:50:26.000000000 +0400
@@ -966,11 +966,12 @@
 #define __NR_dup3			(__NR_Linux + 290)
 #define __NR_pipe2			(__NR_Linux + 291)
 #define __NR_inotify_init1		(__NR_Linux + 292)
+#define __NR_mmap2			(__NR_Linux + 293)
 
 /*
  * Offset of the last N32 flavoured syscall
  */
-#define __NR_Linux_syscalls		292
+#define __NR_Linux_syscalls		293
 
 #endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
 

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

end of thread, other threads:[~2008-09-25 12:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-19  6:31 mmap is broken for MIPS64 n32 and o32 abis Dinar Temirbulatov
2008-09-19 10:14 ` Sergei Shtylyov
2008-09-19 12:33 ` Maciej W. Rozycki
2008-09-19 16:53   ` Dinar Temirbulatov
2008-09-19 17:25     ` Maciej W. Rozycki
2008-09-21 10:55       ` Dinar Temirbulatov
2008-09-23 12:32         ` Maciej W. Rozycki
2008-09-25 12:34           ` Dinar Temirbulatov

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