From nobody Tue Feb 10 12:39:40 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 1523377332314105.50894566888223; Tue, 10 Apr 2018 09:22:12 -0700 (PDT) Received: from localhost ([::1]:55131 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5w27-0000UH-Fp for importer@patchew.org; Tue, 10 Apr 2018 12:22:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46186) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5vzs-0007Pw-Se for qemu-devel@nongnu.org; Tue, 10 Apr 2018 12:19:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5vzp-0002ze-Po for qemu-devel@nongnu.org; Tue, 10 Apr 2018 12:19:52 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:50607) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f5vzp-0002yw-Lh for qemu-devel@nongnu.org; Tue, 10 Apr 2018 12:19:49 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id E4A3020F2C; Tue, 10 Apr 2018 12:19:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 10 Apr 2018 12:19:48 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 9C38E1025E; Tue, 10 Apr 2018 12:19:48 -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=z55d2/oxwr1EOf UK+PPkwg0SmIqngGCwpyicjO2n6kw=; b=R4HoRNg4jPJWrVXS7CwzNe3rlLOlrM xGwh/eay0ykkvxaWCQlyXj1vB5Vur2yGMANpOYanSlU8+y67kjKCiy8BAVJB28mp odrXscQreF3uiOqSGLTTsBtf3eZHNbFTcuNurkIeyI6spVRPTlw/65th3LebMyG6 qRw26GekgJdG8= 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=z55d2/oxwr1EOfUK+PPkwg0SmIqngGCwpyicjO2n6kw=; b=YxG+E6o3 pEvykb4lgKbee+Z6GC4KZRpvzKqCvbtIqn1iwMu8tKa8wQnGUukZ9aFDxYt881TS xSaqkTzVgb5xcFMkU1LXRUrCgVMhHfHQitFlA8SpqKbr2wI/UutAwX++Q8Kxck3W r5n1s4bM5m2IpJFqmdRxa1KH/x1gYjuYKmm6rudsIEcwYFSE9mXWyFxverm5HTSV VdVz7nCpZzHGtMsjnN4SdAaYxbBPy/QuxcMjIUViS90/m6FqWXrffXqJezWsOwMs fPLUWDf88Tcz0b30wupiBGlM2PZkOhX1L1wiET90bM97w5XQdLeKJA3+1zLQnzh5 WhQBo3nOzQ2wHA== X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Tue, 10 Apr 2018 12:19:42 -0400 Message-Id: <1523377186-32578-7-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 06/10] target/tilegx: 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: Richard Henderson 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. Signed-off-by: Emilio G. Cota --- target/tilegx/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/tilegx/translate.c b/target/tilegx/translate.c index d63bf5b..6c53c5e 100644 --- a/target/tilegx/translate.c +++ b/target/tilegx/translate.c @@ -2375,7 +2375,7 @@ void gen_intermediate_code(CPUState *cs, struct Trans= lationBlock *tb) DisasContext ctx; DisasContext *dc =3D &ctx; uint64_t pc_start =3D tb->pc; - uint64_t next_page_start =3D (pc_start & TARGET_PAGE_MASK) + TARGET_PA= GE_SIZE; + uint64_t page_start =3D pc_start & TARGET_PAGE_MASK; int num_insns =3D 0; int max_insns =3D tb_cflags(tb) & CF_COUNT_MASK; =20 @@ -2415,7 +2415,7 @@ void gen_intermediate_code(CPUState *cs, struct Trans= lationBlock *tb) } dc->pc +=3D TILEGX_BUNDLE_SIZE_IN_BYTES; if (num_insns >=3D max_insns - || dc->pc >=3D next_page_start + || (dc->pc - page_start >=3D TARGET_PAGE_SIZE) || tcg_op_buf_full()) { /* Ending the TB due to TB size or page boundary. Set PC. */ tcg_gen_movi_tl(cpu_pc, dc->pc); --=20 2.7.4