Skip to content

Commit

Permalink
Merge pull request #388 from nicholasbishop/bishop-update-uefi-031
Browse files Browse the repository at this point in the history
chore(deps): update uefi to 0.31.0
  • Loading branch information
RaitoBezarius authored Oct 1, 2024
2 parents e7bd94e + 386df64 commit e2365a1
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 32 deletions.
12 changes: 6 additions & 6 deletions rust/uefi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/uefi/linux-bootloader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repository = "https://github.com/nix-community/lanzaboote/"
rust-version = "1.68"

[dependencies]
uefi = { version = "0.28.0", default-features = false, features = [ "alloc", "global_allocator" ] }
uefi = { version = "0.31.0", default-features = false, features = [ "alloc", "global_allocator" ] }
# Update blocked by #237
goblin = { version = "=0.6.1", default-features = false, features = [ "pe64", "alloc" ]}
bitflags = "2.5.0"
Expand Down
21 changes: 5 additions & 16 deletions rust/uefi/linux-bootloader/src/tpm.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use alloc::{vec, vec::Vec};
use core::mem::{self, MaybeUninit};
use alloc::vec::Vec;
use log::warn;
use uefi::{
prelude::BootServices,
proto::tcg::{v2, EventType, PcrIndex},
table::boot::ScopedProtocol,
ResultExt,
};

fn open_capable_tpm2(boot_services: &BootServices) -> uefi::Result<ScopedProtocol<v2::Tcg>> {
Expand Down Expand Up @@ -50,21 +50,10 @@ pub fn tpm_log_event_ascii(
.flat_map(|c| c.to_le_bytes())
.collect::<Vec<_>>();

let required_size = mem::size_of::<u32>()
// EventHeader is private…
+ mem::size_of::<u32>() + mem::size_of::<u16>() + mem::size_of::<PcrIndex>() + mem::size_of::<EventType>()
+ description_encoded.len();

let mut event_buffer = vec![MaybeUninit::<u8>::uninit(); required_size];

let event = v2::PcrEventInputs::new_in_buffer(
event_buffer.as_mut_slice(),
pcr_index,
EventType::IPL,
&description_encoded,
)?;
let event = v2::PcrEventInputs::new_in_box(pcr_index, EventType::IPL, &description_encoded)
.discard_errdata()?;
// FIXME: what do we want as flags here?
tpm2.hash_log_extend_event(Default::default(), buffer, event)?;
tpm2.hash_log_extend_event(Default::default(), buffer, &event)?;
}

Ok(true)
Expand Down
2 changes: 1 addition & 1 deletion rust/uefi/stub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
publish = false

[dependencies]
uefi = { version = "0.28.0", default-features = false, features = [ "alloc", "global_allocator", "panic_handler", "logger" ] }
uefi = { version = "0.31.0", default-features = false, features = [ "alloc", "global_allocator", "panic_handler", "logger" ] }
# Even in debug builds, we don't enable the debug logs, because they generate a lot of spam from goblin.
log = { version = "0.4.21", default-features = false, features = [ "max_level_info", "release_max_level_warn" ]}
# Use software implementation because the UEFI target seems to need it.
Expand Down
4 changes: 1 addition & 3 deletions rust/uefi/stub/src/fat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ impl EmbeddedConfiguration {

pub fn boot_linux(
handle: Handle,
mut system_table: SystemTable<Boot>,
system_table: SystemTable<Boot>,
dynamic_initrds: Vec<Vec<u8>>,
) -> Status {
uefi::helpers::init(&mut system_table).unwrap();

// SAFETY: We get a slice that represents our currently running
// image and then parse the PE data structures from it. This is
// safe, because we don't touch any data in the data sections that
Expand Down
4 changes: 2 additions & 2 deletions rust/uefi/stub/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fn print_logo() {
}

#[entry]
fn main(handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
uefi::helpers::init(&mut system_table).unwrap();
fn main(handle: Handle, system_table: SystemTable<Boot>) -> Status {
uefi::helpers::init().unwrap();

print_logo();

Expand Down
4 changes: 1 addition & 3 deletions rust/uefi/stub/src/thin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ fn check_hash(data: &[u8], expected_hash: Hash, name: &str, secure_boot: bool) -

pub fn boot_linux(
handle: Handle,
mut system_table: SystemTable<Boot>,
system_table: SystemTable<Boot>,
dynamic_initrds: Vec<Vec<u8>>,
) -> uefi::Result<()> {
uefi::helpers::init(&mut system_table).unwrap();

// SAFETY: We get a slice that represents our currently running
// image and then parse the PE data structures from it. This is
// safe, because we don't touch any data in the data sections that
Expand Down

0 comments on commit e2365a1

Please sign in to comment.