From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, Riku Voipio <riku.voipio@iki.fi>
Subject: [Qemu-devel] [PATCH 2/3] linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests
Date: Tue, 31 May 2016 15:45:10 +0100 [thread overview]
Message-ID: <1464705911-28960-3-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1464705911-28960-1-git-send-email-peter.maydell@linaro.org>
Fix errors in the implementation of NR_fadvise64 and NR_fadvise64_64
for 32-bit guests, which pass their off_t values in register pairs.
We can't use the 64-bit code path for this, so split out the 32-bit
cases, so that we can correctly handle the "only offset is 64-bit"
and "both offset and length are 64-bit" syscall flavours, and
"uses aligned register pairs" and "does not" flavours of target.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
linux-user/syscall.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4894919..638b455 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9340,6 +9340,44 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = -host_to_target_errno(ret);
break;
#endif
+
+#if TARGET_ABI_BITS == 32
+
+#ifdef TARGET_NR_fadvise64_64
+ case TARGET_NR_fadvise64_64:
+ /* 6 args: fd, offset (high, low), len (high, low), advice */
+ if (regpairs_aligned(cpu_env)) {
+ /* offset is in (3,4), len in (5,6) and advice in 7 */
+ arg2 = arg3;
+ arg3 = arg4;
+ arg4 = arg5;
+ arg5 = arg6;
+ arg6 = arg7;
+ }
+ ret = -host_to_target_errno(posix_fadvise(arg1,
+ target_offset64(arg2, arg3),
+ target_offset64(arg4, arg5),
+ arg6));
+ break;
+#endif
+
+#ifdef TARGET_NR_fadvise64
+ case TARGET_NR_fadvise64:
+ /* 5 args: fd, offset (high, low), len, advice */
+ if (regpairs_aligned(cpu_env)) {
+ /* offset is in (3,4), len in 5 and advice in 6 */
+ arg2 = arg3;
+ arg3 = arg4;
+ arg4 = arg5;
+ arg5 = arg6;
+ }
+ ret = -host_to_target_errno(posix_fadvise(arg1,
+ target_offset64(arg2, arg3),
+ arg4, arg5));
+ break;
+#endif
+
+#else /* not a 32-bit ABI */
#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_fadvise64)
#ifdef TARGET_NR_fadvise64_64
case TARGET_NR_fadvise64_64:
@@ -9359,6 +9397,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = -posix_fadvise(arg1, arg2, arg3, arg4);
break;
#endif
+#endif /* end of 64-bit ABI fadvise handling */
+
#ifdef TARGET_NR_madvise
case TARGET_NR_madvise:
/* A straight passthrough may not be safe because qemu sometimes
--
1.9.1
next prev parent reply other threads:[~2016-05-31 14:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-31 14:45 [Qemu-devel] [PATCH 0/3] linux-user: fix bugs in fadvise syscalls Peter Maydell
2016-05-31 14:45 ` [Qemu-devel] [PATCH 1/3] linux-user: Fix handling of arm_fadvise64_64 syscall Peter Maydell
2016-06-02 13:29 ` Laurent Vivier
2016-05-31 14:45 ` Peter Maydell [this message]
2016-06-02 13:29 ` [Qemu-devel] [PATCH 2/3] linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests Laurent Vivier
2016-05-31 14:45 ` [Qemu-devel] [PATCH 3/3] linux-user: Fix error conversion in 64-bit fadvise syscall Peter Maydell
2016-06-02 13:30 ` Laurent Vivier
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 \
--in-reply-to=1464705911-28960-3-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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;
as well as URLs for NNTP newsgroup(s).