Re: mmap is broken for MIPS64 n32 and o32 abis

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 23, 2008 at 4:32 PM, Maciej W. Rozycki <macro@xxxxxxxxxxxxxx> wrote:

>  The problem is you cannot represent the file offset of 3053453312 or
> 0x00000000b6000000 using the 32-bit interface.  What you can represent is
> -1241513984 or 0xffffffffb6000000 and that is a valid offset for calls
> like lseek(), but not necessarily mmap() (though arguably we have a
> bug/feature in Linux where negative offsets are not explicitly checked for
> in mmap()).  To represent 3053453312 or 0x00000000b6000000 correctly you
> need to use the 64-bit interface LFS calls provide.  In this case that
> would be mmap64() or use _FILE_OFFSET_BITS as appropriate.
yes, this is correct, thanks Maciej.

but there is another problem on n32 abi, kernel does not provide
mmap64() system call for n32 and that results on following problem of
the glibc side: The generic implementation of __mmap64() returns an
error if the value passed in for the "offset" parameter is greater
than what can fit in a __off_t, which for  n32 is 2^32. This prevents
mmap64() from being used to map file offsets greater than 2^32 bytes
for n32.


I think this change is required:

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-25
16:21:52.000000000 +0400
@@ -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/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 */

                                             thanks, Dinar.


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux