From patchwork Thu Nov 9 13:42:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 742572 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:110f:b0:32d:baff:b0ca with SMTP id z15csp845548wrw; Thu, 9 Nov 2023 05:49:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGzSDAxln7aSjd4x+YpGpMIfWsZkQHR+k4ZmOh8lwufAlDqcj9f5QdO/Rn2ypb9pjEtDTY9 X-Received: by 2002:a05:622a:130c:b0:419:5b97:2fbb with SMTP id v12-20020a05622a130c00b004195b972fbbmr5351712qtk.34.1699537747006; Thu, 09 Nov 2023 05:49:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699537746; cv=none; d=google.com; s=arc-20160816; b=BhvwO+Tol9d8v8YGGDW9JwqphkMuTxWMo+ADqyumk/TmqGFD44vaEgsot4el1LeyEX ugf86t+NTX6RkNIW4zoAz/95UOayO7zeXJcQF8wo5Ksjw2aEdzJGJ5/BSn44vWxeR2dk Q+wvKaHUmqeZhbj3lFbAEP5rXyleaX4ENhEd2Gssa5Bh+Qb4phKWxobPG641D6PxFx11 S27sNHBuem44f59nyfnSlhP+cTv79tURvFMrjPbCdEYhjl/jndU2gA1OfHeOorb9/U5F 4h35NfE9k7/pEEsXGvXiWov3s7HG/GVPXzPw0zEMEhAJawM56nXF8tu3nW1ofvZQSRlg amYA== 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=GMjk2oFcSN1uFAEC/0Y2hnCAJZTdDme830V46OphV2k=; fh=He0A/96iGS/hdBTIvTFKPoE7yByjlEm52ubAJxr7bqo=; b=UTwh7tLzwQeS4XIjjBy+I/1oj4e8ws3KQhfmKqoJyWXvNxLjgSNoI3Po4kx0FWXAvZ HLcRgWQK8EcNGzUvh5QnpaekstIuQyW/5gfYr5wZRkzDyEXP3D7VX683oSSr+h8uE/8v VFLNf6Hw1sg+A+JeaaIoXduD3DFGS0xrg2t2nnRi8M0fdRCUJu03y9rz52CdgxpUezQG 1QRmcg/Fxhjfy9Lmg3myNqc0Mij4pAbus2/rqh0kHe6JhULs+IBcFzEts6F7q2H4gWRa jqpPM1FmrVspgah7+Q6RoQ3aocccZQ/WekOgNbTcKY3Mtk6ybnjxtylrjrL2sZtsuaIV QRgw== 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 q11-20020a05622a030b00b0041972bc1dd8si3100646qtw.93.2023.11.09.05.49.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Nov 2023 05:49:06 -0800 (PST) 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 1r15Nt-0001iU-V6; Thu, 09 Nov 2023 08:47:50 -0500 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 1r15NP-0007vG-Ae; Thu, 09 Nov 2023 08:47:19 -0500 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 1r15NM-00028q-N5; Thu, 09 Nov 2023 08:47:18 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 8202C31B1F; Thu, 9 Nov 2023 16:43:14 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id 927E9344C5; Thu, 9 Nov 2023 16:43:06 +0300 (MSK) Received: (nullmailer pid 1461879 invoked by uid 1000); Thu, 09 Nov 2023 13:43:02 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Michael Tokarev Subject: [Stable-8.1.3 39/55] target/arm: Fix A64 LDRA immediate decode Date: Thu, 9 Nov 2023 16:42:43 +0300 Message-Id: <20231109134300.1461632-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 In commit be23a049 in the conversion to decodetree we broke the decoding of the immediate value in the LDRA instruction. This should be a 10 bit signed value that is scaled by 8, but in the conversion we incorrectly ended up scaling it only by 2. Fix the scaling factor. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1970 Fixes: be23a049 ("target/arm: Convert load (pointer auth) insns to decodetree") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-id: 20231106113445.1163063-1-peter.maydell@linaro.org (cherry picked from commit 5722fc471296d5f042df4b005a851cc8008df0c9) Signed-off-by: Michael Tokarev diff --git a/target/arm/tcg/a64.decode b/target/arm/tcg/a64.decode index ef64a3f9cb..7e09fd18b4 100644 --- a/target/arm/tcg/a64.decode +++ b/target/arm/tcg/a64.decode @@ -461,7 +461,7 @@ LDAPR sz:2 111 0 00 1 0 1 11111 1100 00 rn:5 rt:5 # Load/store register (pointer authentication) # LDRA immediate is 10 bits signed and scaled, but the bits aren't all contiguous -%ldra_imm 22:s1 12:9 !function=times_2 +%ldra_imm 22:s1 12:9 !function=times_8 LDRA 11 111 0 00 m:1 . 1 ......... w:1 1 rn:5 rt:5 imm=%ldra_imm diff --git a/target/arm/tcg/translate.h b/target/arm/tcg/translate.h index d1cacff0b2..1afcd16ab1 100644 --- a/target/arm/tcg/translate.h +++ b/target/arm/tcg/translate.h @@ -203,6 +203,11 @@ static inline int times_4(DisasContext *s, int x) return x * 4; } +static inline int times_8(DisasContext *s, int x) +{ + return x * 8; +} + static inline int times_2_plus_1(DisasContext *s, int x) { return x * 2 + 1;