[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 14/15] linux-user: make MIPS and ARM eabi use same a
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PATCH 14/15] linux-user: make MIPS and ARM eabi use same argument reordering |
Date: |
Wed, 13 Jul 2011 17:48:53 +0300 |
From: Riku Voipio <address@hidden>
MIPS uses similar calling convention than ARM eabi, where when using
64-bit values some registers are skipped. This patch makes MIPS and ARM
eabi share the argument reordering code.
This affects ftruncate64, creating insane sized fails (or just failing).
Cc: Wesley W. Terpstra <address@hidden>
Cc: address@hidden
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 38 ++++++++++++++++++--------------------
1 files changed, 18 insertions(+), 20 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9eb41a0..1dd7aad 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -580,6 +580,17 @@ extern int setfsuid(int);
extern int setfsgid(int);
extern int setgroups(int, gid_t *);
+/* ARM EABI and MIPS expect 64bit types aligned even on pairs or registers */
+#ifdef TARGET_ARM
+static inline int regpairs_aligned(void *cpu_env) {
+ return ((((CPUARMState *)cpu_env)->eabi) == 1) ;
+}
+#elif defined(TARGET_MIPS)
+static inline int regpairs_aligned(void *cpu_env) { return 1; }
+#else
+static inline int regpairs_aligned(void *cpu_env) { return 0; }
+#endif
+
#define ERRNO_TABLE_SIZE 1200
/* target_to_host_errno_table[] is initialized from
@@ -4375,13 +4386,10 @@ static inline abi_long target_truncate64(void *cpu_env,
const char *arg1,
abi_long arg3,
abi_long arg4)
{
-#ifdef TARGET_ARM
- if (((CPUARMState *)cpu_env)->eabi)
- {
+ if (regpairs_aligned(cpu_env)) {
arg2 = arg3;
arg3 = arg4;
- }
-#endif
+ }
return get_errno(truncate64(arg1, target_offset64(arg2, arg3)));
}
#endif
@@ -4392,13 +4400,10 @@ static inline abi_long target_ftruncate64(void
*cpu_env, abi_long arg1,
abi_long arg3,
abi_long arg4)
{
-#ifdef TARGET_ARM
- if (((CPUARMState *)cpu_env)->eabi)
- {
+ if (regpairs_aligned(cpu_env)) {
arg2 = arg3;
arg3 = arg4;
- }
-#endif
+ }
return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3)));
}
#endif
@@ -6857,20 +6862,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
#endif
#ifdef TARGET_NR_pread
case TARGET_NR_pread:
-#ifdef TARGET_ARM
- if (((CPUARMState *)cpu_env)->eabi)
+ if (regpairs_aligned(cpu_env))
arg4 = arg5;
-#endif
if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
goto efault;
ret = get_errno(pread(arg1, p, arg3, arg4));
unlock_user(p, arg2, ret);
break;
case TARGET_NR_pwrite:
-#ifdef TARGET_ARM
- if (((CPUARMState *)cpu_env)->eabi)
+ if (regpairs_aligned(cpu_env))
arg4 = arg5;
-#endif
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
goto efault;
ret = get_errno(pwrite(arg1, p, arg3, arg4));
@@ -7621,14 +7622,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
#ifdef TARGET_NR_readahead
case TARGET_NR_readahead:
#if TARGET_ABI_BITS == 32
-#ifdef TARGET_ARM
- if (((CPUARMState *)cpu_env)->eabi)
- {
+ if (regpairs_aligned(cpu_env)) {
arg2 = arg3;
arg3 = arg4;
arg4 = arg5;
}
-#endif
ret = get_errno(readahead(arg1, ((off64_t)arg3 << 32) | arg2, arg4));
#else
ret = get_errno(readahead(arg1, arg2, arg3));
--
1.7.4.1
- [Qemu-devel] [PATCH 05/15] linux-user: Add syscall numbers from kernel 2.6.39.2, (continued)
- [Qemu-devel] [PATCH 05/15] linux-user: Add syscall numbers from kernel 2.6.39.2, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 01/15] arm-semi: Provide access to CLI arguments passed through the "-append" option, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 06/15] linux-user: Implement prlimit64 syscall, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 02/15] linux-user: Add support for KD...LED ioctls, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 07/15] linux-user/syscall.c: Enforce pselect6 sigset size restrictions, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 08/15] mips: sigaltstack args, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 09/15] mips: missing syscall returns wrong errno, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 11/15] mips: rlimit incorrectly converts values, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 10/15] mips: null pointer deref should segfault, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 13/15] linux-user: correct syscall 123 on sh4, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 14/15] linux-user: make MIPS and ARM eabi use same argument reordering,
riku . voipio <=
- [Qemu-devel] [PATCH 12/15] mips: rlimit codes are not the same, riku . voipio, 2011/07/13
- [Qemu-devel] [PATCH 15/15] linux-user/signal.c: Rename s390 target_ucontext fields to fix ia64, riku . voipio, 2011/07/13