From nobody Tue Feb 10 11:32:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.221.49 as permitted sender) client-ip=209.85.221.49; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-f49.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1624613018; cv=none; d=zohomail.com; s=zohoarc; b=QQDK69x1sSRqlNO2KF076VfaEmhRTSObrX+8dIAs/b7erTGdoqQ2p3XRBWpBSWIsQ+j5fko7J3/iy8oOdlg8ysBZvk7B8bUUpz4td+t2IDs3YbqN2BTOhHpRQYc6hWYcU3YKD2wVdgo/Lw9BXlC7ao8ip090NAqFZOmIWZePzAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1624613018; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gz6y+LXm6Y2GsD6kiV72O4IHW4d4JM1W8BSMcONGr5Q=; b=VtzlNCXB7aw+QxCvPQWuycVB3oanDaWY8s5jcI4B8uRtCXHEdd+A6tRrzMJnR9/g22XvV/7CRCbiXoYJHRFXez+svPp3r1+ihNkMMujkFts59gdAkNpH/wKgBOcrp61Fnst8H7ncavJED0oDrSp2eonJ2iX8zgl9uJ3niWTNjKc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mx.zohomail.com with SMTPS id 1624613018147461.63682333997235; Fri, 25 Jun 2021 02:23:38 -0700 (PDT) Received: by mail-wr1-f49.google.com with SMTP id g7so5197040wri.7 for ; Fri, 25 Jun 2021 02:23:37 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (93.red-83-35-24.dynamicip.rima-tde.net. [83.35.24.93]) by smtp.gmail.com with ESMTPSA id f5sm6485034wrf.22.2021.06.25.02.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 02:23:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gz6y+LXm6Y2GsD6kiV72O4IHW4d4JM1W8BSMcONGr5Q=; b=uv8uReOB3tOqhZzwjDR3y8nku2uC3YNc5yO+z0H4W0qUsuHux1IAXgTMm7pTc8zXq1 YM92JY7FuVFyyzeis4B/7yVpvdKQ14ub+/bpX/9EtquQAJp66p7eJyhA3/06NE41TeX6 bV9nJLv8WKhm5bD6Y/8goQR3hD19BhvshoIi7k8Uj9v6rhUb79T+1zz60SLjNP6uvKWu wBe+snuDrpJKtWRRdpPAMOtterrIS0a+B9JniYVbIt0AUxm0hhsSc7K6BPkglKrTPdEj aPrnzy3go9Ntf1zzWFaohpUGC4tkMr8qRX4x5QAUf1qVyHCYW/JCFys3zSsPVwi8plOF tSbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=gz6y+LXm6Y2GsD6kiV72O4IHW4d4JM1W8BSMcONGr5Q=; b=V6i77rO3iOG0BuGq8+nLpdy3wRFOmucM0ORieTR20K/6AKQx+C1+5z8F59Qr36MkRi HVhwb+tTgB4F6EOhkBfI2Wtu/EklY/APgkMn5ahuFdtgpQBZLEDpPzO9HIezFI1VOoyl GiSnWt/OF5DcgrOPbkfUSTHSWWx4cYWrxRAk+p4K1NHvK0Rx1ZTl5b9sEkQVxRHMQvWL GfRdxngmRplPzEFRJOyOmFBktfU3J4W0UAAJQgQdzk98Koix8dfrdKDh5DN152sMk31+ 1w8HnjfqqBGGQQ8uG6yFu+UTdZlEVefY9hZ9Q59dqBxtNoTe3HJNAWjpEx//ay5nWdI5 dL7w== X-Gm-Message-State: AOAM533Bgn40v18+pbTG2oN0p3SBT4Vt4X2R180Mbpf+sGrR2QTfLdKs pqgJ2PpGIoz3zhvyGbqwByc= X-Google-Smtp-Source: ABdhPJzpMEHTloVfP8WGQdc3KecRuNknXbcLZ4SU4YedJjvQNz2zQIQ7Zb1Epsh0qMShItAjnLREhw== X-Received: by 2002:a5d:6583:: with SMTP id q3mr9933130wru.360.1624613016406; Fri, 25 Jun 2021 02:23:36 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aleksandar Rikalo , Jiaxun Yang , Aurelien Jarno , Richard Henderson Subject: [PULL 01/15] target/mips: Fix potential integer overflow (CID 1452921) Date: Fri, 25 Jun 2021 11:23:15 +0200 Message-Id: <20210625092329.1529100-2-f4bug@amsat.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625092329.1529100-1-f4bug@amsat.org> References: <20210625092329.1529100-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) Use the BIT_ULL() macro to ensure we use 64-bit arithmetic. This fixes the following Coverity issue (OVERFLOW_BEFORE_WIDEN): CID 1452921: Integer handling issues: Potentially overflowing expression "1 << w" with type "int" (32 bits, signed) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned). Fixes: 074cfcb4dae ("target/mips: Implement hardware page table walker") Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson Message-Id: <20210505215119.1517465-1-f4bug@amsat.org> --- target/mips/tcg/sysemu/tlb_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/mips/tcg/sysemu/tlb_helper.c b/target/mips/tcg/sysemu/t= lb_helper.c index 259f780d19f..a150a014ec1 100644 --- a/target/mips/tcg/sysemu/tlb_helper.c +++ b/target/mips/tcg/sysemu/tlb_helper.c @@ -17,6 +17,7 @@ * License along with this library; if not, see . */ #include "qemu/osdep.h" +#include "qemu/bitops.h" =20 #include "cpu.h" #include "internal.h" @@ -659,7 +660,7 @@ static int walk_directory(CPUMIPSState *env, uint64_t *= vaddr, w =3D directory_index - 1; if (directory_index & 0x1) { /* Generate adjacent page from same PTE for odd TLB page */ - lsb =3D (1 << w) >> 6; + lsb =3D BIT_ULL(w) >> 6; *pw_entrylo0 =3D entry & ~lsb; /* even page */ *pw_entrylo1 =3D entry | lsb; /* odd page */ } else if (dph) { --=20 2.31.1