Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 4 additions & 23 deletions src/migtd/src/migration/servtd_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,11 @@
read_field(TDCS_FIELD_SERVTD_INFO_HASH, 8, &mut cur_servtd_info_hash)?;
read_field(TDCS_FIELD_SERVTD_ATTR, 8, &mut cur_servtd_attr)?;

// Verify CURR_SERVTD_ATTR matches both the hardcoded expected value and the
// INIT_ATTR from MigTDData's TDINFO per GHCI 1.5.
// Verify CURR_SERVTD_ATTR matches the hardcoded expected value per GHCI 1.5.
let actual_attr = u64::from_le_bytes(cur_servtd_attr);
let expected_init_attr = u64::from_le_bytes(init_attr);
if actual_attr != EXPECTED_SERVTD_ATTR {
log::error!(
"SERVTD_ATTR mismatch vs hardcoded: expected {EXPECTED_SERVTD_ATTR:#x}, got {actual_attr:#x}"
);
return Err(MigrationResult::InvalidParameter);
}
if actual_attr != expected_init_attr {
log::error!(
"SERVTD_ATTR mismatch vs INIT_ATTR: expected {expected_init_attr:#x}, got {actual_attr:#x}"
"SERVTD_ATTR mismatch: expected {EXPECTED_SERVTD_ATTR:#x}, got {actual_attr:#x}"
);
return Err(MigrationResult::InvalidParameter);
}
Expand All @@ -154,8 +146,7 @@
})
}

/// Verify that CURR_SERVTD_ATTR of the target TD matches both the hardcoded
/// expected value and the INIT_ATTR from MigTDData's TDINFO.
/// Verify that CURR_SERVTD_ATTR of the target TD matches the hardcoded expected value.
///
/// Per GHCI 1.5: Both source and destination MigTDs must verify this before
/// any TDG.SERVTD.WR operations (mig_dec_key, mig_version).
Expand All @@ -167,17 +158,7 @@
let actual_attr = result.content;
if actual_attr != EXPECTED_SERVTD_ATTR {
log::error!(
"SERVTD_ATTR mismatch vs hardcoded: expected {EXPECTED_SERVTD_ATTR:#x}, got {actual_attr:#x}"
);
return Err(MigrationResult::InvalidParameter);
}

let init_result =
tdcall_servtd_rd(binding_handle, TDCS_FIELD_SERVTD_INIT_ATTR, target_td_uuid)?;
let expected_init_attr = init_result.content;
if actual_attr != expected_init_attr {
log::error!(
"SERVTD_ATTR mismatch vs INIT_ATTR: expected {expected_init_attr:#x}, got {actual_attr:#x}"
"SERVTD_ATTR mismatch: expected {EXPECTED_SERVTD_ATTR:#x}, got {actual_attr:#x}"
);
return Err(MigrationResult::InvalidParameter);
}
Expand All @@ -202,7 +183,7 @@
}

mod test {
use super::ServtdExt;

Check warning on line 186 in src/migtd/src/migration/servtd_ext.rs

View workflow job for this annotation

GitHub Actions / Format

unused import: `super::ServtdExt`

#[test]
fn test_structure_sizes() {
Expand Down
Loading