From patchwork Tue Nov 5 18:11:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 178533 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp1111537ilf; Tue, 5 Nov 2019 10:12:10 -0800 (PST) X-Google-Smtp-Source: APXvYqxZDMb4pnFkYpawawIZedBe7Lezzno00DE1EcYq0SwiO8+CSG4RmukGoHdxS+/dDrOmmr6F X-Received: by 2002:aed:2392:: with SMTP id j18mr19059552qtc.296.1572977530187; Tue, 05 Nov 2019 10:12:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572977530; cv=none; d=google.com; s=arc-20160816; b=kUyVPH8dwZ3RPaAH2lK7lN3aXcvKpuyd1XEjCuUBK1rE+B27ZBBtFMP/PDAgRCQXRp vRDpr1W9GdsR6ifphtGoVt2uppteuZ9RwH6WzDfiIvvnNZJSZMkh+ckC0IjItLKvBbee 9lrF6mIdcGuk8gFgwthVQnmLMGn1BbfVYZr1cVds3eJnR+NHMZbKYZEHM2QyKE8X2bwe rc2+t1Ro8SVePbjh0RhCUl5q37dxFle4ZEPMNKxOIUQlfXgQefAPcIQrchUmlk1PHyNg 1v7q3K4uvDAdwYpyB9QC43cDPm59NPwdn6kh+Fsf7cwHBxe0jq6PKLnHy/kmvAZu6L8y cnzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from; bh=ohWz1yYrsymqeLR4U5xp79aUBFZZHzqc9dvzrOAnsbo=; b=S4+s7UtAEnaexUGgrwOUFKQGZlcKsgM/d/sDMbIv6WKBEbHYa0SXDg1CGTVgSu1chn txwS96Sff3QdII2UYtyBWP5ALn+qNX7QgKKF5GA8qnFWYo2kBD81cKDQUUuIeFpniESb 3XPSfgNrSoUvgTcIK4fZo/RDKBycwWxn5rEV7o+nZrBIdNQYtCesuZj+8/N9+K+2uZxV q6w2as1VlJpYGXYD/Wm7mufdkD4TTTQN7uDtnoeo8XRbCzkIgb6+ApV0N4oaM3IkK/cW LZJBWsMEww3Xwend1axhkFMSeTiHQEp/LFOhaUfXzq8PWZuTm02X/O5G3oJal35hoK8i xP9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u57si15852005qtj.99.2019.11.05.10.12.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Nov 2019 10:12:10 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:47132 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iS3JH-00067M-MV for patch@linaro.org; Tue, 05 Nov 2019 13:12:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52031) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iS3Ir-0005x0-Px for qemu-devel@nongnu.org; Tue, 05 Nov 2019 13:11:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iS3Ip-0004gc-QP for qemu-devel@nongnu.org; Tue, 05 Nov 2019 13:11:41 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:33527) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iS3Ip-0004fc-Fr for qemu-devel@nongnu.org; Tue, 05 Nov 2019 13:11:39 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1N0WLC-1hgfq51yKK-00wV5h; Tue, 05 Nov 2019 19:11:33 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 10/13] linux-user: Rename cpu_clone_regs to cpu_clone_regs_child Date: Tue, 5 Nov 2019 19:11:16 +0100 Message-Id: <20191105181119.26779-11-laurent@vivier.eu> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191105181119.26779-1-laurent@vivier.eu> References: <20191105181119.26779-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:z1OVwN1/7yWMYtmB9SgCSZ15RHD917OPC0DUFAVUiTjBbXQx3Sl JVMm+wupe5i3oiQUM9Dm8KgAmxiZ0C9XQieJmdfLiLPnHLse8fIXiej5jwZqbOxJD+WJuWg t3w8CdSZSJTp3DF3PAoI8IeKpuVBdCXI2VK+UruuIPb5H/ni/bM0Ktg3QWuSk2FLmwt4jpO 0qf4gA1hEptCXzR5f2nbQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:LhD+djBbke8=:yrLJ5qHqnrhEgBf96u1va3 covi9x07XjNxteNKlvZA8fFuZ+v5lcfOihOFQYTtj2MEMGkUHZjn9tUWRcfhi/p8ZkE8fVfwY SS/MZ89QIPbDqLHTcFSoi8gUF3gYXrr2tV9rn1wWfhXAb2cWRf/zXMq2pNPBntzLvpMqCoFRl t90gTOdq+m6MHIMjUQ9dw/vjspBAsw5+EwVdgTPAWj0w2yAXwCtj0v1SZOF9Z7IIxxA66BqaH MsLHBkAQVsvV+rLCqVOLRBGAeLvL4lByJ/zG2kigR7jI1jLY7CwlhxFKc36j7Jbw+mPN2NjH0 wcxM5VVpXF1I6Vk4R4Tqu6Be2/GFurIVdcplDfIQAxGDmNfXSTEPWxhusAs35WY66mXn/u8uq 8SN6vKPSvaV7isjijHtJz4JDMlDtl+X4MT/HQDEwK209ODhS6XkMoINSL1QzRPUPs0vR29iMv DGK5JakHdwdHDGSt7k/uB4vjU4Vf5gV5SidOiSqg1x/MH/bpwQS909+Esd3Q/RgV/gRAwiuJ5 A0h9Bhc5fv0aAaBtlmy1IiHkwrescngIg9zkqU9O0EUb6Yhkp4nnsx8VHzYDDarUHzUdbiDle Bv81SpfRwZiWHECIvrGaVMSU5647HORxw1ebik0nMpReCJvr7/nWuV+YMHU/m/S/QxW3UPMAX RBw1euQDUub4KLS3u9hS0QrCgxq2OwCzCIlauC25nDkzTaUzliTi1fzup5eSgSIhNvKrL/zlA JWCbrA+F0uPLUNxsIkxN0YiAMhoQMuzjPoWJa2pKbSQWsan2LVY94M0VvRmrYAImiaLsKupsN 3Rjph0vSwp4ymqWYl7BMZHszk4dWJ8LWCpCcOlVH7B3mWgcQqdfaeG9gMvFQsfZuKSXHtF59v DgMpIQ9yPgYXFURI2FJ65l4P4E1/RdI9yhY++puGs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.13 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Cave-Ayland , Riku Voipio , Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Artyom Tarasenko Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson We will need a target-specific hook for adjusting registers in the parent during clone. To avoid confusion, rename the one we have to make it clear it affects the child. At the same time, pass in the flags from the clone syscall. We will need them for correct behaviour for Sparc. Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20191025113921.9412-10-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/aarch64/target_cpu.h | 3 ++- linux-user/alpha/target_cpu.h | 3 ++- linux-user/arm/target_cpu.h | 3 ++- linux-user/cris/target_cpu.h | 3 ++- linux-user/hppa/target_cpu.h | 3 ++- linux-user/i386/target_cpu.h | 3 ++- linux-user/m68k/target_cpu.h | 3 ++- linux-user/microblaze/target_cpu.h | 3 ++- linux-user/mips/target_cpu.h | 3 ++- linux-user/nios2/target_cpu.h | 3 ++- linux-user/openrisc/target_cpu.h | 4 +++- linux-user/ppc/target_cpu.h | 3 ++- linux-user/riscv/target_cpu.h | 3 ++- linux-user/s390x/target_cpu.h | 3 ++- linux-user/sh4/target_cpu.h | 3 ++- linux-user/sparc/target_cpu.h | 3 ++- linux-user/syscall.c | 4 ++-- linux-user/tilegx/target_cpu.h | 3 ++- linux-user/xtensa/target_cpu.h | 4 +++- 19 files changed, 40 insertions(+), 20 deletions(-) -- 2.21.0 diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cpu.h index a021c95fa418..cd012e0dc1c8 100644 --- a/linux-user/aarch64/target_cpu.h +++ b/linux-user/aarch64/target_cpu.h @@ -19,7 +19,8 @@ #ifndef AARCH64_TARGET_CPU_H #define AARCH64_TARGET_CPU_H -static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->xregs[31] = newsp; diff --git a/linux-user/alpha/target_cpu.h b/linux-user/alpha/target_cpu.h index ac4d255ae752..37ba00cf41d1 100644 --- a/linux-user/alpha/target_cpu.h +++ b/linux-user/alpha/target_cpu.h @@ -19,7 +19,8 @@ #ifndef ALPHA_TARGET_CPU_H #define ALPHA_TARGET_CPU_H -static inline void cpu_clone_regs(CPUAlphaState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUAlphaState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->ir[IR_SP] = newsp; diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h index 3f79356a07fc..6e2ba8ad4b8e 100644 --- a/linux-user/arm/target_cpu.h +++ b/linux-user/arm/target_cpu.h @@ -41,7 +41,8 @@ static inline unsigned long arm_max_reserved_va(CPUState *cs) } #define MAX_RESERVED_VA arm_max_reserved_va -static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUARMState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->regs[13] = newsp; diff --git a/linux-user/cris/target_cpu.h b/linux-user/cris/target_cpu.h index 23093439790c..eacc4d8d13e9 100644 --- a/linux-user/cris/target_cpu.h +++ b/linux-user/cris/target_cpu.h @@ -20,7 +20,8 @@ #ifndef CRIS_TARGET_CPU_H #define CRIS_TARGET_CPU_H -static inline void cpu_clone_regs(CPUCRISState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUCRISState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->regs[14] = newsp; diff --git a/linux-user/hppa/target_cpu.h b/linux-user/hppa/target_cpu.h index 1c539bdbd6e9..f25077079088 100644 --- a/linux-user/hppa/target_cpu.h +++ b/linux-user/hppa/target_cpu.h @@ -19,7 +19,8 @@ #ifndef HPPA_TARGET_CPU_H #define HPPA_TARGET_CPU_H -static inline void cpu_clone_regs(CPUHPPAState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUHPPAState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->gr[30] = newsp; diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h index ece04d096675..1fadbf57c367 100644 --- a/linux-user/i386/target_cpu.h +++ b/linux-user/i386/target_cpu.h @@ -20,7 +20,8 @@ #ifndef I386_TARGET_CPU_H #define I386_TARGET_CPU_H -static inline void cpu_clone_regs(CPUX86State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUX86State *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->regs[R_ESP] = newsp; diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h index bc7446fbafdd..57b647bc0753 100644 --- a/linux-user/m68k/target_cpu.h +++ b/linux-user/m68k/target_cpu.h @@ -21,7 +21,8 @@ #ifndef M68K_TARGET_CPU_H #define M68K_TARGET_CPU_H -static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUM68KState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->aregs[7] = newsp; diff --git a/linux-user/microblaze/target_cpu.h b/linux-user/microblaze/target_cpu.h index 73e139938cc6..e9bc0fce6547 100644 --- a/linux-user/microblaze/target_cpu.h +++ b/linux-user/microblaze/target_cpu.h @@ -19,7 +19,8 @@ #ifndef MICROBLAZE_TARGET_CPU_H #define MICROBLAZE_TARGET_CPU_H -static inline void cpu_clone_regs(CPUMBState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUMBState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->regs[R_SP] = newsp; diff --git a/linux-user/mips/target_cpu.h b/linux-user/mips/target_cpu.h index 02cf5eeff7c2..8601f712e086 100644 --- a/linux-user/mips/target_cpu.h +++ b/linux-user/mips/target_cpu.h @@ -19,7 +19,8 @@ #ifndef MIPS_TARGET_CPU_H #define MIPS_TARGET_CPU_H -static inline void cpu_clone_regs(CPUMIPSState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUMIPSState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->active_tc.gpr[29] = newsp; diff --git a/linux-user/nios2/target_cpu.h b/linux-user/nios2/target_cpu.h index 5596c05c9c0f..fe5de7a9e3c7 100644 --- a/linux-user/nios2/target_cpu.h +++ b/linux-user/nios2/target_cpu.h @@ -20,7 +20,8 @@ #ifndef NIOS2_TARGET_CPU_H #define NIOS2_TARGET_CPU_H -static inline void cpu_clone_regs(CPUNios2State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUNios2State *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->regs[R_SP] = newsp; diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_cpu.h index 32ff135089e0..309cf3eeb73e 100644 --- a/linux-user/openrisc/target_cpu.h +++ b/linux-user/openrisc/target_cpu.h @@ -20,7 +20,9 @@ #ifndef OPENRISC_TARGET_CPU_H #define OPENRISC_TARGET_CPU_H -static inline void cpu_clone_regs(CPUOpenRISCState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUOpenRISCState *env, + target_ulong newsp, + unsigned flags) { if (newsp) { cpu_set_gpr(env, 1, newsp); diff --git a/linux-user/ppc/target_cpu.h b/linux-user/ppc/target_cpu.h index c4641834e794..028b28312c51 100644 --- a/linux-user/ppc/target_cpu.h +++ b/linux-user/ppc/target_cpu.h @@ -19,7 +19,8 @@ #ifndef PPC_TARGET_CPU_H #define PPC_TARGET_CPU_H -static inline void cpu_clone_regs(CPUPPCState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUPPCState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->gpr[1] = newsp; diff --git a/linux-user/riscv/target_cpu.h b/linux-user/riscv/target_cpu.h index 90f9a4171ee7..26dcafab1c77 100644 --- a/linux-user/riscv/target_cpu.h +++ b/linux-user/riscv/target_cpu.h @@ -1,7 +1,8 @@ #ifndef RISCV_TARGET_CPU_H #define RISCV_TARGET_CPU_H -static inline void cpu_clone_regs(CPURISCVState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPURISCVState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->gpr[xSP] = newsp; diff --git a/linux-user/s390x/target_cpu.h b/linux-user/s390x/target_cpu.h index aa181ceaee83..0b19e42f758b 100644 --- a/linux-user/s390x/target_cpu.h +++ b/linux-user/s390x/target_cpu.h @@ -19,7 +19,8 @@ #ifndef S390X_TARGET_CPU_H #define S390X_TARGET_CPU_H -static inline void cpu_clone_regs(CPUS390XState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUS390XState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->regs[15] = newsp; diff --git a/linux-user/sh4/target_cpu.h b/linux-user/sh4/target_cpu.h index b0be9a2c1bb0..857af43ee3aa 100644 --- a/linux-user/sh4/target_cpu.h +++ b/linux-user/sh4/target_cpu.h @@ -19,7 +19,8 @@ #ifndef SH4_TARGET_CPU_H #define SH4_TARGET_CPU_H -static inline void cpu_clone_regs(CPUSH4State *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUSH4State *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->gregs[15] = newsp; diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index b30fbc72c43b..029b0fc5475a 100644 --- a/linux-user/sparc/target_cpu.h +++ b/linux-user/sparc/target_cpu.h @@ -20,7 +20,8 @@ #ifndef SPARC_TARGET_CPU_H #define SPARC_TARGET_CPU_H -static inline void cpu_clone_regs(CPUSPARCState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUSPARCState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->regwptr[22] = newsp; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 247883292ce5..245ed315c834 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5820,7 +5820,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, /* we create a new CPU instance. */ new_env = cpu_copy(env); /* Init regs that differ from the parent. */ - cpu_clone_regs(new_env, newsp); + cpu_clone_regs_child(new_env, newsp, flags); new_cpu = env_cpu(new_env); new_cpu->opaque = ts; ts->bprm = parent_ts->bprm; @@ -5899,7 +5899,7 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, ret = fork(); if (ret == 0) { /* Child Process. */ - cpu_clone_regs(env, newsp); + cpu_clone_regs_child(env, newsp, flags); fork_end(1); /* There is a race condition here. The parent process could theoretically read the TID in the child process before the child diff --git a/linux-user/tilegx/target_cpu.h b/linux-user/tilegx/target_cpu.h index d1aa5824f292..0523dc414cc5 100644 --- a/linux-user/tilegx/target_cpu.h +++ b/linux-user/tilegx/target_cpu.h @@ -19,7 +19,8 @@ #ifndef TILEGX_TARGET_CPU_H #define TILEGX_TARGET_CPU_H -static inline void cpu_clone_regs(CPUTLGState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUTLGState *env, target_ulong newsp, + unsigned flags) { if (newsp) { env->regs[TILEGX_R_SP] = newsp; diff --git a/linux-user/xtensa/target_cpu.h b/linux-user/xtensa/target_cpu.h index e31efe3ea090..84f67d469ec0 100644 --- a/linux-user/xtensa/target_cpu.h +++ b/linux-user/xtensa/target_cpu.h @@ -4,7 +4,9 @@ #ifndef XTENSA_TARGET_CPU_H #define XTENSA_TARGET_CPU_H -static inline void cpu_clone_regs(CPUXtensaState *env, target_ulong newsp) +static inline void cpu_clone_regs_child(CPUXtensaState *env, + target_ulong newsp, + unsigned flags) { if (newsp) { env->regs[1] = newsp;