From nobody Wed Oct 29 22:58:36 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 1525888843618983.1778413723475; Wed, 9 May 2018 11:00:43 -0700 (PDT) Received: from localhost ([::1]:58115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTOI-0002oF-HV for importer@patchew.org; Wed, 09 May 2018 14:00:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTJ2-0004R5-Fx for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGTJ0-0005FG-Td for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:12 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:40594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGTJ0-0005Do-GN for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:10 -0400 Received: by mail-pf0-x243.google.com with SMTP id f189so25991699pfa.7 for ; Wed, 09 May 2018 10:55:10 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 10:55:08 -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=6VQangtIjAwJ133sYgDadXihJUXTelwtJPHnYxQD5HQ=; b=Be48oPbQ+FH2te8U1jkoPAyuCo56CRMeKVQI0ejuwVID4prj6xbkiKIGw2lR41PrdN f0Bkbw4KRK5bc1o4CWFv2JiXFWeAQc5T2pe/CoAvJ9c1OPsXbt2W4DO2djSrWlnTlkUL FhcX94Tj9RvzOag7JbvkqWgIJ/YpVux0Ej9To= 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=6VQangtIjAwJ133sYgDadXihJUXTelwtJPHnYxQD5HQ=; b=sNDxCelZiu9+0SPC5MtpFTOg7VPe8U/itXBTtaOFkpUE45tH0lCuWEiGtZI1VAFMm5 nHuuK3B5p0bvCAc0YcRKPCqtObwxnc7dOmaGgeAwCS5yyGxdB5fA+qCoj8uB2sx8bZjs t4ijwrRfu9RQ8mCMEyW2b+HQxgXe2B1hI6niS69bYEJPITXh9DlN+e4bwpaL2trqKdiW EjLueM2k3aPKeTohVjCOguB1p/FFmOMhQvjX320EhArbdj1mvq7wNCo+h+JD03W444sr k3/nQRy4ZNSJ1grn5HsSiJMZgB/csV/SNGZisyUEOrLxa6j7l9P4N9x0F09D/sQPZVxt cXgA== X-Gm-Message-State: ALKqPweKnIHE8lNzuh70Uz3VaJ5/ndoTkxzhisI324XXv/dcgcFDqgs/ KgqfBS7CUbBS2xwgs5jn2lC5EbZ0pzw= X-Google-Smtp-Source: AB8JxZozKX/3Du1CT7YNrQSG0/qDc1WocN+A/M6aV+1KfAwhrSsZaebHhqI/hZw5BS+TPSu2PmJqtA== X-Received: by 2002:a63:6142:: with SMTP id v63-v6mr1994037pgb.432.1525888509070; Wed, 09 May 2018 10:55:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 10:54:35 -0700 Message-Id: <20180509175458.15642-6-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:c00::243 Subject: [Qemu-devel] [PULL 05/28] target/unicore32: 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: Guan Xuetao Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/unicore32/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index 5b51f2166d..abe2ea8592 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -1875,7 +1875,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb) CPUUniCore32State *env =3D cs->env_ptr; DisasContext dc1, *dc =3D &dc1; target_ulong pc_start; - uint32_t next_page_start; + uint32_t page_start; int num_insns; int max_insns; =20 @@ -1894,7 +1894,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb) cpu_F1s =3D tcg_temp_new_i32(); cpu_F0d =3D tcg_temp_new_i64(); cpu_F1d =3D tcg_temp_new_i64(); - 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) { @@ -1951,7 +1951,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb) } while (!dc->is_jmp && !tcg_op_buf_full() && !cs->singlestep_enabled && !singlestep && - dc->pc < next_page_start && + dc->pc - page_start < TARGET_PAGE_SIZE && num_insns < max_insns); =20 if (tb_cflags(tb) & CF_LAST_IO) { --=20 2.17.0