From patchwork Mon Oct 10 18:12:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 77455 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp37956qge; Mon, 10 Oct 2016 11:15:08 -0700 (PDT) X-Received: by 10.36.254.200 with SMTP id w191mr9544205ith.101.1476123308200; Mon, 10 Oct 2016 11:15:08 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id bg9si31626563pab.316.2016.10.10.11.15.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Oct 2016 11:15:08 -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 1btf4k-0005E1-2M; Mon, 10 Oct 2016 18:13:22 +0000 Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1btf4d-00050B-0R for linux-arm-kernel@lists.infradead.org; Mon, 10 Oct 2016 18:13:17 +0000 Received: by mail-qk0-x22c.google.com with SMTP id o68so124937317qkf.3 for ; Mon, 10 Oct 2016 11:12:54 -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; bh=pwnMd1OM80SxXxWqVOpxqF4zFfsxNpcPLoTFZJauJoM=; b=hsxd5bCJTsDQJDMhtcNKMGL2mQMjBtc1apHoIMIKDgrHgdy6TDvD9HlSimU2z/GEx7 mXlEIvPTcFK4B/Rc8bgpZ6xgRjqORPmuiZW8GTZlMusRVtvgCgz7mxr+AurEGbu0D4Kk /nvb+4SxN959zSJbEmfa030HHC0QKieC4G/xg= 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; bh=pwnMd1OM80SxXxWqVOpxqF4zFfsxNpcPLoTFZJauJoM=; b=GQgYrASxaINE6eGgzRN3AFbnsRdmzf0U+giuybSMbVJ0u2uqPnyNi5Le5e522n8WUP mYJ5XOTAPlU3npL2ParZTJ7nGKfW4NXI53qOIkidD7q8aQwVyrckAx68XeXuxPmvOdBh alJJjXOyU88NNU0gMIzq2rF6UjJYGOhNOS6u7x86MOXuG+RKDkIhxJf8IWHCRobbVfoj S4Z6ICO+6JT9CuUonkTqwOuZb7Yg3fATSKtXP08sGToflFcOXue+igO6233nVGS+Crnz ed+1H6tkMKqHB6KjIZjz6ZgO5VBKsKm2tCxDKcuS0oyXZ7TWdbu7W0yXwJ3fLOPZPoNt OBvg== X-Gm-Message-State: AA6/9RlbLwUVZrOa5zLEyygG2lyx31BzzIdDzPAGT95fHloLvNjv5DTz7+2TnnONhGAMKV5L X-Received: by 10.194.87.170 with SMTP id az10mr35314185wjb.189.1476123173115; Mon, 10 Oct 2016 11:12:53 -0700 (PDT) Received: from localhost.localdomain ([105.146.228.123]) by smtp.gmail.com with ESMTPSA id uq6sm41843263wjc.37.2016.10.10.11.12.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 10 Oct 2016 11:12:51 -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] arm64: mmu: set the contiguous for kernel mappings when appropriate Date: Mon, 10 Oct 2016 19:12:44 +0100 Message-Id: <1476123164-10532-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161010_111315_604315_BD7CD2E9 X-CRM114-Status: GOOD ( 14.02 ) 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:22c 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: 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. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/mmu.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 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 05615a3fdc6f..c491025c6a70 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -98,8 +98,11 @@ static phys_addr_t __init early_pgtable_alloc(void) 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 allow_block_mappings) { + pgprot_t prot_cont = __pgprot(pgprot_val(prot) | PTE_CONT); + bool cont = false; pte_t *pte; BUG_ON(pmd_sect(*pmd)); @@ -115,7 +118,20 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr, pte = pte_set_fixmap_offset(pmd, addr); do { - 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_MASK) == 0) + cont = allow_block_mappings && end - addr >= CONT_SIZE; + + /* + * Ensure that we do not change the contiguous bit once this + * PTE has been assigned. + */ + BUG_ON(!pte_none(*pte) && (cont ^ !!(pte_val(*pte) & PTE_CONT))); + + set_pte(pte, pfn_pte(pfn, cont ? prot_cont : prot)); pfn++; } while (pte++, addr += PAGE_SIZE, addr != end); @@ -166,7 +182,8 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, } } else { alloc_init_pte(pmd, addr, next, __phys_to_pfn(phys), - prot, pgtable_alloc); + prot, pgtable_alloc, + allow_block_mappings); } phys += next - addr; } while (pmd++, addr = next, addr != end);