From nobody Mon May 6 14:33:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584720482; cv=none; d=zohomail.com; s=zohoarc; b=LdwOJVmZEw4GRpB2NP4JFxUTU6QPPKn2FwT26gWghv29lAUpS94dkO6gFq+yOlBLgK04Uz9rMy5jGKG6WicLIp/lz/J6KaeEMkMVq9VVu4yO+P/hpItzpg2/q8PE0ghA+XtMEy1MulAV3vxwrP+PTpieagYnaLOBdxbqM/s0w1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584720482; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z+SDME4E2sCY/GphbA3qjA/hZrqxGNEA6/MPHDiVJqY=; b=VXuYyDL8k6TGvXOtplKtSy/CPP1tl/APrEiCKeCQFwED7R8rUwRLKPQ7/LaE1ra5yjqnQ7ZH+Xc9/mjd4cK+yk/0jSETSnUsy7bZPkF/fsP17n7a2u2BsW8GDjOlsT7oHvX/mB/b6XKU45kSAkmvrEaFQL9Ea9i70LJ61HBQmhc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584720482809302.3417057530406; Fri, 20 Mar 2020 09:08:02 -0700 (PDT) Received: from localhost ([::1]:55338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFKBl-00041n-I1 for importer@patchew.org; Fri, 20 Mar 2020 12:08:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39803) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFKAG-0001wi-6D for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFKAF-0001aI-5d for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:28 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:47080) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jFKAE-0001Zg-Vr for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:27 -0400 Received: by mail-pl1-x642.google.com with SMTP id r3so2659868pls.13 for ; Fri, 20 Mar 2020 09:06:26 -0700 (PDT) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id nu13sm5272745pjb.22.2020.03.20.09.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 09:06:24 -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 :mime-version:content-transfer-encoding; bh=Z+SDME4E2sCY/GphbA3qjA/hZrqxGNEA6/MPHDiVJqY=; b=mauQ6A8a9rBMA3rXL0UlYYMFBZUNKfZWi/KhS+T4kl1u7hBr11rrtv7ujJbx5ujx3U zClxvn/SdO4ludJjbBdr+XeQ7ebWa22HvZkdZtjr6PBEdt0dmObvR0+ndjOR4z3C1HrD sC2ITIiKq/YWPKh1yzfH3fTyXr9c2HVbIt7+qqmPuek965F3dWi/LkmX2p+MrLyuH8K/ ODrpP0tjkQdaqGTg2jCcbPxB9v3WTzQ08ID6E5JiD93saoiiqvGtOmV8AoHSMnP4yayS Wr8e8T1DJENUBZY4ifmcC8ekBjvcRXCr0tzaqjKLyAqp3Ukb7NFQIs6TurvZC6wjmD6L 89Vg== 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:mime-version:content-transfer-encoding; bh=Z+SDME4E2sCY/GphbA3qjA/hZrqxGNEA6/MPHDiVJqY=; b=MO9NQVvZuRCM1lF17o1B+IrjgJWhdt6bXaeZfhAyLLP4/XqFcY62dBxOHYd4Ur5EZD nRJiVqAXYkZ20/IsgPEkDB+mZRtiTKMXBhSFsLsHlSuprgwY5tkYTiiI60Q0T3YeV1Cp K+8vbxOcfub6NFC+H/VM6IleZoEu/XFVlwQkW13/bHlA9/SXk/u4Uhh9BzoHWSBb2c2V nTiLexd6TkhnVlCbvDWMd6QZ4Y5U2cvHbvYKhSrpUBd8sVpjVGvgqXs/Eo8HHhBloO0y USEKoD7a3GbdQqVATuyYhtLr6hCRR099csD8rEs9ZuwkZ+/NDJVo0zYiIj8iphjR3INi 3Uvw== X-Gm-Message-State: ANhLgQ2B5aVxNdlZ9ecaOQKKqpK0garypN6Pq7RC3N5xywUJm9SvY3sC 2AgHWNfA41vTv5Ly/ELATQlrRhG7y1M= X-Google-Smtp-Source: ADFU+vv1ip7zS0WUJ4bL+8xS6APyw4z2AccLRzWZQXrd9q8K43Ps4y47bc9gqK1Gt21i5zzkZehxUg== X-Received: by 2002:a17:90a:c244:: with SMTP id d4mr10382017pjx.136.1584720385438; Fri, 20 Mar 2020 09:06:25 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/3] target/arm: Rearrange disabled check for watchpoints Date: Fri, 20 Mar 2020 09:06:20 -0700 Message-Id: <20200320160622.8040-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200320160622.8040-1-richard.henderson@linaro.org> References: <20200320160622.8040-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 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: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Coverity rightly notes that ctz32(bas) on 0 will return 32, which makes the len calculation a BAD_SHIFT. A value of 0 in DBGWCR_EL1.BAS is reserved. Simply move the existing check we have for this case. Reported-by: Coverity (CID 1421964) Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/helper.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index d2ec2c5351..b7b6887241 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6340,17 +6340,18 @@ void hw_watchpoint_update(ARMCPU *cpu, int n) int bas =3D extract64(wcr, 5, 8); int basstart; =20 - if (bas =3D=3D 0) { - /* This must act as if the watchpoint is disabled */ - return; - } - if (extract64(wvr, 2, 1)) { /* Deprecated case of an only 4-aligned address. BAS[7:4] are * ignored, and BAS[3:0] define which bytes to watch. */ bas &=3D 0xf; } + + if (bas =3D=3D 0) { + /* This must act as if the watchpoint is disabled */ + return; + } + /* The BAS bits are supposed to be programmed to indicate a contig= uous * range of bytes. Otherwise it is CONSTRAINED UNPREDICTABLE wheth= er * we fire for each byte in the word/doubleword addressed by the W= VR. --=20 2.20.1 From nobody Mon May 6 14:33:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584720478; cv=none; d=zohomail.com; s=zohoarc; b=Bv/bnn4xNDp7LjNQAoOdEu1rkzZE4HzYBEVmhOXYm252k1lDsfiMnEX1m1H6R5Zam+AvKbFN3fCSWiORCzKOMlTgD1XrsdKgPiHlMt26KIJlz5qNbCouQsAbe2Heb9COwLCsXF2ZH2HNjNRKQe9zzPG0MwYmJ/cHng9iWF1g+vE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584720478; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dbRF0UtzAGUl4dV/70qbuWKf9aMAX0BAQV5Mmox41wg=; b=cjksHIppmCdCFHn9IY6RH2Q65enNFMwB4msm5hVYVwqdI0sofudJtX0AXWqzbuN5lqcTVcSVzmE3yBQYEfPjgRlJ/s7DNmhz4ySJgNN/Dm53aJ2ndbFFsqJmIoTDHDQ6/04IS2PijHJ+wKLj4ZaYBRO8Wt6Zvqw/BnxAtvcpL7c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584720478122674.2271371020677; Fri, 20 Mar 2020 09:07:58 -0700 (PDT) Received: from localhost ([::1]:55332 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFKBg-0003rh-S4 for importer@patchew.org; Fri, 20 Mar 2020 12:07:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39859) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFKAI-00020R-FI for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFKAG-0001bo-Bp for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:30 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:32808) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jFKAG-0001aq-6E for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:28 -0400 Received: by mail-pl1-x642.google.com with SMTP id g18so2687535plq.0 for ; Fri, 20 Mar 2020 09:06:28 -0700 (PDT) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id nu13sm5272745pjb.22.2020.03.20.09.06.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 09:06:26 -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 :mime-version:content-transfer-encoding; bh=dbRF0UtzAGUl4dV/70qbuWKf9aMAX0BAQV5Mmox41wg=; b=Dy/ScsalsaWfoO9SP4pdSz0cSIWr/8VBuzldEkUglRbzatGtKgnF8B1ihUq+o/kGCy wwQwOEaEht2RkyyzASr/07f9VLqqqOmJmu7+PlCZ3g9Z/BJbQDEkwI/cPol+FSUEaZuC aJQEu2j6CzyDuaKonCPREPBEXQUJfqk9NKFRpbpcAfrIg7NlFBjhi7LvgMbzwJkNoYgd BuEURRl8l90EfGjkDuqCTbN2C4IhwwkCeFklhgc1sPFa5WqKbLbmTQWNISwcWgPR70EK trDKJQh1Uc2O0D8l7PeoXOO4xLArS4+Er3YvWEfhXbtON8T+aGs/qA6r+7XcAEWBTnXt 7yxQ== 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:mime-version:content-transfer-encoding; bh=dbRF0UtzAGUl4dV/70qbuWKf9aMAX0BAQV5Mmox41wg=; b=haf79DYN8AL6IAJXDDTsFVIpT7yNQJb5u8Owk/bWrk5U5tpOTViWgIOdcxvk+drHXz FwhCBioXIVyU8DU+i2uMnh0oH1fDexS17/3o0ffJzLM66w3A0Fhv/Vs/mCJtXnHMAQD4 XO6ec4H7KglTTjAnZ2IxEd2WNtXImt4IaPysxWEtGZ4X1WQyDCpfhpT7IKRGaObhP73n Bx0F9BNYiPMzXTBSQKPNPN5nB4dOLPF/qOzCuXEkLaa1yPn15ClRyyhGTpdARNg1VIBd TKcbIZfOUgfjUtuDEVSIzeRxSjSKOy9mpbiy8n6F88II4KufloJLo7LrtIFX3KbtdihF GguA== X-Gm-Message-State: ANhLgQ31IpPFO2BAi6G3e3zakqxq8nMa5o20v+LMVuaimZIGFXJWBjSd NnKQLpWCqyE5INA7Oh6Je3Qzaz4DXrQ= X-Google-Smtp-Source: ADFU+vt2do9sGB4m6axc52NsxtC0zeQHHnAJsa6fdDdQPfsXbKv8l/7cbURBl0+lCvKlzlNpQJK3Vw== X-Received: by 2002:a17:90a:757:: with SMTP id s23mr10262632pje.166.1584720386867; Fri, 20 Mar 2020 09:06:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/3] target/arm: Assert immh != 0 in disas_simd_shift_imm Date: Fri, 20 Mar 2020 09:06:21 -0700 Message-Id: <20200320160622.8040-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200320160622.8040-1-richard.henderson@linaro.org> References: <20200320160622.8040-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::642 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: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Coverity raised a shed-load of errors cascading from inferring that clz32(immh) might yield 32, from immh might be 0. While immh cannot be 0 from encoding, it is not obvious even to a human how we've checked that: via the filtering provided by data_proc_simd[]. Reported-by: Coverity (CID 1421923, and more) Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/translate-a64.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 8fffb52203..032478614c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -10405,6 +10405,9 @@ static void disas_simd_shift_imm(DisasContext *s, u= int32_t insn) bool is_u =3D extract32(insn, 29, 1); bool is_q =3D extract32(insn, 30, 1); =20 + /* data_proc_simd[] has sent immh =3D=3D 0 to disas_simd_mod_imm. */ + assert(immh !=3D 0); + switch (opcode) { case 0x08: /* SRI */ if (!is_u) { --=20 2.20.1 From nobody Mon May 6 14:33:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1584720581; cv=none; d=zohomail.com; s=zohoarc; b=n1TN6rfL8QCqtkeA2/JJHf0rsh1/7CrvdASjwdn0ppAgDUvdVI/3qZhxtFbA/B1/1DVRyDuQ7Ks2ey66lqMLIbApiittPR+N6ZR5jkD4pd5jgyRsZsfpftawKu5JC3RGuC1gz9XoQ/ntdXLitzdHTOJ7S8GbfXGyJlk2Um7I+0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584720581; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9N6FLF8sUw4XVnPIwBVzCdAPTwyubp1J/tKDvqzTiXA=; b=jb0veOaxg4fdzCERf1cNWPk0hd+wEnmLoGmLNEsRQeh7+qHj35xWvaJkkmAt/YLxTfGFvAHUQF9rwRIHF6+czNJYVK7xxrmqthn7eq0SrSzgTnbQ6rjm4DP+421Fd9pVRMrTCWZIIx4erOUsuzPDD9BBlDPd3yHGRK+kUrOLel4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158472058099243.24442775410171; Fri, 20 Mar 2020 09:09:40 -0700 (PDT) Received: from localhost ([::1]:55418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFKDL-0006Pm-Im for importer@patchew.org; Fri, 20 Mar 2020 12:09:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39863) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jFKAI-00020o-Nd for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jFKAH-0001cv-HW for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:30 -0400 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:34714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jFKAH-0001cR-Br for qemu-devel@nongnu.org; Fri, 20 Mar 2020 12:06:29 -0400 Received: by mail-pj1-x1044.google.com with SMTP id q16so3592087pje.1 for ; Fri, 20 Mar 2020 09:06:29 -0700 (PDT) Received: from localhost.localdomain (97-126-123-70.tukw.qwest.net. [97.126.123.70]) by smtp.gmail.com with ESMTPSA id nu13sm5272745pjb.22.2020.03.20.09.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 09:06:27 -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 :mime-version:content-transfer-encoding; bh=9N6FLF8sUw4XVnPIwBVzCdAPTwyubp1J/tKDvqzTiXA=; b=sinYBWdKPXM87ZyspIJS8N8F+GXUJppxt202/ZQkT99Eg8bR4pvRLUmgByGD0hx0xI nJFDBVddSlbNtOc6IsVeOcW7Tm6L5sPKvCgsoaOmuUD1XJlE+tis5nD6VRBTKIlAk5DF F3dSjk8o9T72oL00+HtVlQoDUpngTeVf5XJDLApLB4dZptJSlUEcLDh7ToUMgw/0JSa3 1mURHO/iqOuys/U9K3Ghrxbtn/e38w0ZJHpYIX2m3ib4knFoZLLa9ncbXOVHwRwdHJj2 TFxbgDdYz0RszcBptnHmH4N+Hg9u7TCGO2TPSUb8Y9QJEvorDknLz6jlFl39uxdiKDgP tulQ== 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:mime-version:content-transfer-encoding; bh=9N6FLF8sUw4XVnPIwBVzCdAPTwyubp1J/tKDvqzTiXA=; b=igcLGy2zSxRwtkFd7BjCMkftq2oovvZjJG9dr2x9tEFg9ZTLYAIe97bdmFgoTE5FFT usmilYxeoIXKsmUWTykDfxdq6sOkXm/AmYrJHxEgDatibfBaZAxRckjsEoBz2epOL+Wd GbTYpUW3Y57xHIvVgjxI4FqRIrsmSc83JwbVW8nLvg/Eqqa6UTOmKPbVa3pJ3sqnIERE SeMfsq2Yr950tCwum+XcS55tjgFOLKVwnevoTx+d6V7T+lG+TpqzdRh1DKVAxU65LTnz P4rnmihFhYKF1nPOqhOTzAkCnu5jaPTy0IpXQ4qUAfe0KEtFKgR/fajJULokBeB25cFG yXig== X-Gm-Message-State: ANhLgQ0lZPLyEVcRmqUffm9NUZbDAXTF1TZby6NpZs21qgb7TSbUY/PZ jXXh1FecxG+wCDod11nZw/UNa62YIrA= X-Google-Smtp-Source: ADFU+vv5jD6NaTiHidXgK0P+b1zwJQakVbWlD9CCBU8oZzxYkyml4HWfQSix+JohtFRh/Im48ygFUg== X-Received: by 2002:a17:902:eb49:: with SMTP id i9mr8953254pli.91.1584720388077; Fri, 20 Mar 2020 09:06:28 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/3] target/arm: Move computation of index in handle_simd_dupe Date: Fri, 20 Mar 2020 09:06:22 -0700 Message-Id: <20200320160622.8040-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200320160622.8040-1-richard.henderson@linaro.org> References: <20200320160622.8040-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::1044 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: peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" Coverity reports a BAD_SHIFT with ctz32(imm5), with imm5 =3D=3D 0. This is an invalid encoding, but we diagnose that just below by rejecting size > 3. Avoid the warning by sinking the computation of index below the check. Reported-by: Coverity (CID 1421965) Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/translate-a64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 032478614c..7580e46367 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -7422,7 +7422,7 @@ static void handle_simd_dupe(DisasContext *s, int is_= q, int rd, int rn, int imm5) { int size =3D ctz32(imm5); - int index =3D imm5 >> (size + 1); + int index; =20 if (size > 3 || (size =3D=3D 3 && !is_q)) { unallocated_encoding(s); @@ -7433,6 +7433,7 @@ static void handle_simd_dupe(DisasContext *s, int is_= q, int rd, int rn, return; } =20 + index =3D imm5 >> (size + 1); tcg_gen_gvec_dup_mem(size, vec_full_reg_offset(s, rd), vec_reg_offset(s, rn, index, size), is_q ? 16 : 8, vec_full_reg_size(s)); --=20 2.20.1