From patchwork Wed May 9 17:54:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135334 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp57785lji; Wed, 9 May 2018 11:05:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZovTRqs27FGvapu80dKEs9rVoqFjh98afD3KKscMjprAKR+7OMoRN4hGvmPJGIr8+3HW55V X-Received: by 2002:aed:2317:: with SMTP id h23-v6mr6847593qtc.283.1525889118670; Wed, 09 May 2018 11:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525889118; cv=none; d=google.com; s=arc-20160816; b=p7WFfpTKwu5USnKkTWSDsY1VtSabSNh7WR0/mAPi6sEBqyC4mxT9w2dK6FrHo2Rd8b J8hlKA6GQoU1IrYqN0JylA7EAd7f/mIgKiprLJvctm7IXRG8kXdvByAgsSy9Bcnf7Bfx svD1aLfI+hvO4eGxxzkhQdYFqlS8oFtO1R4PlI5BDy9XesmKvCoqq7MPWQ/AWjNLE6W/ Q81c9ZREOtBNEgXd7sGSjVkKIIMTtWt+5hwrVcc+CqVUvsobdnHOxqIfNg8K8gPKNjnn U02eyt1vmSuJxrmuKJruoAlYS+2CrY6pypdEZYU31pXJUDrr+dgE/W2sf+HFsU1GzXX2 wzWA== 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=MkVuuWcFJCGMt7LHPmcNqXMoE3YSRnpJbNj4Ej/eAOc=; b=hJh4sI7G9hugM2NReVZym4cVgrzz8RCue2viYNafRjH9FqGUphMCp4Jqk+CjvDn2ze ftxJVlcULX4Z8+XqMpVX1PoQJmW+EgkwSA1ZPMVAyCpTcc6QSHLxqgpYLPD5B8BkToKo QZqT11CeLZbLVjO9WJsY/DzhpBAEfASZ0cICu9/2OZqJ7i4MHpxd8vFL599FiFMQnnim q46jRljJ+/9xmpzjQtmBNvjqcq03+iaVP6IsLTE0Bg+IooWFZph6IBP3u9meYI7wnP0o qVDPKcSc2YomVQzucJUb+PxU0ENwi5D1t+hPucvFMZdFGGwDRVIPG6ewfXHSswuYhyXG GmQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kgsys3DT; 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 15si25703196qkl.97.2018.05.09.11.05.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 May 2018 11:05:18 -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=kgsys3DT; 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]:58165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTSo-0007OV-4R for patch@linaro.org; Wed, 09 May 2018 14:05:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTJ8-0004fS-G6 for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGTJ4-0005LU-3R for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:18 -0400 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:41945) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGTJ3-0005Jt-Qi for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:13 -0400 Received: by mail-pg0-x242.google.com with SMTP id m21-v6so23010213pgv.8 for ; Wed, 09 May 2018 10:55:13 -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=MkVuuWcFJCGMt7LHPmcNqXMoE3YSRnpJbNj4Ej/eAOc=; b=kgsys3DTJpgoHRbxVjeCM0550i/Kr5g2tq1LiA8i2wHSWeJTFPOu40swcD3rf7cEL5 rnCp4RX9idfVBXZ4JQxg/utADnvg8MMKCm6l3IJ/rz5Cud5qq8A6w5DHpLK7pgIGkDMD qPDsgsWzZQ7/9hbTFnbAW4A814Hlqd2Z27ho0= 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=MkVuuWcFJCGMt7LHPmcNqXMoE3YSRnpJbNj4Ej/eAOc=; b=pPTVxI/IJVZboqu81soEn3pLx37bFzLZYck6h6eSLVP0tcqB7RkL0Yne1S4Pxi7SJ8 TIdVjFApGR0WqTJZ7LD7kLuIbH8w13QH4BZXlbZ7G3NDfn8ZtRf8KWCptGmstPWtRGTi o6VVcAbWBdWDnd9AWN6CKR9D/eyEfUfTAIbJxUO5AeV+nS1Rm6YVPw6rowQ487uRfRPQ wODoa7Nb0w01HyKkjwTuTodbnPd257wDRRLue7nlTEN2uPsUAfNT3ZaL36dSeCZgAg/6 sfO4aFpPo86Nys3BsYhAT2IBmy469Or9t3hVHeWNQm3Ywq6N85VZwTosbxynLoB0dokm pHLg== X-Gm-Message-State: ALQs6tCkfrFoCpYvlpbjGebet7LHoyV3fyEbBSnoNINNccsizFGVb9pM dusa8wMAbSOWbkjffxeVPUA2Fo1BJLM= X-Received: by 2002:a65:635a:: with SMTP id p26-v6mr36473512pgv.163.1525888512457; Wed, 09 May 2018 10:55:12 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 10:55:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 10:54:37 -0700 Message-Id: <20180509175458.15642-8-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::242 Subject: [Qemu-devel] [PULL 07/28] target/microblaze: 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/microblaze/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.0 diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 100883e2cc..0872dc9ded 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1635,7 +1635,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) uint32_t pc_start; struct DisasContext ctx; struct DisasContext *dc = &ctx; - uint32_t next_page_start, org_flags; + uint32_t page_start, org_flags; target_ulong npc; int num_insns; int max_insns; @@ -1661,7 +1661,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) cpu_abort(cs, "Microblaze: unaligned PC=%x\n", pc_start); } - 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) { @@ -1747,7 +1747,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); npc = dc->pc;