From patchwork Wed Nov 6 13:04:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 178694 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp597636ilf; Wed, 6 Nov 2019 05:20:01 -0800 (PST) X-Google-Smtp-Source: APXvYqz9NLMyP88OErpLsf0QR2Le1pUectvYGnznQlYxYZwgnVZ2VzQNO5mugDxybUQohEWausQc X-Received: by 2002:aa7:c44a:: with SMTP id n10mr2544433edr.282.1573046401131; Wed, 06 Nov 2019 05:20:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573046401; cv=none; d=google.com; s=arc-20160816; b=N8aV69XYmgI/Guk9vH9xzZdmhjtx1q2L/3Qpox48pq20FlXZwBbVRhmHtVG1coxbb0 7njtusJ+u7RNOMcZE6ko4pY1BLHgGyL+fuZaCKL3QPMY4NjEkbSCAE57twnUeyBt3Fyo TZ7s4BvJH5unHLLufFqFCRBT0TKJpRlis823duDvtGnrPR1FutCh2ks3I0ik6TCYN/5+ 8n5GTISKspFDQ1kHj6qEsPzMdcbLw8BCbtDpwS/fbj5OOJn+uL/7pKwR8CgLrM52ZFvy rAqOpTwPjBS/LeETIFLmxMeP6Yn7vcBGKwIAOtOwbpCrwpoXIxOKenWgjscbqBgpXpWG +SWw== 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=sJFYvzGNAtG2Y10f9vNUZIRuluUY9W4idI/lmnJt/ew=; b=j4S5ufyhcu8yBgyQV7FuDPy7Z1HTcwnx1WsXzw5UcwcQGAfB3KFiln214gShu97wC5 FyvvfQoZMhGV0aiuwJelhq3fjYxBqqN8sbEamC7Mq7rDfY5iikT8brjwcnqwO8EfNgpN KbZdXppP8/stcwU/nExUyUB8dt2o0xXdKqTQPs1t1cv8952A4YKVKGgW1awMQOvPQ8AO 7RWQ0d5ce29/aYLiB+KvGwWV/4RNUZG9uTcrONzeFzM6nc5fIf26GBjwHHSN399RdfMY HoIH0LusPnpXFGVwtrbi+l0KFLI90l0u41cpdHXA/9UXTMwMc6wMZ5vLofntZuJUgqZi +uGA== 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 bi3si13427048edb.331.2019.11.06.05.20.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Nov 2019 05:20:01 -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]:57998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSLE7-0005om-Qy for patch@linaro.org; Wed, 06 Nov 2019 08:19:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36578) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iSL06-0003qX-Mk for qemu-devel@nongnu.org; Wed, 06 Nov 2019 08:05:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iSL04-00035L-M7 for qemu-devel@nongnu.org; Wed, 06 Nov 2019 08:05:30 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:38071) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iSL04-00034n-CX for qemu-devel@nongnu.org; Wed, 06 Nov 2019 08:05:28 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MG9c4-1iitPD3z9o-00GViD; Wed, 06 Nov 2019 14:05:16 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 11/13] linux-user: Introduce cpu_clone_regs_parent Date: Wed, 6 Nov 2019 14:04:54 +0100 Message-Id: <20191106130456.6176-12-laurent@vivier.eu> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191106130456.6176-1-laurent@vivier.eu> References: <20191106130456.6176-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:fqCF6jQb4Tqp7Xg/84QPi/I3oc9P5g5PkjdYffnAgrZIN8CAzbu JwA1nw8pSUPPseM0OUskbsO4QCJefBUv58KW/a9FcnEhkJH3w4ZCBMYU4aRfTGfqcq/bhjc uKZmsAwf4a6Rf8P6myjo2f0JRfA1gVnEoOCtzBEax8gxKmXqrPMKrWeLaNHhefgUaTKZURE Xd7Fl6pvAN6CQJpXkudnQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:nxemIHFpLnY=:iSVcNWT5/zaNmytBSQAzk/ qrX+YkTtVBoSdaS3aCpGu+8CP8/kerOPhwxwIRJWsi2xiF+QaRV3IRIOAtU8E8IZs1axsMiGe Dj0wk4DQoi6aNSkdt+kyrJ472nJ41F4VVEsZ+8xK9Y0FGrxSWt0XXcGblssakljz70V8BH9tp 8+NsJkA+FLncyLioXRN8qP4hgpsDP2uENL5fZrQz7fPqAMx8JvmR4Mzop9/BpES+mDixHyVm3 6UClvAvGXbQ72grILwxhJH2dFW1DDPG4PKROuEurbFC5kEJZ7yKBl353HvDWNqtuZcNyhvjmr sb9w8vyA6ySAVJYWFIF4AxNl2O2vZ/zKpdhoWNZ+y90UhUMmX202PZBwUKcdSGujSCoibWHTH k4fZYjmdn4ntEeTUDmBMcqcvaBp3OgysqDuNn/Q+Ac/9YHi1K/fz8RynsH96mlxaMAsnmBTHW 3KQEhZoH2UYcytg94bhGmEg9XtjyFiPu7L9Y+lD+MMpwYH6Qsull1eWhzdj+UgdKmX+H/1xZ7 trMDF3WbHH1ryz0I/GFl8eSspqJE+Ipcu52fROYP7Ta8tUrGaLWlRboBJp7KFdb8jUXPkg+I/ py/nkaAcL21BFuCDJ7BVMr3ZnlAAQbrJg5hqNOWZWcnGBkftG3jGuiQ8WfygiH05K/HMti5eW /bwm8q7zL/AGlp2Cl2KTwM/eTl+mEVGHrGoRxWkAJoFJYbh7tEeUx+aVdLB057s5IATjlGBVN 79TbfisBdMTpaLBJ8USA5S2bHZ0D/8jPNVN4jaeuqwmdkvQD8xLpvKgRxeCSwqm6tx9VqS9I6 FMrvkBkekvr+xOsApAn70QPFegxaZuX9ZVFaeU5GjYZCDGllQokI1NDhjNmrE/8P0P1wDx5qk EEA+vTL+QJwzN2tjDeRQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.187 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: Richard Henderson , Riku Voipio , Mark Cave-Ayland , 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. Add an empty inline function for each target, and invoke it from the proper places. Reviewed-by: Laurent Vivier Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20191106113318.10226-11-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- 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/syscall.c | 2 ++ linux-user/tilegx/target_cpu.h | 4 ++++ linux-user/xtensa/target_cpu.h | 4 ++++ 19 files changed, 74 insertions(+) -- 2.21.0 diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cpu.h index cd012e0dc1c8..6cc02e7dcdfb 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 37ba00cf41d1..dd25e18f47fb 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 6e2ba8ad4b8e..2747211b24ab 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 eacc4d8d13e9..74ead55c8114 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 f25077079088..71654b3cd4c0 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 1fadbf57c367..0b44530854c8 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 57b647bc0753..c3f288dfe83e 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 e9bc0fce6547..ce7b22ece7c4 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 8601f712e086..758ae4d933fe 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 fe5de7a9e3c7..50f03810675a 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 309cf3eeb73e..74370d67c45d 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 028b28312c51..76b67d2882bf 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 26dcafab1c77..9c642367a362 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 0b19e42f758b..7cd71e2dbab3 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 857af43ee3aa..5114f1942482 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 029b0fc5475a..8ff706adcef7 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/syscall.c b/linux-user/syscall.c index 245ed315c834..ab9d933e53af 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -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); } } diff --git a/linux-user/tilegx/target_cpu.h b/linux-user/tilegx/target_cpu.h index 0523dc414cc5..316b7a639c3d 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 84f67d469ec0..0c77bafd66f7 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;