From patchwork Wed Jan 27 22:16:08 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: 8144841 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D6821BEEE5 for ; Wed, 27 Jan 2016 22:17:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3270520212 for ; Wed, 27 Jan 2016 22:17:02 +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 85F5A20211 for ; Wed, 27 Jan 2016 22:17:01 +0000 (UTC) Received: from localhost ([::1]:52826 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOYOa-0000k4-RF for patchwork-qemu-devel@patchwork.kernel.org; Wed, 27 Jan 2016 17:17:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOYOP-0000gM-42 for qemu-devel@nongnu.org; Wed, 27 Jan 2016 17:16:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOYOO-0007Lc-9h for qemu-devel@nongnu.org; Wed, 27 Jan 2016 17:16:49 -0500 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35849) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOYOO-0007LY-2O; Wed, 27 Jan 2016 17:16:48 -0500 Received: by mail-pf0-x243.google.com with SMTP id n128so1009422pfn.3; Wed, 27 Jan 2016 14:16:47 -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=5rGQzaC/OVFGVU6s0smwuqX5fwq3sU8NAIcMqVbAe5s=; b=X6pOdcHEfXd+dBHM0MgaZSVIk5uPnIXTX1seNCw1XYPx2Z1cyFdA9csNcF/pZR2sUf I3DXnw+SjcfvG3pSaTeGpZ2r9d5IEGIM9R9KRvqRBGsAU30S1YBAU8GmdPQh7jIDc3Qk 7qMRV02Gr3INnxgWXH5cR90uKPrdwSqJrCtWsKfFccatzG5ZLScLnXzHAOLwmDUDeMGT KxG8dPXFKCwjm43brVEU6Y7hCqDzd/E9ALLtTBY1XhCLrcK9K5xEyvvUFzBHJRFfGceb eIzbBLBSwK7ExFM7bYT8so/HwyVlY/htTPflHJYjoSg2HZpvQi/qd9hQNzhYX3X6yMLV ObsA== 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=5rGQzaC/OVFGVU6s0smwuqX5fwq3sU8NAIcMqVbAe5s=; b=d8wfN6NAVjqa/ysfRIvw64qLJAk1rMIW8Xh0DmPsQa+TjxnHkqqQ31dlssewe2cvdT wDQa/Z6tF8voekc+/u4GoQTz0hzNi05iSy4ETYfnewypR89k8YtRmlL62vFN84tQ9iTd axKnVsh9p5P0OnbYaUn5tIlYCvEmRqfZuIB5PEqCTEjcD/W3XeUd7/QNjpyGNZSgVUin sqdHUMKYaL9XNliKak01md6LCoh1vYPAfZ3+3XpcRdT3G1kKwCI0Ji5bm8Se2cGabvxk qM+Bc1+ufVS/Cw3g10Ea5dBSVICsWSSqZV11V/G5mQ27kbukJJF9gcxa0MiKYUsvckyA HKGw== X-Gm-Message-State: AG10YOQZkPAwvDxJ3JIvgvAyNa2RYO29weCtS0MdE4bJCubDGb30XySBC3Emo8Q1NbAslQ== X-Received: by 10.98.73.29 with SMTP id w29mr45536236pfa.106.1453933007424; Wed, 27 Jan 2016 14:16:47 -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 yh5sm11291091pab.13.2016.01.27.14.16.45 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 27 Jan 2016 14:16:46 -0800 (PST) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Wed, 27 Jan 2016 23:16:08 +0100 Message-Id: <1453932970-14576-2-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453932970-14576-1-git-send-email-edgar.iglesias@gmail.com> References: <1453932970-14576-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:400e:c00::243 Cc: edgar.iglesias@xilinx.com, qemu-arm@nongnu.org, alex.bennee@linaro.org Subject: [Qemu-devel] [PATCH v4 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 Reviewed-by: Peter Maydell Signed-off-by: Edgar E. Iglesias --- 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 ae02486..5d6f297 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -6775,11 +6775,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); @@ -6803,20 +6811,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; }