From patchwork Fri Aug 4 19:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 710236 Delivered-To: patch@linaro.org Received: by 2002:a05:6359:d30:b0:129:c516:61db with SMTP id gp48csp162773rwb; Fri, 4 Aug 2023 12:19:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGDFfQgRmUCFKZlEU+eEf9JG1UCltAWKJmVtI6KXP/jV/+g/2NubZhB25kPR0n8/dZ2gUN2 X-Received: by 2002:a05:620a:2587:b0:767:81fc:c6b8 with SMTP id x7-20020a05620a258700b0076781fcc6b8mr3077282qko.6.1691176758982; Fri, 04 Aug 2023 12:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691176758; cv=none; d=google.com; s=arc-20160816; b=gBAPi1GEwW//+v78x6nRu9I1IfwJVasCQHHiXxJQyHUtHhj4Ne/QjTfxPIzxA6hBaC Qofol24gR3laoB17Udraljzstm5sAGtZt78zaCR2hmHle40F4zdytCJY/rH4gI44sFuq qQG6UJFTIPbTBP9g7l+pL60vYb9ypQKZ0PN0zTdC0EyM+cuRwxvpExPmfY/KhRoB9KuJ o/o4hSXrmZI1QNsgZWKEsuMYzDOWvaGB+Z7BsuFFC+mZfaPUWmr5Rozv5aYBv4B+eOA2 nBk5ySvhUNPltCFrUtu9kfK6XZFWhcgsetKCGzIBY8vs1rGZRUdr5AORlNFqwzP+enaE 2SBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from; bh=Fp59DzngyvKyxdVCUWBHng4ZbMtv2B/kXWjI+o4Lz+U=; fh=+twXHueQny8msdLYk4HIx2SowV0ZnuRfIAxEj9lDJjg=; b=vXrqjcDHm0876YRmKo1TG8QyYa9sXUWC66XlIVUpGYDbtDNYfklKdY1BB+OCp/XY+I K4nhvugDQ0+7QfmnpdC5mEWGWuewkJpTQi4L3FkkSgFHxXm4WUt1JfIvm3X7pmryuahF G8cWcWV1J9KwG5/r8z3AARYx08CxlNQabrd/AKgPKT2cAjh6HN3wU1gCqwPBdcbRGgAB 3tjIm95SEbCkz0Cv7RtAcxStvK1BW/8JZq04mLWRfFlVdsmiHxIEyBcqbmsr/MUYO20C gWNJCuuo4gFNjY+nautlCyEAkT7h6oiLcvPWbvDa0iIsgat6hYCGw7tBIMPk6trMFpvd sHQw== 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 12-20020a05620a040c00b0076c93916911si1623879qkp.584.2023.08.04.12.19.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Aug 2023 12:19:18 -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; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qS0IR-0000OR-BA; Fri, 04 Aug 2023 15:17:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qS0IP-0000No-H2; Fri, 04 Aug 2023 15:17:09 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qS0IO-0006xN-0S; Fri, 04 Aug 2023 15:17:09 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 659FE1845A; Fri, 4 Aug 2023 22:17:11 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id EA7741B89D; Fri, 4 Aug 2023 22:16:50 +0300 (MSK) Received: (nullmailer pid 1875711 invoked by uid 1000); Fri, 04 Aug 2023 19:16:49 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-8.0.4 40/63] target/arm: Avoid writing to constant TCGv in trans_CSEL() Date: Fri, 4 Aug 2023 22:16:23 +0300 Message-Id: <20230804191647.1875608-9-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Peter Maydell In commit 0b188ea05acb5 we changed the implementation of trans_CSEL() to use tcg_constant_i32(). However, this change was incorrect, because the implementation of the function sets up the TCGv_i32 rn and rm to be either zero or else a TCG temp created in load_reg(), and these TCG temps are then in both cases written to by the emitted TCG ops. The result is that we hit a TCG assertion: qemu-system-arm: ../../tcg/tcg.c:4455: tcg_reg_alloc_mov: Assertion `!temp_readonly(ots)' failed. (or on a non-debug build, just produce a garbage result) Adjust the code so that rn and rm are always writeable temporaries whether the instruction is using the special case "0" or a normal register as input. Cc: qemu-stable@nongnu.org Fixes: 0b188ea05acb5 ("target/arm: Use tcg_constant in trans_CSEL") Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230727103906.2641264-1-peter.maydell@linaro.org (cherry picked from commit 2b0d656ab6484cae7f174e194215a6d50343ecd2) Signed-off-by: Michael Tokarev diff --git a/target/arm/tcg/translate.c b/target/arm/tcg/translate.c index 7468476724..1e4d94e58a 100644 --- a/target/arm/tcg/translate.c +++ b/target/arm/tcg/translate.c @@ -8814,7 +8814,7 @@ static bool trans_IT(DisasContext *s, arg_IT *a) /* v8.1M CSEL/CSINC/CSNEG/CSINV */ static bool trans_CSEL(DisasContext *s, arg_CSEL *a) { - TCGv_i32 rn, rm, zero; + TCGv_i32 rn, rm; DisasCompare c; if (!arm_dc_feature(s, ARM_FEATURE_V8_1M)) { @@ -8832,16 +8832,17 @@ static bool trans_CSEL(DisasContext *s, arg_CSEL *a) } /* In this insn input reg fields of 0b1111 mean "zero", not "PC" */ - zero = tcg_constant_i32(0); + rn = tcg_temp_new_i32(); + rm = tcg_temp_new_i32(); if (a->rn == 15) { - rn = zero; + tcg_gen_movi_i32(rn, 0); } else { - rn = load_reg(s, a->rn); + load_reg_var(s, rn, a->rn); } if (a->rm == 15) { - rm = zero; + tcg_gen_movi_i32(rm, 0); } else { - rm = load_reg(s, a->rm); + load_reg_var(s, rm, a->rm); } switch (a->op) { @@ -8861,7 +8862,7 @@ static bool trans_CSEL(DisasContext *s, arg_CSEL *a) } arm_test_cc(&c, a->fcond); - tcg_gen_movcond_i32(c.cond, rn, c.value, zero, rn, rm); + tcg_gen_movcond_i32(c.cond, rn, c.value, tcg_constant_i32(0), rn, rm); store_reg(s, a->rd, rn); return true;