From patchwork Wed May 9 17:54:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135340 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp63786lji; Wed, 9 May 2018 11:11:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqfZ1l3fl51ft14e4YtnktVkx5h4ombbJGs8x2Ld9chXRUWTrmgobdXuSqaV7l/JIiVySGm X-Received: by 10.55.239.2 with SMTP id j2mr38911253qkk.279.1525889491482; Wed, 09 May 2018 11:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525889491; cv=none; d=google.com; s=arc-20160816; b=zP8G85iOY1Wa8tj24AoRbZ88tObWKmQK9oJ35fMf7MnY+KgpXe5i9nQUkE1ivqFOg7 1qmFEbRRQk7GNE1vqRQH6OGB6drau7l+rw85f0Z3jyGaSOL4rbDhDm6cVEqctEu8THTU dHKlPfnxNh39oebJVsz94tTO/N2Ymcn6/KvBv/0NAOrG2SqnUxQ1RKp2L7oNhxXiBkCR EuvmZFQe15KhgU+XOi2fRlzvBe/8KBaTj1hUWGVCw319bYq8xKlQUtcA62XVDzg6PAAS GGdfwTGE3BxG/DyiDVAB4i6QoASb+YDcpCbTmdvdn2mzM6jPpxT7fLkLGoSp/hnlvjWj /6yQ== 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=S/2JGGydUpeF2M5E3pq1XD2DFxk3JsLAsIrsUVrcu1E=; b=Or/oC6TB0Safl9d1TB8Tv7QhYxE8mTXddiyT4MxP165G0ykbrSei/FnZXQdvhCkmQP yV+1dLcvBk2vTcG+J/AdBUrGFvcWe1p4Nz0YzAuxd50yjYJrX1sqeFdAuLe80t7O/KSv Q5XEtHwasU/RRSu/mh2tyKvOVpNaYwVy1K6DFCGhKLdNGFE2telHBoS1voDWavl4jAcm 0qvA4mgVgW2FYhK/ew6vwIjm1r1qoH6MZ8Pagls7bmpe/wMK31LV4Qn2Pag/2GCgkiP0 j7QEG6JnrqO8bPU5ekjfrQCvJP67CzYhDp8oSoaD5RIn1E+sO4PUxYUH6PYQ0RA/78HJ IWKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DzwQoQdH; 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 w4-v6si2785650qvc.248.2018.05.09.11.11.31 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 May 2018 11:11:31 -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=DzwQoQdH; 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]:58212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTYo-0005w4-89 for patch@linaro.org; Wed, 09 May 2018 14:11:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTJD-0004xg-Hc for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGTJ9-0005Wx-8V for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:23 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:45813) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGTJ8-0005Uk-Th for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:19 -0400 Received: by mail-pg0-x244.google.com with SMTP id w3-v6so2473432pgv.12 for ; Wed, 09 May 2018 10:55:18 -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=S/2JGGydUpeF2M5E3pq1XD2DFxk3JsLAsIrsUVrcu1E=; b=DzwQoQdHgXYDTu8EPEgY37Ii0/fGlmbiRVuHuH/kSt8KLyjZ080/YhQ8m/SzJ25Khy G0onN7A/Xp2wUcQV+p89pfQEkBUwuGxIwlcMgSmbt5YVBigIbQx88cTw2MqglJZ0YZTe RH3KET/yx4PpceB2F230ftNxCQ5WV46aPCbCQ= 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=S/2JGGydUpeF2M5E3pq1XD2DFxk3JsLAsIrsUVrcu1E=; b=T0VcTq+yw/W/zGYcdOuxTwXaA9V99+jJu9jTE9lpOtIQyukOxrIa4FPpxKw+lWPhIO u+e+aDrswbmy1UyKzfZu9sUOQXv+5164Cm6PNJfGhzzS19RWTDGtqAxlEDFbdQ0S3syo KifaJistJJo66mT8twVp3GAGjV4e81vKd/avPc/tBt8uLf4MJ8zJbnDozpBofK7FHRi+ bYSwe7Q4xAWoiT3cSs/6MyRxV1mR1SL+08Yi8JUvVDS0VvSdsHpkorMMD1JtFTFsWnyl 3DjlKq4zgB2tqXDIGj9nDktIMA/2/l2tQ88c9gi6K3sPJtwJCPIL/b/uTZNQspJAGlXV QrlA== X-Gm-Message-State: ALQs6tA3sboMnYnUW19kVJAHzOItFri/N4XrvHFFNDzonHHat+QZiilJ NocqyOeYYNoJlX02VvWYlVPIcuGyIZk= X-Received: by 10.98.157.137 with SMTP id a9mr44574172pfk.206.1525888517560; Wed, 09 May 2018 10:55:17 -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.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 10:55:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 10:54:40 -0700 Message-Id: <20180509175458.15642-11-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 10/28] target/mips: 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: Aurelien Jarno Cc: Yongbok Kim Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/mips/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.0 diff --git a/target/mips/translate.c b/target/mips/translate.c index d05ee67e63..d8e717dacf 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -20202,14 +20202,14 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) CPUMIPSState *env = cs->env_ptr; DisasContext ctx; target_ulong pc_start; - target_ulong next_page_start; + target_ulong page_start; int num_insns; int max_insns; int insn_bytes; int is_slot; pc_start = tb->pc; - next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + page_start = pc_start & TARGET_PAGE_MASK; ctx.pc = pc_start; ctx.saved_pc = -1; ctx.singlestep_enabled = cs->singlestep_enabled; @@ -20320,7 +20320,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) break; } - if (ctx.pc >= next_page_start) { + if (ctx.pc - page_start >= TARGET_PAGE_SIZE) { break; }