All of lore.kernel.org
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6sub1 04/11] arm64: add support for ioremap() block mappings
Date: Tue, 16 Feb 2016 13:52:35 +0100	[thread overview]
Message-ID: <1455627162-31600-5-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1455627162-31600-1-git-send-email-ard.biesheuvel@linaro.org>

This wires up the existing generic huge-vmap feature, which allows
ioremap() to use PMD or PUD sized block mappings. It also adds support
to the unmap path for dealing with block mappings, which will allow us
to unmap the __init region using unmap_kernel_range() in a subsequent
patch.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Documentation/features/vm/huge-vmap/arch-support.txt |  2 +-
 arch/arm64/Kconfig                                   |  1 +
 arch/arm64/include/asm/memory.h                      |  6 +++
 arch/arm64/mm/mmu.c                                  | 41 ++++++++++++++++++++
 4 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/Documentation/features/vm/huge-vmap/arch-support.txt b/Documentation/features/vm/huge-vmap/arch-support.txt
index af6816bccb43..df1d1f3c9af2 100644
--- a/Documentation/features/vm/huge-vmap/arch-support.txt
+++ b/Documentation/features/vm/huge-vmap/arch-support.txt
@@ -9,7 +9,7 @@
     |       alpha: | TODO |
     |         arc: | TODO |
     |         arm: | TODO |
-    |       arm64: | TODO |
+    |       arm64: |  ok  |
     |       avr32: | TODO |
     |    blackfin: | TODO |
     |         c6x: | TODO |
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 8cc62289a63e..cd767fa3037a 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -49,6 +49,7 @@ config ARM64
 	select HAVE_ALIGNED_STRUCT_PAGE if SLUB
 	select HAVE_ARCH_AUDITSYSCALL
 	select HAVE_ARCH_BITREVERSE
+	select HAVE_ARCH_HUGE_VMAP
 	select HAVE_ARCH_JUMP_LABEL
 	select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP && !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
 	select HAVE_ARCH_KGDB
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index 853953cd1f08..c65aad7b13dc 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -100,6 +100,12 @@
 #define MT_S2_NORMAL		0xf
 #define MT_S2_DEVICE_nGnRE	0x1
 
+#ifdef CONFIG_ARM64_4K_PAGES
+#define IOREMAP_MAX_ORDER	(PUD_SHIFT)
+#else
+#define IOREMAP_MAX_ORDER	(PMD_SHIFT)
+#endif
+
 #ifndef __ASSEMBLY__
 
 extern phys_addr_t		memstart_addr;
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 7711554a94f4..73383019f212 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -714,3 +714,44 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys)
 
 	return dt_virt;
 }
+
+int __init arch_ioremap_pud_supported(void)
+{
+	/* only 4k granule supports level 1 block mappings */
+	return IS_ENABLED(CONFIG_ARM64_4K_PAGES);
+}
+
+int __init arch_ioremap_pmd_supported(void)
+{
+	return 1;
+}
+
+int pud_set_huge(pud_t *pud, phys_addr_t phys, pgprot_t prot)
+{
+	BUG_ON(phys & ~PUD_MASK);
+	set_pud(pud, __pud(phys | PUD_TYPE_SECT | pgprot_val(mk_sect_prot(prot))));
+	return 1;
+}
+
+int pmd_set_huge(pmd_t *pmd, phys_addr_t phys, pgprot_t prot)
+{
+	BUG_ON(phys & ~PMD_MASK);
+	set_pmd(pmd, __pmd(phys | PMD_TYPE_SECT | pgprot_val(mk_sect_prot(prot))));
+	return 1;
+}
+
+int pud_clear_huge(pud_t *pud)
+{
+	if (!pud_sect(*pud))
+		return 0;
+	pud_clear(pud);
+	return 1;
+}
+
+int pmd_clear_huge(pmd_t *pmd)
+{
+	if (!pmd_sect(*pmd))
+		return 0;
+	pmd_clear(pmd);
+	return 1;
+}
-- 
2.5.0

  parent reply	other threads:[~2016-02-16 12:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 12:52 [PATCH v6sub1 00/11] arm64: split linear and kernel mappings Ard Biesheuvel
2016-02-16 12:52 ` [PATCH v6sub1 01/11] of/fdt: make memblock minimum physical address arch configurable Ard Biesheuvel
2016-02-16 12:52 ` [PATCH v6sub1 02/11] of/fdt: factor out assignment of initrd_start/initrd_end Ard Biesheuvel
2016-02-16 17:28   ` Rob Herring
2016-02-16 12:52 ` [PATCH v6sub1 03/11] arm64: prevent potential circular header dependencies in asm/bug.h Ard Biesheuvel
2016-02-16 12:52 ` Ard Biesheuvel [this message]
2016-02-16 12:52 ` [PATCH v6sub1 05/11] arm64: introduce KIMAGE_VADDR as the virtual base of the kernel region Ard Biesheuvel
2016-02-16 12:52 ` [PATCH v6sub1 06/11] arm64: pgtable: implement static [pte|pmd|pud]_offset variants Ard Biesheuvel
2016-02-16 12:52 ` [PATCH v6sub1 07/11] arm64: decouple early fixmap init from linear mapping Ard Biesheuvel
2016-02-16 12:52 ` [PATCH v6sub1 08/11] arm64: kvm: deal with kernel symbols outside of " Ard Biesheuvel
2016-02-16 12:52 ` [PATCH v6sub1 09/11] arm64: move kernel image to base of vmalloc area Ard Biesheuvel
2016-02-16 12:52 ` [PATCH v6sub1 10/11] arm64: defer __va translation of initrd_start and initrd_end Ard Biesheuvel
2016-02-16 12:52 ` [PATCH v6sub1 11/11] arm64: allow kernel Image to be loaded anywhere in physical memory Ard Biesheuvel
2016-02-18 18:25 ` [PATCH v6sub1 00/11] arm64: split linear and kernel mappings Catalin Marinas
2016-02-18 18:27   ` Ard Biesheuvel
2016-02-18 19:38     ` Ard Biesheuvel
2016-02-19  8:05       ` Ard Biesheuvel
2016-02-19 14:25         ` Catalin Marinas
2016-02-19 14:27           ` Ard Biesheuvel
2016-02-19 14:29             ` Ard Biesheuvel
2016-02-19 14:37               ` Catalin Marinas
2016-02-19 14:40                 ` Ard Biesheuvel
2016-02-19 14:57                   ` Catalin Marinas
2016-02-19 17:34                   ` Catalin Marinas
2016-02-19 17:38                     ` Ard Biesheuvel
2016-02-19 17:43                       ` Catalin Marinas

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=1455627162-31600-5-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.