[kernel][arm64] Delay boot map init
This is a reland on http://fxrev.dev/1212556, which caused a crash in
start-up on sorrel. Previously the call was delayed until
arm64_mmu_early_init(), though it's unclear why that was an issue for
sorrel alone. In any case, it's clear that this call needs to be moved
up to before the periphmap is initialized (which is the last bit of code
directly dependent on the boot map)
We push back arm64_boot_map_init() to platform_early_init(), just
before periphmap initialization. The boot map logic will go away
entirely soon, but until then there is no longer a need to call this in
assembly (as we're no longer setting up mappings in that context).
Bug: 42164859
Change-Id: I42f80479a2b6c7ae2684635a376152074520259b
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1218005
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Fuchsia-Auto-Submit: Joshua Seaton <joshuaseaton@google.com>
Reviewed-by: Travis Geiselbrecht <travisg@google.com>
diff --git a/zircon/kernel/arch/arm64/start.S b/zircon/kernel/arch/arm64/start.S
index 849e8b9..5bad6f9 100644
--- a/zircon/kernel/arch/arm64/start.S
+++ b/zircon/kernel/arch/arm64/start.S
@@ -83,11 +83,6 @@
adr_global tmp, .Lboot_cpu_kstack_end
mov sp, tmp
- // Call into the arm64 boot mapping code to give it a chance to initialize its page tables
- adr_global x0, __executable_start
- sub x0, kernel_vaddr, x0 // compute the delta between virtual and physical addresses
- bl arm64_boot_map_init
-
.Lmmu_on_pc:
isb
diff --git a/zircon/kernel/platform/generic-arm/platform.cc b/zircon/kernel/platform/generic-arm/platform.cc
index 9e6e221..c7d878a 100644
--- a/zircon/kernel/platform/generic-arm/platform.cc
+++ b/zircon/kernel/platform/generic-arm/platform.cc
@@ -351,6 +351,8 @@
// Initialize the PmmChecker now that the cmdline has been parsed.
pmm_checker_init_from_cmdline();
+ arm64_boot_map_init(reinterpret_cast<uintptr_t>(__executable_start) -
+ reinterpret_cast<uintptr_t>(KernelPhysicalLoadAddress()));
for (const memalloc::Range& range : gPhysHandoff->memory.get()) {
if (range.type == memalloc::Type::kPeripheral) {
dprintf(INFO, "ZBI: peripheral range [%#" PRIx64 ", %#" PRIx64 ")\n", range.addr,