diff mbox series

[03/13] linux-user: Introduce cpu_clone_regs_parent

Message ID 20190519201953.20161-4-richard.henderson@linaro.org
State Superseded
Headers show
Series linux-user: path, clone, sparc, shmat fixes | expand

Commit Message

Richard Henderson May 19, 2019, 8:19 p.m. UTC
Add an empty inline function for each target, and invoke it
from the proper places.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/aarch64/target_cpu.h    | 4 ++++
 linux-user/alpha/target_cpu.h      | 4 ++++
 linux-user/arm/target_cpu.h        | 4 ++++
 linux-user/cris/target_cpu.h       | 4 ++++
 linux-user/hppa/target_cpu.h       | 4 ++++
 linux-user/i386/target_cpu.h       | 4 ++++
 linux-user/m68k/target_cpu.h       | 4 ++++
 linux-user/microblaze/target_cpu.h | 4 ++++
 linux-user/mips/target_cpu.h       | 4 ++++
 linux-user/nios2/target_cpu.h      | 4 ++++
 linux-user/openrisc/target_cpu.h   | 4 ++++
 linux-user/ppc/target_cpu.h        | 4 ++++
 linux-user/riscv/target_cpu.h      | 4 ++++
 linux-user/s390x/target_cpu.h      | 4 ++++
 linux-user/sh4/target_cpu.h        | 4 ++++
 linux-user/sparc/target_cpu.h      | 4 ++++
 linux-user/tilegx/target_cpu.h     | 4 ++++
 linux-user/xtensa/target_cpu.h     | 4 ++++
 linux-user/syscall.c               | 2 ++
 19 files changed, 74 insertions(+)

-- 
2.17.1

Comments

Laurent Vivier June 13, 2019, 4:26 p.m. UTC | #1
Le 19/05/2019 à 22:19, Richard Henderson a écrit :
> Add an empty inline function for each target, and invoke it

> from the proper places.

> 

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  linux-user/aarch64/target_cpu.h    | 4 ++++

>  linux-user/alpha/target_cpu.h      | 4 ++++

>  linux-user/arm/target_cpu.h        | 4 ++++

>  linux-user/cris/target_cpu.h       | 4 ++++

>  linux-user/hppa/target_cpu.h       | 4 ++++

>  linux-user/i386/target_cpu.h       | 4 ++++

>  linux-user/m68k/target_cpu.h       | 4 ++++

>  linux-user/microblaze/target_cpu.h | 4 ++++

>  linux-user/mips/target_cpu.h       | 4 ++++

>  linux-user/nios2/target_cpu.h      | 4 ++++

>  linux-user/openrisc/target_cpu.h   | 4 ++++

>  linux-user/ppc/target_cpu.h        | 4 ++++

>  linux-user/riscv/target_cpu.h      | 4 ++++

>  linux-user/s390x/target_cpu.h      | 4 ++++

>  linux-user/sh4/target_cpu.h        | 4 ++++

>  linux-user/sparc/target_cpu.h      | 4 ++++

>  linux-user/tilegx/target_cpu.h     | 4 ++++

>  linux-user/xtensa/target_cpu.h     | 4 ++++

>  linux-user/syscall.c               | 2 ++

>  19 files changed, 74 insertions(+)

> 


Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Aleksandar Markovic June 13, 2019, 7:10 p.m. UTC | #2
On May 19, 2019 10:27 PM, "Richard Henderson" <richard.henderson@linaro.org>
wrote:
>

> Add an empty inline function for each target, and invoke it

> from the proper places.

>


Can we outline the meaning/purpose of the new function here?

This commit message looks horrible.

Regards,
Aleksandar

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

> ---

>  linux-user/aarch64/target_cpu.h    | 4 ++++

>  linux-user/alpha/target_cpu.h      | 4 ++++

>  linux-user/arm/target_cpu.h        | 4 ++++

>  linux-user/cris/target_cpu.h       | 4 ++++

>  linux-user/hppa/target_cpu.h       | 4 ++++

>  linux-user/i386/target_cpu.h       | 4 ++++

>  linux-user/m68k/target_cpu.h       | 4 ++++

