[RFC PATCH v0 6/6] Temporarily pass the kaslr seed via register X1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ard Biesheuvel <ardb@xxxxxxxxxx>

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(-)

diff --git a/src/main.rs b/src/main.rs
index 81208c18d094..ad12e069372f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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);
     }
 }
 
-- 
2.30.2




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux