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: 911075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MntaApi6"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40h46d4HmKz9s2t for ; Thu, 10 May 2018 04:06:17 +1000 (AEST) Received: from localhost ([::1]:58168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTTj-0007V7-AP for incoming@patchwork.ozlabs.org; Wed, 09 May 2018 14:06:15 -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-Google-Smtp-Source: AB8JxZrkZxo33LFDBwUe29W0yt6V+nagj7SxMklyW7qzHp5kROY+wXHrV4B/zyO8Z41+K1Ofx8IAug== 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+incoming=patchwork.ozlabs.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(-) 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