From patchwork Mon Nov 16 18:32:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 56677 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1482658lbb; Mon, 16 Nov 2015 10:37:18 -0800 (PST) X-Received: by 10.68.57.171 with SMTP id j11mr57255866pbq.17.1447699037697; Mon, 16 Nov 2015 10:37:17 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id py15si22742688pab.12.2015.11.16.10.37.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 10:37:17 -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 1ZyOcz-0002NJ-RN; Mon, 16 Nov 2015 18:35:45 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyOai-0007Vv-GJ for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2015 18:33:29 +0000 Received: by wmec201 with SMTP id c201so191330383wme.0 for ; Mon, 16 Nov 2015 10:33:04 -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=b6gO2rWfuIU3Cf8zbMR3sUSo+YQjAc22T0o3cF8WRYA=; b=fdjFBmZf6LXKPbuZU6YZ6ErFFCayJtkHwTk9kq2HIipHPu/PcmzirhgW9KjJ6gs79z o6lUstKWTDC43fpTwQzMBtSnxOQjjd8WPjpcuiaLmnnjV5OAgEMD1sa1MI+V09Qy95gq 8Gmc3PObUb60wdG3SgmxbYcOmqBt1RaJsllOXbd06Jb8gDW8odjTcSJ+wFJdZ1JpVke7 vkKTJoTjwShZOPCOBuSidFYiVoIhxjkfURLtXdV9o3QQP5RwXx+T34pixRpZnqXvcbQP UJt4YazYwZxtWOtEw3bVwP0Ho7PLxKGwXeWtEA2T+mxitTa0VjjCd16iJAgwdi/N6Wkv exUg== 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=b6gO2rWfuIU3Cf8zbMR3sUSo+YQjAc22T0o3cF8WRYA=; b=cdEA2zRGrIPmkIkRFSOLsJOb/meYuwxlIi4TWvak59f3btNRdHDUsB5H+CGF932KHw 2kc9a4seLytFkUYSYl7897rzdxuO1gJOx+dbGtIkeeKtN+AKaHdw4stGU8KulCQ0W0HE RAyApkF2XOV79Waf26b2iXnOx7eUbfbtcOBSRQuiloNIv5dLAqzpYBrm8cAV+ONpxg10 +CdBt0Wo3neQU8X12zdleLEQwdKUkYo7qFScigURMCg+OV8tz9ZfbVXKWDJ/qBaYqosy 8vmlWSKlo95IhQXaB6Nmn6mWvzbV/bcdic+6Mexm8S1dWbWfzE2p/5gBwND4/ciZgM6U +D2A== X-Gm-Message-State: ALoCoQlDWR5Om9xfJ/nzFrtP+7ebrek7t74xTyuZiLo/THVLX9nvmOFHvbtxXmTVpL2NajR5T189 X-Received: by 10.28.131.84 with SMTP id f81mr19525349wmd.57.1447698784648; Mon, 16 Nov 2015 10:33:04 -0800 (PST) Received: from ards-macbook-pro.lan (2-237-3-18.ip236.fastwebnet.it. [2.237.3.18]) by smtp.gmail.com with ESMTPSA id he3sm35796779wjc.48.2015.11.16.10.33.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 10:33:04 -0800 (PST) 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, catalin.marinas@arm.com, mark.rutland@arm.com, leif.lindholm@linaro.org, roy.franz@linaro.org Subject: [PATCH v2 08/12] ARM: factor out allocation routine from __create_mapping() Date: Mon, 16 Nov 2015 19:32:33 +0100 Message-Id: <1447698757-8762-9-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447698757-8762-1-git-send-email-ard.biesheuvel@linaro.org> References: <1447698757-8762-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151116_103324_859364_022F8492 X-CRM114-Status: GOOD ( 13.46 ) 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:234 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: linux-mm@kvack.org, ryan.harkin@linaro.org, Ard Biesheuvel , akpm@linux-foundation.org, msalter@redhat.com 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. 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); } /*