From 832f09a075364058b836389625bd11ff086e3329 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Wed, 15 Dec 2021 15:10:30 +0100 Subject: [PATCH] vmm: tdx: Insert payload into the HOB If a payload is found in the TDVF section, and after it's been copied to the guest memory, make sure to create the corresponding TdPayload structure and insert it through the HOB. Signed-off-by: Jiaqi Gao Signed-off-by: Sebastien Boeuf --- vmm/src/vm.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 68e751254..509e3b14c 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -1764,6 +1764,7 @@ impl Vm { // is safe to copy from the TDVF file into it. let guest_memory = self.memory_manager.lock().as_ref().unwrap().guest_memory(); let mem = guest_memory.memory(); + let mut payload_info = None; let mut hob_offset = None; for section in sections { info!("Populating TDVF Section: {:x?}", section); @@ -1823,6 +1824,13 @@ impl Vm { payload_size as usize, ) .unwrap(); + + // Create the payload info that will be inserted into + // the HOB. + payload_info = Some(PayloadInfo { + image_type: PayloadImageType::BzImage, + entry_point: section.address, + }); } } TdvfSectionType::PayloadParam => { @@ -1922,6 +1930,12 @@ impl Vm { .map_err(Error::PopulateHob)?; } + // If a payload info has been created, let's insert it into the HOB. + if let Some(payload_info) = payload_info { + hob.add_payload(&mem, payload_info) + .map_err(Error::PopulateHob)?; + } + hob.finish(&mem).map_err(Error::PopulateHob)?; Ok(hob_offset)