From patchwork Fri May 10 03:27:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163816 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp1821362ilr; Thu, 9 May 2019 20:30:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNHTC3F5VNBXjHlf1ahT/YzYOG19zNC+ac5/BYkm+gkc9yqpBIT3XpuXEPNTfpoPydAy+J X-Received: by 2002:adf:f548:: with SMTP id j8mr5800107wrp.171.1557459017951; Thu, 09 May 2019 20:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557459017; cv=none; d=google.com; s=arc-20160816; b=BrVjJCC90Guodi9/FLVLNMfqocIzUa2xb9XABqu+xkWFqzz2lGG7hziCS81MehWfHh hh3qP01zmUckMK4Aq86qda7G4a+sc/Y09kn/zUOn6GH4AtIcjXoMKnsggCsztPlNUAt2 zTxE+y9EXP/dRz3jcfHx5t0or5s9Jhyxy2qi+my+LQROc1HC+cLhzydS7OpSXm63Br42 y5sd2FTF5jrhXyC2Xs802yWyQV07P8Vvh/OsWyNber6xhjyTqXLAJku/cztKuufiSlUo +fBccaKijrZfgxKCpZoil0kIRIfnrR3A0EriwdVXCW/MK469ZVAwaJimOIn1XEBeb/Kb Uh/g== 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; bh=dB9naD8XYt7AtlbN9T/W2D2B/j/Ax2scb9z0hcM/3hI=; b=Fwcvz9Whwu5epDppBwURDNRijEKiPfm2M9DnBq1L1Sa88ZBusORJv8sS5sNKsjTRnu 9Q6IwaSslJzFdm5dG0OtikWEHmoyhdXnxb16KElbu5FRUNXrUumx+Z7JQ+CH8mmXcw6/ S0HKcCQW5E8khrvQ3SOzrQ3erSqNqLi9N39T9a1ahoj7HP50KKRltOmZKpUFcl+S+r0l AmsQkL9c5Mbt4s6yDfo+OJD3XJ5H8PAt+cfzkzngLCZOvQt5NJlpP0Pp3Pkr09j2gl/S JlkO1cSHEQH/ehnZee0j86v/pERSjCNUtk2XGpzXFQVkx9FOOxviDCgpIXXWgzn350U0 pEew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=m3jv+bsa; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p5si2803201wmh.35.2019.05.09.20.30.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 May 2019 20:30:17 -0700 (PDT) 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; dkim=fail header.i=@linaro.org header.s=google header.b=m3jv+bsa; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:36167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOwEi-0005WG-TG for patch@linaro.org; Thu, 09 May 2019 23:30:16 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOwBu-00030H-QU for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOwBt-0001Sd-SW for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:22 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:35589) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOwBt-0001SI-NE for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:21 -0400 Received: by mail-pl1-x641.google.com with SMTP id g5so2133963plt.2 for ; Thu, 09 May 2019 20:27:21 -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=dB9naD8XYt7AtlbN9T/W2D2B/j/Ax2scb9z0hcM/3hI=; b=m3jv+bsahW28jCHcbKpzohUtOdPkYK7q8eZnPVQW7aSDBZTwJXydlhMlSuGAvbeTck wJV28h8VS0IHTiDiVXVwWV+/dPZzZwn3fuySms7kdUJP2ay635//MNzuaC4MV9HZNs+2 /j/7pYo7FdkLstxY2yX3U9TUpCju3XPKSDJbqyi8L6dfgw2pzp+x6it5QRFTwgn9HNOB XF4OMIbbJZIZ3pVPK53yJ1B6SPfVQ/3PNGWRFFPrAXlUC+PsVgm9B/gUnJ6aTkThYcK+ RgtF4b7alkCTPik6QsqdKUzcm8YgEa5LVoeF70OaIdqBC8JGbPuo7vgB183aigzOTtDj WNVQ== 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=dB9naD8XYt7AtlbN9T/W2D2B/j/Ax2scb9z0hcM/3hI=; b=J0k3w4lugu15hKiLTxC+bW39RQ2y1AiE0PFKVLfIO8xr4OXx2cBrG1KOVhaCx8E7bw LTfRMnpBny483DIl6bpqZl8RLLXVA3Two1dhJa4zNDLG1Pnew4C1f0as5whKnQtQo6/c gY5noggOiXa2VnYXAVXvyG8k64qzZ6QHuE3NipJVcX3ImQTXGhetyFwl189xuKldOXn8 g+vs/FDBHK6r0363RO+T5bjwoQ4BWAzWmLB2rCSz2guwe8+fQp7G6KQx38eg80aKKvzO gRff3QR6vsDNch8wtigrn8omSSsRkrj1s69TPAHi+MzIq51hGd+qg8cuFsJONe8m3V/q O33w== X-Gm-Message-State: APjAAAXSbsCTOqkUICfIdUsont9nHEp67oxlVr+/cR0cOGm6g/fvh+PJ SxBkp4EULsEnEV09FBA3SBzmw0AK07s= X-Received: by 2002:a17:902:be09:: with SMTP id r9mr10113624pls.215.1557458840529; Thu, 09 May 2019 20:27:20 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id t26sm6259695pgk.62.2019.05.09.20.27.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 20:27:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 20:27:08 -0700 Message-Id: <20190510032710.23910-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510032710.23910-1-richard.henderson@linaro.org> References: <20190510032710.23910-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v2 6/8] 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: laurent@vivier.eu 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, we failed to adjust regwptr into the new structure, we stored the stack pointer into the wrong register. Signed-off-by: Richard Henderson --- linux-user/sparc/target_cpu.h | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/linux-user/sparc/target_cpu.h b/linux-user/sparc/target_cpu.h index 567351d564..bbcb3a92ed 100644 --- a/linux-user/sparc/target_cpu.h +++ b/linux-user/sparc/target_cpu.h @@ -23,18 +23,34 @@ static inline void cpu_clone_regs(CPUSPARCState *env, CPUSPARCState *old_env, target_ulong newsp) { - if (newsp) { - env->regwptr[22] = newsp; - } - /* syscall return for clone child: 0, and clear CF since - * this counts as a success return value. + /* + * After cpu_copy, env->regwptr is pointing into old_env. + * Update the new cpu to use its own register window. */ - env->regwptr[0] = 0; + env->regwptr = env->regbase + (env->cwp * 16); + + /* Set a new stack, if requested. */ + if (newsp) { + env->regwptr[WREG_SP] = newsp; + } + + /* + * 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[WREG_O0] = 0; #if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) env->xcc &= ~PSR_CARRY; #else env->psr &= ~PSR_CARRY; #endif + env->regwptr[WREG_O1] = 1; + env->pc = env->npc; + env->npc = env->npc + 4; + + /* Set the second return value for the parent: %o1 = 0. */ + old_env->regwptr[WREG_O1] = 0; } static inline void cpu_set_tls(CPUSPARCState *env, target_ulong newtls)