From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Ammar Faizi <[email protected]>,
io-uring Mailing List <[email protected]>,
GNU/Weeb Mailing List <[email protected]>,
Pavel Begunkov <[email protected]>,
Alviro Iskandar Setiawan <[email protected]>
Subject: [PATCH liburing 1/3] arch/syscall-defs: Use `__NR_mmap2` instead of `__NR_mmap` for x86 32-bit
Date: Fri, 15 Apr 2022 05:41:38 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
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 <[email protected]>
Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
src/arch/syscall-defs.h | 11 +++++++++--
1 file 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)
--
Ammar Faizi
next prev parent reply other threads:[~2022-04-14 22:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-14 22:41 [PATCH liburing 0/3] Add x86 32-bit support for the nolibc build Ammar Faizi
2022-04-14 22:41 ` Ammar Faizi [this message]
2022-04-14 22:41 ` [PATCH liburing 2/3] arch/x86/lib: Provide `get_page_size()` function for x86 32-bit Ammar Faizi
2022-04-14 22:41 ` [PATCH liburing 3/3] arch/x86/syscall: Add x86 32-bit native syscall support Ammar Faizi
2022-04-18 2:01 ` [PATCH liburing 0/3] Add x86 32-bit support for the nolibc build Jens Axboe
2022-04-18 14:14 ` Ammar Faizi
2022-04-18 15:23 ` Jens Axboe
2022-04-18 15:24 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox