Skip to content

Commit 324420b

Browse files
Ard Biesheuvelctmarinas
authored andcommitted
arm64: add support for ioremap() block mappings
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> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 03336b1 commit 324420b

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

Documentation/features/vm/huge-vmap/arch-support.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| alpha: | TODO |
1010
| arc: | TODO |
1111
| arm: | TODO |
12-
| arm64: | TODO |
12+
| arm64: | ok |
1313
| avr32: | TODO |
1414
| blackfin: | TODO |
1515
| c6x: | TODO |

arch/arm64/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ config ARM64
5050
select HAVE_ALIGNED_STRUCT_PAGE if SLUB
5151
select HAVE_ARCH_AUDITSYSCALL
5252
select HAVE_ARCH_BITREVERSE
53+
select HAVE_ARCH_HUGE_VMAP
5354
select HAVE_ARCH_JUMP_LABEL
5455
select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP && !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
5556
select HAVE_ARCH_KGDB

arch/arm64/include/asm/memory.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@
100100
#define MT_S2_NORMAL 0xf
101101
#define MT_S2_DEVICE_nGnRE 0x1
102102

103+
#ifdef CONFIG_ARM64_4K_PAGES
104+
#define IOREMAP_MAX_ORDER (PUD_SHIFT)
105+
#else
106+
#define IOREMAP_MAX_ORDER (PMD_SHIFT)
107+
#endif
108+
103109
#ifndef __ASSEMBLY__
104110

105111
extern phys_addr_t memstart_addr;

arch/arm64/mm/mmu.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -747,3 +747,44 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys)
747747

748748
return dt_virt;
749749
}
750+
751+
int __init arch_ioremap_pud_supported(void)
752+
{
753+
/* only 4k granule supports level 1 block mappings */
754+
return IS_ENABLED(CONFIG_ARM64_4K_PAGES);
755+
}
756+
757+
int __init arch_ioremap_pmd_supported(void)
758+
{
759+
return 1;
760+
}
761+
762+
int pud_set_huge(pud_t *pud, phys_addr_t phys, pgprot_t prot)
763+
{
764+
BUG_ON(phys & ~PUD_MASK);
765+
set_pud(pud, __pud(phys | PUD_TYPE_SECT | pgprot_val(mk_sect_prot(prot))));
766+
return 1;
767+
}
768+
769+
int pmd_set_huge(pmd_t *pmd, phys_addr_t phys, pgprot_t prot)
770+
{
771+
BUG_ON(phys & ~PMD_MASK);
772+
set_pmd(pmd, __pmd(phys | PMD_TYPE_SECT | pgprot_val(mk_sect_prot(prot))));
773+
return 1;
774+
}
775+
776+
int pud_clear_huge(pud_t *pud)
777+
{
778+
if (!pud_sect(*pud))
779+
return 0;
780+
pud_clear(pud);
781+
return 1;
782+
}
783+
784+
int pmd_clear_huge(pmd_t *pmd)
785+
{
786+
if (!pmd_sect(*pmd))
787+
return 0;
788+
pmd_clear(pmd);
789+
return 1;
790+
}

0 commit comments

Comments
 (0)