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.
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 */