From patchwork Wed May 9 17:54:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135329 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp54031lji; Wed, 9 May 2018 11:02:00 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq94kW18vRGns3W0aFfm4zEHBP7lrwAmt6yPq/Pu1UQ18uiwYsU9y89mb8f/B4FCVd8Hgz7 X-Received: by 10.55.207.205 with SMTP id v74mr39316736qkl.240.1525888919962; Wed, 09 May 2018 11:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525888919; cv=none; d=google.com; s=arc-20160816; b=d7xlzL4aoG5FA4BHOsLSHMddJoxn2xplpKJMVWe0515sKlhRWmM/u7Fdue+a/HJ1Qd Is77KRaOwXWKq76uJQBvQouH0KlrLcajYfLqMeyc/68wM4mVzPNzP1dD/iQVbtXFbq2z VL4ke7wXICO42Z29GN2N4asIfwM2umVb/eHVHVfU2JE9mfzfHqJtzkCY2RXK84U/Y6qT JBgiZLKVpB45RfrRbiIYKn3y+JEt81C3ndUbqX7Z2Q9TYSAkMq9wkNN50DI1ozMbYOnv mUP24a1yd1sa9gSRik2B27R5gsSfHiY6vbQ83rpFNpZ+7cQvKP8gNeVQvyvhTe1Tsbz0 +wow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=TiojlQ7+bOmRyh2JassU7YgApdfRFoNSCnyqvh/LGfo=; b=dJtvI1zOowt523a97sB0LYu7P8IskRpM3VImepNd5JcukC632x+uiZ33Vo3uZf+Ws+ +X/xRG8DeSouyoOKd4WE99RMOIkovwePeIwVVGZfh46vdWVWlrWFmkLhFhlZdlvFpXqw 9DxjtM3h+Cf+nlvBdrj2IxNCksnitjGOAE395KRrANaa0XoBgedAdFHW7DRbU7eo3RxS g/f2XtVUobE5zqmUQHneOL0ZWxA+VeBP0pPv0txXVp25oaniJlQzIgrDKG8BK0HLHJNO +JqVtTheDwgrCRC2g0G9Kmp1z5JhlnAESChA0EzjXgVsfof21qigBT52Z/LLUk2i4qpO A8Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cKYJL1vg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q18-v6si4328843qvm.211.2018.05.09.11.01.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 May 2018 11:01:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cKYJL1vg; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58138 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTPb-0004O7-CE for patch@linaro.org; Wed, 09 May 2018 14:01:59 -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) 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-Received: by 2002:a65:5a81:: with SMTP id c1-v6mr36858067pgt.20.1525888503802; Wed, 09 May 2018 10:55:03 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.0 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 TranslationBlock *tb) unsigned int insn_len; struct DisasContext ctx; struct DisasContext *dc = &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 TranslationBlock *tb) dc->cpustate_changed = 0; - next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + page_start = pc_start & TARGET_PAGE_MASK; num_insns = 0; max_insns = tb_cflags(tb) & CF_COUNT_MASK; if (max_insns == 0) { @@ -3234,7 +3234,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *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); if (dc->clear_locked_irq) {