From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 4/7] alpha-linux-user: Fix pipe return mechanism.
Date: Mon, 3 May 2010 10:07:52 -0700 [thread overview]
Message-ID: <1272906475-14480-5-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1272906475-14480-4-git-send-email-rth@twiddle.net>
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 <rth@twiddle.net>
---
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:
--
1.6.6.1
next prev parent reply other threads:[~2010-05-03 17:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-03 17:07 [Qemu-devel] [PATCH 0/7] alpha-linux syscall fixes Richard Henderson
2010-05-03 17:07 ` [Qemu-devel] [PATCH 1/7] alpha-linux-user: Fix brk error return Richard Henderson
2010-05-03 17:07 ` [Qemu-devel] [PATCH 2/7] alpha-linux-user: Fix siginfo.si_addr for SIGSEGV and SIGBUS Richard Henderson
2010-05-03 17:07 ` [Qemu-devel] [PATCH 3/7] alpha-linux-user: Add correct sigaction constants Richard Henderson
2010-05-03 17:07 ` Richard Henderson [this message]
2010-05-03 17:07 ` [Qemu-devel] [PATCH 5/7] alpha-linux-user: Fix getxpid Richard Henderson
2010-05-03 17:07 ` [Qemu-devel] [PATCH 6/7] alpha-linux-user: Fix sigsuspend parameters Richard Henderson
2010-05-03 17:07 ` [Qemu-devel] [PATCH 7/7] alpha-linux-user: Fix sigprocmask Richard Henderson
2010-05-21 16:27 ` [Qemu-devel] [PATCH 0/7] alpha-linux syscall fixes Aurelien Jarno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1272906475-14480-5-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).