qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: alex.bennee@linaro.org
Subject: Re: [PATCH v2 10/12] linux-user: Introduce cpu_clone_regs_parent
Date: Tue, 5 Nov 2019 10:52:52 +0100	[thread overview]
Message-ID: <58a009e6-d0c6-7a99-72fa-86b087efb4ad@vivier.eu> (raw)
In-Reply-To: <20191025113921.9412-11-richard.henderson@linaro.org>

Le 25/10/2019 à 13:39, Richard Henderson a écrit :
> 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>
> ---
>  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 cd012e0dc1..6cc02e7dcd 100644
> --- a/linux-user/aarch64/target_cpu.h
> +++ b/linux-user/aarch64/target_cpu.h
> @@ -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
> diff --git a/linux-user/alpha/target_cpu.h b/linux-user/alpha/target_cpu.h
> index 37ba00cf41..dd25e18f47 100644
> --- a/linux-user/alpha/target_cpu.h
> +++ b/linux-user/alpha/target_cpu.h
> @@ -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;
> diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h
> index 6e2ba8ad4b..2747211b24 100644
> --- a/linux-user/arm/target_cpu.h
> +++ b/linux-user/arm/target_cpu.h
> @@ -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)) {
> diff --git a/linux-user/cris/target_cpu.h b/linux-user/cris/target_cpu.h
> index eacc4d8d13..74ead55c81 100644
> --- a/linux-user/cris/target_cpu.h
> +++ b/linux-user/cris/target_cpu.h
> @@ -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;
> diff --git a/linux-user/hppa/target_cpu.h b/linux-user/hppa/target_cpu.h
> index f250770790..71654b3cd4 100644
> --- a/linux-user/hppa/target_cpu.h
> +++ b/linux-user/hppa/target_cpu.h
> @@ -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;
> diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h
> index 1fadbf57c3..0b44530854 100644
> --- a/linux-user/i386/target_cpu.h
> +++ b/linux-user/i386/target_cpu.h
> @@ -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);
>  
> diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h
> index 57b647bc07..c3f288dfe8 100644
> --- a/linux-user/m68k/target_cpu.h
> +++ b/linux-user/m68k/target_cpu.h
> @@ -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);
> diff --git a/linux-user/microblaze/target_cpu.h b/linux-user/microblaze/target_cpu.h
> index e9bc0fce65..ce7b22ece7 100644
> --- a/linux-user/microblaze/target_cpu.h
> +++ b/linux-user/microblaze/target_cpu.h
> @@ -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;
> diff --git a/linux-user/mips/target_cpu.h b/linux-user/mips/target_cpu.h
> index 8601f712e0..758ae4d933 100644
> --- a/linux-user/mips/target_cpu.h
> +++ b/linux-user/mips/target_cpu.h
> @@ -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;
> diff --git a/linux-user/nios2/target_cpu.h b/linux-user/nios2/target_cpu.h
> index fe5de7a9e3..50f0381067 100644
> --- a/linux-user/nios2/target_cpu.h
> +++ b/linux-user/nios2/target_cpu.h
> @@ -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)
>  {
>      /*
> diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_cpu.h
> index 309cf3eeb7..74370d67c4 100644
> --- a/linux-user/openrisc/target_cpu.h
> +++ b/linux-user/openrisc/target_cpu.h
> @@ -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);
> diff --git a/linux-user/ppc/target_cpu.h b/linux-user/ppc/target_cpu.h
> index 028b28312c..76b67d2882 100644
> --- a/linux-user/ppc/target_cpu.h
> +++ b/linux-user/ppc/target_cpu.h
> @@ -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)
> diff --git a/linux-user/riscv/target_cpu.h b/linux-user/riscv/target_cpu.h
> index 26dcafab1c..9c642367a3 100644
> --- a/linux-user/riscv/target_cpu.h
> +++ b/linux-user/riscv/target_cpu.h
> @@ -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;
> diff --git a/linux-user/s390x/target_cpu.h b/linux-user/s390x/target_cpu.h
> index 0b19e42f75..7cd71e2dba 100644
> --- a/linux-user/s390x/target_cpu.h
> +++ b/linux-user/s390x/target_cpu.h
> @@ -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;
> diff --git a/linux-user/sh4/target_cpu.h b/linux-user/sh4/target_cpu.h
> index 857af43ee3..5114f19424 100644
> --- a/linux-user/sh4/target_cpu.h
> +++ b/linux-user/sh4/target_cpu.h
> @@ -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;
> diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h
> index 029b0fc547..8ff706adce 100644
> --- a/linux-user/sparc/target_cpu.h
> +++ b/linux-user/sparc/target_cpu.h
> @@ -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;
> diff --git a/linux-user/tilegx/target_cpu.h b/linux-user/tilegx/target_cpu.h
> index 0523dc414c..316b7a639c 100644
> --- a/linux-user/tilegx/target_cpu.h
> +++ b/linux-user/tilegx/target_cpu.h
> @@ -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;
> diff --git a/linux-user/xtensa/target_cpu.h b/linux-user/xtensa/target_cpu.h
> index 84f67d469e..0c77bafd66 100644
> --- a/linux-user/xtensa/target_cpu.h
> +++ b/linux-user/xtensa/target_cpu.h
> @@ -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;
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index a07d4b4774..ed18bcc825 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -5719,6 +5719,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;
> @@ -5815,6 +5816,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);
>          }
>      }
> 

Applied to my linux-user branch.

Thanks,
Laurent


  parent reply	other threads:[~2019-11-05  9:58 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-25 11:39 [PATCH v2 00/12] linux-user sparc fixes Richard Henderson
2019-10-25 11:39 ` [PATCH v2 01/12] scripts/qemu-binfmt-conf: Update for sparc64 Richard Henderson
2019-11-05  9:43   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 02/12] tests/tcg/multiarch/linux-test: Fix error check for shmat Richard Henderson
2019-10-25 12:59   ` Philippe Mathieu-Daudé
2019-10-25 13:00   ` Philippe Mathieu-Daudé
2019-11-05  9:45   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 03/12] target/sparc: Define an enumeration for accessing env->regwptr Richard Henderson
2019-11-05  9:45   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 04/12] linux-user/sparc: Use WREG constants in sparc/target_cpu.h Richard Henderson
2019-10-25 12:09   ` Laurent Vivier
2019-11-05  9:49   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 05/12] linux-user/sparc: Begin using WREG constants in sparc/signal.c Richard Henderson
2019-10-25 12:16   ` Laurent Vivier
2019-11-05  9:49   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 06/12] linux-user/sparc: Use WREG_SP constant " Richard Henderson
2019-10-25 12:19   ` Laurent Vivier
2019-11-05  9:50   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 07/12] linux-user/sparc: Fix WREG usage in setup_frame Richard Henderson
2019-11-05  9:50   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 08/12] linux-user/sparc64: Fix target_signal_frame Richard Henderson
2019-10-25 12:47   ` Laurent Vivier
2019-10-25 13:38     ` Richard Henderson
2019-10-25 13:43       ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 09/12] linux-user: Rename cpu_clone_regs to cpu_clone_regs_child Richard Henderson
2019-10-25 13:03   ` Philippe Mathieu-Daudé
2019-11-05  9:52   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 10/12] linux-user: Introduce cpu_clone_regs_parent Richard Henderson
2019-10-25 13:04   ` Philippe Mathieu-Daudé
2019-11-05  9:52   ` Laurent Vivier [this message]
2019-10-25 11:39 ` [PATCH v2 11/12] linux-user/sparc: Fix cpu_clone_regs_* Richard Henderson
2019-11-05  9:54   ` Laurent Vivier
2019-10-25 11:39 ` [PATCH v2 12/12] linux-user/alpha: Set r20 secondary return value Richard Henderson
2019-10-25 12:56   ` Laurent Vivier
2019-11-05  9:53   ` Laurent Vivier
2019-10-25 12:50 ` [PATCH v2 00/12] linux-user sparc fixes Laurent Vivier
2019-10-26  7:02 ` no-reply

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=58a009e6-d0c6-7a99-72fa-86b087efb4ad@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=alex.bennee@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).