>  linux-user/microblaze/target_cpu.h | 4 ++++

>  linux-user/mips/target_cpu.h       | 4 ++++

>  linux-user/nios2/target_cpu.h      | 4 ++++

>  linux-user/openrisc/target_cpu.h   | 4 ++++

>  linux-user/ppc/target_cpu.h        | 4 ++++

>  linux-user/riscv/target_cpu.h      | 4 ++++

>  linux-user/s390x/target_cpu.h      | 4 ++++

>  linux-user/sh4/target_cpu.h        | 4 ++++

>  linux-user/sparc/target_cpu.h      | 4 ++++

>  linux-user/tilegx/target_cpu.h     | 4 ++++

>  linux-user/xtensa/target_cpu.h     | 4 ++++

>  linux-user/syscall.c               | 2 ++

>  19 files changed, 74 insertions(+)

>

> diff --git a/linux-user/aarch64/target_cpu.h

b/linux-user/aarch64/target_cpu.h
> index abde35b104..0182bfca07 100644

> --- a/linux-user/aarch64/target_cpu.h

> +++ b/linux-user/aarch64/target_cpu.h

> @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUARMState

*env, target_ulong newsp)
>      env->xregs[0] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUARMState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)

>  {

>      /* Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is

> diff --git a/linux-user/alpha/target_cpu.h b/linux-user/alpha/target_cpu.h

> index dc02f2234c..140a459f73 100644

> --- a/linux-user/alpha/target_cpu.h

> +++ b/linux-user/alpha/target_cpu.h

> @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUAlphaState

*env, target_ulong newsp)
>      env->ir[IR_A3] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUAlphaState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls)

>  {

>      env->unique = newtls;

> diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h

> index d35c997287..3e66d5b106 100644

> --- a/linux-user/arm/target_cpu.h

> +++ b/linux-user/arm/target_cpu.h

> @@ -31,6 +31,10 @@ static inline void cpu_clone_regs_child(CPUARMState

*env, target_ulong newsp)
>      env->regs[0] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUARMState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)

>  {

>      if (access_secure_reg(env)) {

> diff --git a/linux-user/cris/target_cpu.h b/linux-user/cris/target_cpu.h

> index 9c847caaef..4da074b4fd 100644

> --- a/linux-user/cris/target_cpu.h

> +++ b/linux-user/cris/target_cpu.h

> @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUCRISState

*env, target_ulong newsp)
>      env->regs[10] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUCRISState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls)

>  {

>      env->pregs[PR_PID] = (env->pregs[PR_PID] & 0xff) | newtls;

> diff --git a/linux-user/hppa/target_cpu.h b/linux-user/hppa/target_cpu.h

> index b98e5a1cfe..6b323297af 100644

> --- a/linux-user/hppa/target_cpu.h

> +++ b/linux-user/hppa/target_cpu.h

> @@ -31,6 +31,10 @@ static inline void cpu_clone_regs_child(CPUHPPAState

*env, target_ulong newsp)
>      env->iaoq_b = env->gr[31] + 4;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUHPPAState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUHPPAState *env, target_ulong newtls)

>  {

>      env->cr[27] = newtls;

> diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h

> index e1c9e03490..6dbb856c52 100644

> --- a/linux-user/i386/target_cpu.h

> +++ b/linux-user/i386/target_cpu.h

> @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUX86State

*env, target_ulong newsp)
>      env->regs[R_EAX] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUX86State *env)

> +{

> +}

> +

>  #if defined(TARGET_ABI32)

>  abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr);

>

> diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h

> index 7637a98cab..f1a53cdee5 100644

> --- a/linux-user/m68k/target_cpu.h

> +++ b/linux-user/m68k/target_cpu.h

> @@ -29,6 +29,10 @@ static inline void cpu_clone_regs_child(CPUM68KState

*env, target_ulong newsp)
>      env->dregs[0] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUM68KState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls)

>  {

>      CPUState *cs = CPU(m68k_env_get_cpu(env));

> diff --git a/linux-user/microblaze/target_cpu.h

b/linux-user/microblaze/target_cpu.h
> index 526b80d54d..5e285e9211 100644

> --- a/linux-user/microblaze/target_cpu.h

> +++ b/linux-user/microblaze/target_cpu.h

> @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUMBState

*env, target_ulong newsp)
>      env->regs[3] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUMBState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUMBState *env, target_ulong newtls)

>  {

>      env->regs[21] = newtls;

> diff --git a/linux-user/mips/target_cpu.h b/linux-user/mips/target_cpu.h

> index c42660b047..d0e0b1bac0 100644

> --- a/linux-user/mips/target_cpu.h

> +++ b/linux-user/mips/target_cpu.h

> @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUMIPSState

*env, target_ulong newsp)
>      env->active_tc.gpr[2] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUMIPSState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUMIPSState *env, target_ulong newtls)

>  {

>      env->active_tc.CP0_UserLocal = newtls;

> diff --git a/linux-user/nios2/target_cpu.h b/linux-user/nios2/target_cpu.h

> index bec2ea79c4..01725ba004 100644

> --- a/linux-user/nios2/target_cpu.h

> +++ b/linux-user/nios2/target_cpu.h

> @@ -28,6 +28,10 @@ static inline void cpu_clone_regs_child(CPUNios2State

*env, target_ulong newsp)
>      env->regs[R_RET0] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUNios2State *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUNios2State *env, target_ulong newtls)

>  {

>      /*

> diff --git a/linux-user/openrisc/target_cpu.h

b/linux-user/openrisc/target_cpu.h
> index d163ba2e26..6586951c5b 100644

> --- a/linux-user/openrisc/target_cpu.h

> +++ b/linux-user/openrisc/target_cpu.h

> @@ -29,6 +29,10 @@ static inline void

cpu_clone_regs_child(CPUOpenRISCState *env,
>      cpu_set_gpr(env, 11, 0);

>  }

>

> +static inline void cpu_clone_regs_parent(CPUOpenRISCState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUOpenRISCState *env, target_ulong

newtls)
>  {

>      cpu_set_gpr(env, 10, newtls);

> diff --git a/linux-user/ppc/target_cpu.h b/linux-user/ppc/target_cpu.h

> index 34decf3876..00c9f5eb86 100644

> --- a/linux-user/ppc/target_cpu.h

> +++ b/linux-user/ppc/target_cpu.h

> @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUPPCState

*env, target_ulong newsp)
>      env->gpr[3] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUPPCState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUPPCState *env, target_ulong newtls)

>  {

>  #if defined(TARGET_PPC64)

> diff --git a/linux-user/riscv/target_cpu.h b/linux-user/riscv/target_cpu.h

> index d92153851c..4ef1b23b4f 100644

> --- a/linux-user/riscv/target_cpu.h

> +++ b/linux-user/riscv/target_cpu.h

> @@ -10,6 +10,10 @@ static inline void cpu_clone_regs_child(CPURISCVState

*env, target_ulong newsp)
>      env->gpr[xA0] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPURISCVState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPURISCVState *env, target_ulong newtls)

>  {

>      env->gpr[xTP] = newtls;

> diff --git a/linux-user/s390x/target_cpu.h b/linux-user/s390x/target_cpu.h

> index e0baa98e75..18e290ece8 100644

> --- a/linux-user/s390x/target_cpu.h

> +++ b/linux-user/s390x/target_cpu.h

> @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUS390XState

*env, target_ulong newsp)
>      env->regs[2] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUS390XState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls)

>  {

>      env->aregs[0] = newtls >> 32;

> diff --git a/linux-user/sh4/target_cpu.h b/linux-user/sh4/target_cpu.h

> index 854955aa5a..b0e4ab23a7 100644

> --- a/linux-user/sh4/target_cpu.h

> +++ b/linux-user/sh4/target_cpu.h

> @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUSH4State

*env, target_ulong newsp)
>      env->gregs[0] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUSH4State *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUSH4State *env, target_ulong newtls)

>  {

>    env->gbr = newtls;

> diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h

> index 8511fc3f6f..52c9d8c7db 100644

> --- a/linux-user/sparc/target_cpu.h

> +++ b/linux-user/sparc/target_cpu.h

> @@ -36,6 +36,10 @@ static inline void cpu_clone_regs_child(CPUSPARCState

*env, target_ulong newsp)
>  #endif

>  }

>

> +static inline void cpu_clone_regs_parent(CPUSPARCState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls)

>  {

>      env->gregs[7] = newtls;

> diff --git a/linux-user/tilegx/target_cpu.h

b/linux-user/tilegx/target_cpu.h
> index dfca8d9598..9577462821 100644

> --- a/linux-user/tilegx/target_cpu.h

> +++ b/linux-user/tilegx/target_cpu.h

> @@ -27,6 +27,10 @@ static inline void cpu_clone_regs_child(CPUTLGState

*env, target_ulong newsp)
>      env->regs[TILEGX_R_RE] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUTLGState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUTLGState *env, target_ulong newtls)

>  {

>      env->regs[TILEGX_R_TP] = newtls;

> diff --git a/linux-user/xtensa/target_cpu.h

b/linux-user/xtensa/target_cpu.h
> index f436b160c4..42e66211cf 100644

> --- a/linux-user/xtensa/target_cpu.h

> +++ b/linux-user/xtensa/target_cpu.h

> @@ -15,6 +15,10 @@ static inline void cpu_clone_regs_child(CPUXtensaState

*env,
>      env->regs[2] = 0;

>  }

>

> +static inline void cpu_clone_regs_parent(CPUXtensaState *env)

> +{

> +}

> +

>  static inline void cpu_set_tls(CPUXtensaState *env, target_ulong newtls)

>  {

>      env->uregs[THREADPTR] = newtls;

> diff --git a/linux-user/syscall.c b/linux-user/syscall.c

> index b9127a9601..f960556bf8 100644

> --- a/linux-user/syscall.c

> +++ b/linux-user/syscall.c

> @@ -5535,6 +5535,7 @@ static int do_fork(CPUArchState *env, unsigned int

flags, abi_ulong newsp,
>          new_env = cpu_copy(env);

>          /* Init regs that differ from the parent.  */

>          cpu_clone_regs_child(new_env, newsp);

> +        cpu_clone_regs_parent(env);

>          new_cpu = ENV_GET_CPU(new_env);

>          new_cpu->opaque = ts;

>          ts->bprm = parent_ts->bprm;

> @@ -5630,6 +5631,7 @@ static int do_fork(CPUArchState *env, unsigned int

flags, abi_ulong newsp,
>              if (flags & CLONE_CHILD_CLEARTID)

>                  ts->child_tidptr = child_tidptr;

>          } else {

> +            cpu_clone_regs_parent(env);

>              fork_end(0);

>          }

>      }

