From patchwork Tue Oct 11 12:39:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 77483 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp329694qge; Tue, 11 Oct 2016 05:42:19 -0700 (PDT) X-Received: by 10.107.154.134 with SMTP id c128mr6136147ioe.184.1476189739514; Tue, 11 Oct 2016 05:42:19 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id m13si3969824pfk.87.2016.10.11.05.42.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Oct 2016 05:42:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for 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; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1btwMu-0000yF-Pi; Tue, 11 Oct 2016 12:41:16 +0000 Received: from mail-qk0-x235.google.com ([2607:f8b0:400d:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1btwM5-0008JC-81 for linux-arm-kernel@lists.infradead.org; Tue, 11 Oct 2016 12:40:26 +0000 Received: by mail-qk0-x235.google.com with SMTP id f128so30710470qkb.1 for ; Tue, 11 Oct 2016 05:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pccH1ATkMxgTgfSECDgCbgPR+qVXj/2tuR9Mq5/0KfA=; b=iH03v5Tj6KRNHOqd8wltSAOLDRj22dsIHZczDPNa/uOwdE8L2dySyvx3oD0XwAnwrR Rba43reD5Vn4lRf8yEKeEJ+bVyHF+YhjeOT8zLBqJZVG20U6ZlMToJr6PLbEbBDsF/Fw gJ0wtSSE0YsapAa6mDokjTK8H9Ldi00kpVVRQ= 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=pccH1ATkMxgTgfSECDgCbgPR+qVXj/2tuR9Mq5/0KfA=; b=IzP1LCwJv5++vl6BliUHoYfXYpzsfS27iChz6+dV3rNkIDWKeddiGjsdHjB/fwUcyI G1l1qGLyQW48qH9B8v9Vpu/djJFGG5wthRTzsKAdgLwGX+kLdwbNHV52tWgOYzWv72Ka GmAmXkbTMUjdj9nvK9afCVf7mDQP3i4Vjme1uYwkJKlkFTFpmIqWwdUfoMN3kRa/EYRd x7Ugr14Kd/L3J3i0ocmU5PScEQQARbBgd+Lvtl/NO0JJLbdn5fw1z9m3hP/PhV1r60/g Cw3PTFNNd+8tGGIjOK2lLtkVoxm7/S686Ae9xhQ7UsuD1iqPbv/dUEQSTpQVw+7G6IpE vcVA== X-Gm-Message-State: AA6/9RkasgcIAJeMBByxft1Ked1rrUGYJoB6fxg6mVWpq78X4POLyP07cn/0Wmmce+HVf6O4 X-Received: by 10.194.68.106 with SMTP id v10mr4870228wjt.149.1476189602224; Tue, 11 Oct 2016 05:40:02 -0700 (PDT) Received: from localhost.localdomain ([105.147.31.57]) by smtp.gmail.com with ESMTPSA id h3sm6069913wjp.45.2016.10.11.05.40.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Oct 2016 05:40:01 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v2 3/3] arm64: mm: set the contiguous bit for kernel mappings where appropriate Date: Tue, 11 Oct 2016 13:39:49 +0100 Message-Id: <1476189589-1443-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476189589-1443-1-git-send-email-ard.biesheuvel@linaro.org> References: <1476189589-1443-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161011_054025_445351_23632B7A X-CRM114-Status: GOOD ( 14.63 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400d:c09:0:0:0:235 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_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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: steve.capper@linaro.org, jeremy.linton@arm.com, Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Now that we no longer allow live kernel PMDs to be split, it is safe to start using the contiguous bit for kernel mappings. So set the contiguous bit in the kernel page mappings for regions whose size and alignment are suitable for this. This includes contiguous level 2 mappings for 16k granule kernels. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/mmu.c | 35 +++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index ee3cda6c41a7..c2bf7396888b 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -102,8 +102,10 @@ static const pteval_t modifiable_attr_mask = PTE_PXN | PTE_RDONLY | PTE_WRITE; static void alloc_init_pte(pmd_t *pmd, unsigned long addr, unsigned long end, unsigned long pfn, pgprot_t prot, - phys_addr_t (*pgtable_alloc)(void)) + phys_addr_t (*pgtable_alloc)(void), + bool page_mappings_only) { + pgprot_t __prot = prot; pte_t *pte; BUG_ON(pmd_sect(*pmd)); @@ -121,7 +123,18 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr, do { pte_t old_pte = *pte; - set_pte(pte, pfn_pte(pfn, prot)); + /* + * Set the contiguous bit for the subsequent group of PTEs if + * its size and alignment are suitable. + */ + if (((addr | PFN_PHYS(pfn)) & ~CONT_PTE_MASK) == 0) { + if (!page_mappings_only && end - addr >= CONT_PTE_SIZE) + __prot = __pgprot(pgprot_val(prot) | PTE_CONT); + else + __prot = prot; + } + + set_pte(pte, pfn_pte(pfn, __prot)); pfn++; /* @@ -141,6 +154,7 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, phys_addr_t (*pgtable_alloc)(void), bool page_mappings_only) { + pgprot_t __prot = prot; pmd_t *pmd; unsigned long next; @@ -164,10 +178,22 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, next = pmd_addr_end(addr, end); + /* + * For 16K granule only, attempt to put down a 1 GB block by + * stringing 32 PMD block mappings together. + */ + if (IS_ENABLED(CONFIG_ARM64_16K_PAGES) && + ((addr | phys) & ~CONT_PMD_MASK) == 0) { + if (!page_mappings_only && end - addr >= CONT_PMD_SIZE) + __prot = __pgprot(pgprot_val(prot) | PTE_CONT); + else + __prot = prot; + } + /* try section mapping first */ if (((addr | next | phys) & ~SECTION_MASK) == 0 && !page_mappings_only) { - pmd_set_huge(pmd, phys, prot); + pmd_set_huge(pmd, phys, __prot); /* * After the PMD entry has been populated once, we @@ -178,7 +204,8 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, ~modifiable_attr_mask) != 0); } else { alloc_init_pte(pmd, addr, next, __phys_to_pfn(phys), - prot, pgtable_alloc); + prot, pgtable_alloc, + page_mappings_only); BUG_ON(!pmd_none(old_pmd) && pmd_val(old_pmd) != pmd_val(*pmd));