vmbase: Initialize heap in rust_entry
Initialize the heap as we enter Rust so that any code that follows can
make use of alloc, preventing bugs such as aosp/2567870 where client
code used the heap before initializing it.
Test: TH
Change-Id: Ibe6629a22cd828d8b9c6418b91b5971dbbeb4c3d
diff --git a/vmbase/src/entry.rs b/vmbase/src/entry.rs
index 8cdfe77..df0bb7c 100644
--- a/vmbase/src/entry.rs
+++ b/vmbase/src/entry.rs
@@ -14,11 +14,13 @@
//! Rust entry point.
-use crate::{console, power::shutdown};
+use crate::{console, heap, power::shutdown};
/// This is the entry point to the Rust code, called from the binary entry point in `entry.S`.
#[no_mangle]
extern "C" fn rust_entry(x0: u64, x1: u64, x2: u64, x3: u64) -> ! {
+ // SAFETY - Only called once, from here, and inaccessible to client code.
+ unsafe { heap::init() };
console::init();
unsafe {
main(x0, x1, x2, x3);