From patchwork Mon Nov 16 18:32:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 56678 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1483154lbb; Mon, 16 Nov 2015 10:38:06 -0800 (PST) X-Received: by 10.66.118.134 with SMTP id km6mr57287767pab.16.1447699086582; Mon, 16 Nov 2015 10:38:06 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id w16si52166335pbs.251.2015.11.16.10.38.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 10:38:06 -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 1ZyOdZ-0002x7-Ca; Mon, 16 Nov 2015 18:36:21 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyOai-0007Ue-22 for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2015 18:33:28 +0000 Received: by wmww144 with SMTP id w144so132051247wmw.0 for ; Mon, 16 Nov 2015 10:33:02 -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=SMdj3c++5v6+idx8qZx1a5YKx1RkuUZVH8RFX2SRJ1A=; b=p2Io+0mJrSfdMfbOIXOamgBQoAG42P274H1+eYvvsXCSaX5XXq7rubnA4BXiSXUJ9V qerTi7uGb/SHCSGkTGbGmwntphQauawjhnZFKKdMX8U5i4cXF317mKs/Z+sSGgktd7ZB hTtB0PJafdWIs5rGWKQGNvMsWvks3Ww20j5YJN2wwf1f5UC8KdhHkUr/AhbDctZY32rD XzwPRQzkVVUXVzp215l3uMYLZ9KFLXZKj2XmblWKubmWNbetGjweqs0291UPA1RoQACs jCqOcXVyhyGCLFUnYHgUp1wApbVqjhL8PcOR0zAGFRwUN0N2tv862kIWjKTdpM3yF2F7 z9Wg== 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=SMdj3c++5v6+idx8qZx1a5YKx1RkuUZVH8RFX2SRJ1A=; b=jdcEwba6KERpaZHnvjUIBxEK5Q5jKtcmp5rJD21jXdh6RlWA6PNot4wLRjFiWZOJ9s YhGJRJ/23Dm6bdnPGH80N2HH7tfznk2CjZqrVlEo/T5TeoZdOViKcUmKqUjTKKiKlyi+ EYxCYuKtkBnDQN1RPaH9KZ46V2CxfTI40TrwFwqt06ZaJv2rqnGhhhpXIH5aMisew0i5 yn7B2Mz8NZIf0pNp+TAj04EG/IgciZlpiiMvq792UjMwze8YkmHOADgSGMKx8zCBUB2U Pi8JXMVqllge+q7qdHisl4bBMhXhP7imYSKNJ+5ildXFh6ZAmWUS1+HtZo5DbWfrFPKr qYOw== X-Gm-Message-State: ALoCoQk5zm/t7ERppo3ucT16O2383+jjxKdfUWia/UPcshSFxyiaSWKDwuJt8ZHLZwa7DpAvp/QM X-Received: by 10.28.14.209 with SMTP id 200mr7476139wmo.103.1447698782417; Mon, 16 Nov 2015 10:33:02 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 10:33:01 -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 07/12] ARM: split off core mapping logic from create_mapping Date: Mon, 16 Nov 2015 19:32:32 +0100 Message-Id: <1447698757-8762-8-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_494034_F33CD8DA X-CRM114-Status: GOOD ( 16.45 ) 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:22a 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 In order to be able to reuse the core mapping logic of create_mapping for mapping the UEFI Runtime Services into a private set of page tables, split it off from create_mapping() into a separate function __create_mapping which we will wire up in a subsequent patch. Signed-off-by: Ard Biesheuvel --- arch/arm/mm/mmu.c | 56 +++++++++++--------- 1 file changed, 31 insertions(+), 25 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 de19f90221e2..3100de92148b 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -818,7 +818,8 @@ static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr, } #ifndef CONFIG_ARM_LPAE -static void __init create_36bit_mapping(struct map_desc *md, +static void __init create_36bit_mapping(struct mm_struct *mm, + struct map_desc *md, const struct mem_type *type) { unsigned long addr, length, end; @@ -859,7 +860,7 @@ static void __init create_36bit_mapping(struct map_desc *md, */ phys |= (((md->pfn >> (32 - PAGE_SHIFT)) & 0xF) << 20); - pgd = pgd_offset_k(addr); + pgd = pgd_offset(mm, addr); end = addr + length; do { pud_t *pud = pud_offset(pgd, addr); @@ -876,33 +877,13 @@ static void __init create_36bit_mapping(struct map_desc *md, } #endif /* !CONFIG_ARM_LPAE */ -/* - * Create the page directory entries and any necessary - * page tables for the mapping specified by `md'. We - * are able to cope here with varying sizes and address - * offsets, and we take full advantage of sections and - * supersections. - */ -static void __init create_mapping(struct map_desc *md) +static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md) { unsigned long addr, length, end; phys_addr_t phys; const struct mem_type *type; pgd_t *pgd; - if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) { - pr_warn("BUG: not creating mapping for 0x%08llx at 0x%08lx in user region\n", - (long long)__pfn_to_phys((u64)md->pfn), md->virtual); - return; - } - - if ((md->type == MT_DEVICE || md->type == MT_ROM) && - md->virtual >= PAGE_OFFSET && md->virtual < FIXADDR_START && - (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) { - pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n", - (long long)__pfn_to_phys((u64)md->pfn), md->virtual); - } - type = &mem_types[md->type]; #ifndef CONFIG_ARM_LPAE @@ -910,7 +891,7 @@ static void __init create_mapping(struct map_desc *md) * Catch 36-bit addresses */ if (md->pfn >= 0x100000) { - create_36bit_mapping(md, type); + create_36bit_mapping(mm, md, type); return; } #endif @@ -925,7 +906,7 @@ static void __init create_mapping(struct map_desc *md) return; } - pgd = pgd_offset_k(addr); + pgd = pgd_offset(mm, addr); end = addr + length; do { unsigned long next = pgd_addr_end(addr, end); @@ -938,6 +919,31 @@ static void __init create_mapping(struct map_desc *md) } /* + * Create the page directory entries and any necessary + * page tables for the mapping specified by `md'. We + * are able to cope here with varying sizes and address + * offsets, and we take full advantage of sections and + * supersections. + */ +static void __init create_mapping(struct map_desc *md) +{ + if (md->virtual != vectors_base() && md->virtual < TASK_SIZE) { + pr_warn("BUG: not creating mapping for 0x%08llx at 0x%08lx in user region\n", + (long long)__pfn_to_phys((u64)md->pfn), md->virtual); + return; + } + + if ((md->type == MT_DEVICE || md->type == MT_ROM) && + md->virtual >= PAGE_OFFSET && md->virtual < FIXADDR_START && + (md->virtual < VMALLOC_START || md->virtual >= VMALLOC_END)) { + pr_warn("BUG: mapping for 0x%08llx at 0x%08lx out of vmalloc space\n", + (long long)__pfn_to_phys((u64)md->pfn), md->virtual); + } + + __create_mapping(&init_mm, md); +} + +/* * Create the architecture specific mappings */ void __init iotable_init(struct map_desc *io_desc, int nr)