Skip to content

Commit

Permalink
td-shim: subtract large payload size for metadata offset
Browse files Browse the repository at this point in the history
The metadata offset at the `end - 0x20`of image is the offset of the
metadata from the beginning of the file, so subtract the large payload
size when calculating metadata offset.

Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
  • Loading branch information
gaojiaqi7 committed May 10, 2024
1 parent bc5764e commit 5b53096
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions td-shim/src/bin/td-shim/shim_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use core::mem::size_of;
use core::str::FromStr;
use log::error;
use scroll::{Pread, Pwrite};
use td_layout::build_time::{TD_SHIM_FIRMWARE_BASE, TD_SHIM_FIRMWARE_SIZE};
use td_layout::build_time::{
TD_SHIM_FIRMWARE_BASE, TD_SHIM_FIRMWARE_SIZE, TD_SHIM_LARGE_PAYLOAD_SIZE,
};
use td_layout::memslice;
use td_shim::speculation_barrier;
use td_shim::{
Expand Down Expand Up @@ -35,7 +37,8 @@ impl BootTimeStatic {
// Validate the metadata and get the basic infomation from
// it if any
pub fn new() -> Option<Self> {
let metadata_offset = unsafe { *((u32::MAX - TDX_METADATA_OFFSET + 1) as *const u32) };
let metadata_offset = unsafe { *((u32::MAX - TDX_METADATA_OFFSET + 1) as *const u32) }
- TD_SHIM_LARGE_PAYLOAD_SIZE;
if metadata_offset >= TD_SHIM_FIRMWARE_SIZE
|| metadata_offset < size_of::<Guid>() as u32
|| metadata_offset > TD_SHIM_FIRMWARE_SIZE - size_of::<TdxMetadataDescriptor>() as u32
Expand Down

0 comments on commit 5b53096

Please sign in to comment.