summaryrefslogtreecommitdiffstats
path: root/arch/arm64
diff options
context:
space:
mode:
authorLaura Abbott <labbott@fedoraproject.org>2016-02-05 19:24:46 -0500
committerCatalin Marinas <catalin.marinas@arm.com>2016-02-16 10:12:34 -0500
commit132233a759580f5ce9b1bfaac9073e47d03c460d (patch)
treef016316a4b5a3941bdb5f2efcca1f2938f459103 /arch/arm64
parentafb83cc3f0e4f86ea0e1cc3db7a90f58f1abd4d5 (diff)
arm64: Drop alloc function from create_mapping
create_mapping is only used in fixmap_remap_fdt. All the create_mapping calls need to happen on existing translation table pages without additional allocations. Rather than have an alloc function be called and fail, just set it to NULL and catch its use. Also change the name to create_mapping_noalloc to better capture what exactly is going on. Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Laura Abbott <labbott@fedoraproject.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch/arm64')
-rw-r--r--arch/arm64/mm/mmu.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 7711554a94f4..ef0d66cf5535 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -116,7 +116,9 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
116 pte_t *pte; 116 pte_t *pte;
117 117
118 if (pmd_none(*pmd) || pmd_sect(*pmd)) { 118 if (pmd_none(*pmd) || pmd_sect(*pmd)) {
119 phys_addr_t pte_phys = pgtable_alloc(); 119 phys_addr_t pte_phys;
120 BUG_ON(!pgtable_alloc);
121 pte_phys = pgtable_alloc();
120 pte = pte_set_fixmap(pte_phys); 122 pte = pte_set_fixmap(pte_phys);
121 if (pmd_sect(*pmd)) 123 if (pmd_sect(*pmd))
122 split_pmd(pmd, pte); 124 split_pmd(pmd, pte);
@@ -158,7 +160,9 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
158 * Check for initial section mappings in the pgd/pud and remove them. 160 * Check for initial section mappings in the pgd/pud and remove them.
159 */ 161 */
160 if (pud_none(*pud) || pud_sect(*pud)) { 162 if (pud_none(*pud) || pud_sect(*pud)) {
161 phys_addr_t pmd_phys = pgtable_alloc(); 163 phys_addr_t pmd_phys;
164 BUG_ON(!pgtable_alloc);
165 pmd_phys = pgtable_alloc();
162 pmd = pmd_set_fixmap(pmd_phys); 166 pmd = pmd_set_fixmap(pmd_phys);
163 if (pud_sect(*pud)) { 167 if (pud_sect(*pud)) {
164 /* 168 /*
@@ -223,7 +227,9 @@ static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end,
223 unsigned long next; 227 unsigned long next;
224 228
225 if (pgd_none(*pgd)) { 229 if (pgd_none(*pgd)) {
226 phys_addr_t pud_phys = pgtable_alloc(); 230 phys_addr_t pud_phys;
231 BUG_ON(!pgtable_alloc);
232 pud_phys = pgtable_alloc();
227 __pgd_populate(pgd, pud_phys, PUD_TYPE_TABLE); 233 __pgd_populate(pgd, pud_phys, PUD_TYPE_TABLE);
228 } 234 }
229 BUG_ON(pgd_bad(*pgd)); 235 BUG_ON(pgd_bad(*pgd));
@@ -312,7 +318,12 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
312 init_pgd(pgd_offset_raw(pgdir, virt), phys, virt, size, prot, alloc); 318 init_pgd(pgd_offset_raw(pgdir, virt), phys, virt, size, prot, alloc);
313} 319}
314 320
315static void __init create_mapping(phys_addr_t phys, unsigned long virt, 321/*
322 * This function can only be used to modify existing table entries,
323 * without allocating new levels of table. Note that this permits the
324 * creation of new section or page entries.
325 */
326static void __init create_mapping_noalloc(phys_addr_t phys, unsigned long virt,
316 phys_addr_t size, pgprot_t prot) 327 phys_addr_t size, pgprot_t prot)
317{ 328{
318 if (virt < VMALLOC_START) { 329 if (virt < VMALLOC_START) {
@@ -321,7 +332,7 @@ static void __init create_mapping(phys_addr_t phys, unsigned long virt,
321 return; 332 return;
322 } 333 }
323 __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, 334 __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot,
324 early_pgtable_alloc); 335 NULL);
325} 336}
326 337
327void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, 338void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
@@ -680,7 +691,7 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys)
680 /* 691 /*
681 * Make sure that the FDT region can be mapped without the need to 692 * Make sure that the FDT region can be mapped without the need to
682 * allocate additional translation table pages, so that it is safe 693 * allocate additional translation table pages, so that it is safe
683 * to call create_mapping() this early. 694 * to call create_mapping_noalloc() this early.
684 * 695 *
685 * On 64k pages, the FDT will be mapped using PTEs, so we need to 696 * On 64k pages, the FDT will be mapped using PTEs, so we need to
686 * be in the same PMD as the rest of the fixmap. 697 * be in the same PMD as the rest of the fixmap.
@@ -696,8 +707,8 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys)
696 dt_virt = (void *)dt_virt_base + offset; 707 dt_virt = (void *)dt_virt_base + offset;
697 708
698 /* map the first chunk so we can read the size from the header */ 709 /* map the first chunk so we can read the size from the header */
699 create_mapping(round_down(dt_phys, SWAPPER_BLOCK_SIZE), dt_virt_base, 710 create_mapping_noalloc(round_down(dt_phys, SWAPPER_BLOCK_SIZE),
700 SWAPPER_BLOCK_SIZE, prot); 711 dt_virt_base, SWAPPER_BLOCK_SIZE, prot);
701 712
702 if (fdt_check_header(dt_virt) != 0) 713 if (fdt_check_header(dt_virt) != 0)
703 return NULL; 714 return NULL;
@@ -707,7 +718,7 @@ void *__init fixmap_remap_fdt(phys_addr_t dt_phys)
707 return NULL; 718 return NULL;
708 719
709 if (offset + size > SWAPPER_BLOCK_SIZE) 720 if (offset + size > SWAPPER_BLOCK_SIZE)
710 create_mapping(round_down(dt_phys, SWAPPER_BLOCK_SIZE), dt_virt_base, 721 create_mapping_noalloc(round_down(dt_phys, SWAPPER_BLOCK_SIZE), dt_virt_base,
711 round_up(offset + size, SWAPPER_BLOCK_SIZE), prot); 722 round_up(offset + size, SWAPPER_BLOCK_SIZE), prot);
712 723
713 memblock_reserve(dt_phys, size); 724 memblock_reserve(dt_phys, size);