From patchwork Mon Nov 23 09:06:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 57121 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1316674lbb; Mon, 23 Nov 2015 01:11:27 -0800 (PST) X-Received: by 10.66.65.134 with SMTP id x6mr9133345pas.64.1448269887610; Mon, 23 Nov 2015 01:11:27 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ac4si299739pbc.67.2015.11.23.01.11.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2015 01:11:27 -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 1a0n8H-0005DY-0f; Mon, 23 Nov 2015 09:09: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 1a0n66-0003MZ-Fx for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2015 09:07:44 +0000 Received: by wmww144 with SMTP id w144so86939285wmw.1 for ; Mon, 23 Nov 2015 01:07:21 -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=0hpscngWg3lCVVBCF4O8uDahdAtHcZC4sAY0ZFlAmb8=; b=SyY6uCKNW6Yh2XDrRKf8Nqn34gTVkLvo4KEuuO8O0KhZauMPLcEreA937wuNZEVHnk VTuClTb2CjEiCO4Yk0g3Xvs+MN0WuToSUlqiLk2FiHAEfwIyJ21QIlzoJnQs73ya1iMz fZVI0XhkWtwbTX07yTfCBzowKHw9yWhvUVh1oQLX0CH7X8w2aSqP63PCaPOrNempaoyo R6cdwcacMmtwbs+HucYyySB5MzgOzDHhHsnlqiFoWcQr+bee0c9dMbMhWeC1BY3+WPvE XIAF6jKipg9g/RCs4LgSNbyw6nmnsT4i/wKn1IBJOWRK4lvf036w4LzI+jk4sN4q57DU +7BA== 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=0hpscngWg3lCVVBCF4O8uDahdAtHcZC4sAY0ZFlAmb8=; b=XW7Pp279UG8R/C1nS047UU4fCIPtKkayaR5tGnlzmUNGz1q3QQsMxRC2Booi//cLWs umc3l12tBR5yvRjLd8eSWfJLOF4OYrYclKxTj+baUZaGKZZBkQEYqX9UEwUKs0+tSSb2 W8vPogRsFmtRhpoybpBLF8daaMyB6pGmdakvzNod3WWemsCfZauwfCnLqSQrnt/sk5n1 J7lU23bVPKLwPio/Pzk3UE//Pz8l/q0uP9SlZBQ8cPgbLKleHCVaMyuBtSQI6/q7Y8BN guKNb3QNj9p12KQhz33oDb2hNuXno3OkqA7bIXsMbJKps2dJTfV0LWUhlr2uiYAay1lu GfXg== X-Gm-Message-State: ALoCoQmNuXnONIV2T6SomvYi2EMCd0nM9zvIsl2w7SA9tAID1nkZWivd9z5hLWk6JLUz4CIbH5xr X-Received: by 10.28.68.134 with SMTP id r128mr15373555wma.6.1448269641079; Mon, 23 Nov 2015 01:07:21 -0800 (PST) Received: from localhost.localdomain ([2.44.140.166]) by smtp.gmail.com with ESMTPSA id h189sm12241754wme.1.2015.11.23.01.07.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Nov 2015 01:07:20 -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 Subject: [PATCH v3 09/13] ARM: add support for non-global kernel mappings Date: Mon, 23 Nov 2015 10:06:29 +0100 Message-Id: <1448269593-20758-10-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1448269593-20758-1-git-send-email-ard.biesheuvel@linaro.org> References: <1448269593-20758-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151123_010742_682194_9B15FBF7 X-CRM114-Status: GOOD ( 15.73 ) 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:229 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 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 ASID scoped mappings in the userland range. Signed-off-by: Ard Biesheuvel --- arch/arm/mm/mmu.c | 35 +++++++++++--------- 1 file changed, 20 insertions(+), 15 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 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); } /*