From patchwork Fri Jan 22 09:50:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 8088621 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 027299F6FA for ; Fri, 22 Jan 2016 09:51:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45DA5203B4 for ; Fri, 22 Jan 2016 09:51:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DA03203A9 for ; Fri, 22 Jan 2016 09:51:17 +0000 (UTC) Received: from localhost ([::1]:52119 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMYNB-0002QA-3x for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Jan 2016 04:51:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMYN2-0002Np-GN for qemu-devel@nongnu.org; Fri, 22 Jan 2016 04:51:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMYN1-0005mx-Ii for qemu-devel@nongnu.org; Fri, 22 Jan 2016 04:51:08 -0500 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:34778) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMYN1-0005ms-Dc; Fri, 22 Jan 2016 04:51:07 -0500 Received: by mail-oi0-x242.google.com with SMTP id x140so3468704oif.1; Fri, 22 Jan 2016 01:51:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=1REl11RSjNFPLmCelV3StMMHfBl2ELyKWREuny76YIY=; b=IVyvM7d7Vfh7C9GlaI6lYH+cBA9ijtMU2DVAAAWa2MGguo2u30zcuvThXMbn8je0Ml mNAaSZA+yDggLDGOHnAas2+VzgmYRDZViydGhrhGnJfv0NlO/vI+UgtwiAzGg4/RgLql MUH46KclqcJ+VUuUpdJELWivc0WtIvpnS2+jFWGYcFAfeuCswBu2UfeBA59zIyKIzhOE ghyTD0lff4XUT7VVeYWjPyHszBvJPt7x3qkorBpGBwpl23AUMjycNJBuli+xCvrm6mg2 XgP2Bdv71e7Zz0EdzNjL/y7bCiNWDCzYkytc7ssl7LeX5efx/+18zQiqilNHmuplhvkq qRLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=1REl11RSjNFPLmCelV3StMMHfBl2ELyKWREuny76YIY=; b=F8TO2oD4gaFCsA0FrQjlkg61U9Ryg2VKwn/z5/bagTGdQ3V8M6jLY9BNEo5gwoz6gc pyv/oos+AhjCOCAqF7qR8fW6A0DDr/olsWhoPzg1tl5b0QCqFYSka7lOTYxYcWasxom/ YSY0HAuYpkHzRyl69m1c+c9XLQ5/END9HaXWW18t79fn1Wlxi1X8xMZcBfm48j252KfV 2q6uRtwNMVubwr6aAHRO92QDAxhbAOZbb1tmkdCf7RwUQKiqEb94KrgsAjvh6RoCCwur oMJ/K1iIoZxP85hc0XiAYnYr+ncNwMnpZGMbs96OSRxJnfvlV433q5FnZipSJ98Ls4Bj FS7Q== X-Gm-Message-State: AG10YOTiPiRd+oGumHbwVnCr8BmZeE91J+60h373Te/FXzwRMFqo+42NexAcw6uPxOtdbQ== X-Received: by 10.202.211.80 with SMTP id k77mr1553671oig.98.1453456266919; Fri, 22 Jan 2016 01:51:06 -0800 (PST) Received: from localhost (ec2-52-8-89-49.us-west-1.compute.amazonaws.com. [52.8.89.49]) by smtp.gmail.com with ESMTPSA id a128sm2747746oig.3.2016.01.22.01.51.05 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 22 Jan 2016 01:51:06 -0800 (PST) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Fri, 22 Jan 2016 10:50:41 +0100 Message-Id: <1453456243-19879-2-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453456243-19879-1-git-send-email-edgar.iglesias@gmail.com> References: <1453456243-19879-1-git-send-email-edgar.iglesias@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::242 Cc: edgar.iglesias@xilinx.com, qemu-arm@nongnu.org, alex.bennee@linaro.org Subject: [Qemu-devel] [PATCH v3 1/3] target-arm: Apply S2 MMU startlevel table size check to AArch64 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Edgar E. Iglesias" The S2 starting level table size check applies to both AArch32 and AArch64. Move it to common code. Reviewed-by: Alex Bennée Signed-off-by: Edgar E. Iglesias Reviewed-by: Peter Maydell --- target-arm/helper.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index f956b67..8aedce9 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -6581,11 +6581,19 @@ typedef enum { static bool check_s2_startlevel(ARMCPU *cpu, bool is_aa64, int level, int inputsize, int stride) { + const int grainsize = stride + 3; + int startsizecheck; + /* Negative levels are never allowed. */ if (level < 0) { return false; } + startsizecheck = inputsize - ((3 - level) * stride + grainsize); + if (startsizecheck < 1 || startsizecheck > stride + 4) { + return false; + } + if (is_aa64) { unsigned int pamax = arm_pamax(cpu); @@ -6609,20 +6617,12 @@ static bool check_s2_startlevel(ARMCPU *cpu, bool is_aa64, int level, g_assert_not_reached(); } } else { - const int grainsize = stride + 3; - int startsizecheck; - /* AArch32 only supports 4KB pages. Assert on that. */ assert(stride == 9); if (level == 0) { return false; } - - startsizecheck = inputsize - ((3 - level) * stride + grainsize); - if (startsizecheck < 1 || startsizecheck > stride + 4) { - return false; - } } return true; }