From patchwork Fri Jan 4 18:04:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154790 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp893330ljp; Fri, 4 Jan 2019 10:22:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN5hz9cNJkHO/l10bpnHo+cmTwvyKWX5c33+LS31rKBn93C/sDfi0ZsgtWi4jXRxPiLkrsNz X-Received: by 2002:a63:134f:: with SMTP id 15mr2487507pgt.19.1546626134138; Fri, 04 Jan 2019 10:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546626134; cv=none; d=google.com; s=arc-20160816; b=HxYG0GYdi8Vch8VDtz6dIJMGCYQ1lM0/YbI8wG4+IrmRVfmiJQSq7ITbabPTQDgDnG exrpR7VzdyWg15qek+ljggvMwKnpJ6LCxbSBRTLP0RTAqZGKw7j2MO7O64uS4dQMigVi k0fE1L3yKF0h36cz7nHePMC6afXwconymWGsDGxHFknpkO3EQllzVdiOOApT4fbs2Eav lrF6L4cDnjKKYWor9X0yNfCYR5mu8FS7MaZ6og/AoeKRJ7dd6inE62S9MlxWJ15ylSQt LcjaAsIYTnR6+n2o3+aDPMGeAvqqEY4DnB3gIm3klU1XIc1sPuMGnc0POfJifP+S4HXV WwIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :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:delivered-to; bh=C+BwI5Lb13UvNJ6B2PH3kJHNnbejpPhpsfUxcsaKEC0=; b=EfoTvpIlYuucxiJOK+MBYSXpQotlOw/5ARhvmKR5Bc2bTwN/4qp+BMsBXL6AdAdmTT FpwJm0E1z0f+P3XDxDOpvJKQ5UiQgfRFxbjdra0QzdN1O7eE500b7310JUP7uabPEDJD koC5fGdrKtLb3s7F+qd8wd9NIv0A7LDMiLVUOptxc4bdJZnVFrcnFYSPuw9t7i59BSxM u1Oc1SFaSxu2vKd+ymgUi3LfYjLyM5QLae7dLeXulcBavqrqS+uhUx1Cv+S+LumrKyOP n7t9wH164xdZGsnwwP9tNWg3BWWv0oxrrNny8N2bui5YlSzO2iuPi2+srDxImaJwVlsV qOww== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TU5c+KS8; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id c64si23388885pfg.239.2019.01.04.10.22.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 10:22:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=TU5c+KS8; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D23DF2194D3B8; Fri, 4 Jan 2019 10:22:08 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::543; helo=mail-ed1-x543.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B20B7211AEA4B for ; Fri, 4 Jan 2019 10:05:04 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id h50so32527140ede.5 for ; Fri, 04 Jan 2019 10:05:04 -0800 (PST) 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=DknfAsB782kb3Js4W/x6Vm9HBaGgnaqZtNKcJnzorJY=; b=TU5c+KS8VKk8aPxck7PZYmCnclXKTKk6X3bgbNhjEPT6svaYRbuMkrwBQQxLPFq4Da /xLdakm/U2yrwfAs0cThJVx7q/7n0UiyJGvirx3GzM+wd0TyzmgRAb1++f4hSecqHRfh boqBPHt3bCI+noZl4ZH1w0ldMJ0FeULe4rsPc= 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=DknfAsB782kb3Js4W/x6Vm9HBaGgnaqZtNKcJnzorJY=; b=uUu+h8DbrkvFzU6nl1AP3qbcRKpYSk50BDWectvgr52vWMJk7CHboC0/Ks8KYfjaBz E9xEIOaWo+Ta6BLHyXFKjf/PhSq/vkoCsHQQtWEX5i/4Cwdj0oA3sENm4pwEQjS0I9y1 i9ZtL/d3NDtwEubGK9m3xebBjMl7SNQDu/9cgVtchF5Lt2eEzk5BbQ3/EJ/vurifaMaP QBe1k1smgTvn0jUYcvwjIDMO/Q6xjkbNA3MEQrYOxndycnbr9U1phUVEUsHQ4XlVYMfh wnNNhZgeh43qkA/9MNg06wMgdmdC33ohxncRzqg2Y5jYwX/oh46oxcEmio/2+HsGFdMt QKfg== X-Gm-Message-State: AA+aEWYijCNgG8A38wF5KJgSasXL94X0NJHyX9I3IzVaYc+Fs+5EdSaz +oMjDzxHSazIHW9afIHrZkLDaOm21m8cIw== X-Received: by 2002:a50:a826:: with SMTP id j35mr48314907edc.230.1546625102948; Fri, 04 Jan 2019 10:05:02 -0800 (PST) Received: from dogfood.home ([2a01:cb1d:112:6f00:183a:9013:d5a3:37a8]) by smtp.gmail.com with ESMTPSA id t26sm26038977eda.22.2019.01.04.10.05.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 10:05:01 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 4 Jan 2019 19:04:32 +0100 Message-Id: <20190104180432.24480-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190104180432.24480-1-ard.biesheuvel@linaro.org> References: <20190104180432.24480-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/2] ArmPkg/ArmMmuLib ARM: fix thinko in second level page table handling X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" PopulateLevel2PageTable () is invoked for [parts of] mappings that start or end on a non-1 MB aligned address (or both). The size of the mapping depends on both the start address modulo 1 MB and the length of the mapping, but the logic that calculates this size is flawed: subtracting 'start address modulo 1 MB' could result in a negative value for the remaining length, which is obviously wrong. So instead, take either RemainLength, or the rest of the 1 MB block, whichever is smaller. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c index b237321a8d8b..3b3b20aa9b78 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -294,8 +294,8 @@ FillTranslationTable ( PhysicalBase += TT_DESCRIPTOR_SECTION_SIZE; RemainLength -= TT_DESCRIPTOR_SECTION_SIZE; } else { - PageMapLength = MIN (RemainLength, TT_DESCRIPTOR_SECTION_SIZE) - - (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE); + PageMapLength = MIN (RemainLength, TT_DESCRIPTOR_SECTION_SIZE - + (PhysicalBase % TT_DESCRIPTOR_SECTION_SIZE)); // Case: Physical address aligned on the Section Size (1MB) && the length // does not fill a section