]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user: Introduce cpu_clone_regs_parent
authorRichard Henderson <richard.henderson@linaro.org>
Wed, 6 Nov 2019 11:33:16 +0000 (12:33 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Wed, 6 Nov 2019 12:43:25 +0000 (13:43 +0100)
We will need a target-specific hook for adjusting registers
in the parent during clone.  Add an empty inline function for
each target, and invoke it from the proper places.

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20191106113318.10226-11-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
19 files changed:
linux-user/aarch64/target_cpu.h
linux-user/alpha/target_cpu.h
linux-user/arm/target_cpu.h
linux-user/cris/target_cpu.h
linux-user/hppa/target_cpu.h
linux-user/i386/target_cpu.h
linux-user/m68k/target_cpu.h
linux-user/microblaze/target_cpu.h
linux-user/mips/target_cpu.h
linux-user/nios2/target_cpu.h
linux-user/openrisc/target_cpu.h
linux-user/ppc/target_cpu.h
linux-user/riscv/target_cpu.h
linux-user/s390x/target_cpu.h
linux-user/sh4/target_cpu.h
linux-user/sparc/target_cpu.h
linux-user/syscall.c
linux-user/tilegx/target_cpu.h
linux-user/xtensa/target_cpu.h

index cd012e0dc1c800f5e3ecc7a714e7086a32af0453..6cc02e7dcdfbce3f419e1928c5155071e1349fc0 100644 (file)
@@ -28,6 +28,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)
 {
     /* Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is
index 37ba00cf41d1d0118a07ed11dbaf32f9120e88ab..dd25e18f47fb123fa64aed444e1a99355ee48782 100644 (file)
@@ -29,6 +29,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls)
 {
     env->unique = newtls;
index 6e2ba8ad4b8e393149b614db97ee00330dc55de6..2747211b24ab597f5caa274f6f3e98f1a181b8c9 100644 (file)
@@ -50,6 +50,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls)
 {
     if (access_secure_reg(env)) {
index eacc4d8d13e9e5096305bc532ad81a941bafe89f..74ead55c8114af2c8e491309d870def4c789e0d8 100644 (file)
@@ -29,6 +29,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls)
 {
     env->pregs[PR_PID] = (env->pregs[PR_PID] & 0xff) | newtls;
index f25077079088de9e47fc67ef670aec3045c0898b..71654b3cd4c0ba8a39062b45a0f6a960a23c89a3 100644 (file)
@@ -32,6 +32,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUHPPAState *env, target_ulong newtls)
 {
     env->cr[27] = newtls;
index 1fadbf57c367916a41a8d8011eb572b1b929c786..0b44530854c8be0eaa69f0188765190b8fa66a23 100644 (file)
@@ -29,6 +29,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, unsigned flags)
+{
+}
+
 #if defined(TARGET_ABI32)
 abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr);
 
index 57b647bc0753c062e948bf8f9f908406ea579a10..c3f288dfe83eb830e1ba4a92673bdcc6120e198d 100644 (file)
@@ -30,6 +30,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls)
 {
     CPUState *cs = env_cpu(env);
index e9bc0fce6547107e363ae626b359538b96121387..ce7b22ece7c4891a0c04cf0dea68b1ca32f9df51 100644 (file)
@@ -28,6 +28,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUMBState *env, target_ulong newtls)
 {
     env->regs[21] = newtls;
index 8601f712e08650dbf2019965306983959326cc91..758ae4d933fe6f5be510d79ccf804b3ce2e4dcfc 100644 (file)
@@ -29,6 +29,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUMIPSState *env, target_ulong newtls)
 {
     env->active_tc.CP0_UserLocal = newtls;
index fe5de7a9e3c71a1cf34c2b1401af09a5716a51b7..50f03810675afbc7743892558faee0b1fbd548e4 100644 (file)
@@ -29,6 +29,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUNios2State *env, target_ulong newtls)
 {
     /*
index 309cf3eeb73e316367fa6c92c1fd3286e50562ec..74370d67c45d457f3308656e8e9cc4aca8056fe6 100644 (file)
@@ -30,6 +30,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUOpenRISCState *env, target_ulong newtls)
 {
     cpu_set_gpr(env, 10, newtls);
index 028b28312c515e7e71dae12fe50639963e4d6d1c..76b67d2882bf7ab7e1b1436ccb8cc31e7e210cfe 100644 (file)
@@ -28,6 +28,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUPPCState *env, target_ulong newtls)
 {
 #if defined(TARGET_PPC64)
index 26dcafab1c774af6b7145aec81abbbaaa8a19501..9c642367a3620b54b41b80bbfeac10032c9559f5 100644 (file)
@@ -11,6 +11,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPURISCVState *env, target_ulong newtls)
 {
     env->gpr[xTP] = newtls;
index 0b19e42f758b81af844d9177555ac9b2737cf1a9..7cd71e2dbab3eb56b31cf6f43f455c06f8ebd247 100644 (file)
@@ -28,6 +28,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls)
 {
     env->aregs[0] = newtls >> 32;
index 857af43ee3aaa7d6b67e61ae87ddee9b206170ec..5114f1942482cd1a13d654d47c7589f78f449fa1 100644 (file)
@@ -28,6 +28,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUSH4State *env, target_ulong newtls)
 {
   env->gbr = newtls;
index 029b0fc5475a06be134899ca185761b97f5c3a99..8ff706adcef7826af2c61482fb3eba3d32ed9f3b 100644 (file)
@@ -37,6 +37,10 @@ static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong newsp,
 #endif
 }
 
+static inline void cpu_clone_regs_parent(CPUSPARCState *env, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls)
 {
     env->gregs[7] = newtls;
index 245ed315c834a67b5e27a141b17f3146597ca425..ab9d933e53af357b2a3a45078ff69b3a27474eaf 100644 (file)
@@ -5821,6 +5821,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, flags);
+        cpu_clone_regs_parent(env, flags);
         new_cpu = env_cpu(new_env);
         new_cpu->opaque = ts;
         ts->bprm = parent_ts->bprm;
@@ -5917,6 +5918,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, flags);
             fork_end(0);
         }
     }
index 0523dc414cc59909db0088c1a30c99d822ae7d85..316b7a639c3d557343d57c03ff21b39f3162c980 100644 (file)
@@ -28,6 +28,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, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUTLGState *env, target_ulong newtls)
 {
     env->regs[TILEGX_R_TP] = newtls;
index 84f67d469ec072ea30761e8795fa254c8c8311b7..0c77bafd66f7696d51f96478d21ea438a7590008 100644 (file)
@@ -16,6 +16,10 @@ static inline void cpu_clone_regs_child(CPUXtensaState *env,
     env->regs[2] = 0;
 }
 
+static inline void cpu_clone_regs_parent(CPUXtensaState *env, unsigned flags)
+{
+}
+
 static inline void cpu_set_tls(CPUXtensaState *env, target_ulong newtls)
 {
     env->uregs[THREADPTR] = newtls;