pvmfw: Initialize heap as soon as we enter Rust
In order to have a valid Rust environment as soon as we start executing
compiled code, move the heap initialization to the very first code
executed from pvmfw/.
Test: TH
Change-Id: I0274427bf9e5168c03ce59152d2900141a785328
diff --git a/pvmfw/src/entry.rs b/pvmfw/src/entry.rs
index 8e3e47b..d172474 100644
--- a/pvmfw/src/entry.rs
+++ b/pvmfw/src/entry.rs
@@ -64,6 +64,9 @@
// - can't access non-pvmfw memory (only statically-mapped memory)
// - can't access MMIO (therefore, no logging)
+ // SAFETY - This function should and will only be called once, here.
+ unsafe { heap::init() };
+
match main_wrapper(fdt_address as usize, payload_start as usize, payload_size as usize) {
Ok((entry, bcc)) => jump_to_payload(fdt_address, entry.try_into().unwrap(), bcc),
Err(_) => reboot(), // TODO(b/220071963) propagate the reason back to the host.
@@ -188,9 +191,6 @@
// - only perform logging once the logger has been initialized
// - only access non-pvmfw memory once (and while) it has been mapped
- // SAFETY - This function should and will only be called once, here.
- unsafe { heap::init() };
-
logger::init(LevelFilter::Info).map_err(|_| RebootReason::InternalError)?;
// Use debug!() to avoid printing to the UART if we failed to configure it as only local