@@ -118,9 +118,21 @@ extern "C" fn efilite_main(base: usize, mapped: usize, used: usize) {
paging::map_range(LOAD_ADDRESS as u64, code_size, nor_flags);
paging::activate();
+ // TODO remove this once we boot via the EFI entry point
+ // passing the kaslr seed via x1 is part of the stub's internal boot protocol
+ let kaslr_seed: u64 = {
+ let mut seed: u64 = 0;
+ let chosen = fdt.find_node("/chosen").unwrap();
+ if let Some(prop) = chosen.property("kaslr-seed") {
+ seed = prop.as_usize().unwrap() as _;
+ info!("/chosen/kaslr-seed: {:#x}\n", seed);
+ };
+ seed
+ };
+
unsafe {
let entrypoint: EntryFn = core::mem::transmute(LOAD_ADDRESS);
- entrypoint(&_dtb as *const _, 0, 0, 0);
+ entrypoint(&_dtb as *const _, kaslr_seed, 0, 0);
}
}
From: Ard Biesheuvel <ardb@google.com> Currently, we boot the kernel via its 'bare metal' entry point, rather than via the EFI entry point, as we haven't implemented EFI yet. Booting with the MMU enabled requires that the KASLR seed is known before setting up the page tables, as we will do so only once, rather than twice when reading the seed from the DT. For this reason, the EFI stub passes the KASLR seed via register X1 as well as the kaslr-seed property in chosen, and those values need to be in sync. So as long as we are not using the EFI entry point, pass the DT's kaslr-seed value via register X1 at boot. --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)