From cd57a3addfdaf13f59060bcfd183b703d7a78e72 Mon Sep 17 00:00:00 2001 From: Jiaqi Gao Date: Fri, 10 May 2024 03:51:34 -0400 Subject: [PATCH] td-shim: try to find payload image from two regions As upstream qemu does not support TDVF `payload` section type, try both `Payload` and `LargePayload` region to find the firmware volume that payload image may be packaged in. Signed-off-by: Jiaqi Gao --- td-shim/src/bin/td-shim/main.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/td-shim/src/bin/td-shim/main.rs b/td-shim/src/bin/td-shim/main.rs index 43ed88c1..b8c5f175 100644 --- a/td-shim/src/bin/td-shim/main.rs +++ b/td-shim/src/bin/td-shim/main.rs @@ -218,13 +218,21 @@ fn boot_builtin_payload( acpi_tables: &Vec<&[u8]>, ) { // Get and parse image file from the payload firmware volume. - let fv_buffer = memslice::get_mem_slice(memslice::SliceType::ShimPayload); - let mut payload_bin = fv::get_image_from_fv( - fv_buffer, + let mut payload_bin = if let Some(image) = fv::get_image_from_fv( + memslice::get_mem_slice(memslice::SliceType::ShimPayload), pi::fv::FV_FILETYPE_DXE_CORE, pi::fv::SECTION_PE32, - ) - .expect("Failed to get image file from Firmware Volume"); + ) { + image + } else if let Some(large_image) = fv::get_image_from_fv( + memslice::get_mem_slice(memslice::SliceType::LargePayload), + pi::fv::FV_FILETYPE_DXE_CORE, + pi::fv::SECTION_PE32, + ) { + large_image + } else { + panic!("Failed to find payload image from ") + }; #[cfg(feature = "secure-boot")] {