From patchwork Mon Nov 30 12:28:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 7723881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 55D14BEEE1 for ; Mon, 30 Nov 2015 12:34:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50D5520527 for ; Mon, 30 Nov 2015 12:34:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 34E6B204DE for ; Mon, 30 Nov 2015 12:34:56 +0000 (UTC) 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 1a3NdZ-00087e-6i; Mon, 30 Nov 2015 12:32:57 +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 1a3Naa-0004QP-LZ for linux-arm-kernel@lists.infradead.org; Mon, 30 Nov 2015 12:30:08 +0000 Received: by wmww144 with SMTP id w144so127169548wmw.1 for ; Mon, 30 Nov 2015 04:29:31 -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=1pgHIrPXt3XHvFxkmhBVqLvlIB4tVPpEATlro4F0wyY=; b=JRi9KM7hq4NHRd9n6XlsmmF0wMgIPX81jDNMDqgYAJ0n/wpFjssREswWOHeZtcaHpn dncTifjzgOcgwxWxMcXzothHbbyNxPeHGzz3+T1Np+mmgROVhopExbYiRH1CwEXzZsOM rxHP1AEYL28iB6SmBUV5ap77ncGb/rDHu7HIR8979eB3oFEwnlSpHdooO3c+8M5SZUeg eFOkNtj6IBcPi1oeXXfJStITz7b7K3BD/EDoHjXdyPounvkQ8+teHmNYrbw/a2wGE9PH kbhOsMvCrNG5BWTLjR39l1t8VPSGJel6J7S7YFoj7Vg0181eAUNyPnYPn4mrNllqh+VS /9dQ== 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=1pgHIrPXt3XHvFxkmhBVqLvlIB4tVPpEATlro4F0wyY=; b=aM5WtX7FQrKsFsKbBDDTEgjrbxRR6sKUmtY7eGRmg0j7YMZQeYAU9mImCgHhZqTq68 SYxDuNjQJsuNGqNfXd9sGXRe/fLi42S838TmSgBT2QmwPTA6q3cdTVcyOKZ9Pkkkq3ol SC8uWZCdegppN6Mh/5oFmeEUFPjvVbReS7ywXKfSGz0x/7HYKiOpYs193qnR8dZdaJTN uZoxsJ9T3D/ouHebarrOg+tczV/fZZFUKfzInOpMGKilRYLQbeoW06OvktdbcVQRFoUo B7hyFQ8QhICw/Yakr1zLHStJ05E9qYMaVWvGh1FuHkl9ekmCK3f2NQlO1ucXd1E5Xh9e n9Ew== X-Gm-Message-State: ALoCoQmzsNTxhGCXIybCCeo6emLflPScKlHxm97UgJ3T0G2dTB78z2S6qtXeAVw1FA47lgvnmPbV X-Received: by 10.194.249.97 with SMTP id yt1mr77372274wjc.89.1448886571408; Mon, 30 Nov 2015 04:29:31 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 04:29:30 -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 09/13] ARM: add support for non-global kernel mappings Date: Mon, 30 Nov 2015 13:28:23 +0100 Message-Id: <1448886507-3216-10-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_042953_290898_9B1A24FE X-CRM114-Status: GOOD ( 15.30 ) X-Spam-Score: -1.9 (-) 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support to the kernel translation table population routines for creating non-global mappings. This will be used by the UEFI runtime services, which will use temporary mappings in the userland range. Reviewed-by: Matt Fleming Signed-off-by: Ard Biesheuvel --- arch/arm/mm/mmu.c | 35 +++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 87dc49dbe231..2d9f628a7fe8 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -745,18 +745,20 @@ static pte_t * __init early_pte_alloc(pmd_t *pmd, unsigned long addr, static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr, unsigned long end, unsigned long pfn, const struct mem_type *type, - void *(*alloc)(unsigned long sz)) + void *(*alloc)(unsigned long sz), + bool ng) { pte_t *pte = pte_alloc(pmd, addr, type->prot_l1, alloc); do { - set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0); + set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), + ng ? PTE_EXT_NG : 0); pfn++; } while (pte++, addr += PAGE_SIZE, addr != end); } static void __init __map_init_section(pmd_t *pmd, unsigned long addr, unsigned long end, phys_addr_t phys, - const struct mem_type *type) + const struct mem_type *type, bool ng) { pmd_t *p = pmd; @@ -774,7 +776,7 @@ static void __init __map_init_section(pmd_t *pmd, unsigned long addr, pmd++; #endif do { - *pmd = __pmd(phys | type->prot_sect); + *pmd = __pmd(phys | type->prot_sect | (ng ? PMD_SECT_nG : 0)); phys += SECTION_SIZE; } while (pmd++, addr += SECTION_SIZE, addr != end); @@ -784,7 +786,7 @@ 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, - void *(*alloc)(unsigned long sz)) + void *(*alloc)(unsigned long sz), bool ng) { pmd_t *pmd = pmd_offset(pud, addr); unsigned long next; @@ -802,10 +804,10 @@ static void __init alloc_init_pmd(pud_t *pud, unsigned long addr, */ if (type->prot_sect && ((addr | next | phys) & ~SECTION_MASK) == 0) { - __map_init_section(pmd, addr, next, phys, type); + __map_init_section(pmd, addr, next, phys, type, ng); } else { alloc_init_pte(pmd, addr, next, - __phys_to_pfn(phys), type, alloc); + __phys_to_pfn(phys), type, alloc, ng); } phys += next - addr; @@ -816,14 +818,14 @@ 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, - void *(*alloc)(unsigned long sz)) + void *(*alloc)(unsigned long sz), bool ng) { 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); + alloc_init_pmd(pud, addr, next, phys, type, alloc, ng); phys += next - addr; } while (pud++, addr = next, addr != end); } @@ -831,7 +833,8 @@ static void __init alloc_init_pud(pgd_t *pgd, unsigned long addr, #ifndef CONFIG_ARM_LPAE static void __init create_36bit_mapping(struct mm_struct *mm, struct map_desc *md, - const struct mem_type *type) + const struct mem_type *type, + bool ng) { unsigned long addr, length, end; phys_addr_t phys; @@ -879,7 +882,8 @@ static void __init create_36bit_mapping(struct mm_struct *mm, int i; for (i = 0; i < 16; i++) - *pmd++ = __pmd(phys | type->prot_sect | PMD_SECT_SUPER); + *pmd++ = __pmd(phys | type->prot_sect | PMD_SECT_SUPER | + (ng ? PMD_SECT_nG : 0)); addr += SUPERSECTION_SIZE; phys += SUPERSECTION_SIZE; @@ -889,7 +893,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, - void *(*alloc)(unsigned long sz)) + void *(*alloc)(unsigned long sz), + bool ng) { unsigned long addr, length, end; phys_addr_t phys; @@ -903,7 +908,7 @@ static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md, * Catch 36-bit addresses */ if (md->pfn >= 0x100000) { - create_36bit_mapping(mm, md, type); + create_36bit_mapping(mm, md, type, ng); return; } #endif @@ -923,7 +928,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); + alloc_init_pud(pgd, addr, next, phys, type, alloc, ng); phys += next - addr; addr = next; @@ -952,7 +957,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, early_alloc); + __create_mapping(&init_mm, md, early_alloc, false); } /*