> --

> 2.17.1

>

>
diff mbox series

Patch

diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cpu.h
index abde35b104..0182bfca07 100644
--- a/linux-user/aarch64/target_cpu.h
+++ b/linux-user/aarch64/target_cpu.h
@@ -27,6 +27,10 @@  static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong newsp)
     env->xregs[0] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUARMState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)
 {
     /* Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is
diff --git a/linux-user/alpha/target_cpu.h b/linux-user/alpha/target_cpu.h
index dc02f2234c..140a459f73 100644
--- a/linux-user/alpha/target_cpu.h
+++ b/linux-user/alpha/target_cpu.h
@@ -28,6 +28,10 @@  static inline void cpu_clone_regs_child(CPUAlphaState *env, target_ulong newsp)
     env->ir[IR_A3] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUAlphaState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls)
 {
     env->unique = newtls;
diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h
index d35c997287..3e66d5b106 100644
--- a/linux-user/arm/target_cpu.h
+++ b/linux-user/arm/target_cpu.h
@@ -31,6 +31,10 @@  static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong newsp)
     env->regs[0] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUARMState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)
 {
     if (access_secure_reg(env)) {
diff --git a/linux-user/cris/target_cpu.h b/linux-user/cris/target_cpu.h
index 9c847caaef..4da074b4fd 100644
--- a/linux-user/cris/target_cpu.h
+++ b/linux-user/cris/target_cpu.h
@@ -28,6 +28,10 @@  static inline void cpu_clone_regs_child(CPUCRISState *env, target_ulong newsp)
     env->regs[10] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUCRISState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls)
 {
     env->pregs[PR_PID] = (env->pregs[PR_PID] & 0xff) | newtls;
diff --git a/linux-user/hppa/target_cpu.h b/linux-user/hppa/target_cpu.h
index b98e5a1cfe..6b323297af 100644
--- a/linux-user/hppa/target_cpu.h
+++ b/linux-user/hppa/target_cpu.h
@@ -31,6 +31,10 @@  static inline void cpu_clone_regs_child(CPUHPPAState *env, target_ulong newsp)
     env->iaoq_b = env->gr[31] + 4;
 }
 
+static inline void cpu_clone_regs_parent(CPUHPPAState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUHPPAState *env, target_ulong newtls)
 {
     env->cr[27] = newtls;
diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h
index e1c9e03490..6dbb856c52 100644
--- a/linux-user/i386/target_cpu.h
+++ b/linux-user/i386/target_cpu.h
@@ -28,6 +28,10 @@  static inline void cpu_clone_regs_child(CPUX86State *env, target_ulong newsp)
     env->regs[R_EAX] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUX86State *env)
+{
+}
+
 #if defined(TARGET_ABI32)
 abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr);
 
diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h
index 7637a98cab..f1a53cdee5 100644
--- a/linux-user/m68k/target_cpu.h
+++ b/linux-user/m68k/target_cpu.h
@@ -29,6 +29,10 @@  static inline void cpu_clone_regs_child(CPUM68KState *env, target_ulong newsp)
     env->dregs[0] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUM68KState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls)
 {
     CPUState *cs = CPU(m68k_env_get_cpu(env));
diff --git a/linux-user/microblaze/target_cpu.h b/linux-user/microblaze/target_cpu.h
index 526b80d54d..5e285e9211 100644
--- a/linux-user/microblaze/target_cpu.h
+++ b/linux-user/microblaze/target_cpu.h
@@ -27,6 +27,10 @@  static inline void cpu_clone_regs_child(CPUMBState *env, target_ulong newsp)
     env->regs[3] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUMBState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUMBState *env, target_ulong newtls)
 {
     env->regs[21] = newtls;
diff --git a/linux-user/mips/target_cpu.h b/linux-user/mips/target_cpu.h
index c42660b047..d0e0b1bac0 100644
--- a/linux-user/mips/target_cpu.h
+++ b/linux-user/mips/target_cpu.h
@@ -28,6 +28,10 @@  static inline void cpu_clone_regs_child(CPUMIPSState *env, target_ulong newsp)
     env->active_tc.gpr[2] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUMIPSState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUMIPSState *env, target_ulong newtls)
 {
     env->active_tc.CP0_UserLocal = newtls;
diff --git a/linux-user/nios2/target_cpu.h b/linux-user/nios2/target_cpu.h
index bec2ea79c4..01725ba004 100644
--- a/linux-user/nios2/target_cpu.h
+++ b/linux-user/nios2/target_cpu.h
@@ -28,6 +28,10 @@  static inline void cpu_clone_regs_child(CPUNios2State *env, target_ulong newsp)
     env->regs[R_RET0] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUNios2State *env)
+{
+}
+
 static inline void cpu_set_tls(CPUNios2State *env, target_ulong newtls)
 {
     /*
diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_cpu.h
index d163ba2e26..6586951c5b 100644
--- a/linux-user/openrisc/target_cpu.h
+++ b/linux-user/openrisc/target_cpu.h
@@ -29,6 +29,10 @@  static inline void cpu_clone_regs_child(CPUOpenRISCState *env,
     cpu_set_gpr(env, 11, 0);
 }
 
+static inline void cpu_clone_regs_parent(CPUOpenRISCState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUOpenRISCState *env, target_ulong newtls)
 {
     cpu_set_gpr(env, 10, newtls);
diff --git a/linux-user/ppc/target_cpu.h b/linux-user/ppc/target_cpu.h
index 34decf3876..00c9f5eb86 100644
--- a/linux-user/ppc/target_cpu.h
+++ b/linux-user/ppc/target_cpu.h
@@ -27,6 +27,10 @@  static inline void cpu_clone_regs_child(CPUPPCState *env, target_ulong newsp)
     env->gpr[3] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUPPCState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUPPCState *env, target_ulong newtls)
 {
 #if defined(TARGET_PPC64)
diff --git a/linux-user/riscv/target_cpu.h b/linux-user/riscv/target_cpu.h
index d92153851c..4ef1b23b4f 100644
--- a/linux-user/riscv/target_cpu.h
+++ b/linux-user/riscv/target_cpu.h
@@ -10,6 +10,10 @@  static inline void cpu_clone_regs_child(CPURISCVState *env, target_ulong newsp)
     env->gpr[xA0] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPURISCVState *env)
+{
+}
+
 static inline void cpu_set_tls(CPURISCVState *env, target_ulong newtls)
 {
     env->gpr[xTP] = newtls;
diff --git a/linux-user/s390x/target_cpu.h b/linux-user/s390x/target_cpu.h
index e0baa98e75..18e290ece8 100644
--- a/linux-user/s390x/target_cpu.h
+++ b/linux-user/s390x/target_cpu.h
@@ -27,6 +27,10 @@  static inline void cpu_clone_regs_child(CPUS390XState *env, target_ulong newsp)
     env->regs[2] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUS390XState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls)
 {
     env->aregs[0] = newtls >> 32;
diff --git a/linux-user/sh4/target_cpu.h b/linux-user/sh4/target_cpu.h
index 854955aa5a..b0e4ab23a7 100644
--- a/linux-user/sh4/target_cpu.h
+++ b/linux-user/sh4/target_cpu.h
@@ -27,6 +27,10 @@  static inline void cpu_clone_regs_child(CPUSH4State *env, target_ulong newsp)
     env->gregs[0] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUSH4State *env)
+{
+}
+
 static inline void cpu_set_tls(CPUSH4State *env, target_ulong newtls)
 {
   env->gbr = newtls;
diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h
index 8511fc3f6f..52c9d8c7db 100644
--- a/linux-user/sparc/target_cpu.h
+++ b/linux-user/sparc/target_cpu.h
@@ -36,6 +36,10 @@  static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong newsp)
 #endif
 }
 
+static inline void cpu_clone_regs_parent(CPUSPARCState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls)
 {
     env->gregs[7] = newtls;
diff --git a/linux-user/tilegx/target_cpu.h b/linux-user/tilegx/target_cpu.h
index dfca8d9598..9577462821 100644
--- a/linux-user/tilegx/target_cpu.h
+++ b/linux-user/tilegx/target_cpu.h
@@ -27,6 +27,10 @@  static inline void cpu_clone_regs_child(CPUTLGState *env, target_ulong newsp)
     env->regs[TILEGX_R_RE] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUTLGState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUTLGState *env, target_ulong newtls)
 {
     env->regs[TILEGX_R_TP] = newtls;
diff --git a/linux-user/xtensa/target_cpu.h b/linux-user/xtensa/target_cpu.h
index f436b160c4..42e66211cf 100644
--- a/linux-user/xtensa/target_cpu.h
+++ b/linux-user/xtensa/target_cpu.h
@@ -15,6 +15,10 @@  static inline void cpu_clone_regs_child(CPUXtensaState *env,
     env->regs[2] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUXtensaState *env)
+{
+}
+
 static inline void cpu_set_tls(CPUXtensaState *env, target_ulong newtls)
 {
     env->uregs[THREADPTR] = newtls;
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b9127a9601..f960556bf8 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5535,6 +5535,7 @@  static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
         new_env = cpu_copy(env);
         /* Init regs that differ from the parent.  */
         cpu_clone_regs_child(new_env, newsp);
+        cpu_clone_regs_parent(env);
         new_cpu = ENV_GET_CPU(new_env);
         new_cpu->opaque = ts;
         ts->bprm = parent_ts->bprm;
@@ -5630,6 +5631,7 @@  static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
             if (flags & CLONE_CHILD_CLEARTID)
                 ts->child_tidptr = child_tidptr;
         } else {
+            cpu_clone_regs_parent(env);
             fork_end(0);
         }
     }