[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 26/44] linux-user: Fix NR_fadvise64 and NR_fadvise64_
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 26/44] linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests |
Date: |
Wed, 8 Jun 2016 16:30:07 +0300 |
From: Peter Maydell <address@hidden>
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 <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8c08e7c..5cff9f7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9981,6 +9981,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:
@@ -10000,6 +10038,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
--
2.1.4
- [Qemu-devel] [PULL 17/44] linux-user: Block signals during sigaction() handling, (continued)
- [Qemu-devel] [PULL 17/44] linux-user: Block signals during sigaction() handling, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 24/44] linux-user: provide frame information in x86-64 safe_syscall, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 15/44] linux-user: Remove real-time signal queuing, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 23/44] linux-user: Avoid possible misalignment in target_to_host_siginfo(), riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 19/44] linux-user: Restart exit() if signal pending, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 20/44] linux-user: Use safe_syscall for kill, tkill and tgkill syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 25/44] linux-user: Fix handling of arm_fadvise64_64 syscall, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 21/44] linux-user: Restart fork() if signals pending, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 28/44] linux-user: Use safe_syscall wrapper for readv and writev syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 22/44] linux-user: Use both si_code and si_signo when converting siginfo_t, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 26/44] linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests,
riku . voipio <=
- [Qemu-devel] [PULL 33/44] linux-user: Use safe_syscall wrapper for flock, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 30/44] linux-user: Use safe_syscall wrapper for send* and recv* syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 29/44] linux-user: Use safe_syscall wrapper for connect syscall, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 37/44] linux-user: Use safe_syscall wrapper for epoll_wait syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 27/44] linux-user: Fix error conversion in 64-bit fadvise syscall, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 36/44] linux-user: Use safe_syscall wrapper for poll and ppoll syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 32/44] linux-user: Use safe_syscall wrapper for mq_timedsend and mq_timedreceive, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 35/44] linux-user: Use safe_syscall wrapper for sleep syscalls, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 31/44] linux-user: Use safe_syscall wrapper for msgsnd and msgrcv, riku . voipio, 2016/06/08
- [Qemu-devel] [PULL 38/44] linux-user: Use safe_syscall wrapper for semop, riku . voipio, 2016/06/08