linux-user: Fix handling of arm_fadvise64_64 syscall
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 31 May 2016 14:45:09 +0000 (15:45 +0100)
committerRiku Voipio <riku.voipio@linaro.org>
Wed, 8 Jun 2016 07:13:45 +0000 (10:13 +0300)
32-bit ARM has an odd variant of the fadvise syscall which has
rearranged arguments, which we try to implement. Unfortunately we got
the rearrangement wrong.

This is a six-argument syscall whose arguments are:
 * fd
 * advise parameter
 * offset high half
 * offset low half
 * len high half
 * len low half

Stop trying to share code with the standard fadvise syscalls,
and just implement the syscall with the correct argument order.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c

index a2d591ed8ac40b4b58af96602998b1d109304bf9..8c08e7c1895d0cac49f4d1bef4fc64a4e9e29dc2 100644 (file)
@@ -9970,18 +9970,18 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #endif
 #ifdef TARGET_NR_arm_fadvise64_64
     case TARGET_NR_arm_fadvise64_64:
-       {
-               /*
-                * arm_fadvise64_64 looks like fadvise64_64 but
-                * with different argument order
-                */
-               abi_long temp;
-               temp = arg3;
-               arg3 = arg4;
-               arg4 = temp;
-       }
+        /* arm_fadvise64_64 looks like fadvise64_64 but
+         * with different argument order: fd, advice, offset, len
+         * rather than the usual fd, offset, len, advice.
+         * Note that offset and len are both 64-bit so appear as
+         * pairs of 32-bit registers.
+         */
+        ret = posix_fadvise(arg1, target_offset64(arg3, arg4),
+                            target_offset64(arg5, arg6), arg2);
+        ret = -host_to_target_errno(ret);
+        break;
 #endif
-#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_arm_fadvise64_64) || defined(TARGET_NR_fadvise64)
+#if defined(TARGET_NR_fadvise64_64) || defined(TARGET_NR_fadvise64)
 #ifdef TARGET_NR_fadvise64_64
     case TARGET_NR_fadvise64_64:
 #endif