From patchwork Wed May 9 17:54:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135325 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp49432lji; Wed, 9 May 2018 10:58:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqy42DFGGL2+TBNoAEJeYjx3V4af0mJcRZizSKtpkjBaKHzjjjfOYCb5s9otuTaHCQnCN2S X-Received: by 2002:ac8:1204:: with SMTP id x4-v6mr43919893qti.35.1525888695267; Wed, 09 May 2018 10:58:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525888695; cv=none; d=google.com; s=arc-20160816; b=ZTjZUWc2UsXxN8zBM+zyhflpLZKHp0eDDVysF4PDE+EOZ4zTLbcjgSw4q6ZD0aQqFA Kikw07+phy6G3JN6dle2SYHGCrd42VPEPW82Es+Mu3oA9+HTDjasV17NnZrq6E8OmRoy ryhkHKI2HW6CDbSu4nJLIlJGes32S2XZByBOvsOWJPYYF1sAhXli4JNGyNUS0dJ/KLSh eNr0grQCdFvLamLZvW4R3GIrYpAP+q3njYoea9fFJdbcyymhm9uGo6oXHhMd/XQxnPF3 D8iItArt6OxesLI+Ph9EgQjqTqFbA8dadoxKvLYVvRG3IC3sGar/Fp4QisIcDWToFb6G lYaw== 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=Cz2RaWEKME9UX5uwabOkLGSwHGoSJuvxngLRai2i1EQ=; b=Vb2t4UZI0AlpeieLu0TX++guHccdh/jFR49dCOXLULGQm/0WHiQhaNkfl+ogPRSRdc /fq/7u9G5K6UxQMZyl5WcdsL+83ZSTn/q2ri5785eiwnn95+d8G1prQgIttm9ri+O0NX 1o2BapytMVDQEDv5EJgSugjeyB4sAcUhSPRhic/R0UxjWW1KNI5rwVbQk9BgN+IHeNqy hoYj98XF+ixGXxfPzHvHNSRcfmzzQTxJpHNIpS9TOZnn8NhGNIbi3zkYAdXAH7nQAAvc 4AnjpJnrxCksg7foQ2ASv3CGZE/3OQ5eBONQ4elCnVDGBjQATZOKNstQmAEg3Aq2S2YP BmtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QjqzPWQs; 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 u11-v6si3676617qtg.246.2018.05.09.10.58.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 May 2018 10:58:15 -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=QjqzPWQs; 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]:58102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTLy-0008PT-L9 for patch@linaro.org; Wed, 09 May 2018 13:58:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47685) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTJ0-0004Pn-49 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 1fGTIx-00059F-Ab for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:10 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:38256) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGTIx-00057P-2h for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:07 -0400 Received: by mail-pg0-x244.google.com with SMTP id n9-v6so23007485pgq.5 for ; Wed, 09 May 2018 10:55:06 -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=Cz2RaWEKME9UX5uwabOkLGSwHGoSJuvxngLRai2i1EQ=; b=QjqzPWQs3TKsoxhezr4ziyC32p8TwnvNHlQ3GuLt1LNP/M9zuyyQar5KN41h4K8qal KkYIhQFl98Li5JsBkLjW+gdHisnCUjKkoG2xof6gnKKAYstHUQ55/Cda/8yuROycGaOt 5Z/j+HxuX2dWD0zAhIq6RzDDENWgep9pEAw0A= 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=Cz2RaWEKME9UX5uwabOkLGSwHGoSJuvxngLRai2i1EQ=; b=bpJYFfPjlSx4uhJUDTuY1as/wn70WykUgRDEE7iDuu8wP02d6S4lNGlRB/nVFL8xb2 hAKRIjbKGd384zJGNYF/EnLNBX26oE1Q7aZQaQYOlx7MWRrQqD/GULzxHOkpGncc0Zk3 kuDw1DGDSFSKPyJMXyc20TofmNGG/Bbzrm6a8VLBkO6ijmjGDWVTSC5FBq1IEZSt5RAd ZdfHhzwYsc+grLzMaeDEcg9UO1MoEzbgfv8iw/p4VTHal/PqwEtlw4jN1Z7a3RyNB3k8 BiMxtHyQvODY3jQaAVXFquL/UqZLPIyuExCuObc9gnCXqF1wDN9XODAGqJZsLhB4N33+ A16A== X-Gm-Message-State: ALQs6tAzgP6ZDgbRpQwPtyVyPmQAvd87Van7SDsxBwgtwyRsHaH4bkXA 7UJ6rOabaEjmdGB78JO7SI5OoZh9LBM= X-Received: by 2002:a65:55ca:: with SMTP id k10-v6mr37474252pgs.422.1525888505615; Wed, 09 May 2018 10:55:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 10:55:04 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 10:54:33 -0700 Message-Id: <20180509175458.15642-4-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::244 Subject: [Qemu-devel] [PULL 03/28] target/lm32: 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 Acked-by: Michael Walle Cc: Michael Walle Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/lm32/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.0 diff --git a/target/lm32/translate.c b/target/lm32/translate.c index 2e1c5e6d01..fdd206a860 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -1055,7 +1055,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) LM32CPU *cpu = lm32_env_get_cpu(env); struct DisasContext ctx, *dc = &ctx; uint32_t pc_start; - uint32_t next_page_start; + uint32_t page_start; int num_insns; int max_insns; @@ -1075,7 +1075,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) pc_start &= ~3; } - 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) { @@ -1115,7 +1115,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) && !tcg_op_buf_full() && !cs->singlestep_enabled && !singlestep - && (dc->pc < next_page_start) + && (dc->pc - page_start < TARGET_PAGE_SIZE) && num_insns < max_insns); if (tb_cflags(tb) & CF_LAST_IO) {