From nobody Wed Oct 29 22:58:38 2025 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525888869281143.83563500001708; Wed, 9 May 2018 11:01:09 -0700 (PDT) Received: from localhost ([::1]:58123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTOm-0003Cw-Bo for importer@patchew.org; Wed, 09 May 2018 14:01:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTIy-0004Mx-E5 for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGTIv-00055d-D7 for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:08 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:41945) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGTIv-00054M-3J for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:05 -0400 Received: by mail-pg0-x243.google.com with SMTP id m21-v6so23010047pgv.8 for ; Wed, 09 May 2018 10:55:04 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id l90sm60332813pfb.149.2018.05.09.10.55.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 10:55:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TiojlQ7+bOmRyh2JassU7YgApdfRFoNSCnyqvh/LGfo=; b=cKYJL1vgxm9vAGftvezFo45pepZN8Xw+F2LZ4IwOFiLEgyt6v+hToPWm+J5SGlWNHb Mh7JNlzfi+a1t29CRHBvCxjJA3puZ/6egjARQI/31qlDGouPzh9jWNkhi3+C2aWVjcb7 KA1Lb3fCkmSYLU19g0SkS808/d6eE7P9ExdQI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TiojlQ7+bOmRyh2JassU7YgApdfRFoNSCnyqvh/LGfo=; b=pTMK+cJL9JRjfAGp6BOGj3xNw3AHTUgeWtDDDYt08SwzkPSCVZvA+vn5N3lQfqfvQw wC4nfFgF6lZytaeuhf0xwhtwTSN+gFeMzUvOgBNo8HCEz+PsVZPnyTeIJf0Lu7gs+21S sHHBxhpsvKafLbzDyR9f9vrO6zs2tUnvYSPo3Fh8QQkfkVaDlTvQ/xcKi49sYzrgtPcs 7+/Ab6oWiEOjmXbRGeKGTDIHU5KzGNInC88wspFXmx+EzMi6Q4nvKxd0sfsIlHddflRS kqQ7G3uEEuL0Bq4E9U+UYODPkQfFsQWN5eGaVZ3tHZ6zwBmQTSY+rIlpaBjo/szaMj4W qsPw== X-Gm-Message-State: ALQs6tAMIw1qiz584iCj7Os4n6+7dLP9BfTEA3iajJ4Jt37zwonWbeCO zvijPELhNUMXRlPIrobJFN8JWk7sxdA= X-Google-Smtp-Source: AB8JxZrvs6bNFiKd6yW7moXJwlXjkdFYogChxl9LA8RKrEyIy5t5FjEirOedel5/7LARFJbtjHKeog== X-Received: by 2002:a65:5a81:: with SMTP id c1-v6mr36858067pgt.20.1525888503802; Wed, 09 May 2018 10:55:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 10:54:32 -0700 Message-Id: <20180509175458.15642-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180509175458.15642-1-richard.henderson@linaro.org> References: <20180509175458.15642-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PULL 02/28] target/cris: 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: peter.maydell@linaro.org, Sagar Karandikar , David Hildenbrand , Palmer Dabbelt , Mark Cave-Ayland , Max Filippov , Michael Clark , "Edgar E. Iglesias" , Guan Xuetao , Yongbok Kim , Alexander Graf , "Emilio G. Cota" , Richard Henderson , Artyom Tarasenko , Eduardo Habkost , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Stafford Horne , David Gibson , Peter Crosthwaite , Bastian Koppelmann , Cornelia Huck , Michael Walle , qemu-ppc@nongnu.org, Paolo Bonzini , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Emilio G. Cota" If the PC is in the last page of the address space, next_page_start overflows to 0. Fix it. Reviewed-by: Richard Henderson Cc: "Edgar E. Iglesias" Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/cris/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/cris/translate.c b/target/cris/translate.c index f51a731db9..64b9ec6649 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3091,7 +3091,7 @@ void gen_intermediate_code(CPUState *cs, struct Trans= lationBlock *tb) unsigned int insn_len; struct DisasContext ctx; struct DisasContext *dc =3D &ctx; - uint32_t next_page_start; + uint32_t page_start; target_ulong npc; int num_insns; int max_insns; @@ -3138,7 +3138,7 @@ void gen_intermediate_code(CPUState *cs, struct Trans= lationBlock *tb) =20 dc->cpustate_changed =3D 0; =20 - next_page_start =3D (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + page_start =3D pc_start & TARGET_PAGE_MASK; num_insns =3D 0; max_insns =3D tb_cflags(tb) & CF_COUNT_MASK; if (max_insns =3D=3D 0) { @@ -3234,7 +3234,7 @@ void gen_intermediate_code(CPUState *cs, struct Trans= lationBlock *tb) } while (!dc->is_jmp && !dc->cpustate_changed && !tcg_op_buf_full() && !singlestep - && (dc->pc < next_page_start) + && (dc->pc - page_start < TARGET_PAGE_SIZE) && num_insns < max_insns); =20 if (dc->clear_locked_irq) { --=20 2.17.0