linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: lauraa@codeaurora.org (Laura Abbott)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC][PATCH] arm64: efi: Obey EFI memory type in dmi_remap
Date: Fri, 16 Jan 2015 18:24:39 -0800	[thread overview]
Message-ID: <1421461479-31608-1-git-send-email-lauraa@codeaurora.org> (raw)

Currently, dmi_remap unconditionally calls ioremap_cache for dmi_remap.
The memory that's being remapped may be part of the existing EFI
memory map and already remapped as uncached. Remapping as cached can
created unexpected behavior so check the physical address against the
EFI memory type before remapping.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
---
Actual bug, not just theoretical problem. I'm marking this as RFC
because I'm not sure what any kind of specificaiton may have to say.
---
 arch/arm64/include/asm/dmi.h |  5 +++--
 arch/arm64/kernel/efi.c      | 23 +++++++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/dmi.h b/arch/arm64/include/asm/dmi.h
index 69d37d8..f0cc8d0 100644
--- a/arch/arm64/include/asm/dmi.h
+++ b/arch/arm64/include/asm/dmi.h
@@ -22,9 +22,10 @@
  * request a virtual mapping for configuration tables such as SMBIOS.
  * This means we have to map them before use.
  */
-#define dmi_early_remap(x, l)		ioremap_cache(x, l)
+#define dmi_early_remap(x, l)		dmi_remap(x, l)
 #define dmi_early_unmap(x, l)		iounmap(x)
-#define dmi_remap(x, l)			ioremap_cache(x, l)
+
+extern void __iomem *dmi_remap(phys_addr_t phys_addr, size_t size);
 #define dmi_unmap(x)			iounmap(x)
 #define dmi_alloc(l)			kzalloc(l, GFP_KERNEL)
 
diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index 82f27c3..139666e 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -22,6 +22,7 @@
 #include <linux/slab.h>
 
 #include <asm/cacheflush.h>
+#include <asm/io.h>
 #include <asm/efi.h>
 #include <asm/tlbflush.h>
 #include <asm/mmu_context.h>
@@ -321,6 +322,28 @@ void __init efi_init(void)
 	reserve_regions();
 }
 
+static bool is_phys_addr_normal_ram(unsigned long phys_addr)
+{
+	efi_memory_desc_t *md;
+
+	for_each_efi_memory_desc(&memmap, md) {
+		if ((md->phys_addr <= phys_addr) &&
+		    (phys_addr < (md->phys_addr +
+				  (md->num_pages << EFI_PAGE_SHIFT))))
+			return is_normal_ram(md);
+	}
+	return false;
+}
+
+void __iomem *dmi_remap(phys_addr_t phys_addr, size_t size)
+{
+	if (is_phys_addr_normal_ram(phys_addr))
+		return ioremap_cache(phys_addr, size);
+	else
+		return ioremap(phys_addr, size);
+}
+
+
 void __init efi_idmap_init(void)
 {
 	if (!efi_enabled(EFI_BOOT))
-- 
Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

             reply	other threads:[~2015-01-17  2:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-17  2:24 Laura Abbott [this message]
2015-01-17  8:24 ` [RFC][PATCH] arm64: efi: Obey EFI memory type in dmi_remap Ard Biesheuvel
2015-01-17 11:56   ` Leif Lindholm
2015-01-17 12:43     ` Ard Biesheuvel
2015-01-17 14:36       ` Leif Lindholm
2015-01-19  9:49         ` Ard Biesheuvel
2015-01-19 12:22           ` Leif Lindholm
2015-01-19 23:02   ` Laura Abbott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421461479-31608-1-git-send-email-lauraa@codeaurora.org \
    --to=lauraa@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).