init.c (8f3a2b4a96dc014e99e1df327db1450fdbbd5e15) init.c (6262f661ff5d7d6a2613b95d0b7820c60b46b0b5)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2019 Western Digital Corporation or its affiliates.
5 */
6
7#include <linux/init.h>
8#include <linux/mm.h>

--- 389 unchanged lines hidden (view full) ---

398#endif
399
400asmlinkage void __init setup_vm(uintptr_t dtb_pa)
401{
402 uintptr_t va, pa, end_va;
403 uintptr_t load_pa = (uintptr_t)(&_start);
404 uintptr_t load_sz = (uintptr_t)(&_end) - load_pa;
405 uintptr_t map_size = best_map_size(load_pa, MAX_EARLY_MAPPING_SIZE);
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 * Copyright (C) 2019 Western Digital Corporation or its affiliates.
5 */
6
7#include <linux/init.h>
8#include <linux/mm.h>

--- 389 unchanged lines hidden (view full) ---

398#endif
399
400asmlinkage void __init setup_vm(uintptr_t dtb_pa)
401{
402 uintptr_t va, pa, end_va;
403 uintptr_t load_pa = (uintptr_t)(&_start);
404 uintptr_t load_sz = (uintptr_t)(&_end) - load_pa;
405 uintptr_t map_size = best_map_size(load_pa, MAX_EARLY_MAPPING_SIZE);
406#ifndef __PAGETABLE_PMD_FOLDED
407 pmd_t fix_bmap_spmd, fix_bmap_epmd;
408#endif
406
407 va_pa_offset = PAGE_OFFSET - load_pa;
408 pfn_base = PFN_DOWN(load_pa);
409
410 /*
411 * Enforce boot alignment requirements of RV32 and
412 * RV64 by only allowing PMD or PGD mappings.
413 */

--- 37 unchanged lines hidden (view full) ---

451 /* Create two consecutive PGD mappings for FDT early scan */
452 pa = dtb_pa & ~(PGDIR_SIZE - 1);
453 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA,
454 pa, PGDIR_SIZE, PAGE_KERNEL);
455 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA + PGDIR_SIZE,
456 pa + PGDIR_SIZE, PGDIR_SIZE, PAGE_KERNEL);
457 dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PGDIR_SIZE - 1));
458 dtb_early_pa = dtb_pa;
409
410 va_pa_offset = PAGE_OFFSET - load_pa;
411 pfn_base = PFN_DOWN(load_pa);
412
413 /*
414 * Enforce boot alignment requirements of RV32 and
415 * RV64 by only allowing PMD or PGD mappings.
416 */

--- 37 unchanged lines hidden (view full) ---

454 /* Create two consecutive PGD mappings for FDT early scan */
455 pa = dtb_pa & ~(PGDIR_SIZE - 1);
456 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA,
457 pa, PGDIR_SIZE, PAGE_KERNEL);
458 create_pgd_mapping(early_pg_dir, DTB_EARLY_BASE_VA + PGDIR_SIZE,
459 pa + PGDIR_SIZE, PGDIR_SIZE, PAGE_KERNEL);
460 dtb_early_va = (void *)DTB_EARLY_BASE_VA + (dtb_pa & (PGDIR_SIZE - 1));
461 dtb_early_pa = dtb_pa;
462
463 /*
464 * Bootime fixmap only can handle PMD_SIZE mapping. Thus, boot-ioremap
465 * range can not span multiple pmds.
466 */
467 BUILD_BUG_ON((__fix_to_virt(FIX_BTMAP_BEGIN) >> PMD_SHIFT)
468 != (__fix_to_virt(FIX_BTMAP_END) >> PMD_SHIFT));
469
470#ifndef __PAGETABLE_PMD_FOLDED
471 /*
472 * Early ioremap fixmap is already created as it lies within first 2MB
473 * of fixmap region. We always map PMD_SIZE. Thus, both FIX_BTMAP_END
474 * FIX_BTMAP_BEGIN should lie in the same pmd. Verify that and warn
475 * the user if not.
476 */
477 fix_bmap_spmd = fixmap_pmd[pmd_index(__fix_to_virt(FIX_BTMAP_BEGIN))];
478 fix_bmap_epmd = fixmap_pmd[pmd_index(__fix_to_virt(FIX_BTMAP_END))];
479 if (pmd_val(fix_bmap_spmd) != pmd_val(fix_bmap_epmd)) {
480 WARN_ON(1);
481 pr_warn("fixmap btmap start [%08lx] != end [%08lx]\n",
482 pmd_val(fix_bmap_spmd), pmd_val(fix_bmap_epmd));
483 pr_warn("fix_to_virt(FIX_BTMAP_BEGIN): %08lx\n",
484 fix_to_virt(FIX_BTMAP_BEGIN));
485 pr_warn("fix_to_virt(FIX_BTMAP_END): %08lx\n",
486 fix_to_virt(FIX_BTMAP_END));
487
488 pr_warn("FIX_BTMAP_END: %d\n", FIX_BTMAP_END);
489 pr_warn("FIX_BTMAP_BEGIN: %d\n", FIX_BTMAP_BEGIN);
490 }
491#endif
459}
460
461static void __init setup_vm_final(void)
462{
463 uintptr_t va, map_size;
464 phys_addr_t pa, start, end;
465 struct memblock_region *reg;
466

--- 117 unchanged lines hidden ---
492}
493
494static void __init setup_vm_final(void)
495{
496 uintptr_t va, map_size;
497 phys_addr_t pa, start, end;
498 struct memblock_region *reg;
499

--- 117 unchanged lines hidden ---