From patchwork Mon Jun 26 18:58:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 696484 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3392178wrm; Mon, 26 Jun 2023 12:16:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HR2yYSATzitJa0r9f1z5ET6EjNpB1eOsW3gtfOup/AlZN0f5nTDVGMF2AGw402a/Zteow X-Received: by 2002:a05:620a:8e04:b0:762:55f7:7105 with SMTP id re4-20020a05620a8e0400b0076255f77105mr22327399qkn.28.1687807009593; Mon, 26 Jun 2023 12:16:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687807009; cv=none; d=google.com; s=arc-20160816; b=CindFTvTMv09xw0GxDn264eFb32IkPi4ongF9ULSMM6utT3qldPyeDB30qOFKpKVp2 WY+FJMzGNs0n0V+4Mg/WTsToMoeevd6trfIhNnewewBePesVzsLt9i/BamlaSu+ixkzG TrD4d6giOCXI+1cO6fzdNqlcpNfp4loyiSogHNuzB122t1bMfpaS0mY3D70r6dFnBBOQ EVc+7u0K8bTupKnkmy/0Lr3xHCHD4vOB4XB7MuAEUo9AJW+prmdGhvfV2dqR88z2h1fW ME4QP1ZXBqFrwOLGR9X3VnqqdYvdDKm/ByXh+2qoxlIEuPLvdRaPhzwFWtR8pxFQ5MG4 yJ/Q== 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=KBSbbNh44nS2xiZYeDKAmdRVBSEXxV17K8hgTI3W3GA=; fh=0Xp2JyaTaNttgD8GBymZGxc1xOSx5UTRsLJ5GvGrdK8=; b=z9Qg/bZBWs4M3hv/Fym+johV2aiYsx9eyzG9kSpPsnxJ4aJHjSHIJwGT0J4bCYDrMc kI9xLNze5aibqJZDvOu8wZNTzP2RlHYEZQChUX/GTdlFnukQIi+41C7KfiCIsjAEYg3x 2FkGGllXtHVwz8dsIsOIh3SOO3FkfVh3jgoe4xG9FYbfBK/ebTy9d3B4yhOV9giSrl1s 7Z7672i1DX09drG8u9GfXSffjhVZQLASHB5TYityrcOY9kA+jKt4y6MDW+KfXT3ThwNn ofqmyrCFHGbiOIZkmG9DqbKExZwosnEXLSzvptDZlP1rsFM91mupyYVkxcz51vEAYnBg qMMA== 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 bm20-20020a05620a199400b0075c9c3c3b75si2139202qkb.645.2023.06.26.12.16.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 12:16:49 -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 1qDrTL-00018r-U2; Mon, 26 Jun 2023 15:02:00 -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 1qDrTA-0000CW-Np; Mon, 26 Jun 2023 15:01:49 -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 1qDrT9-0007nd-5k; Mon, 26 Jun 2023 15:01:48 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 9B9C7EFC0; Mon, 26 Jun 2023 21:59:13 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 2DFA9F7FC; Mon, 26 Jun 2023 21:59:12 +0300 (MSK) Received: (nullmailer pid 1575370 invoked by uid 1000); Mon, 26 Jun 2023 18:59:05 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org, qemu-stable@nongnu.org Cc: Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.4 31/43] target/arm: Fix return value from LDSMIN/LDSMAX 8/16 bit atomics Date: Mon, 26 Jun 2023 21:58:49 +0300 Message-Id: <20230626185902.1575177-31-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/translate-a64.c b/target/arm/translate-a64.c index 2ee171f249..3c356d238f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -3536,8 +3536,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(); + } } }