summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmmar Faizi <ammarfaizi2@gnuweeb.org>2022-04-15 05:41:38 +0700
committerJens Axboe <axboe@kernel.dk>2022-04-18 09:24:08 -0600
commit2afb268164ba99ebe720add3632b4051651296b6 (patch)
tree43c88be2bb3afb5e98e92db0ca2eef5fd450639c
parentda2f4ce1722b38fcf72641fea0bf6a296f0cfdc0 (diff)
downloadliburing-2afb268164ba99ebe720add3632b4051651296b6.tar.gz
liburing-2afb268164ba99ebe720add3632b4051651296b6.tar.bz2
arch/syscall-defs: Use `__NR_mmap2` instead of `__NR_mmap` for x86 32-bit
A preparation to add x86 32-bit native syscall support for the nolibc build. On x86 32-bit, the __NR_mmap maps to sys_old_mmap: long sys_old_mmap(struct mmap_arg_struct __user *arg); which only receives one argument and is not suitable with the canonical mmap() definition we use. As such, use __NR_mmap2 that maps to sys_mmap_pgoff: long sys_mmap_pgoff(unsigned long addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff); Note: For __NR_mmap2, the offset must be shifted-right by 12-bit. Co-authored-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org> Signed-off-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org> Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Link: https://lore.kernel.org/r/20220414224001.187778-2-ammar.faizi@intel.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/arch/syscall-defs.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/arch/syscall-defs.h b/src/arch/syscall-defs.h
index f79f56a..1e8ae1b 100644
--- a/src/arch/syscall-defs.h
+++ b/src/arch/syscall-defs.h
@@ -6,8 +6,15 @@
static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset)
{
- return (void *) __do_syscall6(__NR_mmap, addr, length, prot, flags, fd,
- offset);
+ int nr;
+
+#if defined(__i386__)
+ nr = __NR_mmap2;
+ offset >>= 12;
+#else
+ nr = __NR_mmap;
+#endif
+ return (void *) __do_syscall6(nr, addr, length, prot, flags, fd, offset);
}
static inline int __sys_munmap(void *addr, size_t length)