From nobody Tue Feb 10 15:46:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1523377824842630.0985832843274; Tue, 10 Apr 2018 09:30:24 -0700 (PDT) Received: from localhost ([::1]:55466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5w9z-0007f3-T7 for importer@patchew.org; Tue, 10 Apr 2018 12:30:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5vzu-0007Qy-AP for qemu-devel@nongnu.org; Tue, 10 Apr 2018 12:19:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5vzq-00030D-5R for qemu-devel@nongnu.org; Tue, 10 Apr 2018 12:19:54 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:44943) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f5vzq-0002zo-21 for qemu-devel@nongnu.org; Tue, 10 Apr 2018 12:19:50 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id BA05120ABC; Tue, 10 Apr 2018 12:19:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 10 Apr 2018 12:19:49 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 7842A1025E; Tue, 10 Apr 2018 12:19:49 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=8KJPRuS4bH408c 0Xm79xevv+JdqXLM89Dd6E51Ybmbg=; b=Xkt822viZuhrcJee/pcDXB+1ulz4hY nizwyZNBEtTrd9QPSbXxRIEZ0HW8nrdm9wOEUpDQAqGmZ6jqFtJqaS0kNyaHeJcr ZoUY2A8pJx/iEZ867xWC0PVFGkr9zMLqrOu8i80y/syYOfcLi2Ou3gEV0Qulc3y5 lKndPdjwO94Io= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=8KJPRuS4bH408c0Xm79xevv+JdqXLM89Dd6E51Ybmbg=; b=OqxuZlqj S/u/MTletS97eHAWfbHFm7oLwyVhDdFY7safbd9Oz+9UBCNjjCl2uoYxCY8T8WZi tLIHJ5Bvz/cNguyL4NdILHUhX4cyxW09S+DoHhgOW/9JSB2D5FTtKvEjw4eyPERm gw7yUVo2scX6Uot1ivF7PZEm3g2LGzvQ3AlNck2RmATtSIGANlMvgKb/WXpUde30 frlKS8DoverEH9n0dgSIBWJS4YwdZ6fbGdOT/qFYKm5wLLe9DhC6PlVb+wiusTyE /MNfDwI3VdqCNW74frzxLL+mlE3zvMdUiRi96NMnSILdbpgLjNIQkAsKaUVLp+nc oNiYrW0z5wyndw== X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 10 Apr 2018 12:19:46 -0400 Message-Id: <1523377186-32578-11-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523377186-32578-1-git-send-email-cota@braap.org> References: <1523377186-32578-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.111.4.29 Subject: [Qemu-devel] [PATCH 10/10] target/mips: avoid integer overflow in next_page PC check 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: Yongbok Kim , Richard Henderson , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the PC is in the last page of the address space, next_page_start overflows to 0. Fix it. Cc: Aurelien Jarno Cc: Yongbok Kim Signed-off-by: Emilio G. Cota --- target/mips/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/mips/translate.c b/target/mips/translate.c index d05ee67..d8e717d 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20202,14 +20202,14 @@ void gen_intermediate_code(CPUState *cs, struct T= ranslationBlock *tb) CPUMIPSState *env =3D cs->env_ptr; DisasContext ctx; target_ulong pc_start; - target_ulong next_page_start; + target_ulong page_start; int num_insns; int max_insns; int insn_bytes; int is_slot; =20 pc_start =3D tb->pc; - next_page_start =3D (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + page_start =3D pc_start & TARGET_PAGE_MASK; ctx.pc =3D pc_start; ctx.saved_pc =3D -1; ctx.singlestep_enabled =3D cs->singlestep_enabled; @@ -20320,7 +20320,7 @@ void gen_intermediate_code(CPUState *cs, struct Tra= nslationBlock *tb) break; } =20 - if (ctx.pc >=3D next_page_start) { + if (ctx.pc - page_start >=3D TARGET_PAGE_SIZE) { break; } =20 --=20 2.7.4