Skip to content

Commit fc0fa3f

Browse files
authored
igvm: Update SevVmsa structure definition. Pad to full 4K. (#109)
Fixes #108 - Updates SevVmsa with documented VMSA fields and extends structure to 4K page size.
1 parent eaaf6a2 commit fc0fa3f

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

igvm/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,14 +1860,10 @@ impl IgvmDirectiveHeader {
18601860
.and_then(|x| x.get(..PAGE_SIZE_4K as usize))
18611861
.ok_or(BinaryHeaderError::InvalidDataSize)?;
18621862

1863-
// Copy the VMSA bytes into the VMSA, and validate the remaining bytes are 0.
1863+
// Copy the VMSA bytes into the VMSA.
18641864
// todo: zerocopy: as of 0.8, can recover from allocation failure
18651865
let mut vmsa = SevVmsa::new_box_zeroed().unwrap();
1866-
let (vmsa_slice, remaining) = data.split_at(size_of::<SevVmsa>());
1867-
vmsa.as_mut_bytes().copy_from_slice(vmsa_slice);
1868-
if remaining.iter().any(|b| *b != 0) {
1869-
return Err(BinaryHeaderError::InvalidVmsa);
1870-
}
1866+
vmsa.as_mut_bytes().copy_from_slice(data);
18711867

18721868
IgvmDirectiveHeader::SnpVpContext {
18731869
gpa: header.gpa.into(),

igvm/src/snp_defs.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,4 +324,7 @@ pub struct SevVmsa {
324324

325325
// YMM high registers
326326
pub ymm_registers: [SevXmmRegister; 16],
327+
328+
// Pad to 4KB
329+
pub vmsa_padding: [u8; 2448],
327330
}

0 commit comments

Comments
 (0)