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)