From patchwork Wed Jul 13 14:48:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 2680 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0E0F823F3F for ; Wed, 13 Jul 2011 14:49:36 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id B5C9FA1875F for ; Wed, 13 Jul 2011 14:49:35 +0000 (UTC) Received: by qwb8 with SMTP id 8so4115275qwb.11 for ; Wed, 13 Jul 2011 07:49:35 -0700 (PDT) Received: by 10.224.198.7 with SMTP id em7mr1081081qab.112.1310568575160; Wed, 13 Jul 2011 07:49:35 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs23875qcb; Wed, 13 Jul 2011 07:49:34 -0700 (PDT) Received: by 10.52.74.130 with SMTP id t2mr1333899vdv.55.1310568574481; Wed, 13 Jul 2011 07:49:34 -0700 (PDT) Received: from afflict.kos.to (afflict.kos.to [92.243.29.197]) by mx.google.com with ESMTPS id u1si19473098vdg.141.2011.07.13.07.49.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 13 Jul 2011 07:49:33 -0700 (PDT) Received-SPF: pass (google.com: domain of riku.voipio@iki.fi designates 92.243.29.197 as permitted sender) client-ip=92.243.29.197; Authentication-Results: mx.google.com; spf=pass (google.com: domain of riku.voipio@iki.fi designates 92.243.29.197 as permitted sender) smtp.mail=riku.voipio@iki.fi Received: from kos.to (a88-115-163-181.elisa-laajakaista.fi [88.115.163.181]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id BB64026699; Wed, 13 Jul 2011 14:49:29 +0000 (UTC) Received: by kos.to (sSMTP sendmail emulation); Wed, 13 Jul 2011 17:49:29 +0300 From: riku.voipio@iki.fi To: qemu-devel@nongnu.org Cc: Riku Voipio , "Wesley W. Terpstra" , patches@linaro.org Subject: [PATCH 14/15] linux-user: make MIPS and ARM eabi use same argument reordering Date: Wed, 13 Jul 2011 17:48:53 +0300 Message-Id: <48e515d4fa7c6ffdc21944ffc8620a161c772c09.1310568214.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: References: From: Riku Voipio 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 Cc: patches@linaro.org Signed-off-by: Riku Voipio --- 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));