From patchwork Thu Oct 1 17:04:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 54385 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 6A98E23010 for ; Thu, 1 Oct 2015 17:07:30 +0000 (UTC) Received: by laer8 with SMTP id r8sf39224907lae.2 for ; Thu, 01 Oct 2015 10:07:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:cc:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=vwarN42nwUKa7D8nkfzYWQF1/Mv1IPNHSniIDYkhdc4=; b=OJ599YgVLXqWGNyBQdP8aVc060E+0qd1dJPNvLX6s0SYYmJv0aonOzzLraIgVLkQvD o/SawSdp7JvxKDDa75TnDZZrNOGCAHZVT9nZo3y7EIOg3D6IpHHWM9V36TbNvfQuOWMO +DuMQ5P6LKCnZMOG0bS5Kvrniv4zJnB9CTiK/A+0suxCFa10zFWir2l9MAdRH3B3PlkP 4psdayYWg5eVwVh0koEH6aA3i6ijTVhQy8V95qgFJSQ/h0Htk5ya+0z4v1trbHR/0pUO XdnFiy0wP2ej4fjtegQvMAqWCibFtjKGRoPvMENFoPZ6cgsIca2egUYTABaSd2MhiI2z genQ== X-Gm-Message-State: ALoCoQmHoaWj7jtlbIkL9UEnEZN/xygzeO5no8HUv7t25kWp7C9/M3z7mJeoFC5GtnLkA4qBVbF4 X-Received: by 10.194.6.170 with SMTP id c10mr1631945wja.7.1443719249133; Thu, 01 Oct 2015 10:07:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.87.139 with SMTP id l133ls140167lfb.34.gmail; Thu, 01 Oct 2015 10:07:28 -0700 (PDT) X-Received: by 10.112.139.201 with SMTP id ra9mr3416686lbb.29.1443719248892; Thu, 01 Oct 2015 10:07:28 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id wd1si3331841lbb.91.2015.10.01.10.07.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 10:07:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbwr8 with SMTP id r8so13053507lbw.2 for ; Thu, 01 Oct 2015 10:07:28 -0700 (PDT) X-Received: by 10.25.86.213 with SMTP id k204mr2271091lfb.36.1443719248742; Thu, 01 Oct 2015 10:07:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp729964lbq; Thu, 1 Oct 2015 10:07:28 -0700 (PDT) X-Received: by 10.195.11.165 with SMTP id ej5mr2526516wjd.117.1443719248069; Thu, 01 Oct 2015 10:07:28 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id o6si8431360wja.71.2015.10.01.10.07.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 10:07:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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 1ZhhIz-000403-DG; Thu, 01 Oct 2015 17:06:05 +0000 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZhhI1-000212-9p for linux-arm-kernel@lists.infradead.org; Thu, 01 Oct 2015 17:05:06 +0000 Received: by wicgb1 with SMTP id gb1so39125220wic.1 for ; Thu, 01 Oct 2015 10:04:43 -0700 (PDT) X-Received: by 10.180.39.175 with SMTP id q15mr4702588wik.73.1443719083703; Thu, 01 Oct 2015 10:04:43 -0700 (PDT) Received: from localhost.localdomain ([83.225.55.104]) by smtp.gmail.com with ESMTPSA id x9sm7036760wjf.44.2015.10.01.10.04.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Oct 2015 10:04:43 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, matt.fleming@intel.com, linux@arm.linux.org.uk, will.deacon@arm.com, grant.likely@linaro.org, leif.lindholm@linaro.org, roy.franz@linaro.org, mark.rutland@arm.com, catalin.marinas@arm.com Subject: [PATCH 7/9] ARM: implement create_mapping_late() for EFI use Date: Thu, 1 Oct 2015 19:04:21 +0200 Message-Id: <1443719063-6832-8-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1443719063-6832-1-git-send-email-ard.biesheuvel@linaro.org> References: <1443719063-6832-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151001_100505_641679_E1DB5946 X-CRM114-Status: GOOD ( 13.40 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.212.172 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.212.172 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Cc: ryan.harkin@linaro.org, Ard Biesheuvel , msalter@redhat.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 This implements create_mapping_late(), which we will use to populate the UEFI Runtime Services page tables. Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/mach/map.h | 1 + arch/arm/mm/mmu.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h index f98c7f32c9c8..14fe67bd0272 100644 --- a/arch/arm/include/asm/mach/map.h +++ b/arch/arm/include/asm/mach/map.h @@ -42,6 +42,7 @@ enum { extern void iotable_init(struct map_desc *, int); extern void vm_reserve_area_early(unsigned long addr, unsigned long size, void *caller); +extern void create_mapping_late(struct mm_struct *mm, struct map_desc *md); #ifdef CONFIG_DEBUG_LL extern void debug_ll_addr(unsigned long *paddr, unsigned long *vaddr); diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index dd0967ee23b7..c5f0c0ade981 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -723,6 +723,14 @@ static void __init *early_alloc(unsigned long sz) return early_alloc_aligned(sz, sz); } +static void *__init late_alloc(unsigned long sz) +{ + void *ptr = (void *)__get_free_pages(PGALLOC_GFP, get_order(sz)); + + BUG_ON(!ptr); + return ptr; +} + static pte_t * __init pte_alloc(pmd_t *pmd, unsigned long addr, unsigned long prot, void *(*alloc)(unsigned long sz)) @@ -954,6 +962,17 @@ static void __init create_mapping(struct map_desc *md) __create_mapping(&init_mm, md, early_alloc); } +void __init create_mapping_late(struct mm_struct *mm, struct map_desc *md) +{ +#ifdef CONFIG_ARM_LPAE + pud_t *pud = pud_alloc(mm, pgd_offset(mm, md->virtual), md->virtual); + if (WARN_ON(!pud)) + return; + pmd_alloc(mm, pud, 0); +#endif + __create_mapping(mm, md, late_alloc); +} + /* * Create the architecture specific mappings */