From nobody Sun Nov 9 15:10:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550753391020453.37461820983754; Thu, 21 Feb 2019 04:49:51 -0800 (PST) Received: from localhost ([127.0.0.1]:59576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwnnL-00063B-Lm for importer@patchew.org; Thu, 21 Feb 2019 07:49:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55064) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwnl3-0004du-0a for qemu-devel@nongnu.org; Thu, 21 Feb 2019 07:47:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwnl1-000610-UH for qemu-devel@nongnu.org; Thu, 21 Feb 2019 07:47:20 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:35601 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwnl1-0004os-Ll for qemu-devel@nongnu.org; Thu, 21 Feb 2019 07:47:19 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 54F0D1A22C8; Thu, 21 Feb 2019 13:46:12 +0100 (CET) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id 2A1861A21BB; Thu, 21 Feb 2019 13:46:12 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 13:45:53 +0100 Message-Id: <1550753160-15142-2-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550753160-15142-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1550753160-15142-1-git-send-email-aleksandar.markovic@rt-rk.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PULL 1/8] hw/misc: mips_itu: Fix 32/64 bit issue in a line involving shift operator X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Aleksandar Markovic Fix 32/64 bit issue in a line involving shift operator. "1 << ..." calculation of size is done as a 32-bit signed integer which may then be unintentionally sign-extended into the 64-bit result. The problem was discovered by Coverity (CID 1398648). Using "1ULL" instead of "1" on the LHS of the shift fixes this problem. Reported-by: Peter Maydell Signed-off-by: Aleksandar Markovic Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/misc/mips_itu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c index 1257d8f..3afdbe6 100644 --- a/hw/misc/mips_itu.c +++ b/hw/misc/mips_itu.c @@ -94,7 +94,7 @@ void itc_reconfigure(MIPSITUState *tag) =20 if (tag->saar_present) { address =3D ((*(uint64_t *) tag->saar) & 0xFFFFFFFFE000ULL) << 4; - size =3D 1 << ((*(uint64_t *) tag->saar >> 1) & 0x1f); + size =3D 1ULL << ((*(uint64_t *) tag->saar >> 1) & 0x1f); is_enabled =3D *(uint64_t *) tag->saar & 1; } =20 --=20 2.7.4