From patchwork Wed May 9 17:54:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135327 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp53527lji; Wed, 9 May 2018 11:01:40 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqe/Df7BYaK+dVzjjJdRavd75q1+FedxHep/2CZzQikTsDPJAL/XflxPlv9pPxLbcvOyVGX X-Received: by 2002:aed:3622:: with SMTP id e31-v6mr40875576qtb.82.1525888900001; Wed, 09 May 2018 11:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525888899; cv=none; d=google.com; s=arc-20160816; b=DKY4Hs1ga3GakwNn8Rl6bqPnVeMrpw28AKdz8A1eHBLZDx8TFkxj4YCOdV/9RURMZ+ WitBk6Xw8uglk6Z37qWEF1h6YlWSFvoSl2snMsM75zywkdHkDAc55Z/ri/9kA4mLLGOJ /fhvVNurHP+FGzS9AIMhidtv9RrFQQqQUg8aiV/SnKaef7eLb4kx+N37RUlVHKmnar9M qJIPw44oCyI0yZ5i695j9PtlkIDoZNpE77ft9FYvkj/VRaXTOLe7Y3d8k5+IaewCzZM9 yieGD5wR9BzK8uo4u5PIs7pfhoWLlu8S+ZAFEVGSxmte2PMf5ns4jB18eFECNhDnyFg1 etIg== 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=6VQangtIjAwJ133sYgDadXihJUXTelwtJPHnYxQD5HQ=; b=wIMIO+DsakbDXQsWpn/EIy/elzwkfs+GBO6Yze6l8X/p2pejWNH6DMTetdFqgy5wSK I3v8tdx2FJR78g4/nul3hrMlXNlA01Iu213EMrpaRF/QUqnFbNCf1ScaPRhDDPYdch2A bFmrK58K9rdS9s7s//7EXJ0kz7/4uWaulK+No5c7cPKjHJNkwuVTeLMUuqjSos109GKF M+jssNqXoDMjxEcBdFYid+3R0xqkB98d+LnX5vdz+/1HuAcoq1htzhZ5STNdWNEBeWOr 6WQ5dB6s48pZvQx/3Fi+Oc7LX5iJWqqBM9oN4nutfKLRpOtJ+RSmkOIHLhNcLLdwRWKB CJ4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Be48oPbQ; 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 t56-v6si1701082qtt.294.2018.05.09.11.01.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 09 May 2018 11:01:39 -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=Be48oPbQ; 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]:58129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTPH-00046P-Dl for patch@linaro.org; Wed, 09 May 2018 14:01:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGTJ2-0004R5-Fx for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGTJ0-0005FG-Td for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:12 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:40594) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGTJ0-0005Do-GN for qemu-devel@nongnu.org; Wed, 09 May 2018 13:55:10 -0400 Received: by mail-pf0-x243.google.com with SMTP id f189so25991699pfa.7 for ; Wed, 09 May 2018 10:55:10 -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=6VQangtIjAwJ133sYgDadXihJUXTelwtJPHnYxQD5HQ=; b=Be48oPbQ+FH2te8U1jkoPAyuCo56CRMeKVQI0ejuwVID4prj6xbkiKIGw2lR41PrdN f0Bkbw4KRK5bc1o4CWFv2JiXFWeAQc5T2pe/CoAvJ9c1OPsXbt2W4DO2djSrWlnTlkUL FhcX94Tj9RvzOag7JbvkqWgIJ/YpVux0Ej9To= 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=6VQangtIjAwJ133sYgDadXihJUXTelwtJPHnYxQD5HQ=; b=sNDxCelZiu9+0SPC5MtpFTOg7VPe8U/itXBTtaOFkpUE45tH0lCuWEiGtZI1VAFMm5 nHuuK3B5p0bvCAc0YcRKPCqtObwxnc7dOmaGgeAwCS5yyGxdB5fA+qCoj8uB2sx8bZjs t4ijwrRfu9RQ8mCMEyW2b+HQxgXe2B1hI6niS69bYEJPITXh9DlN+e4bwpaL2trqKdiW EjLueM2k3aPKeTohVjCOguB1p/FFmOMhQvjX320EhArbdj1mvq7wNCo+h+JD03W444sr k3/nQRy4ZNSJ1grn5HsSiJMZgB/csV/SNGZisyUEOrLxa6j7l9P4N9x0F09D/sQPZVxt cXgA== X-Gm-Message-State: ALKqPweKnIHE8lNzuh70Uz3VaJ5/ndoTkxzhisI324XXv/dcgcFDqgs/ KgqfBS7CUbBS2xwgs5jn2lC5EbZ0pzw= X-Received: by 2002:a63:6142:: with SMTP id v63-v6mr1994037pgb.432.1525888509070; Wed, 09 May 2018 10:55:09 -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.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 May 2018 10:55:08 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 May 2018 10:54:35 -0700 Message-Id: <20180509175458.15642-6-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:c00::243 Subject: [Qemu-devel] [PULL 05/28] target/unicore32: 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: Guan Xuetao Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/unicore32/translate.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.17.0 diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index 5b51f2166d..abe2ea8592 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -1875,7 +1875,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) CPUUniCore32State *env = cs->env_ptr; DisasContext dc1, *dc = &dc1; target_ulong pc_start; - uint32_t next_page_start; + uint32_t page_start; int num_insns; int max_insns; @@ -1894,7 +1894,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) cpu_F1s = tcg_temp_new_i32(); cpu_F0d = tcg_temp_new_i64(); cpu_F1d = tcg_temp_new_i64(); - 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) { @@ -1951,7 +1951,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb) } while (!dc->is_jmp && !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) {