From patchwork Sat Jan 17 02:24:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 5651441 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E8BB29F357 for ; Sat, 17 Jan 2015 02:29:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19914203F4 for ; Sat, 17 Jan 2015 02:29:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 59620203EB for ; Sat, 17 Jan 2015 02:29:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YCJ4X-0004qO-Bx; Sat, 17 Jan 2015 02:25:09 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YCJ4U-0003kW-PC for linux-arm-kernel@lists.infradead.org; Sat, 17 Jan 2015 02:25:07 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id C93D0140FC6; Sat, 17 Jan 2015 02:24:45 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id B951E140FFF; Sat, 17 Jan 2015 02:24:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from linux-kernel-memory-lab-01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: lauraa@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id E97CE140FC6; Sat, 17 Jan 2015 02:24:44 +0000 (UTC) From: Laura Abbott To: Yi Li , Leif Lindholm , Ard Biesheuvel Subject: [RFC][PATCH] arm64: efi: Obey EFI memory type in dmi_remap Date: Fri, 16 Jan 2015 18:24:39 -0800 Message-Id: <1421461479-31608-1-git-send-email-lauraa@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150116_182506_859498_BE83C4CF X-CRM114-Status: GOOD ( 13.97 ) X-Spam-Score: -0.0 (/) Cc: Will Deacon , Ashwin Chaugle , Laura Abbott , linux-arm-kernel@lists.infradead.org, Catalin Marinas X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 #include +#include #include #include #include @@ -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))