From patchwork Wed Aug 24 15:24:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 74624 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp374050qga; Wed, 24 Aug 2016 08:26:08 -0700 (PDT) X-Received: by 10.98.84.65 with SMTP id i62mr6736144pfb.72.1472052368627; Wed, 24 Aug 2016 08:26:08 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id f74si10097382pff.158.2016.08.24.08.26.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2016 08:26:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bca2w-0007zJ-2E; Wed, 24 Aug 2016 15:24:54 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bca2o-0007xW-Ty for linux-arm-kernel@lists.infradead.org; Wed, 24 Aug 2016 15:24:48 +0000 Received: by mail-wm0-x232.google.com with SMTP id o80so33211671wme.1 for ; Wed, 24 Aug 2016 08:24:25 -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; bh=lWo8R7RcJD0GSZ3B97YJWwg5OfBGnSoCWYFCKkQ3tzI=; b=ZnjJ/ConqYIQBIFRTI+FOQTm5IKdqc3dQWJU1Bx7S5dg72O6gTaQurr0CG1rod6J7V TxFvoApAUh0H1gyAupujtQmnfr1AUkirnZtkJsRkz/GdsHIxp3Ln01uaF/BfSe0l6RpV HnZcbXTTXMkie5TKLEMLeB51QYhlyzEgp8ep8= 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; bh=lWo8R7RcJD0GSZ3B97YJWwg5OfBGnSoCWYFCKkQ3tzI=; b=afwA9IoafPXBwO9tFvMPWa2EdOgZF+tIE2/ZzWDFrgDYaP4hPQdcc6vem1om0p/whE EmBREHgCOC40Znzwv3tfVL9jn7XtPXl2JCGgxIDFXNUxTycxXcse8LXVZ64P4PFyfg/M 2e+YyuOwvCF6uAg+dlO+F0yODTvxmPeB4HjCWAElKMeAAjXhJcx8Lsamm/wDgJUsIf7K W1MeG46sLSFCPQRBJwRFtzptzVFsqYqmlctqF2UrPlhKbmHLDB953lDcO+ynyBVOoq7I z9oEL7vQg7fYbpZYgAWJpL4QyyX9W1hyvLzyUWOFkc5qQZ8uk5cPviRfNiL4evi5EkPq qibg== X-Gm-Message-State: AEkoousydBP6i7XuaLz82CDmfTvFGCqZOA/iQMDm8ZHjiqX00X0zEpCW4Cd4Nv7gcls58dpS X-Received: by 10.28.74.221 with SMTP id n90mr24349667wmi.16.1472052263829; Wed, 24 Aug 2016 08:24:23 -0700 (PDT) Received: from localhost.localdomain ([213.143.60.123]) by smtp.gmail.com with ESMTPSA id jq5sm10566997wjc.20.2016.08.24.08.24.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Aug 2016 08:24:23 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, matt@codeblueprint.co.uk, james.morse@arm.com Subject: [PATCH] efi: arm64: treat regions with WT/WC set but WB cleared as memory Date: Wed, 24 Aug 2016 17:24:16 +0200 Message-Id: <1472052256-26365-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160824_082447_446548_7FA5DC4C X-CRM114-Status: GOOD ( 16.85 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-efi@vger.kernel.org, takahiro.akashi@linaro.org, lorenzo.pieralisi@arm.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Currently, memory regions are only recorded in the memblock memory table if they have the EFI_MEMORY_WB memory type attribute set. In case the region is of a reserved type, it is also marked as MEMBLOCK_NOMAP, which will leave it out of the linear mapping. However, memory regions may legally have the EFI_MEMORY_WT or EFI_MEMORY_WC attributes set, and the EFI_MEMORY_WB cleared, in which case the region in question is obviously backed by normal memory, but is not recorded in the memblock memory table at all. Since it would be useful to be able to identify any UEFI reported memory region using memblock_is_memory(), it makes sense to add all memory to the memblock memory table, and simply mark it as MEMBLOCK_NOMAP if it lacks the EFI_MEMORY_WB attribute. Signed-off-by: Ard Biesheuvel --- Note that this will also result in regions with EFI_MEMORY_WB cleared to be listed in /proc/iomem as 'System RAM', which may be incorrect. However, we already display this incorrect behavior for runtime services code/data regions, so this should be fixed in a separate patch, of which an example has been proposed here: https://www.spinics.net/lists/arm-kernel/msg525369.html drivers/firmware/efi/arm-init.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c index c49d50e68aee..678672d332f8 100644 --- a/drivers/firmware/efi/arm-init.c +++ b/drivers/firmware/efi/arm-init.c @@ -28,7 +28,7 @@ u64 efi_system_table; static int __init is_normal_ram(efi_memory_desc_t *md) { - if (md->attribute & EFI_MEMORY_WB) + if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC)) return 1; return 0; } @@ -163,7 +163,13 @@ static __init int is_reserve_region(efi_memory_desc_t *md) case EFI_BOOT_SERVICES_DATA: case EFI_CONVENTIONAL_MEMORY: case EFI_PERSISTENT_MEMORY: - return 0; + /* + * According to the spec, these regions are no longer reserved + * after calling ExitBootServices(). However, we can only use + * them as System RAM if they can be mapped writeback cacheable. + * Otherwise, treat them as reserved. + */ + return (md->type & EFI_MEMORY_WB) == 0; default: break; }