From patchwork Thu Mar 25 09:04:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomasz_=C5=81ukaszewski?= X-Patchwork-Id: 48506 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0EE03B7C67 for ; Thu, 25 Mar 2010 20:12:04 +1100 (EST) Received: from localhost ([127.0.0.1]:56603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nuj0g-0002he-4h for incoming@patchwork.ozlabs.org; Thu, 25 Mar 2010 05:05:50 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NuizF-0002hZ-Sr for qemu-devel@nongnu.org; Thu, 25 Mar 2010 05:04:21 -0400 Received: from [140.186.70.92] (port=56914 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NuizE-0002hR-4R for qemu-devel@nongnu.org; Thu, 25 Mar 2010 05:04:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NuizC-0005XK-4x for qemu-devel@nongnu.org; Thu, 25 Mar 2010 05:04:19 -0400 Received: from smtp.cubiware.com ([67.23.4.46]:37187) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NuizB-0005X6-Vl for qemu-devel@nongnu.org; Thu, 25 Mar 2010 05:04:18 -0400 Received: from [192.168.1.39] (unknown [89.231.22.22]) (Authenticated sender: lupus@cubiware.com) by smtp.cubiware.com (Postfix) with ESMTPSA id 0E2DFB0201 for ; Thu, 25 Mar 2010 09:11:23 +0000 (UTC) Message-ID: <4BAB270E.1070201@cubiware.com> Date: Thu, 25 Mar 2010 10:04:14 +0100 From: =?UTF-8?B?VG9tYXN6IMWBdWthc3pld3NraQ==?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; pl-PL; rv:1.9.1.8) Gecko/20100228 SUSE/3.0.3-3.1 Thunderbird/3.0.3 MIME-Version: 1.0 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH] Fix 64-bit off_t syscall argument passing in linux-user X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hello, I am evaluating the possibility to use linux-user emulation in qemu for automatic regression testing for some embedded linux projects in the company I work for. I've encountered some problems with syscall interface while testing mips(el), powerpc and arm code, and I am willing to fix them. This is the first patch, I'd appeciate any comments. Best regards, Tomasz Lukaszewski In 32-bit ABIs 64-bit arguments are passed in a pair of registers (ra, rb), where ra is an odd numbered one. This patch fixes such case for truncate64, ftruncate64, pread64 and pwrite64 for mips, ppc and arm-eabi. --- linux-user/syscall.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 62 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 80d8633..0bf146d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3922,6 +3922,7 @@ static inline abi_long target_truncate64(void *cpu_env, const char *arg1, abi_long arg3, abi_long arg4) { +#if TARGET_ABI_BITS == 32 #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { @@ -3929,6 +3930,11 @@ static inline abi_long target_truncate64(void *cpu_env, const char *arg1, arg3 = arg4; } #endif +#if defined TARGET_PPC || defined TARGET_MIPS + arg2 = arg3; + arg3 = arg4; +#endif +#endif return get_errno(truncate64(arg1, target_offset64(arg2, arg3))); } #endif @@ -3939,6 +3945,7 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, abi_long arg3, abi_long arg4) { +#if TARGET_ABI_BITS == 32 #ifdef TARGET_ARM if (((CPUARMState *)cpu_env)->eabi) { @@ -3946,10 +3953,63 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, arg3 = arg4; } #endif +#if defined TARGET_PPC || defined TARGET_MIPS + arg2 = arg3; + arg3 = arg4; +#endif +#endif return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3))); } #endif +#ifdef TARGET_NR_pread64 +static inline abi_long target_pread64(void *cpu_env, abi_long arg1, + void *arg2, + abi_long arg3, + abi_long arg4, + abi_long arg5, + abi_long arg6) +{ +#if TARGET_ABI_BITS == 32 +#ifdef TARGET_ARM + if (((CPUARMState *)cpu_env)->eabi) + { + arg4 = arg5; + arg5 = arg6; + } +#endif +#if defined TARGET_PPC || defined TARGET_MIPS + arg4 = arg5; + arg5 = arg6; +#endif +#endif + return get_errno(pread64(arg1, arg2, arg3, target_offset64(arg4, arg5))); +} + +static inline abi_long target_pwrite64(void *cpu_env, abi_long arg1, + const void *arg2, + abi_long arg3, + abi_long arg4, + abi_long arg5, + abi_long arg6) +{ +#if TARGET_ABI_BITS == 32 +#ifdef TARGET_ARM + if (((CPUARMState *)cpu_env)->eabi) + { + arg4 = arg5; + arg5 = arg6; + } +#endif +#if defined TARGET_PPC || defined TARGET_MIPS + arg4 = arg5; + arg5 = arg6; +#endif +#endif + return get_errno(pwrite64(arg1, arg2, arg3, target_offset64(arg4, arg5))); +} +#endif + static inline abi_long target_to_host_timespec(struct timespec *host_ts, abi_ulong target_addr) { @@ -6166,13 +6226,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_pread64: if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) goto efault; - ret = get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg5))); + ret = target_pread64(cpu_env, arg1, p, arg3, arg4, arg5, arg6); unlock_user(p, arg2, ret); break; case TARGET_NR_pwrite64: if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1))) goto efault; - ret = get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, arg5))); + ret = target_pwrite64(cpu_env, arg1, p, arg3, arg4, arg5, arg6); unlock_user(p, arg2, 0); break; #endif