From nobody Thu Dec 18 22:26:32 2025 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=1584985314; cv=none; d=zohomail.com; s=zohoarc; b=Pk2jHi48S2uDPBZhe4WDofEbgiz6klQ7EZnT177su2EBUmRJ+/9YSbFDDI9cem5nSgFVodNfgA1mWztuG2qYosusQhSx8e2WIQqY6uGWXqfStG9MFDMGrXkWdoJ+o0YPdeHwvjYqbL3p5ElaZQMd97qjFjIEvDHhUO0AFbW6h64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584985314; h=Content-Type:Content-Transfer-Encoding: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=RITZnDTDn/38AGh+VF4YqFkEzRJU1Dvi8yVVJIkiyIw=; b=IqKO3sW9iOCfGW0R4Tdrzlk0DDDKjb9qBWuRlrQ5PJgj5psBiwaB6Eoc8sPvK6UNv7xicMgscX78VMerXmXTtUZAPKNpZ9kJMKwfVTvGxjoYtJOLK4rCgcu3h6xE7ZcIZHQKHyzckxx5Xif5rpEFvcycTiArgIaozoAC/m0K0so= 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 1584985314355177.3130435154019; Mon, 23 Mar 2020 10:41:54 -0700 (PDT) Received: from localhost ([::1]:37618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGR5E-0005zy-EQ for importer@patchew.org; Mon, 23 Mar 2020 13:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52223) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGR3h-0004OJ-KZ for qemu-devel@nongnu.org; Mon, 23 Mar 2020 13:40:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGR3g-0003hU-In for qemu-devel@nongnu.org; Mon, 23 Mar 2020 13:40:17 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:40433) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGR3g-0003gR-AA for qemu-devel@nongnu.org; Mon, 23 Mar 2020 13:40:16 -0400 Received: by mail-wr1-x442.google.com with SMTP id f3so18165960wrw.7 for ; Mon, 23 Mar 2020 10:40:16 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id o9sm25145282wrw.20.2020.03.23.10.40.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 10:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=RITZnDTDn/38AGh+VF4YqFkEzRJU1Dvi8yVVJIkiyIw=; b=lNkaiIsVZhLVcfdrXM4QCWv+fiqLXAVpWEFSgeHNunyKPwaNWSjxEdhEcEF5Fe+Y94 j3MwJx/6lw2BWdkpGTeTid2999JpgNZBiz/hpCsJI4RxxsLE+GX+XYSBX9kp54ciXy4L 3vkPHoMdPJThMiJZYF/OOk7P4LIv5/mpxkTmUwCRmW35p9cUwhPHbXZHRA4PrahETYOk Y/cfX50oE+N0ZmGxmkMvyWjQ9FDpBjxKSuKJanX+HVOJz70GCv6N8uxntPh5KT0Ghntq /Xr/9qhN0OB6LgbBIxUbQnZvvRP1qYXNorK2RNIpqfb55qqQy/ICHZ4tvEDwdgP6usrT rEPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RITZnDTDn/38AGh+VF4YqFkEzRJU1Dvi8yVVJIkiyIw=; b=R6La5c63tk31zb/Pn3jP4vCnJOJjIn0lnTQCU78NQFjkgkS0VYDL5GE6/lZoB4eTKD QSZjGLKsbSoOTH3nnHOLrdH5tlQeyJEASLiK1WjF7hIHwT9jLBqfQKS57PzQ54A0gxdn bKnc4xBF4sG+1F8f9EfUzOelo+2lfd9iahWWcJS0RMsCMVa9SoBef+mLrOHRPos6yheF yyg5DOi9eKstLovTjA8/8H1lqAmFTPk+P460WHy+GJktzp/7Ts0ENbO0qvJeB+83R7qh p3+zCYVKok0K66hYBJvnUgxAz/SyI1rs3UCgJW64Ri7nSw0m/qbLttfLYaIHpsY86cFq 9z3w== X-Gm-Message-State: ANhLgQ0hvkMaHZfbCuVGAarf1PrkR3Fi00WACFdoxGKoENVE+7GuKUmB +BDPHnD9n5lUzh+4RJQTL77CMRwngh5kAg== X-Google-Smtp-Source: ADFU+vsmZGxFB5z5Uiu9MVKsO2O71aEuPDYr7aiXhSBFs26P679sf7zIMwgvek9tgqaXz+ui62MyQA== X-Received: by 2002:adf:80cb:: with SMTP id 69mr29927986wrl.320.1584985215054; Mon, 23 Mar 2020 10:40:15 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/5] target/arm: Move computation of index in handle_simd_dupe Date: Mon, 23 Mar 2020 17:40:06 +0000 Message-Id: <20200323174006.8468-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200323174006.8468-1-peter.maydell@linaro.org> References: <20200323174006.8468-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) From: Richard Henderson 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 Message-id: 20200320160622.8040-4-richard.henderson@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- 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 032478614c4..7580e463674 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