From patchwork Fri Jan 10 22:29:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 3468361 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7BEDC9F374 for ; Fri, 10 Jan 2014 22:31:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7256A2015D for ; Fri, 10 Jan 2014 22:31:36 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 A546E2015A for ; Fri, 10 Jan 2014 22:31:34 +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 1W1kb7-0005km-Kh; Fri, 10 Jan 2014 22:30:37 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W1kat-0005F4-EC; Fri, 10 Jan 2014 22:30:23 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W1kaR-0005AZ-3M for linux-arm-kernel@lists.infradead.org; Fri, 10 Jan 2014 22:29:58 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0AMTUkx028900 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 10 Jan 2014 17:29:30 -0500 Received: from deneb.redhat.com (ovpn-113-39.phx2.redhat.com [10.3.113.39]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0AMTQfe004120; Fri, 10 Jan 2014 17:29:29 -0500 From: Mark Salter To: linux-kernel@vger.kernel.org Subject: [PATCH 2/6] arm64: Add function to create identity mappings Date: Fri, 10 Jan 2014 17:29:06 -0500 Message-Id: <1389392950-22457-3-git-send-email-msalter@redhat.com> In-Reply-To: <1389392950-22457-1-git-send-email-msalter@redhat.com> References: <1389392950-22457-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140110_172955_420162_DAB781FE X-CRM114-Status: GOOD ( 16.88 ) X-Spam-Score: -7.0 (-------) Cc: Grant Likely , matt.fleming@intel.com, patches@linaro.org, Catalin Marinas , Will Deacon , Leif Lindholm , roy.franz@linaro.org, linux-efi@vger.kernel.org, Mark Salter , linux-arm-kernel@lists.infradead.org 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=-4.3 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 At boot time, UEFI runtime support needs to call into the UEFI firmware to switch to a virtual address map. This call must be made with UEFI memory regions identity mapped. The exisitng early boot code creates an identity map of kernel text/data but this is not sufficient for UEFI. This patch adds a create_id_mapping() function which reuses the core code of create_mapping() used to create the kernel RAM mappings. Signed-off-by: Mark Salter CC: Catalin Marinas CC: Will Deacon CC: linux-arm-kernel@lists.infradead.org --- arch/arm64/include/asm/mmu.h | 1 + arch/arm64/mm/mmu.c | 34 ++++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/mmu.h b/arch/arm64/include/asm/mmu.h index f600d40..9ad4dd4 100644 --- a/arch/arm64/include/asm/mmu.h +++ b/arch/arm64/include/asm/mmu.h @@ -28,5 +28,6 @@ extern void paging_init(void); extern void setup_mm_for_reboot(void); extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt); extern void init_mem_pgprot(void); +extern void create_id_mapping(phys_addr_t addr, phys_addr_t size); #endif diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 7b345e3..ccfca44 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -228,22 +228,14 @@ static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr, * Create the page directory entries and any necessary page tables for the * mapping specified by 'md'. */ -static void __init create_mapping(phys_addr_t phys, unsigned long virt, - phys_addr_t size) +static void __init __create_mapping(pgd_t *pgd, phys_addr_t phys, + unsigned long virt, phys_addr_t size) { unsigned long addr, length, end, next; - pgd_t *pgd; - - if (virt < VMALLOC_START) { - pr_warning("BUG: not creating mapping for 0x%016llx at 0x%016lx - outside kernel range\n", - phys, virt); - return; - } addr = virt & PAGE_MASK; length = PAGE_ALIGN(size + (virt & ~PAGE_MASK)); - pgd = pgd_offset_k(addr); end = addr + length; do { next = pgd_addr_end(addr, end); @@ -252,6 +244,28 @@ static void __init create_mapping(phys_addr_t phys, unsigned long virt, } while (pgd++, addr = next, addr != end); } +static void __init create_mapping(phys_addr_t phys, unsigned long virt, + phys_addr_t size) +{ + if (virt < VMALLOC_START) { + pr_warn("BUG: not creating mapping for 0x%016llx at 0x%016lx - outside kernel range\n", + phys, virt); + return; + } + __create_mapping(pgd_offset_k(virt & PAGE_MASK), phys, virt, size); +} + +void __init create_id_mapping(phys_addr_t addr, phys_addr_t size) +{ + pgd_t *pgd = &idmap_pg_dir[pgd_index(addr)]; + + if (pgd >= &idmap_pg_dir[ARRAY_SIZE(idmap_pg_dir)]) { + pr_warn("BUG: not creating id mapping for 0x%016llx\n", addr); + return; + } + __create_mapping(pgd, addr, addr, size); +} + static void __init map_mem(void) { struct memblock_region *reg;