From patchwork Mon Jun 26 18:49:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696473 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3384777wrm; Mon, 26 Jun 2023 12:00:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XHyn/v71gb/OSMtPfisyah8GbBn0DAEs6YMh9o/6JqH6HQleh21RWLG1i/S22SegXZOva X-Received: by 2002:a05:622a:1d4:b0:401:e0d8:25f with SMTP id t20-20020a05622a01d400b00401e0d8025fmr1873024qtw.10.1687806007122; Mon, 26 Jun 2023 12:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687806007; cv=none; d=google.com; s=arc-20160816; b=umrK25BBCd1L99FyVGVRu9mdthuYoVBoX1SHN1P02KdAW7BjCEliKk/EsAW0+8OvhA FFNJJCasCf2iI9j3JNipo021wUyRYYucVR/X8Me8s4ywexFBFKFQSTIJZqJJFeLh26fS U62+ih8Ygue4rX4eq0PMrlTCHE2Lcj7P0gSu07tref/I2Co19ETHwPGph/TTeCCRMDT7 A9CR/1KPtUMsS7I3F9Np/LxSIKlVdpcJMOB33YIS0Axta25X3jVYNqKfe5YybrscQA24 D1bT7I1zuECvLMpLgqwB6G9gVFyUQmU7VWCesFYp16XLuETdpFPQIr0+8quo0Ss9EJZy 7YFw== 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=URFA9I3B2IlzvXFxeP3sPjqPU7F8j79gbWZCbSYEPrc=; fh=0Xp2JyaTaNttgD8GBymZGxc1xOSx5UTRsLJ5GvGrdK8=; b=yDO+RTYy/aBtjB+PEmIzk91qNQPS3PKLE6yNwXV68L6tGVhhg+gLIlqW5CCQoWIC8i 7Zcjl39TXD5I14x3wzl5uHccPyPSz0qBSakmwHYNq9mGUmTTUn4pctzQdvDR1+o2xNBd c/pon0ImAZHSzbyRiYHYFvWfayAfvSKzhVbP+1zyhrsD7aG+bjJQqmyXP3G8qZFpfnVJ x90TYyjhqbibFoayMYuD3+dR1EQpegbEr4hFTa043r/m0wwTworPyJLOC0KGu6nBA/Gw EIzpvzp4/uz4v7rxNPa/UlnLCnetmch2fagTS1mGSXJtJ6WLPIMmXy/dAapBpayhMzxG n1wA== 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 d9-20020ac85ac9000000b003f6b3972858si2124618qtd.170.2023.06.26.12.00.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:00:07 -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 1qDrN9-0003uz-9K; Mon, 26 Jun 2023 14:55:35 -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 1qDrLS-0001rP-BY; Mon, 26 Jun 2023 14:53:53 -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 1qDrLP-0005T9-D3; Mon, 26 Jun 2023 14:53:48 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id E6607EF3E; Mon, 26 Jun 2023 21:50:27 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id B5F9CF7CD; Mon, 26 Jun 2023 21:50:25 +0300 (MSK) Received: (nullmailer pid 1574076 invoked by uid 1000); Mon, 26 Jun 2023 18:50:16 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-8.0.3 39/54] target/arm: Fix return value from LDSMIN/LDSMAX 8/16 bit atomics Date: Mon, 26 Jun 2023 21:49:46 +0300 Message-Id: <20230626185002.1573836-39-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, T_SCC_BODY_TEXT_LINE=-0.01 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 The atomic memory operations are supposed to return the old memory data value in the destination register. This value is not sign-extended, even if the operation is the signed minimum or maximum. (In the pseudocode for the instructions the returned data value is passed to ZeroExtend() to create the value in the register.) We got this wrong because we were doing a 32-to-64 zero extend on the result for 8 and 16 bit data values, rather than the correct amount of zero extension. Fix the bug by using ext8u and ext16u for the MO_8 and MO_16 data sizes rather than ext32u. Cc: qemu-stable@nongnu.org Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20230602155223.2040685-2-peter.maydell@linaro.org (cherry picked from commit 243705aa6ea3465b20e9f5a8bfcf36d3153f3c10) Signed-off-by: Michael Tokarev diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index dff391bfe2..3cb5128135 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -3438,8 +3438,22 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, */ fn(tcg_rt, clean_addr, tcg_rs, get_mem_index(s), mop); - if ((mop & MO_SIGN) && size != MO_64) { - tcg_gen_ext32u_i64(tcg_rt, tcg_rt); + if (mop & MO_SIGN) { + switch (size) { + case MO_8: + tcg_gen_ext8u_i64(tcg_rt, tcg_rt); + break; + case MO_16: + tcg_gen_ext16u_i64(tcg_rt, tcg_rt); + break; + case MO_32: + tcg_gen_ext32u_i64(tcg_rt, tcg_rt); + break; + case MO_64: + break; + default: + g_assert_not_reached(); + } } }