From patchwork Tue Aug 27 00:07:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172229 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp5046131ily; Mon, 26 Aug 2019 17:09:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdWdrR9T6mrwxFUTdytQKeY1XF28geWvxYaKNFlRHIkYgTHABtlp5vCmrueEGBG6X5+T5g X-Received: by 2002:a37:bb06:: with SMTP id l6mr18069353qkf.1.1566864549634; Mon, 26 Aug 2019 17:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566864549; cv=none; d=google.com; s=arc-20160816; b=zGhXLT/SeFiw+CPcQrZTt9b30sJdPplPikPt7w3mbtRcQVGeI/nkVazPnYaOgrbT4D /q47uQHfRRBOSlMJdsw5KMOIOxQcbTM+MrqJuy7XZs8mOVu92dsg37Xt+3pnS1D83e42 p0xfoIBZjzgMnFymr7sOuSAUQM9PzCm9YtC7xSdlNW92wB2LG3ZqDL8u3SD5FIfmpaPP 2kBTy4J4Whkh4CRXF2Kokpr99H69lwMAqjQnMyWGKYJ1YJpfnpfEVcbryRgRRCI4CaBV AZoFjn4u6XcGQFWhzAANriG2pszU+WJ5nJvH+hfTWlsdcKT8qplkYOPrJcRcQAndAXIB Xkyg== 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=vLDY87+4dPSAxr3X1xIFyg3m7CkymniXhiEOvq4Rpg0=; b=VquaMxh70SLoAgVgBm86EQcAvJVcUd/b29ogmicsyqFcTi7Ew3GN3+k+uhuIs0ic+b aO+xgcPaJrbnP6Jm3yycsRXpYp6EOFP47XtoJldfEldTWcTghTr5O607qWNjx5HUTutr 4ougUrHKXdkqcv1He+k7REEjYxjimDcEYmvW6duFDqu+5mSxy3PdLHXwVIfY6BoTM7zb qP2/Jc9x39WEkk59aHHDcXUBuots0fhw+oNR3h3Yfn2wIN9bZRayXVNV8F3q6HHBPqOh /fgI9A335XoIv6MFouNi/yOfpncUG7FKjTKOOh4JYFqsNQ7RkxnahMVI7rA2qF3YNHf9 pGvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DK0AdDDq; 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 11si9008344qky.170.2019.08.26.17.09.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Aug 2019 17:09:09 -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=DK0AdDDq; 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 ([::1]:58512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2P2p-000807-VH for patch@linaro.org; Mon, 26 Aug 2019 20:09:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33572) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2P1d-0007xR-LG for qemu-devel@nongnu.org; Mon, 26 Aug 2019 20:07:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2P1c-00073A-Fe for qemu-devel@nongnu.org; Mon, 26 Aug 2019 20:07:53 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:43127) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i2P1c-00072m-9i for qemu-devel@nongnu.org; Mon, 26 Aug 2019 20:07:52 -0400 Received: by mail-pf1-x442.google.com with SMTP id v12so12862056pfn.10 for ; Mon, 26 Aug 2019 17:07:52 -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=vLDY87+4dPSAxr3X1xIFyg3m7CkymniXhiEOvq4Rpg0=; b=DK0AdDDqNIzB8O9xmKTgrzRTP2K2CqPoA0BhOzOvIA1wc4I71hpPETrf6DlzIYaclG +Zarkovx8Ci9ey347KJyEZ2bmf6uJjtQXLh43YMv8r4sspqAbaHMj8bkPmdRlRHZ59zc kTk12McuTpBVMVQ/T5Do0eBL9KhiwJX/sQmuUTimUMC+76ULjJtO21tlXxBBjQahEK+f wV0Gdcx/NxW325399jq7t6VAFJbU6Q6JVYQj8goCdKZEkyjvVvaaHKSsLAaMVFnn7NU4 H/LjHnLvMs40qKHi17SZJLneciHfCrbNj2svkpeCzRoYZByI5LitzYYzo6bEuKwEH0p1 561w== 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=vLDY87+4dPSAxr3X1xIFyg3m7CkymniXhiEOvq4Rpg0=; b=A0rqG5gXOFU5XALNNlOxSM3b00G1cQCf90lb7H7awB4o7tgmF6lPoYupDb/xloSelM aPiFFgYCc2Xk1nhaz3kQbWzRopAn3q6EGj0+8q/wj5TIgReoIXXr83n79LfJV87UN7PH 27QNxuQ7XnxUWQtWVDPbU1YiHDA0DCX1yF6Vcw0x6dykrNUFbdoRHQmsIOtatn8zsITI ShXPwMzvxzA0xiJfSZbKgiujWObNnAR1EpYbKQSgV5uZgA0oDrcPiDNpoY1EQjIFvaFa 8ghvgri20Zleftrab+yyFxJW52tut7ZjfR3QWNx5CmpZdI2PFBJni8mbCXmy08ucDn0T NEwQ== X-Gm-Message-State: APjAAAVQS+2kaePEqBdhJZWntJIdFx4hvaDkaash65q9bc7uaYqLI9JC VK79/vjXJqclMLy4rtFeWMovNfAUyA8= X-Received: by 2002:a17:90a:21eb:: with SMTP id q98mr22021613pjc.23.1566864471072; Mon, 26 Aug 2019 17:07:51 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id e189sm11691067pgc.15.2019.08.26.17.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2019 17:07:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 26 Aug 2019 17:07:35 -0700 Message-Id: <20190827000745.19645-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190827000745.19645-1-richard.henderson@linaro.org> References: <20190827000745.19645-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::442 Subject: [Qemu-devel] [PATCH 03/13] target/openrisc: Cache R0 in DisasContext 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: shorne@gmail.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Finish the race condition fix from the previous patch. Signed-off-by: Richard Henderson --- target/openrisc/translate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) -- 2.17.1 Reviewed-by: Stafford Horne diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index 3812dc4427..37e8098023 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -48,6 +48,9 @@ typedef struct DisasContext { /* If not -1, jmp_pc contains this value and so is a direct jump. */ target_ulong jmp_pc_imm; + + /* The temporary corresponding to register 0 for this compilation. */ + TCGv R0; } DisasContext; static inline bool is_user(DisasContext *dc) @@ -64,7 +67,6 @@ static inline bool is_user(DisasContext *dc) static TCGv cpu_sr; static TCGv cpu_regs[32]; -static TCGv cpu_R0; static TCGv cpu_pc; static TCGv jmp_pc; /* l.jr/l.jalr temp pc */ static TCGv cpu_ppc; @@ -122,7 +124,6 @@ void openrisc_translate_init(void) shadow_gpr[0][i]), regnames[i]); } - cpu_R0 = cpu_regs[0]; } static void gen_exception(DisasContext *dc, unsigned int excp) @@ -165,7 +166,11 @@ static void check_ov64s(DisasContext *dc) static TCGv cpu_R(DisasContext *dc, int reg) { - return cpu_regs[reg]; + if (reg == 0) { + return dc->R0; + } else { + return cpu_regs[reg]; + } } /* @@ -175,7 +180,7 @@ static TCGv cpu_R(DisasContext *dc, int reg) static void check_r0_write(DisasContext *dc, int reg) { if (unlikely(reg == 0)) { - cpu_regs[0] = cpu_R0; + dc->R0 = cpu_regs[0]; } } @@ -747,7 +752,7 @@ static bool trans_l_swa(DisasContext *dc, arg_store *a) to cpu_regs[0]. Since l.swa is quite often immediately followed by a branch, don't bother reallocating; finish the TB using the "real" R0. This also takes care of RB input across the branch. */ - cpu_regs[0] = cpu_R0; + dc->R0 = cpu_regs[0]; lab_fail = gen_new_label(); lab_done = gen_new_label(); @@ -1292,9 +1297,9 @@ static void openrisc_tr_tb_start(DisasContextBase *db, CPUState *cs) /* Allow the TCG optimizer to see that R0 == 0, when it's true, which is the common case. */ if (dc->tb_flags & TB_FLAGS_R0_0) { - cpu_regs[0] = tcg_const_tl(0); + dc->R0 = tcg_const_tl(0); } else { - cpu_regs[0] = cpu_R0; + dc->R0 = cpu_regs[0]; } }