Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mark Rutland and committed by
Catalin Marinas
11509a30 cdef5f6e

+19 -14
+19 -14
arch/arm64/mm/mmu.c
··· 146 146 } while (pmd++, i++, i < PTRS_PER_PMD); 147 147 } 148 148 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, 151 150 phys_addr_t phys, pgprot_t prot, 152 151 phys_addr_t (*pgtable_alloc)(void)) 153 152 { ··· 214 215 return true; 215 216 } 216 217 217 - static void alloc_init_pud(struct mm_struct *mm, pgd_t *pgd, 218 - unsigned long addr, unsigned long end, 218 + static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end, 219 219 phys_addr_t phys, pgprot_t prot, 220 220 phys_addr_t (*pgtable_alloc)(void)) 221 221 { ··· 255 257 } 256 258 } 257 259 } else { 258 - alloc_init_pmd(mm, pud, addr, next, phys, prot, 260 + alloc_init_pmd(pud, addr, next, phys, prot, 259 261 pgtable_alloc); 260 262 } 261 263 phys += next - addr; ··· 268 270 * Create the page directory entries and any necessary page tables for the 269 271 * mapping specified by 'md'. 270 272 */ 271 - static void __create_mapping(struct mm_struct *mm, pgd_t *pgd, 272 - phys_addr_t phys, unsigned long virt, 273 + static void init_pgd(pgd_t *pgd, phys_addr_t phys, unsigned long virt, 273 274 phys_addr_t size, pgprot_t prot, 274 275 phys_addr_t (*pgtable_alloc)(void)) 275 276 { ··· 288 291 end = addr + length; 289 292 do { 290 293 next = pgd_addr_end(addr, end); 291 - alloc_init_pud(mm, pgd, addr, next, phys, prot, pgtable_alloc); 294 + alloc_init_pud(pgd, addr, next, phys, prot, pgtable_alloc); 292 295 phys += next - addr; 293 296 } while (pgd++, addr = next, addr != end); 294 297 } ··· 303 306 return __pa(ptr); 304 307 } 305 308 309 + static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, 310 + unsigned long virt, phys_addr_t size, 311 + pgprot_t prot, 312 + phys_addr_t (*alloc)(void)) 313 + { 314 + init_pgd(pgd_offset_raw(pgdir, virt), phys, virt, size, prot, alloc); 315 + } 316 + 306 317 static void __init create_mapping(phys_addr_t phys, unsigned long virt, 307 318 phys_addr_t size, pgprot_t prot) 308 319 { ··· 319 314 &phys, virt); 320 315 return; 321 316 } 322 - __create_mapping(&init_mm, pgd_offset_k(virt), phys, virt, 323 - size, prot, early_pgtable_alloc); 317 + __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, 318 + early_pgtable_alloc); 324 319 } 325 320 326 321 void __init create_pgd_mapping(struct mm_struct *mm, phys_addr_t phys, 327 322 unsigned long virt, phys_addr_t size, 328 323 pgprot_t prot) 329 324 { 330 - __create_mapping(mm, pgd_offset(mm, virt), phys, virt, size, prot, 331 - late_pgtable_alloc); 325 + __create_pgd_mapping(mm->pgd, phys, virt, size, prot, 326 + late_pgtable_alloc); 332 327 } 333 328 334 329 static void create_mapping_late(phys_addr_t phys, unsigned long virt, ··· 340 335 return; 341 336 } 342 337 343 - return __create_mapping(&init_mm, pgd_offset_k(virt), 344 - phys, virt, size, prot, late_pgtable_alloc); 338 + __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, 339 + late_pgtable_alloc); 345 340 } 346 341 347 342 #ifdef CONFIG_DEBUG_RODATA