qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

linux-user: Introduce cpu_clone_regs_parent

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>

authored by

Richard Henderson and committed by
Laurent Vivier
07a6ecf4 608999d1

+74
+4
linux-user/aarch64/target_cpu.h
··· 28 28 env->xregs[0] = 0; 29 29 } 30 30 31 + static inline void cpu_clone_regs_parent(CPUARMState *env, unsigned flags) 32 + { 33 + } 34 + 31 35 static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls) 32 36 { 33 37 /* Note that AArch64 Linux keeps the TLS pointer in TPIDR; this is
+4
linux-user/alpha/target_cpu.h
··· 29 29 env->ir[IR_A3] = 0; 30 30 } 31 31 32 + static inline void cpu_clone_regs_parent(CPUAlphaState *env, unsigned flags) 33 + { 34 + } 35 + 32 36 static inline void cpu_set_tls(CPUAlphaState *env, target_ulong newtls) 33 37 { 34 38 env->unique = newtls;
+4
linux-user/arm/target_cpu.h
··· 50 50 env->regs[0] = 0; 51 51 } 52 52 53 + static inline void cpu_clone_regs_parent(CPUARMState *env, unsigned flags) 54 + { 55 + } 56 + 53 57 static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls) 54 58 { 55 59 if (access_secure_reg(env)) {
+4
linux-user/cris/target_cpu.h
··· 29 29 env->regs[10] = 0; 30 30 } 31 31 32 + static inline void cpu_clone_regs_parent(CPUCRISState *env, unsigned flags) 33 + { 34 + } 35 + 32 36 static inline void cpu_set_tls(CPUCRISState *env, target_ulong newtls) 33 37 { 34 38 env->pregs[PR_PID] = (env->pregs[PR_PID] & 0xff) | newtls;
+4
linux-user/hppa/target_cpu.h
··· 32 32 env->iaoq_b = env->gr[31] + 4; 33 33 } 34 34 35 + static inline void cpu_clone_regs_parent(CPUHPPAState *env, unsigned flags) 36 + { 37 + } 38 + 35 39 static inline void cpu_set_tls(CPUHPPAState *env, target_ulong newtls) 36 40 { 37 41 env->cr[27] = newtls;
+4
linux-user/i386/target_cpu.h
··· 29 29 env->regs[R_EAX] = 0; 30 30 } 31 31 32 + static inline void cpu_clone_regs_parent(CPUX86State *env, unsigned flags) 33 + { 34 + } 35 + 32 36 #if defined(TARGET_ABI32) 33 37 abi_long do_set_thread_area(CPUX86State *env, abi_ulong ptr); 34 38
+4
linux-user/m68k/target_cpu.h
··· 30 30 env->dregs[0] = 0; 31 31 } 32 32 33 + static inline void cpu_clone_regs_parent(CPUM68KState *env, unsigned flags) 34 + { 35 + } 36 + 33 37 static inline void cpu_set_tls(CPUM68KState *env, target_ulong newtls) 34 38 { 35 39 CPUState *cs = env_cpu(env);
+4
linux-user/microblaze/target_cpu.h
··· 28 28 env->regs[3] = 0; 29 29 } 30 30 31 + static inline void cpu_clone_regs_parent(CPUMBState *env, unsigned flags) 32 + { 33 + } 34 + 31 35 static inline void cpu_set_tls(CPUMBState *env, target_ulong newtls) 32 36 { 33 37 env->regs[21] = newtls;
+4
linux-user/mips/target_cpu.h
··· 29 29 env->active_tc.gpr[2] = 0; 30 30 } 31 31 32 + static inline void cpu_clone_regs_parent(CPUMIPSState *env, unsigned flags) 33 + { 34 + } 35 + 32 36 static inline void cpu_set_tls(CPUMIPSState *env, target_ulong newtls) 33 37 { 34 38 env->active_tc.CP0_UserLocal = newtls;
+4
linux-user/nios2/target_cpu.h
··· 29 29 env->regs[R_RET0] = 0; 30 30 } 31 31 32 + static inline void cpu_clone_regs_parent(CPUNios2State *env, unsigned flags) 33 + { 34 + } 35 + 32 36 static inline void cpu_set_tls(CPUNios2State *env, target_ulong newtls) 33 37 { 34 38 /*
+4
linux-user/openrisc/target_cpu.h
··· 30 30 cpu_set_gpr(env, 11, 0); 31 31 } 32 32 33 + static inline void cpu_clone_regs_parent(CPUOpenRISCState *env, unsigned flags) 34 + { 35 + } 36 + 33 37 static inline void cpu_set_tls(CPUOpenRISCState *env, target_ulong newtls) 34 38 { 35 39 cpu_set_gpr(env, 10, newtls);
+4
linux-user/ppc/target_cpu.h
··· 28 28 env->gpr[3] = 0; 29 29 } 30 30 31 + static inline void cpu_clone_regs_parent(CPUPPCState *env, unsigned flags) 32 + { 33 + } 34 + 31 35 static inline void cpu_set_tls(CPUPPCState *env, target_ulong newtls) 32 36 { 33 37 #if defined(TARGET_PPC64)
+4
linux-user/riscv/target_cpu.h
··· 11 11 env->gpr[xA0] = 0; 12 12 } 13 13 14 + static inline void cpu_clone_regs_parent(CPURISCVState *env, unsigned flags) 15 + { 16 + } 17 + 14 18 static inline void cpu_set_tls(CPURISCVState *env, target_ulong newtls) 15 19 { 16 20 env->gpr[xTP] = newtls;
+4
linux-user/s390x/target_cpu.h
··· 28 28 env->regs[2] = 0; 29 29 } 30 30 31 + static inline void cpu_clone_regs_parent(CPUS390XState *env, unsigned flags) 32 + { 33 + } 34 + 31 35 static inline void cpu_set_tls(CPUS390XState *env, target_ulong newtls) 32 36 { 33 37 env->aregs[0] = newtls >> 32;
+4
linux-user/sh4/target_cpu.h
··· 28 28 env->gregs[0] = 0; 29 29 } 30 30 31 + static inline void cpu_clone_regs_parent(CPUSH4State *env, unsigned flags) 32 + { 33 + } 34 + 31 35 static inline void cpu_set_tls(CPUSH4State *env, target_ulong newtls) 32 36 { 33 37 env->gbr = newtls;
+4
linux-user/sparc/target_cpu.h
··· 37 37 #endif 38 38 } 39 39 40 + static inline void cpu_clone_regs_parent(CPUSPARCState *env, unsigned flags) 41 + { 42 + } 43 + 40 44 static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls) 41 45 { 42 46 env->gregs[7] = newtls;
+2
linux-user/syscall.c
··· 5821 5821 new_env = cpu_copy(env); 5822 5822 /* Init regs that differ from the parent. */ 5823 5823 cpu_clone_regs_child(new_env, newsp, flags); 5824 + cpu_clone_regs_parent(env, flags); 5824 5825 new_cpu = env_cpu(new_env); 5825 5826 new_cpu->opaque = ts; 5826 5827 ts->bprm = parent_ts->bprm; ··· 5917 5918 if (flags & CLONE_CHILD_CLEARTID) 5918 5919 ts->child_tidptr = child_tidptr; 5919 5920 } else { 5921 + cpu_clone_regs_parent(env, flags); 5920 5922 fork_end(0); 5921 5923 } 5922 5924 }
+4
linux-user/tilegx/target_cpu.h
··· 28 28 env->regs[TILEGX_R_RE] = 0; 29 29 } 30 30 31 + static inline void cpu_clone_regs_parent(CPUTLGState *env, unsigned flags) 32 + { 33 + } 34 + 31 35 static inline void cpu_set_tls(CPUTLGState *env, target_ulong newtls) 32 36 { 33 37 env->regs[TILEGX_R_TP] = newtls;
+4
linux-user/xtensa/target_cpu.h
··· 16 16 env->regs[2] = 0; 17 17 } 18 18 19 + static inline void cpu_clone_regs_parent(CPUXtensaState *env, unsigned flags) 20 + { 21 + } 22 + 19 23 static inline void cpu_set_tls(CPUXtensaState *env, target_ulong newtls) 20 24 { 21 25 env->uregs[THREADPTR] = newtls;