From patchwork Mon May 3 17:07:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 51515 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 77FFDB7D11 for ; Tue, 4 May 2010 03:18:53 +1000 (EST) Received: from localhost ([127.0.0.1]:57880 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O8zHc-0001Sf-Ur for incoming@patchwork.ozlabs.org; Mon, 03 May 2010 13:18:17 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O8z8P-0007dw-78 for qemu-devel@nongnu.org; Mon, 03 May 2010 13:08:45 -0400 Received: from [140.186.70.92] (port=59065 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O8z8N-0007dd-Nx for qemu-devel@nongnu.org; Mon, 03 May 2010 13:08:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O8z8M-0000G1-PN for qemu-devel@nongnu.org; Mon, 03 May 2010 13:08:43 -0400 Received: from mail-qy0-f188.google.com ([209.85.221.188]:62982) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O8z8M-0000Bh-Kf for qemu-devel@nongnu.org; Mon, 03 May 2010 13:08:42 -0400 Received: by mail-qy0-f188.google.com with SMTP id 26so4137992qyk.19 for ; Mon, 03 May 2010 10:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=3CTueXI+Oj1xWSuhu9UN6Q38YRb1d0KqZRPkplRuyKc=; b=cvNaHrvlyqBB5kvS2Wb5ooYai6+ceC5ztfDHqVhC7csTVxOgLXCo2H9Cl+SiMTEjJo 0E+mOGUxlf6+nJvNIr7lc+5r+uEYJDAKf0EniCQEREYeOkx/dbk0EUY2O4XpCRfAzX7c IHz59+P3z+lleUzoT155r3eg+QLayJTJeBumk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; b=MhDDRgyUZElAXMzsEStg0lyLhXm00rfJreHD+z7eh+mQI7lQq/3VRcMV9enmUM23sQ ng6KBQq/+Bc/sksZFhFu7FI/TtE707TIHstQ0w4cYp/+h4w9hNL6ryMfI5WBuXfkLqcW 1HvP1KgjWiC8N0UoOc74fF8O7hb+BuA3b/GcA= Received: by 10.224.47.136 with SMTP id n8mr6624321qaf.171.1272906522419; Mon, 03 May 2010 10:08:42 -0700 (PDT) Received: from localhost.localdomain (are.twiddle.net [75.149.56.221]) by mx.google.com with ESMTPS id 2sm9954190qwi.29.2010.05.03.10.08.41 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 03 May 2010 10:08:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 3 May 2010 10:07:52 -0700 Message-Id: <1272906475-14480-5-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: <1272906475-14480-4-git-send-email-rth@twiddle.net> References: <1272906475-14480-1-git-send-email-rth@twiddle.net> <1272906475-14480-2-git-send-email-rth@twiddle.net> <1272906475-14480-3-git-send-email-rth@twiddle.net> <1272906475-14480-4-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 4/7] alpha-linux-user: Fix pipe return mechanism. 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 At the same time, tidy the code wrt MIPS and SH4 which have the same two register return mechanism. Fix confusion between pipe and pipe2 with an explicit flags=0, when the guest will not be using the two register return mechanism. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 30 ++++++++++++++++++------------ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 81e09b3..3b0e169 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -979,7 +979,8 @@ static abi_long do_pipe2(int host_pipe[], int flags) #endif } -static abi_long do_pipe(void *cpu_env, abi_ulong pipedes, int flags) +static abi_long do_pipe(void *cpu_env, abi_ulong pipedes, + int flags, int is_pipe2) { int host_pipe[2]; abi_long ret; @@ -987,20 +988,25 @@ static abi_long do_pipe(void *cpu_env, abi_ulong pipedes, int flags) if (is_error(ret)) return get_errno(ret); -#if defined(TARGET_MIPS) - ((CPUMIPSState*)cpu_env)->active_tc.gpr[3] = host_pipe[1]; - ret = host_pipe[0]; -#else -#if defined(TARGET_SH4) - if (!flags) { + + /* Several targets have special calling conventions for the original + pipe syscall, but didn't replicate this into the pipe2 syscall. */ + if (!is_pipe2) { +#if defined(TARGET_ALPHA) + ((CPUAlphaState *)cpu_env)->ir[IR_A4] = host_pipe[1]; + return host_pipe[0]; +#elif defined(TARGET_MIPS) + ((CPUMIPSState*)cpu_env)->active_tc.gpr[3] = host_pipe[1]; + return host_pipe[0]; +#elif defined(TARGET_SH4) ((CPUSH4State*)cpu_env)->gregs[1] = host_pipe[1]; - ret = host_pipe[0]; - } else + return host_pipe[0]; #endif + } + if (put_user_s32(host_pipe[0], pipedes) || put_user_s32(host_pipe[1], pipedes + sizeof(host_pipe[0]))) return -TARGET_EFAULT; -#endif return get_errno(ret); } @@ -4690,11 +4696,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(dup(arg1)); break; case TARGET_NR_pipe: - ret = do_pipe(cpu_env, arg1, 0); + ret = do_pipe(cpu_env, arg1, 0, 0); break; #ifdef TARGET_NR_pipe2 case TARGET_NR_pipe2: - ret = do_pipe(cpu_env, arg1, arg2); + ret = do_pipe(cpu_env, arg1, arg2, 1); break; #endif case TARGET_NR_times: