From patchwork Fri Jan 4 18:04:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 154789 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp893271ljp; Fri, 4 Jan 2019 10:22:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN6mdmwosD+3zqH8nHir5MMKHK/6D+39407/XLkLLImyCa3X2ZnvVGwCscvxYGMVFBovPtZV X-Received: by 2002:a17:902:24d:: with SMTP id 71mr50359303plc.225.1546626130960; Fri, 04 Jan 2019 10:22:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546626130; cv=none; d=google.com; s=arc-20160816; b=J+7t6lyCX1AXZv5R4IfFwF5/N7UwPG6jeWzhkYwgcoqssJuEm8lrIZdMLwxSmHpYNX gcK9G7PLDWrAVHZoOamGHPCwChRhXnwbqvhl07qWr4SoggvMHJY2r7m8ovZShWUGQ/+6 kHifNBrlBrw52A8diOpjZuKPA83xrmyUC3kb2+tR7ZWIhmxhVHJoVEP+R718hp/9JEOV LcwNZZTCgtXv5MMpoX+Ia0Vq/YF5rDaHBP7eJIXsY69W9GlJ47BrIcEkqVT4nsw/xUtI wPWKA4JinxLvRwY+FN/IfBLjwcxWROHWVqUWp2+e9D9UMe6GehK0pZN9+G+yLT0Vl3yy XtBQ== 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:message-id:date:to:from:dkim-signature :delivered-to; bh=lsZgV1V3nXxHaAvti/j3MGikoPgUN9bJV7H4x/q4NH4=; b=QQdVsylDGfB7Qpt4dqGMZ0gSR1lhvpt/ACYpMwgMZQUa6ywdDvWGet2bnmmtFPwyq6 YuBwICVNhNzo0zfQFBQK3+2V+KCoHvrG058ReC39jhk7cMT1YvSfqTQrXxakODcW4W92 TIOirxOJqApIo0rQCUDvZNmTj5X5gGTrb30PuaiBOJmDe1N6NOMYamH13hT6Rl/k2Mb7 lyMcx8ZrnIUE3P4XkpN8VBOzFtbjimCcvD8Vbn6wYAqydSSIeP6tvdHM40q4AKlaXBoV dRa+zrvD34J8trYk0DeYqShDwT17YsKwjMCiIqb54L1jRYblqJdfOg3ogAWTjFcE0jeZ Iw6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="D9TRq/XA"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id k12si350132pgg.382.2019.01.04.10.22.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 10:22:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="D9TRq/XA"; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 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 A0DA0211AEA64; 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 02CCF211AEA4B for ; Fri, 4 Jan 2019 10:05:03 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id f9so32485808eds.10 for ; Fri, 04 Jan 2019 10:05:03 -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; bh=2PZh6TDEspZL2y1eli6CiAKGUOrFbdn8KwnQnFwcJH4=; b=D9TRq/XAFr8FJUQHHY3IDs/vXBpeQwisrHatXzFqkkX5OL/Q/ReXPtasZAhTa3TVoM mg1M+rhLc48Z4AHL2KzEotU7alBVZjYu13VQQbg1iALvNiNfqVqZUpCmAZ2HCvDlUUpQ ZNUVF13v6LKHeASWIE5CrgqyJcW3iaVoWbLmk= 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; bh=2PZh6TDEspZL2y1eli6CiAKGUOrFbdn8KwnQnFwcJH4=; b=KfxHBMdtBkgIDkFhyXplcFb5s6jfr9NuY0TQQ2nQmtHZ+VwxOeDueTOcjyGxWIwwNa lUYYk21mFlIK03onljpuP1PYjAPkHrLwV6aqGwaiJo0mBNEWCLrZJjo7zyuXNAIF3tq3 01GovG2IYOoKCuaCw9DRsUzlg61aoFMQaEm4V/3+0WDzkqtn/A/WtYfzCNuYjQH8ErRO Js5d8sOMDg2D83pTaPEjx8JofXFF0oL2spzcONO9LapBtnHChTjf4jjvpT0CzlQ9Fzbf p9npbi6Vn09P5hf+99Pu5wnr+AGNDZWUaAq9bxpzs7aCJ1Qd5DlC++MA3QVG9p4aZC5d f4jw== X-Gm-Message-State: AA+aEWbQSBc0Jbpc0EwbYKguerncEMPRNNkNRa5hveU130n8oF2qQlja IYNOJBXBvpSS7SYHJaCSNzHU7S+XUbh8Gg== X-Received: by 2002:a17:906:a984:: with SMTP id jr4-v6mr38880526ejb.90.1546625101570; Fri, 04 Jan 2019 10:05:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Jan 2019 10:05:00 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Fri, 4 Jan 2019 19:04:31 +0100 Message-Id: <20190104180432.24480-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Subject: [edk2] [PATCH 1/2] ArmPkg/ArmMmuLib ARM: add missing support for non-shareable cached mappings 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" We introduced support for non-shareable cached mappings to the AArch64 version of ArmMmuLib a while ago, but the ARM version was left behind, so fix it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 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 889b22867dc7..b237321a8d8b 100644 --- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibCore.c @@ -135,6 +135,11 @@ PopulateLevel2PageTable ( case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK: PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK; break; + case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE: + case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE: + PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_BACK; + PageAttributes &= ~TT_DESCRIPTOR_PAGE_S_SHARED; + break; case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH: case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH: PageAttributes = TT_DESCRIPTOR_PAGE_WRITE_THROUGH; @@ -239,6 +244,10 @@ FillTranslationTable ( case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK: Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0); break; + case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE: + Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(0); + Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED; + break; case ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH: Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH(0); break; @@ -251,6 +260,10 @@ FillTranslationTable ( case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK: Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(1); break; + case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE: + Attributes = TT_DESCRIPTOR_SECTION_WRITE_BACK(1); + Attributes &= ~TT_DESCRIPTOR_SECTION_S_SHARED; + break; case ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH: Attributes = TT_DESCRIPTOR_SECTION_WRITE_THROUGH(1); break; 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