From patchwork Mon Nov 30 12:28: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: 57445 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1439576lbb; Mon, 30 Nov 2015 04:37:18 -0800 (PST) X-Received: by 10.66.100.166 with SMTP id ez6mr90434065pab.49.1448887038145; Mon, 30 Nov 2015 04:37:18 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id d28si1328921pfj.87.2015.11.30.04.37.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Nov 2015 04:37: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 1a3NgD-0003Ck-I0; Mon, 30 Nov 2015 12:35:41 +0000 Received: from mail-wm0-x229.google.com ([2a00:1450:400c:c09::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a3NaQ-0004MH-M9 for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2015 12:29:56 +0000 Received: by wmec201 with SMTP id c201so135834226wme.1 for ; Mon, 30 Nov 2015 04:29:26 -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=vPfjHr0u0W72ekqY8ea+YkTmkZQ8Rx+gWw1qJTqPSEM=; b=JZn4pnUvoZUcKb+iINMRBdWPJ7O+D9eO6Ephsf+k3WPdj/owM3z5bwneQXUPvt+HwK lLrRPdQGpF67ROGggVcFfBobNKoGzfMFRizMjxso6Ry+u4F9wCcI6B4md27tw9BuOn4m rGjzccYj52luaGIh4qGw2fPWWAcDQMNR15QdKbYWG/qfEXXlmfgb5aREdy4edinz4quF MsoBbVcrJEHQ7FLoBQAeU01Bc2YpeVVothe1sJxK918l1FEQ9WXrdMgLfOG/Kfg+cF5C w4qUcgDrap2v7CwzoMnlDym473GYlu9WhtoxUldeSJsBT+0yLSMR3Cxfkr9PQ3BP/MWl qWjg== 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=vPfjHr0u0W72ekqY8ea+YkTmkZQ8Rx+gWw1qJTqPSEM=; b=KdipEfmyPZ6eYL47iMYh5PH9TLxeLDWc/Jf6EAnzSOm3OdLO+gxEy7R5RGeC0ZYlOI BSa/e6inUK/OkU+ywAjKTSbnBbhz/pLIxVPQf6Qxrr4Cx8RoVgCiGkFiFAFU1zz5YBfY 6JkaJAJPtFPy7OPcwQHZz1tNmxuQ5XYhEgY42nCqDSPP1d05jsWjBByJ6HESiFsNSe0T xdKXFET5m7TFc7beT+XNO87U7z3Q/90uucQ52dQ5dkCIcfcMTb2ljjgVabqoIbAEDGOG 9eTRVu4AVYWvgbAR1xpiPPdkmruxfXLcLwcIioHloCH6vfSZRijHbBf4Ghii2+1I6cMr qxFg== X-Gm-Message-State: ALoCoQmalVKla2grn3lx2qIOrnWDGagH5q54ajMDP8H+USJm7GPwL7yUkxHlZQGiEYUWi6q/8V0K X-Received: by 10.194.179.71 with SMTP id de7mr71608025wjc.119.1448886565985; Mon, 30 Nov 2015 04:29:25 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 04:29:25 -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 07/13] ARM: split off core mapping logic from create_mapping Date: Mon, 30 Nov 2015 13:28:21 +0100 Message-Id: <1448886507-3216-8-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_042943_460564_5F08DBFB X-CRM114-Status: GOOD ( 16.44 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -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 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. Tested-by: Ryan Harkin Reviewed-by: Matt Fleming 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)