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: 23117 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B02DC216DB for ; Fri, 10 Jan 2014 22:29:36 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wm4sf18044297obc.11 for ; Fri, 10 Jan 2014 14:29:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=D9zfmMs9K+PosA1Poi6GQUBNXeRVydA+JafI/dv5DRA=; b=Lq8ZlaoZZuItgoGaoWE1sqTogi+FWT2wwU/i8MpuDvA4ykLMBxOusF0RqmO/vu0a2t qbfH32QIakKtpKjrL5b4tot9SMe9YgmK5QOyvU4idQfNGjT8nxQtTxKVFdsoIdpWS/Kv ++GTCGT1MI+6vHsK57dVEolQadi13OMmzbT5XSyT5++u9l3Y/SxN2GwGwOMwst5PTLI0 tk95RmezS4nRNH6FN0qQ4Eqz5I8DVOLFCMhnUc4NHzsHe0G4r2UKk1JFr8VoopC4wR5f NURQhIuJghYmZqROBkiuUq3D62WdXiHvnDYHhlTLcCP+e+94DpU5Y132hm/Qb8B64teh ksbQ== X-Gm-Message-State: ALoCoQlB8AMHByFDq/CKEu+znBsTb5IhEN8N68OuLB0VdSYirsJkoZomfv9KYEgSrbE/XTsjoAkE X-Received: by 10.43.135.4 with SMTP id ie4mr3983438icc.1.1389392975803; Fri, 10 Jan 2014 14:29:35 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.129.98 with SMTP id nv2ls287802qeb.31.gmail; Fri, 10 Jan 2014 14:29:35 -0800 (PST) X-Received: by 10.52.158.170 with SMTP id wv10mr125041vdb.77.1389392975707; Fri, 10 Jan 2014 14:29:35 -0800 (PST) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id au4si3452937ved.112.2014.01.10.14.29.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Jan 2014 14:29:35 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id p14so3619040vbm.0 for ; Fri, 10 Jan 2014 14:29:35 -0800 (PST) X-Received: by 10.58.145.3 with SMTP id sq3mr121438veb.54.1389392975604; Fri, 10 Jan 2014 14:29:35 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp121817ved; Fri, 10 Jan 2014 14:29:35 -0800 (PST) X-Received: by 10.224.163.9 with SMTP id y9mr12353852qax.31.1389392975132; Fri, 10 Jan 2014 14:29:35 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTP id hm5si6296475qeb.115.2014.01.10.14.29.34 for ; Fri, 10 Jan 2014 14:29:35 -0800 (PST) Received-SPF: pass (google.com: domain of msalter@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; 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 Cc: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, Catalin Marinas , Will Deacon , matt.fleming@intel.com, Leif Lindholm , roy.franz@linaro.org, patches@linaro.org, Grant Likely , Mark Salter 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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;