From patchwork Mon Jul 30 20:15:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 143168 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4489917ljj; Mon, 30 Jul 2018 13:21:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcQ39jWiqSzdZFhzhb4waBjyO0QXJlY6syRbT86BZ/qXg/pBKEfKXsExSi7YsxZ7OGPT77Y X-Received: by 2002:a37:7883:: with SMTP id t125-v6mr17943561qkc.334.1532982068561; Mon, 30 Jul 2018 13:21:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532982068; cv=none; d=google.com; s=arc-20160816; b=0Tggf4hFcaHCkHA2xXoFUcXaZrvZX7BwTFy68E5nDndW1Ci+P0NultxmUzZsHlvTRv BFix8wqjKypcxMTRZlYoLmcgiSiuvCE9DpOSP+aMaGOPGepqnar/IWz6VJSVpp8Te6TM QvC8UIfKwTLPIDupYHjdmTOQjXjuhfkbIswM+AaGMfZx+Q/fIzGWtlQredl2LHZlalUs Lg/djfKcjpKzSWa631IyzjMLLox+gkLq6o9G6hW0p20oHRoLDSYYHLfZuZSVKd0qTF0E ezUyeXiETDY7yD+NbZ90kXedJyro2Lo8ewQMMCFcwAHmdQQ3v3JrQfufBGkiqN78rrh4 xswQ== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=Zk60bfvUd4Qid25+I+xIHckBd4rdjjMbx8r3J4vKn+A=; b=bXkqZszg2eUvfD3uxBMKB80Ibl84DC0OuftJE7LB1eWI8k4/8sQxJE7QCnLFWsH1LF 1/xLM3jxWxZG/TT+heFLvdk1dH0PCmJd81Qs61q683k2oM7YvNpFO3zSMDM65+uglHng MSU3myuPBgMYkwbPEwwiUV561HiWdktzCTLxMv8RzEAe5pMbfpq89BcjEvEy2/80sXjF dIws1dr2T7GdJ+WlL4Oq4oo0D1Fv+1IjTsttSmi3FZk/O1QhgtvsgFs5ye58QF109MP5 7ZqP2qfHsPf/+RWYVP3u+xyQIZLEHVSfhH4xdgomwQ2A1nvh1yfLNCEy2lJxarMlEfGR 6P2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Qm86FIay; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x45-v6si11174927qtk.32.2018.07.30.13.21.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 30 Jul 2018 13:21:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Qm86FIay; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEfE-0003WJ-2W for patch@linaro.org; Mon, 30 Jul 2018 16:21:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEaL-0000Ro-QA for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkEaH-00021J-Ql for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:05 -0400 Received: from mail-ua0-x243.google.com ([2607:f8b0:400c:c08::243]:42124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkEaH-00020y-M0 for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:01 -0400 Received: by mail-ua0-x243.google.com with SMTP id w7-v6so8734497uan.9 for ; Mon, 30 Jul 2018 13:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Zk60bfvUd4Qid25+I+xIHckBd4rdjjMbx8r3J4vKn+A=; b=Qm86FIayvxLSSqjP+nf6EeaEK0yU1l5Md/wSsuX9Qxj2/1lALVUoXL3GJc9SwXNEkG Ll1C2nF01xg5S7UVknwtjoyCDP324FPAzESvC0JbPjyJtzzel5xWXAttxfH5mCwS/M+c ndN27Rxdbevxjeh1z0eGN9dWNAbnGzI3G6LtY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Zk60bfvUd4Qid25+I+xIHckBd4rdjjMbx8r3J4vKn+A=; b=aYoQZO2aqFsZ+lDdA3ct3POyizzUG+FRYBttYrSX1iEPnTp8VoKSNW9RsqhbcCNVgq 63bAyWbp6R8T7Zh6bKSopd6lapncxhNC2tFsApr/x/Wm0yqy6bJh9p+tGcdYtv+kx51f JseNErV0FmgULePG5/KEeGJL+RGrNedFVUjumG20mtWcFctPfftDXGvseBVNxgvke63P 0PZilrLWlP/KSIxriOgUBlcJevtZrNvIV78ISYNlIjZMiBbO4wg1bUuNio8NkwBU8jVu sprhjsSSONsb0mO3LjgldosOcyO7+4sOqW/ffD/6Nwo+EmkZyQchC4C7fC/RyBQF9Sdq CEkA== X-Gm-Message-State: AOUpUlFij8eB4KoZTaN8QqoO/7a2syiEq7j332YrZcqledkXkK2Vso6e l1v4jp9hLuBr974McIpjg7wAPh8T5KA= X-Received: by 2002:ab0:2783:: with SMTP id t3-v6mr13123994uap.181.1532981760866; Mon, 30 Jul 2018 13:16:00 -0700 (PDT) Received: from cloudburst.twiddle.net ([190.166.236.188]) by smtp.gmail.com with ESMTPSA id x12-v6sm2542448uaj.48.2018.07.30.13.15.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Jul 2018 13:16:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 30 Jul 2018 16:15:50 -0400 Message-Id: <20180730201553.32423-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730201553.32423-1-richard.henderson@linaro.org> References: <20180730201553.32423-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c08::243 Subject: [Qemu-devel] [PATCH 1/4] linux-user: Disallow setting newsp for fork X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, laurent@vivier.eu, atar4qemu@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Or really, just clone devolving into fork. This should not ever happen in practice. We do want to reserve calling cpu_clone_regs for the case in which we are actually performing a clone. Signed-off-by: Richard Henderson --- linux-user/syscall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dfc851cc35..5bf8d13de7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6502,10 +6502,14 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, pthread_mutex_destroy(&info.mutex); pthread_mutex_unlock(&clone_lock); } else { - /* if no CLONE_VM, we consider it is a fork */ + /* If no CLONE_VM, we consider it is a fork. */ if (flags & CLONE_INVALID_FORK_FLAGS) { return -TARGET_EINVAL; } + /* As a fork, setting a new sp does not make sense. */ + if (newsp) { + return -TARGET_EINVAL; + } /* We can't support custom termination signals */ if ((flags & CSIGNAL) != TARGET_SIGCHLD) { @@ -6520,7 +6524,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, ret = fork(); if (ret == 0) { /* Child Process. */ - cpu_clone_regs(env, newsp); fork_end(1); /* There is a race condition here. The parent process could theoretically read the TID in the child process before the child From patchwork Mon Jul 30 20:15:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 143166 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4488425ljj; Mon, 30 Jul 2018 13:19:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe3GW6FvXkln7UTxX24NdLi6L9DFOeD/yUFrErSVEpUmmIj/zOxq45FLMj87xVk0tywhNhB X-Received: by 2002:a37:c887:: with SMTP id t7-v6mr554188qkl.300.1532981962433; Mon, 30 Jul 2018 13:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532981962; cv=none; d=google.com; s=arc-20160816; b=pYyHszB6kTIhDSubLydtQnsg1be/pJ8S+wz3cNOvQDEklSDab0Ja3my8FUauSXVGYt yLbPnuMQnXEBnr1zhMewodfp61c/JJbU8sMBQsR4BvB7bLsG1VCohYu3/FMzdaOmVO5n EIYvfJYQOErADOmg2t/iohL3bw6xZGhbRM5zEoV4bDA0EJLiRv3OYZdSVLqbpU+LuAAO acQg9Og8n/U9ifojC2u5aZRn+QNrxK8YAyIBc9Pm3hw9/UOKtiKFGi+U63trPGjMxOHL X/ptCTI6X1yKojO2J/b+33TNcjR/Qi+GcQ0LXy1MFT7prjv4Ehbf65NfjifNWWzvzogJ i/nQ== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=bliRudLcMm9YgmCEU61kvlPBgx9kNE1BVtBcOs0qNKM=; b=XVQEkFHIi5vNUpg/eUxRfa0IN4ae1VSX5l3Zpb+Jkn/3JFYf5O3WoTrkN2DWvd9nl4 gKyQZ10a7nWjsWWJgjQLfLArGlSCiLb2KnT3PmSzXKX8EjRoYmUiXAl5y8d+binqJCTd MEW2BtYLoGm0lphi1YcDkC/mECkFs85sYBemIyIrUjDbYRxI9vnakqImscOWNryfNKAD onDT8IaJvm5LJ2WFj+oOsshUl8p3G1DGUOGfc9eryEDJkHVS//rYd2kyjmqC14Rjseu8 aTATvGSj8Zy9muyXJLxfwdLoBPaw6bPO8zYbFv6493eIfAgyxKsseI4KTiz7BRFs4ScZ 88sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fVzue6o3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n13-v6si1113204qta.189.2018.07.30.13.19.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 30 Jul 2018 13:19:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fVzue6o3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55697 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEdV-0002Gu-SJ for patch@linaro.org; Mon, 30 Jul 2018 16:19:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55808) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEaM-0000Ry-4z for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkEaK-00022M-3X for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:06 -0400 Received: from mail-ua0-x22e.google.com ([2607:f8b0:400c:c08::22e]:33602) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkEaJ-00021z-U1 for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:04 -0400 Received: by mail-ua0-x22e.google.com with SMTP id i4-v6so8733256uak.0 for ; Mon, 30 Jul 2018 13:16:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bliRudLcMm9YgmCEU61kvlPBgx9kNE1BVtBcOs0qNKM=; b=fVzue6o35hKyN5gBgMANK7VfGcb+Ext9PgVjKCDLkiYlDJnYD0jjgjcI6c2rOtsk49 yhWpMwwpoY69RZeZJWXodblo6GFl2DQFq9HdhJFCn2tIiU/UIqOABXPetUWJcCLzwnPB lQwIBmkyWQHD6A1hDjT1BwtuIOqtoayizK+CU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bliRudLcMm9YgmCEU61kvlPBgx9kNE1BVtBcOs0qNKM=; b=Mr48pdzM8WA1AZRWTVcFvRkU4QA37KSKTT1P1R2ia6SrpLV8hYUQNPUDFn7fGIw4j2 sHl6T3Ng/my7so0DzMPU0uTWe8xWGGGLcG33lyM0+1SNO8D5RebCxd02bwVejmgag9Nw 1+WgfYjvep2qlt+KSw8136uIEIJo9IkS4nPk8ei7kHnMmlctZl3+r+GsV6CQMPEjBh5G m9yawZxK83uSXd9fpOQLxwy0AflYXavtUIM5l3CcX1cwzy4kdybtKLpH945VVJdtKNlv B5lpVzjtiZVzHJbQUKnXzngJyWiFwKKeBfWeke8nmKbrcmBN+B3VbSpTkf4ULRMLtY0G SOVw== X-Gm-Message-State: AOUpUlHsVQvkUunGokJ4hesf39jeLBQ31eXRfnuvUBnbaYVRfsrvA0TX Ak9fO1k5xN9rlfaezq/EGDpuzV75V4Y= X-Received: by 2002:ab0:1465:: with SMTP id c34-v6mr13264705uae.65.1532981762854; Mon, 30 Jul 2018 13:16:02 -0700 (PDT) Received: from cloudburst.twiddle.net ([190.166.236.188]) by smtp.gmail.com with ESMTPSA id x12-v6sm2542448uaj.48.2018.07.30.13.16.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Jul 2018 13:16:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 30 Jul 2018 16:15:51 -0400 Message-Id: <20180730201553.32423-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730201553.32423-1-richard.henderson@linaro.org> References: <20180730201553.32423-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c08::22e Subject: [Qemu-devel] [PATCH 2/4] linux-user: Pass the parent env to cpu_clone_regs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, laurent@vivier.eu, atar4qemu@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Implementing clone for sparc requires that we make modifications to both the parent and child cpu state. In all other cases, the new argument can be ignored. Signed-off-by: Richard Henderson --- 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/tilegx/target_cpu.h | 3 ++- linux-user/xtensa/target_cpu.h | 3 ++- linux-user/syscall.c | 2 +- 19 files changed, 38 insertions(+), 19 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/linux-user/aarch64/target_cpu.h b/linux-user/aarch64/target_cpu.h index a021c95fa4..130177115e 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(CPUARMState *env, CPUARMState *old_env, + target_ulong newsp) { if (newsp) { env->xregs[31] = newsp; diff --git a/linux-user/alpha/target_cpu.h b/linux-user/alpha/target_cpu.h index ac4d255ae7..750ffb50d7 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(CPUAlphaState *env, CPUAlphaState *old_env, + target_ulong newsp) { if (newsp) { env->ir[IR_SP] = newsp; diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h index 8a3764919a..5538b6cb29 100644 --- a/linux-user/arm/target_cpu.h +++ b/linux-user/arm/target_cpu.h @@ -23,7 +23,8 @@ See validate_guest_space in linux-user/elfload.c. */ #define MAX_RESERVED_VA 0xffff0000ul -static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) +static inline void cpu_clone_regs(CPUARMState *env, CPUARMState *old_env, + target_ulong newsp) { if (newsp) { env->regs[13] = newsp; diff --git a/linux-user/cris/target_cpu.h b/linux-user/cris/target_cpu.h index 2309343979..baf842b400 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(CPUCRISState *env, CPUCRISState *old_env, + target_ulong newsp) { if (newsp) { env->regs[14] = newsp; diff --git a/linux-user/hppa/target_cpu.h b/linux-user/hppa/target_cpu.h index 1c539bdbd6..7cd8d168a7 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(CPUHPPAState *env, CPUHPPAState *old_env, + target_ulong newsp) { if (newsp) { env->gr[30] = newsp; diff --git a/linux-user/i386/target_cpu.h b/linux-user/i386/target_cpu.h index ece04d0966..8fbe36670f 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(CPUX86State *env, CPUX86State *old_env, + target_ulong newsp) { if (newsp) { env->regs[R_ESP] = newsp; diff --git a/linux-user/m68k/target_cpu.h b/linux-user/m68k/target_cpu.h index 611df065ca..1f0939aea7 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(CPUM68KState *env, CPUM68KState *old_env, + target_ulong newsp) { if (newsp) { env->aregs[7] = newsp; diff --git a/linux-user/microblaze/target_cpu.h b/linux-user/microblaze/target_cpu.h index 73e139938c..3394e98918 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(CPUMBState *env, CPUMBState *old_env, + target_ulong newsp) { if (newsp) { env->regs[R_SP] = newsp; diff --git a/linux-user/mips/target_cpu.h b/linux-user/mips/target_cpu.h index 02cf5eeff7..109348a5c9 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(CPUMIPSState *env, CPUMIPSState *old_env, + target_ulong newsp) { 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 14f63338fa..09d2db74dc 100644 --- a/linux-user/nios2/target_cpu.h +++ b/linux-user/nios2/target_cpu.h @@ -20,7 +20,8 @@ #ifndef TARGET_CPU_H #define TARGET_CPU_H -static inline void cpu_clone_regs(CPUNios2State *env, target_ulong newsp) +static inline void cpu_clone_regs(CPUNios2State *env, CPUNios2State *old_env, + target_ulong newsp) { if (newsp) { env->regs[R_SP] = newsp; diff --git a/linux-user/openrisc/target_cpu.h b/linux-user/openrisc/target_cpu.h index d1ea4506e2..5ea3e1b1a6 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(CPUOpenRISCState *env, + CPUOpenRISCState *old_env, + target_ulong newsp) { 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 c4641834e7..f42e266047 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(CPUPPCState *env, CPUPPCState *old_env, + target_ulong newsp) { if (newsp) { env->gpr[1] = newsp; diff --git a/linux-user/riscv/target_cpu.h b/linux-user/riscv/target_cpu.h index 7e090f376a..b112832d95 100644 --- a/linux-user/riscv/target_cpu.h +++ b/linux-user/riscv/target_cpu.h @@ -1,7 +1,8 @@ #ifndef TARGET_CPU_H #define TARGET_CPU_H -static inline void cpu_clone_regs(CPURISCVState *env, target_ulong newsp) +static inline void cpu_clone_regs(CPURISCVState *env, CPURISCVState *old_env, + target_ulong newsp) { if (newsp) { env->gpr[xSP] = newsp; diff --git a/linux-user/s390x/target_cpu.h b/linux-user/s390x/target_cpu.h index 66ef8aa8c2..b31b9ad09d 100644 --- a/linux-user/s390x/target_cpu.h +++ b/linux-user/s390x/target_cpu.h @@ -22,7 +22,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(CPUS390XState *env, CPUS390XState *old_env, + target_ulong newsp) { if (newsp) { env->regs[15] = newsp; diff --git a/linux-user/sh4/target_cpu.h b/linux-user/sh4/target_cpu.h index 1a647ddb98..7f09ed4c3a 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(CPUSH4State *env, CPUSH4State *old_env, + target_ulong newsp) { if (newsp) { env->gregs[15] = newsp; diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index 1ffc0ae9f2..a92748cae3 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(CPUSPARCState *env, CPUSPARCState *old_env, + target_ulong newsp) { if (newsp) { env->regwptr[22] = newsp; diff --git a/linux-user/tilegx/target_cpu.h b/linux-user/tilegx/target_cpu.h index d1aa5824f2..35100a3d43 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(CPUTLGState *env, CPUTLGState *old_env, + target_ulong newsp) { 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 e31efe3ea0..0e9681e9f9 100644 --- a/linux-user/xtensa/target_cpu.h +++ b/linux-user/xtensa/target_cpu.h @@ -4,7 +4,8 @@ #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(CPUXtensaState *env, CPUXtensaState *old_env, + target_ulong newsp) { if (newsp) { env->regs[1] = newsp; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5bf8d13de7..7273a2fe54 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6442,7 +6442,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(new_env, env, newsp); new_cpu = ENV_GET_CPU(new_env); new_cpu->opaque = ts; ts->bprm = parent_ts->bprm; From patchwork Mon Jul 30 20:15:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 143165 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4486138ljj; Mon, 30 Jul 2018 13:16:35 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcLQDpS7HBoGsFKNIMEeuhPAfOHT4AaKMKkxM5ngwg503CcRL32NxQ08TewEYQLpKE/j/yc X-Received: by 2002:a37:21a0:: with SMTP id f32-v6mr17394983qki.45.1532981795232; Mon, 30 Jul 2018 13:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532981795; cv=none; d=google.com; s=arc-20160816; b=k4fnt/qCVP6vfGH94kEQ6PBMPBN+ncmfrXM8z84/wcbl7wjWY++KtILdtNIZik2vW8 soPjOPA1TZfMrgp8/RKco49hhSJFp0nC0RR0R1NuqhnSUzX0Om9uijXYRjpg2njPJ13Z rwIxXNKBzU+ZH+wtPJ5VUYyav6BCbecgW+1LwLGjjzDlNBrPZx5xtA/4u4ZwcP6D0Az6 SefXBF+Q5inQAdHRoaXCqGHKVJXskuJShy2v7Al3M+qAuO22YXiSnroDFrO9VXWwrCTT Gdu6fl3344wPxew2YztZ2YYtrnBMo3O8eT+XeZcoJ/lycIUqt+7p3uIRPUIp/n7wc0aS tNuQ== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=OQD5eALpbUL4hJOIk3zfGS6ocz2bbR8cZjXyDpaIMAg=; b=qaHR6iTuqobKonr5BLvWQWYXy2BcRnQciJbhLDNYqWwfZKX+AjraGZYUdehxS4Vy2d SO9MhbH7LGY4tWfxbIDCTkAOrwiQpQphtmN1vnKcUau2pRTFgcm4uoSLxMQ+lmrZ8SoR uu5TsdPl3oB2Evm/zmMlfUGXLtMI9THSiffsw6Ryq+dTCDxfXy2exhURtBb2dpHmuccy Hpn36sjOqfEE3M/BVr4NTOLWj/md5YFZ1a/JLzBcE9kRg2u2zQvGAJxhZj8UHrivwAgo RDoMIG85ZUY0oVCgYzSGs91bY+EwHI+e7McUD1eVnA9KtXrZUECnKeT+P8x3BsKepeGZ dkrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=f5aD+Syq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k45-v6si13037685qtf.405.2018.07.30.13.16.35 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 30 Jul 2018 13:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=f5aD+Syq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEao-0000UP-M8 for patch@linaro.org; Mon, 30 Jul 2018 16:16:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEaM-0000ST-TY for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkEaL-00023A-PX for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:06 -0400 Received: from mail-ua0-x236.google.com ([2607:f8b0:400c:c08::236]:45841) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkEaL-000233-KZ for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:05 -0400 Received: by mail-ua0-x236.google.com with SMTP id k8-v6so8730485uaq.12 for ; Mon, 30 Jul 2018 13:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OQD5eALpbUL4hJOIk3zfGS6ocz2bbR8cZjXyDpaIMAg=; b=f5aD+Syqnz04HHxKd+McVcNSeyHQajnrGY+aYokVX3vDr6y7BYdIDd6vKy/72Lp0Jm ZKJcLkCBESD02VgYEOucwMlTmqILgARZvCOvR58H9cewHAbV1Q934uNVuuODfXvLzJ24 at5yWjR1MjsOsW5P60+DqNTNPYB+8dRfHTKcw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OQD5eALpbUL4hJOIk3zfGS6ocz2bbR8cZjXyDpaIMAg=; b=UrBjy0KJVZ206AXjU6bBbJwaYoe2uQPH4UKI1CKop5QuYFXA1dSY43pNTAQXH6xjbj NNChdF8dobwhU2wnp+vGf/cNOUPUhkkpzi/vJgU6v8DxKbOyB69XNwhv3cPmXLt9rQK5 LHOJoK+vsehrQSgj3MbGOqNX4U9HCp60v1XENyzJxnbY/u/OTnZOkwcqLsTEPAh3pPYb rEdfy5Lzf55waLFWiUUmyYXygWQGaxOZ1R95h1FTTfefjEEcLBBXX5ulLjDZo7pQeRMA 8SshD2hrGSrtxN/Kr1mnqKfCRkrlrtv/XOKU1aVfBBV2ehV/KDNwSnnOvaFxXAsDwL3C 0Vfg== X-Gm-Message-State: AOUpUlGipTA4G5cEPKPNX55tLymx+vIArvojlChunQJ4yt/42ZZbZ6bG de70cCv+IKp1blRoW3oqO3PI3+jsyzg= X-Received: by 2002:ab0:5d02:: with SMTP id u2-v6mr13235153uaf.8.1532981764672; Mon, 30 Jul 2018 13:16:04 -0700 (PDT) Received: from cloudburst.twiddle.net ([190.166.236.188]) by smtp.gmail.com with ESMTPSA id x12-v6sm2542448uaj.48.2018.07.30.13.16.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Jul 2018 13:16:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 30 Jul 2018 16:15:52 -0400 Message-Id: <20180730201553.32423-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730201553.32423-1-richard.henderson@linaro.org> References: <20180730201553.32423-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c08::236 Subject: [Qemu-devel] [PATCH 3/4] linux-user/sparc: Fix cpu_clone_regs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, laurent@vivier.eu, atar4qemu@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We failed to set the secondary return value in %o1 we failed to advance the PC past the syscall, and we failed to adjust regwptr into the new structure. Signed-off-by: Richard Henderson --- linux-user/sparc/target_cpu.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index a92748cae3..c223f865e9 100644 --- a/linux-user/sparc/target_cpu.h +++ b/linux-user/sparc/target_cpu.h @@ -23,11 +23,21 @@ static inline void cpu_clone_regs(CPUSPARCState *env, CPUSPARCState *old_env, target_ulong newsp) { + /* + * After cpu_copy, env->regwptr is pointing into old_env. + * Update the new cpu to use its own register window. + */ + env->regwptr = env->regbase + (env->cwp * 16); + + /* Set a new stack, if requested. */ if (newsp) { env->regwptr[22] = newsp; } - /* syscall return for clone child: 0, and clear CF since - * this counts as a success return value. + + /* + * Syscall return for clone child: %o0 = 0 and clear CF since + * this counts as a success return value. %o1 = 1 to indicate + * this is the child. Advance the PC past the syscall. */ env->regwptr[0] = 0; #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) @@ -35,6 +45,12 @@ static inline void cpu_clone_regs(CPUSPARCState *env, CPUSPARCState *old_env, #else env->psr &= ~PSR_CARRY; #endif + env->regwptr[1] = 1; + env->pc = env->npc; + env->npc = env->npc + 4; + + /* Set the second return value for the parent: %o1 = 0. */ + old_env->regwptr[1] = 0; } static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls) From patchwork Mon Jul 30 20:15:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 143167 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4489131ljj; Mon, 30 Jul 2018 13:20:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdwrkjeImA10KRBaxeyuDflK9/iiC797BvAPhyFncakSi3rtBMdUlvf38c1KjASdz5a1G4q X-Received: by 2002:ac8:284d:: with SMTP id 13-v6mr18020515qtr.135.1532982015869; Mon, 30 Jul 2018 13:20:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532982015; cv=none; d=google.com; s=arc-20160816; b=HZZU7hzbP4M6gnjVLUxcOEoy4MQWTGEvHUqgOWCAMWeZ7yFos4NX0w7Xq02H4TlucA sbQPDKv6lJu5GR3zR1BrUkWedt0vGXWRNu2pEFWdbyG5NFjCf0aedS1JBfcbKRvllm7y 3fykwIGKCAjJ3zuienMvhzzHnmE1nzYtrTvsv5UL0zTAoAgJ/M6tFJUATP3dUS/EotaZ q5FQ8GRVvfzmLSrqGqr7eafkLcRTYrI7vtBSs+UEg3+oojQqopzwLoSdUk7ZGJGDOobi V632Olq+l3BU96negTQ64r9BwKjjn9bUXhSBPXXYBek1W51s+6HJ+orWdrBTU0NfOC6X 2fXQ== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=s0ybYs5serVVxaH+rCR3jeBEp8O8+SG5Hy+WdRLMe3c=; b=Ximf6k++mtRLpDxIdG0yvpulx7iNOSEe8BMH3cTZNt2YZLo5XhmD5VKu9fWgDbO4s9 nYzm6xtlOKxvfv2v1bkNb+IhejVct/IuHnq6Id0hK8HXj889mPd+0Py8c/3dTlXmFQQ5 NRgtsbTO42cQGrMxvm3LYTOBejCnfr4wn9FzwqEhtS/09mxXhcOn+mprVWsMDhX4k/Ac QfMwUHizkzaDBBI8bHrxX84mOZ7KhRCwgtjzMemnKUXoa3zfVBJrux46hdClUN9mTo9o SknAWWGtu4crjfbLScYKcQPhf+I6eBmtaf95hzsiAqz/MlHj9zOMj3aijvZ4cU5sLjaY pxHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dgwV4NX2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g32-v6si12418738qtc.257.2018.07.30.13.20.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 30 Jul 2018 13:20:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=dgwV4NX2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEeN-0002Hk-9S for patch@linaro.org; Mon, 30 Jul 2018 16:20:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55843) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEaO-0000Tf-CN for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkEaN-00023y-Jc for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:08 -0400 Received: from mail-ua0-x22a.google.com ([2607:f8b0:400c:c08::22a]:36032) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkEaN-00023p-FQ for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:07 -0400 Received: by mail-ua0-x22a.google.com with SMTP id c12-v6so8731679uan.3 for ; Mon, 30 Jul 2018 13:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=s0ybYs5serVVxaH+rCR3jeBEp8O8+SG5Hy+WdRLMe3c=; b=dgwV4NX2sZKw1KC1qeNzOqOMsxgQ/7j0iKU1FxvEVQP+yc80CkE9wvsFDr02hH0AUl gF+Tmr9tQ53qWDIRSivRABObnl8a4eigYMmgbrCer7nGD1nzY/9ylfQ4j+Mh6eHHZQKO kzdjfFfVJPru+OBjKEGg0UDyg6PJl6xYStzyM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s0ybYs5serVVxaH+rCR3jeBEp8O8+SG5Hy+WdRLMe3c=; b=jFrBsOp6/MBkl5wubWsA1ESUaQTuU5pW8CB/EGf2zzTrzw6nwisrGWfZ3jvpxv2hJS Zw2uh4o+JsGaKHej2JHl7GzO93o8r7n521vtXQXJa9H65DLZrYA3tXa/OfU/WT4teFny X90t4mHqfNduxFFk9uG6hL6OnyOuLUYzII7tepPPV9BMxAwQfARMZpjTFZeKvkZRT1Kz 9VbUP+VbG+MncLVBbxJtVlaVHP4sEwsSaZK6ylez5lGK2hV9zIDJmLZWRQSgU77ff4qN bkiaYkp6Ic58SasSUFR3C4erWxM6juOLoNVjjByxiQzdEYQR9cDEO9iNNQh2JDVHLaxf Fz4A== X-Gm-Message-State: AOUpUlHM84yA1uYU+/ci5DeLEiqZqfLGY/fBaG1xWI5pd9zei0sbbLAu ay78edt+BrUWj3uaChYLpSzT3NdrUBg= X-Received: by 2002:ab0:1407:: with SMTP id b7-v6mr13178040uae.200.1532981766623; Mon, 30 Jul 2018 13:16:06 -0700 (PDT) Received: from cloudburst.twiddle.net ([190.166.236.188]) by smtp.gmail.com with ESMTPSA id x12-v6sm2542448uaj.48.2018.07.30.13.16.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Jul 2018 13:16:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 30 Jul 2018 16:15:53 -0400 Message-Id: <20180730201553.32423-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730201553.32423-1-richard.henderson@linaro.org> References: <20180730201553.32423-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c08::22a Subject: [Qemu-devel] [PATCH 4/4] linux-user/sparc: Flush register windows before clone X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, laurent@vivier.eu, atar4qemu@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As seen as the very first instruction of sys_clone in the kernel. Ideally this would be done in or before cpu_copy, and not with a separate explicit test vs the syscall number, but this is a more minimal solution. Signed-off-by: Richard Henderson --- linux-user/sparc/cpu_loop.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.17.1 diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c index 91f714afc6..fe83f25686 100644 --- a/linux-user/sparc/cpu_loop.c +++ b/linux-user/sparc/cpu_loop.c @@ -169,6 +169,9 @@ void cpu_loop (CPUSPARCState *env) case 0x110: case 0x16d: #endif + if (env->gregs[1] == TARGET_NR_clone) { + flush_windows(env); + } ret = do_syscall (env, env->gregs[1], env->regwptr[0], env->regwptr[1], env->regwptr[2], env->regwptr[3],