From patchwork Mon Nov 30 12:28:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 57447 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1440182lbb; Mon, 30 Nov 2015 04:38:18 -0800 (PST) X-Received: by 10.98.13.211 with SMTP id 80mr70180964pfn.112.1448887098700; Mon, 30 Nov 2015 04:38:18 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id sp7si13928681pac.230.2015.11.30.04.38.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Nov 2015 04:38:18 -0800 (PST) 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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com 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 1a3Nh3-00040y-Dp; Mon, 30 Nov 2015 12:36:33 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a3NaY-0004SW-Vq for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2015 12:29:58 +0000 Received: by wmvv187 with SMTP id v187so154095215wmv.1 for ; Mon, 30 Nov 2015 04:29:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=m0rKreAJWKqCbhbVPFmu9bnrOL9cpAIG2tstD/HafYg=; b=zlA42yLnCGsnNn+MvW1QruVfU4/qBMnByRGR3YfNC2hSUjO9wxeZXXGz/vzV2UPRuB O82xsVYyYuuB2BhUv4PNntW3sD+0F0YdO9+SojbFxuHi6CqXiqkGMWTbfMvxuEyguuH1 8VVbtFxHl6ey8/B2TlNnY6DROsWItnHoE0/2jwdUIzZ85lztFKGMsZGfJ/SDN9px+Ke7 1QMOOD7260WT4/aqeKiN9SjAgaj33Uto1kly/Pkd7eH4Y6i7Voegc8iLA3axEKneOdUT oAv0yOMIus89ml6GwURxqnHbp4Q29k5lxqh6A4QK7CTseGXFBp5b3jNUQhRegQKAWYF/ fcuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=m0rKreAJWKqCbhbVPFmu9bnrOL9cpAIG2tstD/HafYg=; b=HYhXYfUYtD2d9kr/k2t6SX1mwMJn/XFfQ2UVJ8zmwEkaf5M6kH04Z1AbfjMqwT5gbO Xh9rtpefoCP/LGSqrrssT0OLVxOExy5Pe/URW61dPKplfnjvgAqMafb6/21XJyThZCok 7AIMz7Hbr03d1slZT1B6zK9746Xnal+DtWmYncQkQtm1h0bgfxj7y7i16KSB5V0t7L8J +HSeh846ull8VjYnQ5l1lI5BXV2bbpHUU1q2/2NOKbF24e2zmTnIi2+jf8nsim2Wl+SR cWrSR7I7eKJB9rr2v7VyiBZSDcEDXozIC9d6LfUf9BIIgF8Hoea7aGNfERozpXlHhFS1 WmzQ== X-Gm-Message-State: ALoCoQndVGNxnPPhLienP+6JJRpPOn+CGVjdZKl/ocvMU2SXLubM9MQxNG2LJ3Mzh2aM+fDOU6XN X-Received: by 10.194.62.74 with SMTP id w10mr47635596wjr.174.1448886573707; Mon, 30 Nov 2015 04:29:33 -0800 (PST) Received: from localhost.localdomain (host2-115-static.225-95-b.business.telecomitalia.it. [95.225.115.2]) by smtp.gmail.com with ESMTPSA id d2sm46560361wjy.16.2015.11.30.04.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 04:29:33 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will.deacon@arm.com, mark.rutland@arm.com, linux-efi@vger.kernel.org, leif.lindholm@linaro.org, matt@codeblueprint.co.uk, linux@arm.linux.org.uk Subject: [PATCH v4 10/13] ARM: implement create_mapping_late() for EFI use Date: Mon, 30 Nov 2015 13:28:24 +0100 Message-Id: <1448886507-3216-11-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448886507-3216-1-git-send-email-ard.biesheuvel@linaro.org> References: <1448886507-3216-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151130_042951_738055_77B77329 X-CRM114-Status: GOOD ( 11.87 ) 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 [2a00:1450:400c:c09:0:0:0:231 listed in] [list.dnswl.org] -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.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: kuleshovmail@gmail.com, Ard Biesheuvel , roy.franz@linaro.org, linux-mm@kvack.org, ryan.harkin@linaro.org, msalter@redhat.com, grant.likely@linaro.org, akpm@linux-foundation.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org This implements create_mapping_late(), which we will use to populate the UEFI Runtime Services page tables. Tested-by: Ryan Harkin Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/mach/map.h | 2 ++ arch/arm/mm/mmu.c | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h index f98c7f32c9c8..9b7c328fb207 100644 --- a/arch/arm/include/asm/mach/map.h +++ b/arch/arm/include/asm/mach/map.h @@ -42,6 +42,8 @@ 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, + bool ng); #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 2d9f628a7fe8..8c69830e791a 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -724,6 +724,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)) @@ -960,6 +968,18 @@ static void __init create_mapping(struct map_desc *md) __create_mapping(&init_mm, md, early_alloc, false); } +void __init create_mapping_late(struct mm_struct *mm, struct map_desc *md, + bool ng) +{ +#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, ng); +} + /* * Create the architecture specific mappings */