From patchwork Wed May 9 17:54:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135336 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp60830lji; Wed, 9 May 2018 11:08:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrlGBxhY51Pu616xyvyKZV3lSLGq+4nXThWQXx1vYO4aSjGn25p1BwqAnQf0ND+zAxNWvN9 X-Received: by 2002:ac8:870:: with SMTP id x45-v6mr42149465qth.46.1525889302952; Wed, 09 May 2018 11:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525889302; cv=none; d=google.com; s=arc-20160816; b=eZcQtlw3C3LkTtYietMkulUSmsDdh+hX89AaO3ysddVE7hxVelR/smg0RdyT1bdrJW Ay0aNYH20GC/ejIgcPoNd4ThTV2ZxMh6Vxja4Jp2pmZZOTyCBB7sAIft7BgBGkS0HsYh wU1OlkNkqNFIqDfPcJAn1xdPsSkmzT6R38obzz0pg9fE33VGSpZZ8UjNIJ/OqvrYiOJP MqNuoku44vkahgEWFd5P3mxrR/J/8ZQEhQEdbzFzTh1CCL6MgJ8/6cW7AwR3IVMR1ifx IEyQpocBXJbguy8GMcqLiukMWBjmxe6d7nIuel69kw6YQX7IijIi3eSWUvJT/YwSCana q3Sg== 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=6LffsiiHs7lxOOvqYb43jpsKoKbfnr5G0u8u8SMXtOQ=; b=CoQekqcXZYQohsTRNjxdrBvjEroaH2Vt2kc9vWpDXi4vzFMS9290v5Kr4Izu/Gf5Rk Hh9+uAuEvbinjMQWgNMxP87Ibk3sBSJvT0pptF3n1zT2evtkldE42/Vwwo/IJ6yIvFw8 oWIYxcE63g65JbblhI2eqpTtRuMDQF+HS7xvzIiHot41wO5cxyEM1DPTYSzGs4Iwk60A biAApMhEij/Fu4xaOA/59nEtl75xPnCJrbw3BBsi8RqmXg3PIn4kMbw2xPi47O+G826S B5qTHdKxpp2VZfUxN6wQTF8yFuY5GLfMsZtr9+q4b/5jmZrZARH7n/vBEEZSUN571O1R W6Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MntaApi6; 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 b18-v6si2723928qtp.303.2018.05.09.11.08.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 May 2018 11:08:22 -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=MntaApi6; 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]:58187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTVm-0002Gj-CI for patch@linaro.org; Wed, 09 May 2018 14:08:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTJ8-0004g8-NA for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGTJ7-0005Rv-Et for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:18 -0400 Received: from mail-pg0-x241.google.com ([2607:f8b0:400e:c05::241]:46105) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGTJ7-0005Q7-9b for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:17 -0400 Received: by mail-pg0-x241.google.com with SMTP id z4-v6so22986552pgu.13 for ; Wed, 09 May 2018 10:55:17 -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=6LffsiiHs7lxOOvqYb43jpsKoKbfnr5G0u8u8SMXtOQ=; b=MntaApi64e2bNVvjDc3rJx6Zc9OLgTK2OS+r2wOfN7QmCjKNRQV6JCQRm8mPGF7rly pWomKlJVi0UGqEClOFANFI/1ywJuJWB74uZiVGIvKvk57rFWuAPvBoWud7IQY9oWKQGO XxzNWz60hQpNJxi3/0xuwzS0jeQhV9srkGoWI= 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=6LffsiiHs7lxOOvqYb43jpsKoKbfnr5G0u8u8SMXtOQ=; b=hmjonv5sIqjwMyN/5ESYszx9phBMAW8p4GbHJ9+pPoQ8jTdWHc+bleZeot0M2pRqMk TwdtdN4Y3mXgz6B2LghT1yKYd0M0awRKHONM920aYgDZwnK9mldExFrkF1pzOgjQj3UL oPaol6WwPUM5A/6G70wfhNLMjt0o4NUm/IIr+kpWFfJ89wS3wALZjkzrEvcdzlzf+ipq DdcxqgdpisX9QFYMqXQUgACxKVpDFpQqdQnlp/sdz0FBRZGLNH8TNgCQuEoMuQvTi4zH qO48EQxHsgbw7ArqskMVYZPLdinmF4pSRLyXjUZ000Ctv99nVNaGNnaqp1PGRC+frJU3 QgXw== X-Gm-Message-State: ALQs6tD6ljd4FNMRyoAv8TdJG3rRqHEPVODpvFJP1Inm6zhr39relos7 SraNq+7V8L+zLq5BucZmTXFr9ZdZ/6Q= X-Received: by 10.98.202.74 with SMTP id n71mr44855410pfg.149.1525888515954; Wed, 09 May 2018 10:55:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 10:55:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 10:54:39 -0700 Message-Id: <20180509175458.15642-10-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::241 Subject: [Qemu-devel] [PULL 09/28] target/s390x: 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 Reviewed-by: Thomas Huth Reviewed-by: David Hildenbrand Acked-by: Cornelia Huck Cc: Cornelia Huck Cc: Alexander Graf Cc: David Hildenbrand Cc: qemu-s390x@nongnu.org Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/s390x/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.0 diff --git a/target/s390x/translate.c b/target/s390x/translate.c index 7d39ab350d..44449f11ab 100644 --- a/target/s390x/translate.c +++ b/target/s390x/translate.c @@ -6163,7 +6163,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) CPUS390XState *env = cs->env_ptr; DisasContext dc; target_ulong pc_start; - uint64_t next_page_start; + uint64_t page_start; int num_insns, max_insns; ExitStatus status; bool do_debug; @@ -6181,7 +6181,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) dc.ex_value = tb->cs_base; do_debug = dc.singlestep_enabled = cs->singlestep_enabled; - 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; @@ -6218,7 +6218,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) /* If we reach a page boundary, are single stepping, or exhaust instruction count, stop generation. */ if (status == NO_EXIT - && (dc.pc >= next_page_start + && (dc.pc - page_start >= TARGET_PAGE_SIZE || tcg_op_buf_full() || num_insns >= max_insns || singlestep