From d48a55ef347f4384558d991ac9fec8f0b6d1a6e0 Mon Sep 17 00:00:00 2001 From: RARelph <44270374+RARelph@users.noreply.github.com> Date: Tue, 3 Mar 2026 10:15:23 -0600 Subject: [PATCH] igvm: Pad SevVmsa to 4K. Renders the check for non-zero bytes past end of SevVmsa useless. --- igvm/src/lib.rs | 8 ++------ igvm/src/snp_defs.rs | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/igvm/src/lib.rs b/igvm/src/lib.rs index 9a52865..1398cce 100644 --- a/igvm/src/lib.rs +++ b/igvm/src/lib.rs @@ -1860,14 +1860,10 @@ impl IgvmDirectiveHeader { .and_then(|x| x.get(..PAGE_SIZE_4K as usize)) .ok_or(BinaryHeaderError::InvalidDataSize)?; - // Copy the VMSA bytes into the VMSA, and validate the remaining bytes are 0. + // Copy the VMSA bytes into the VMSA. // todo: zerocopy: as of 0.8, can recover from allocation failure let mut vmsa = SevVmsa::new_box_zeroed().unwrap(); - let (vmsa_slice, remaining) = data.split_at(size_of::()); - vmsa.as_mut_bytes().copy_from_slice(vmsa_slice); - if remaining.iter().any(|b| *b != 0) { - return Err(BinaryHeaderError::InvalidVmsa); - } + vmsa.as_mut_bytes().copy_from_slice(data); IgvmDirectiveHeader::SnpVpContext { gpa: header.gpa.into(), diff --git a/igvm/src/snp_defs.rs b/igvm/src/snp_defs.rs index 7f75957..bd67ac7 100644 --- a/igvm/src/snp_defs.rs +++ b/igvm/src/snp_defs.rs @@ -324,4 +324,7 @@ pub struct SevVmsa { // YMM high registers pub ymm_registers: [SevXmmRegister; 16], + + // Pad to 4KB + pub vmsa_padding: [u8; 2448], }