From patchwork Tue Jun 25 18:11:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leif Lindholm X-Patchwork-Id: 2778391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8FD66C0AB1 for ; Tue, 25 Jun 2013 18:09:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F4AB20386 for ; Tue, 25 Jun 2013 18:09:05 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 166A120384 for ; Tue, 25 Jun 2013 18:09:00 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrXeH-0004Gx-Sh; Tue, 25 Jun 2013 18:07:26 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrXe1-0007p4-FS; Tue, 25 Jun 2013 18:07:09 +0000 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrXda-0007kV-R1 for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2013 18:06:45 +0000 Received: by mail-wg0-f54.google.com with SMTP id n11so9548403wgh.33 for ; Tue, 25 Jun 2013 11:06:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=P3l1Ll9dbTsL39PwgRTbydJ8l3nw+B3ysJAGN9llVug=; b=TCGIh5etVaN/AqSRCwkUXsMjJw+3iXBryVDj+Usat2bD8hqys86Fkmq6DkK7wsIBZH bwGaKzPcGpcNuxlr6YND2JEg3XebxJiX2TOShp6b1y3G4X0VQR04tgMf0/H9bMXuIzVF 2/c9gUOu8TN2/a6fE2yGVWVCgkbT2qrmtovYoSVF8x3XyoOTzqnlOequZ7AEMIvW8dGB gNFNTEv1hFc9vDHuWb5bouIpDjvNrf9M69jIsu0xWYGE/rXM3LPg+ORD5+KUo4/zZ7CO 48wRsRFMEjrxFBWdXM21rCxVOiOfy8PVDpnGGcoBbUR/GuaCJ51s9fPD9A2d/xuIi98v F27w== X-Received: by 10.180.189.208 with SMTP id gk16mr10096869wic.9.1372183581076; Tue, 25 Jun 2013 11:06:21 -0700 (PDT) Received: from mohikan.mushroom.smurfnet.nu (cpc4-cmbg17-2-0-cust71.5-4.cable.virginmedia.com. [86.14.224.72]) by mx.google.com with ESMTPSA id j20sm4989952wie.7.2013.06.25.11.06.19 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Jun 2013 11:06:20 -0700 (PDT) From: Leif Lindholm To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] x86: efi: break efi_lookup_mapped_addr out to generic code Date: Tue, 25 Jun 2013 19:11:01 +0100 Message-Id: <1372183863-11333-3-git-send-email-leif.lindholm@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1372183863-11333-1-git-send-email-leif.lindholm@linaro.org> References: <1372183863-11333-1-git-send-email-leif.lindholm@linaro.org> X-Gm-Message-State: ALoCoQneC4B4DnQUBSvkl+EUISvwdIlE831+3zGIrV1jn7jrZATWnpNQL1m9dHf1ntaWdlz+1H9x X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130625_140643_069029_61860C00 X-CRM114-Status: GOOD ( 13.62 ) X-Spam-Score: -1.9 (-) Cc: linux-efi@vger.kernel.org, patches@linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Leif Lindholm , matt.fleming@intel.com, tglx@linutronix.de, hpa@linux.intel.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP efi_lookup_mapped_addr is a handy helper function for translating a physical address to the corresponding virtual one by scanning through memmap.map. This patch breaks it out into a new file for use elsewhere. Signed-off-by: Leif Lindholm Reviewed-by: Grant Likely --- arch/x86/platform/efi/efi.c | 28 ---------------------------- drivers/firmware/efi/Makefile | 2 +- drivers/firmware/efi/efi-helper.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 drivers/firmware/efi/efi-helper.c diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 5ae2eb0..d1a1b6b 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -814,34 +814,6 @@ static void __init runtime_code_page_mkexec(void) } } -/* - * We can't ioremap data in EFI boot services RAM, because we've already mapped - * it as RAM. So, look it up in the existing EFI memory map instead. Only - * callable after efi_enter_virtual_mode and before efi_free_boot_services. - */ -void __iomem *efi_lookup_mapped_addr(u64 phys_addr) -{ - void *p; - if (WARN_ON(!memmap.map)) - return NULL; - for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { - efi_memory_desc_t *md = p; - u64 size = md->num_pages << EFI_PAGE_SHIFT; - u64 end = md->phys_addr + size; - if (!(md->attribute & EFI_MEMORY_RUNTIME) && - md->type != EFI_BOOT_SERVICES_CODE && - md->type != EFI_BOOT_SERVICES_DATA) - continue; - if (!md->virt_addr) - continue; - if (phys_addr >= md->phys_addr && phys_addr < end) { - phys_addr += md->virt_addr - md->phys_addr; - return (__force void __iomem *)(unsigned long)phys_addr; - } - } - return NULL; -} - void efi_memory_uc(u64 addr, unsigned long size) { unsigned long page_shift = 1UL << EFI_PAGE_SHIFT; diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index 99245ab..629a513 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -1,6 +1,6 @@ # # Makefile for linux kernel # -obj-y += efi.o vars.o +obj-y += efi.o vars.o efi-helper.o obj-$(CONFIG_EFI_VARS) += efivars.o obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o diff --git a/drivers/firmware/efi/efi-helper.c b/drivers/firmware/efi/efi-helper.c new file mode 100644 index 0000000..c5c2c72 --- /dev/null +++ b/drivers/firmware/efi/efi-helper.c @@ -0,0 +1,33 @@ +/* + * Common [U]EFI support helper functions across architectures. + */ + +#include + +/* + * We can't ioremap data in EFI boot services RAM, because we've already mapped + * it as RAM. So, look it up in the existing EFI memory map instead. Only + * callable after efi_enter_virtual_mode and before efi_free_boot_services. + */ +void __iomem *efi_lookup_mapped_addr(u64 phys_addr) +{ + void *p; + if (WARN_ON(!memmap.map)) + return NULL; + for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { + efi_memory_desc_t *md = p; + u64 size = md->num_pages << EFI_PAGE_SHIFT; + u64 end = md->phys_addr + size; + if (!(md->attribute & EFI_MEMORY_RUNTIME) && + md->type != EFI_BOOT_SERVICES_CODE && + md->type != EFI_BOOT_SERVICES_DATA) + continue; + if (!md->virt_addr) + continue; + if (phys_addr >= md->phys_addr && phys_addr < end) { + phys_addr += md->virt_addr - md->phys_addr; + return (__force void __iomem *)(unsigned long)phys_addr; + } + } + return NULL; +}