From patchwork Mon Nov 30 12:28:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 57439 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1437765lbb; Mon, 30 Nov 2015 04:34:12 -0800 (PST) X-Received: by 10.98.64.80 with SMTP id n77mr70579037pfa.96.1448886852151; Mon, 30 Nov 2015 04:34:12 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id cm4si10000076pad.81.2015.11.30.04.34.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Nov 2015 04:34:12 -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 1a3NdD-0007sj-Mw; Mon, 30 Nov 2015 12:32:35 +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-0004Oo-Vs for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2015 12:30:05 +0000 Received: by wmww144 with SMTP id w144so135374912wmw.0 for ; Mon, 30 Nov 2015 04:29:29 -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=PiTFhqAYGNWufhBRY5GX8md1+JUennAKHxCyFfBqW84=; b=tTq1criiU6jU9RUKDPcC7yDUwPf1x3NSJ8nHV7zT+c4xwV6RYo4z6ypHW4jM39VtMa SCrFsdiHMJS+KFqmVVDc24qPVRRYRGgCZAgdwQWVkBeUIJHGcPfK0r6Oc2graY19lz8q Ua3IyynChCn0aLavCJjVTj5IeXAWPaZ+ly5aWOH1sZWSuAwgSytkn4l1JBzgXX6RhXtQ hv6qXCW5E1ZEc/pw0dSZznNF3lWQsuAppYj1vkyqz8QgYjX86+pFDf5sB7pnTTqurdM0 Gs7z/qQ32GboP0YxX0lOISFumoNvt/2rLdLf936HW9yLl1ahbkKCyWrgE2TBW5bXxhXZ lmtA== 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=PiTFhqAYGNWufhBRY5GX8md1+JUennAKHxCyFfBqW84=; b=BT+Z9x516Lr7/tjuan82JPQRz0nOnhZyiHxZFiSbOS55+Z8gjxbn4QgEksoxNPcaoB 69EjoEW+eZqu3cD5OovdiDh5HcPTNVxGqmJFhHNuymbN76evuzOKjyN1qc02JPTjgC+z UYAeIfbZH4xdlT2kncBrfxuSJkwN3MJdtQCPUz7AeVzEX94MIzvUYsSNpyb94Db29wMU yP70OyRo6sXtyh72nqwrBxK4MSEo7OsgLeaeZb/DSDZOQ0u7NIGcH4HydQ/CiCPJWjlt pzaPR80r0kPLPi/NBmB61gj8Nf0Pkyjb9XsIVHsOrgbkmjYFSlyVD1BtxtTAF8QAtAYi tmmA== X-Gm-Message-State: ALoCoQmm1EDV3VNIduTxEGqZTwZ+W322I4UUsrTl2lHRvvxXfON3fdf6ubToyGvtgNtkiLGC6zJu X-Received: by 10.194.189.68 with SMTP id gg4mr82739851wjc.146.1448886569312; Mon, 30 Nov 2015 04:29:29 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 04:29:28 -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 08/13] ARM: factor out allocation routine from __create_mapping() Date: Mon, 30 Nov 2015 13:28:22 +0100 Message-Id: <1448886507-3216-9-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_729155_E887B280 X-CRM114-Status: GOOD ( 13.35 ) 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 To allow __create_mapping() to be used for populating UEFI Runtime Services page tables, factor out the allocation routine 'early_alloc' and pass it down as a function pointer into alloc_init_[pud|pmd|pte]. This way, new users of __create_mapping() can supply another allocation function. Tested-by: Ryan Harkin Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/arm/mm/mmu.c | 34 +++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-) -- 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/mm/mmu.c b/arch/arm/mm/mmu.c index 3100de92148b..87dc49dbe231 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -724,21 +724,30 @@ static void __init *early_alloc(unsigned long sz) return early_alloc_aligned(sz, sz); } -static pte_t * __init early_pte_alloc(pmd_t *pmd, unsigned long addr, unsigned long prot) +static pte_t * __init pte_alloc(pmd_t *pmd, unsigned long addr, + unsigned long prot, + void *(*alloc)(unsigned long sz)) { if (pmd_none(*pmd)) { - pte_t *pte = early_alloc(PTE_HWTABLE_OFF + PTE_HWTABLE_SIZE); + pte_t *pte = alloc(PTE_HWTABLE_OFF + PTE_HWTABLE_SIZE); __pmd_populate(pmd, __pa(pte), prot); } BUG_ON(pmd_bad(*pmd)); return pte_offset_kernel(pmd, addr); } +static pte_t * __init early_pte_alloc(pmd_t *pmd, unsigned long addr, + unsigned long prot) +{ + return pte_alloc(pmd, addr, prot, early_alloc); +} + static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, unsigned long end, unsigned long pfn, - const struct mem_type *type) + const struct mem_type *type, + void *(*alloc)(unsigned long sz)) { - pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1); + pte_t *pte = pte_alloc(pmd, addr, type->prot_l1, alloc); do { set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0); pfn++; @@ -774,7 +783,8 @@ static void __init __map_init_section(pmd_t *pmd, unsigned long addr, static void __init alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, phys_addr_t phys, - const struct mem_type *type) + const struct mem_type *type, + void *(*alloc)(unsigned long sz)) { pmd_t *pmd = pmd_offset(pud, addr); unsigned long next; @@ -795,7 +805,7 @@ static void __init alloc_init_pmd(pud_t *pud, unsigned long addr, __map_init_section(pmd, addr, next, phys, type); } else { alloc_init_pte(pmd, addr, next, - __phys_to_pfn(phys), type); + __phys_to_pfn(phys), type, alloc); } phys += next - addr; @@ -805,14 +815,15 @@ static void __init alloc_init_pmd(pud_t *pud, unsigned long addr, static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end, phys_addr_t phys, - const struct mem_type *type) + const struct mem_type *type, + void *(*alloc)(unsigned long sz)) { pud_t *pud = pud_offset(pgd, addr); unsigned long next; do { next = pud_addr_end(addr, end); - alloc_init_pmd(pud, addr, next, phys, type); + alloc_init_pmd(pud, addr, next, phys, type, alloc); phys += next - addr; } while (pud++, addr = next, addr != end); } @@ -877,7 +888,8 @@ static void __init create_36bit_mapping(struct mm_struct *mm, } #endif /* !CONFIG_ARM_LPAE */ -static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md) +static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md, + void *(*alloc)(unsigned long sz)) { unsigned long addr, length, end; phys_addr_t phys; @@ -911,7 +923,7 @@ static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md) do { unsigned long next = pgd_addr_end(addr, end); - alloc_init_pud(pgd, addr, next, phys, type); + alloc_init_pud(pgd, addr, next, phys, type, alloc); phys += next - addr; addr = next; @@ -940,7 +952,7 @@ static void __init create_mapping(struct map_desc *md) (long long)__pfn_to_phys((u64)md->pfn), md->virtual); } - __create_mapping(&init_mm, md); + __create_mapping(&init_mm, md, early_alloc); } /*