linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 5/5] arm64: mm: round memstart_addr to contiguous PUD/PMD size
Date: Wed, 12 Oct 2016 12:23:45 +0100	[thread overview]
Message-ID: <1476271425-19401-6-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1476271425-19401-1-git-send-email-ard.biesheuvel@linaro.org>

Given that contiguous PUDs/PMDs allow the linear region to be mapped more
efficiently, ensure that the relative alignment between the linear virtual
and physical mappings of system RAM are equal modulo the contiguous PUD
size (or contiguous PMD size, for 16k/64k granule size).

Note that this reduces the KASLR randomization of the linear range by
PUD_SHIFT (or PMD_SHIFT) bits.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/arm64/include/asm/kernel-pgtable.h | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/include/asm/kernel-pgtable.h b/arch/arm64/include/asm/kernel-pgtable.h
index 7e51d1b57c0c..71dbd9e1e809 100644
--- a/arch/arm64/include/asm/kernel-pgtable.h
+++ b/arch/arm64/include/asm/kernel-pgtable.h
@@ -83,16 +83,13 @@
 /*
  * To make optimal use of block mappings when laying out the linear
  * mapping, round down the base of physical memory to a size that can
- * be mapped efficiently, i.e., either PUD_SIZE (4k granule) or PMD_SIZE
- * (64k granule), or a multiple that can be mapped using contiguous bits
- * in the page tables: 32 * PMD_SIZE (16k granule)
+ * be mapped efficiently, i.e., either CONT_PUD_SIZE (4k granule) or
+ * CONT_PMD_SIZE (16k/64k granules)
  */
 #if defined(CONFIG_ARM64_4K_PAGES)
-#define ARM64_MEMSTART_SHIFT		PUD_SHIFT
-#elif defined(CONFIG_ARM64_16K_PAGES)
-#define ARM64_MEMSTART_SHIFT		(PMD_SHIFT + 5)
+#define ARM64_MEMSTART_SHIFT		(PUD_SHIFT + CONT_PUD_SHIFT)
 #else
-#define ARM64_MEMSTART_SHIFT		PMD_SHIFT
+#define ARM64_MEMSTART_SHIFT		(PMD_SHIFT + CONT_PMD_SHIFT)
 #endif
 
 /*
-- 
2.7.4

      parent reply	other threads:[~2016-10-12 11:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12 11:23 [PATCH v3 0/5] arm64/mm: use the contiguous attribute for kernel mappings Ard Biesheuvel
2016-10-12 11:23 ` [PATCH v3 1/5] arm64: mm: BUG on unsupported manipulations of live " Ard Biesheuvel
2016-10-12 15:04   ` Catalin Marinas
2016-10-13 12:25     ` Ard Biesheuvel
2016-10-13 14:44       ` Catalin Marinas
2016-10-13 14:48         ` Ard Biesheuvel
2016-10-13 16:51           ` Catalin Marinas
2016-10-13 16:58             ` Ard Biesheuvel
2016-10-12 11:23 ` [PATCH v3 2/5] arm64: mm: replace 'block_mappings_allowed' with 'page_mappings_only' Ard Biesheuvel
2016-10-12 15:07   ` Mark Rutland
2016-10-12 11:23 ` [PATCH v3 3/5] arm64: mm: set the contiguous bit for kernel mappings where appropriate Ard Biesheuvel
2016-10-13 16:28   ` Catalin Marinas
2016-10-13 16:57     ` Ard Biesheuvel
2016-10-13 17:27       ` Catalin Marinas
2016-10-12 11:23 ` [PATCH v3 4/5] arm64: mm: support additional contiguous kernel mapping region sizes Ard Biesheuvel
2016-10-14 10:28   ` Catalin Marinas
2016-10-14 17:51     ` Ard Biesheuvel
2016-10-12 11:23 ` Ard Biesheuvel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476271425-19401-6-git-send-email-ard.biesheuvel@linaro.org \
    --to=ard.biesheuvel@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).