From: ardb@kernel.org
To: linux-efi@vger.kernel.org
Cc: Ard Biesheuvel <ardb@google.com>, Marc Zyngier <maz@kernel.org>,
Will Deacon <will@kernel.org>,
Quentin Perret <qperret@google.com>,
David Brazdil <dbrazdil@google.com>,
Fuad Tabba <tabba@google.com>, Kees Cook <keescook@chromium.org>
Subject: [RFC PATCH v0 2/6] Add DTB processing
Date: Mon, 14 Mar 2022 09:26:40 +0100 [thread overview]
Message-ID: <20220314082644.3436071-3-ardb@kernel.org> (raw)
In-Reply-To: <20220314082644.3436071-1-ardb@kernel.org>
From: Ard Biesheuvel <ardb@google.com>
Add handling of the QEMU provided DTB, which we will need to consult to
find the DRAM layout and the fwcfg device. Initially, just dump the
/chosen/bootargs only, if one is provided.
---
Cargo.lock | 7 +++++++
Cargo.toml | 1 +
src/main.rs | 10 ++++++++++
3 files changed, 18 insertions(+)
diff --git a/Cargo.lock b/Cargo.lock
index 617acc9c6086..2750d4a3937c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -12,12 +12,19 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
name = "efilite"
version = "0.1.0"
dependencies = [
+ "fdt",
"linked_list_allocator",
"log",
"mmio",
"rlibc",
]
+[[package]]
+name = "fdt"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b643857cf70949306b81d7e92cb9d47add673868edac9863c4a49c42feaf3f1e"
+
[[package]]
name = "linked_list_allocator"
version = "0.9.1"
diff --git a/Cargo.toml b/Cargo.toml
index 9bc2b39f6e9b..b073376d9e16 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,7 @@ rlibc = "1.0.0"
linked_list_allocator = "0.9.1"
log = "0.4.14"
mmio = "2.1.0"
+fdt = "0.1.3"
[profile.dev]
panic = "abort"
diff --git a/src/main.rs b/src/main.rs
index 698e9c5724bf..6d880732b469 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,6 +13,10 @@ use log::{error, info};
#[global_allocator]
pub static ALLOCATOR: LockedHeap = LockedHeap::empty();
+extern "C" {
+ static _dtb: u8;
+}
+
#[no_mangle]
extern "C" fn efilite_main(base: usize, mapped: usize, used: usize) {
#[cfg(debug_assertions)]
@@ -28,6 +32,12 @@ extern "C" fn efilite_main(base: usize, mapped: usize, used: usize) {
unsafe {
ALLOCATOR.lock().init(base + used, mapped - used);
}
+
+ let fdt = unsafe { fdt::Fdt::from_ptr(&_dtb).expect("Failed to parse device tree") };
+
+ fdt.chosen()
+ .bootargs()
+ .map(|args| info!("/chosen/bootargs: {:?}\n", args));
}
#[no_mangle]
--
2.30.2
next prev parent reply other threads:[~2022-03-14 8:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 8:26 [RFC PATCH v0 0/6] Minimal Linux/arm64 VM firmware (written in Rust) ardb
2022-03-14 8:26 ` [RFC PATCH v0 1/6] Implement a bare metal Rust runtime on top of QEMU's mach-virt ardb
2022-03-14 8:26 ` ardb [this message]
2022-03-14 8:26 ` [RFC PATCH v0 3/6] Add paging code to manage the full ID map ardb
2022-03-14 8:26 ` [RFC PATCH v0 4/6] Discover QEMU fwcfg device and use it to load the kernel ardb
2022-03-14 8:26 ` [RFC PATCH v0 5/6] Remap code section of loaded kernel and boot it ardb
2022-03-14 8:26 ` [RFC PATCH v0 6/6] Temporarily pass the kaslr seed via register X1 ardb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220314082644.3436071-3-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=ardb@google.com \
--cc=dbrazdil@google.com \
--cc=keescook@chromium.org \
--cc=linux-efi@vger.kernel.org \
--cc=maz@kernel.org \
--cc=qperret@google.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.