Skip to content

Commit 1adf036

Browse files
mrutland-armAlex Shi
authored andcommitted
arm64: mm: allow passing a pgdir to alloc_init_*
To allow us to initialise pgdirs which are fixmapped, allow explicitly passing a pgdir rather than an mm. A new __create_pgd_mapping function is added for this, with existing __create_mapping callers migrated to this. The mm argument was previously only used at the top level. Now that it is redundant at all levels, it is removed. To indicate its new found similarity to alloc_init_{pud,pmd,pte}, __create_mapping is renamed to init_pgd. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Tested-by: Jeremy Linton <jeremy.linton@arm.com> Cc: Laura Abbott <labbott@fedoraproject.org> Cc: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> (cherry picked from commit 11509a306bb6ea595878b2d246d2d56b1783e040) Signed-off-by: Alex Shi <alex.shi@linaro.org>
1 parent ae97b43 commit 1adf036

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

arch/arm64/mm/mmu.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ static void split_pud(pud_t *old_pud, pmd_t *pmd)
146146
} while (pmd++, i++, i < PTRS_PER_PMD);
147147
}
148148

149-
static void alloc_init_pmd(struct mm_struct *mm, pud_t *pud,
150-
unsigned long addr, unsigned long end,
149+
static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
151150
phys_addr_t phys, pgprot_t prot,
152151
phys_addr_t (*pgtable_alloc)(void))
153152
{
@@ -215,8 +214,7 @@ static inline bool use_1G_block(unsigned long addr, unsigned long next,
215214
return true;
216215
}
217216

218-
static void alloc_init_pud(struct mm_struct *mm, pgd_t *pgd,
219-
unsigned long addr, unsigned long end,
217+
static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end,
220218
phys_addr_t phys, pgprot_t prot,
221219
phys_addr_t (*pgtable_alloc)(void))
222220
{
@@ -257,7 +255,7 @@ static void alloc_init_pud(struct mm_struct *mm, pgd_t *pgd,
257255
}
258256
}
259257
} else {
260-
alloc_init_pmd(mm, pud, addr, next, phys, prot,
258+
alloc_init_pmd(pud, addr, next, phys, prot,
261259
pgtable_alloc);
262260
}
263261
phys += next - addr;
@@ -270,8 +268,7 @@ static void alloc_init_pud(struct mm_struct *mm, pgd_t *pgd,
270268
* Create the page directory entries and any necessary page tables for the
271269
* mapping specified by 'md'.
272270
*/
273-
static void __create_mapping(struct mm_struct *mm, pgd_t *pgd,
274-
phys_addr_t phys, unsigned long virt,
271+
static void init_pgd(pgd_t *pgd, phys_addr_t phys, unsigned long virt,
275272
phys_addr_t size, pgprot_t prot,
276273
phys_addr_t (*pgtable_alloc)(void))
277274
{
@@ -283,7 +280,7 @@ static void __create_mapping(struct mm_struct *mm, pgd_t *pgd,
283280
end = addr + length;
284281
do {
285282
next = pgd_addr_end(addr, end);
286-
alloc_init_pud(mm, pgd, addr, next, phys, prot, pgtable_alloc);
283+
alloc_init_pud(pgd, addr, next, phys, prot, pgtable_alloc);
287284
phys += next - addr;
288285
} while (pgd++, addr = next, addr != end);
289286
}
@@ -298,6 +295,14 @@ static phys_addr_t late_pgtable_alloc(void)
298295
return __pa(ptr);
299296
}
300297

298+
static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
299+
unsigned long virt, phys_addr_t size,
300+
pgprot_t prot,
301+
phys_addr_t (*alloc)(void))
302+
{
303+
init_pgd(pgd_offset_raw(pgdir, virt), phys, virt, size, prot, alloc);
304+
}
305+
301306
static void __init create_mapping(phys_addr_t phys, unsigned long virt,
302307
phys_addr_t size, pgprot_t prot)
303308
{
@@ -306,16 +311,16 @@ static void __init create_mapping(phys_addr_t phys, unsigned long virt,
306311
&phys, virt);
307312
return;
308313
}
309-
__create_mapping(&init_mm, pgd_offset_k(virt), phys, virt,
310-
size, prot, early_pgtable_alloc);
314+
__create_pgd_mapping(init_mm.pgd, phys, virt, size, prot,
315+
early_pgtable_alloc);
311316
}
312317

313318
void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys,
314319
unsigned long virt, phys_addr_t size,
315320
pgprot_t prot)
316321
{
317-
__create_mapping(mm, pgd_offset(mm, virt), phys, virt, size, prot,
318-
late_pgtable_alloc);
322+
__create_pgd_mapping(mm->pgd, phys, virt, size, prot,
323+
late_pgtable_alloc);
319324
}
320325

321326
static void create_mapping_late(phys_addr_t phys, unsigned long virt,
@@ -327,8 +332,8 @@ static void create_mapping_late(phys_addr_t phys, unsigned long virt,
327332
return;
328333
}
329334

330-
return __create_mapping(&init_mm, pgd_offset_k(virt),
331-
phys, virt, size, prot, late_pgtable_alloc);
335+
__create_pgd_mapping(init_mm.pgd, phys, virt, size, prot,
336+
late_pgtable_alloc);
332337
}
333338

334339
#ifdef CONFIG_DEBUG_RODATA

0 commit comments

Comments
 (0)