On Fri, Nov 6, 2009 at 9:10 PM, David Munday <cro...@soe.ucsc.edu> wrote: > Hi, > Sorry forgot attachment! I have attached it to this email now. I also noticed > that the last line should assign the pid to the child, but I didn't see where > I can find that info and pass it into the cpu_clone_regs function.
Could you test if this patch helps?
From 7d0c78b22efd38b39b9ac4722784718d05d48a54 Mon Sep 17 00:00:00 2001 From: Blue Swirl <blauwirbel@gmail.com> Date: Sun, 8 Nov 2009 18:26:11 +0000 Subject: [PATCH] sparc-linux-user: fix fork fork() has special semantics on Sparc, see Linux arch/sparc/kernel/process.c. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> --- linux-user/syscall.c | 8 ++++++++ target-sparc/cpu.h | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index e38552c..57c990c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3629,6 +3629,10 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp, if (ret == 0) { /* Child Process. */ cpu_clone_regs(env, newsp); +#ifdef TARGET_SPARC + env->regwptr[0] = getppid(); + env->regwptr[1] = 1; +#endif fork_end(1); #if defined(CONFIG_USE_NPTL) /* There is a race condition here. The parent process could @@ -3648,6 +3652,10 @@ static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp, ts->child_tidptr = child_tidptr; #endif } else { +#ifdef TARGET_SPARC + env->regwptr[0] = ret; + env->regwptr[1] = 0; +#endif fork_end(0); } } diff --git a/target-sparc/cpu.h b/target-sparc/cpu.h index 63aead9..cb26925 100644 --- a/target-sparc/cpu.h +++ b/target-sparc/cpu.h @@ -574,10 +574,6 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) { if (newsp) env->regwptr[22] = newsp; - env->regwptr[0] = 0; - /* FIXME: Do we also need to clear CF? */ - /* XXXXX */ - printf ("HELPME: %s:%d\n", __FILE__, __LINE__); } #endif -- 1.5.6.5