diff options
author | Will Deacon <will.deacon@arm.com> | 2019-04-08 11:23:48 +0100 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2019-04-09 11:21:50 +0100 |
commit | 475ba3fc194b6429eebcca0e1cf9917de6fa173e (patch) | |
tree | 1eeac165fd0bc96aa56f33790bd3316861f51f6a /arch/arm64/mm | |
parent | 54c8d9119ec85de48fd0707946a5e57df9ad7acf (diff) | |
download | linux-475ba3fc194b6429eebcca0e1cf9917de6fa173e.tar.gz linux-475ba3fc194b6429eebcca0e1cf9917de6fa173e.tar.bz2 linux-475ba3fc194b6429eebcca0e1cf9917de6fa173e.zip |
arm64: mm: Consolidate early page table allocation
The logic for early allocation of page tables is duplicated between
pgd_kernel_pgtable_alloc() and pgd_pgtable_alloc(). Drop the duplication
by calling one from the other and renaming pgd_kernel_pgtable_alloc()
accordingly.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/mm')
-rw-r--r-- | arch/arm64/mm/mmu.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 83a221d2d24c..ef82312860ac 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -371,7 +371,7 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, } while (pgdp++, addr = next, addr != end); } -static phys_addr_t pgd_kernel_pgtable_alloc(int shift) +static phys_addr_t __pgd_pgtable_alloc(int shift) { void *ptr = (void *)__get_free_page(PGALLOC_GFP); BUG_ON(!ptr); @@ -383,8 +383,7 @@ static phys_addr_t pgd_kernel_pgtable_alloc(int shift) static phys_addr_t pgd_pgtable_alloc(int shift) { - void *ptr = (void *)__get_free_page(PGALLOC_GFP); - BUG_ON(!ptr); + phys_addr_t pa = __pgd_pgtable_alloc(shift); /* * Call proper page table ctor in case later we need to @@ -395,13 +394,11 @@ static phys_addr_t pgd_pgtable_alloc(int shift) * folded, and if so pgtable_pmd_page_ctor() becomes nop. */ if (shift == PAGE_SHIFT) - BUG_ON(!pgtable_page_ctor(virt_to_page(ptr))); + BUG_ON(!pgtable_page_ctor(phys_to_page(pa))); else if (shift == PMD_SHIFT) - BUG_ON(!pgtable_pmd_page_ctor(virt_to_page(ptr))); + BUG_ON(!pgtable_pmd_page_ctor(phys_to_page(pa))); - /* Ensure the zeroed page is visible to the page table walker */ - dsb(ishst); - return __pa(ptr); + return pa; } /* @@ -605,7 +602,7 @@ static int __init map_entry_trampoline(void) /* Map only the text into the trampoline page table */ memset(tramp_pg_dir, 0, PGD_SIZE); __create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE, - prot, pgd_kernel_pgtable_alloc, 0); + prot, __pgd_pgtable_alloc, 0); /* Map both the text and data into the kernel page table */ __set_fixmap(FIX_ENTRY_TRAMP_TEXT, pa_start, prot); @@ -1077,8 +1074,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; __create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start), - size, PAGE_KERNEL, pgd_kernel_pgtable_alloc, - flags); + size, PAGE_KERNEL, __pgd_pgtable_alloc, flags); return __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT, altmap, want_memblock); |