openhcl: persist trusted host certification evidence#3978
openhcl: persist trusted host certification evidence#3978harshvirMangla wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c6d204c3-77b3-451b-ad13-9c41472fc091
|
@harshvirMangla please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
This PR adds opt-in “Trusted Host Certification” support to the OpenHCL vTPM AK certificate provisioning flow by negotiating the capability via IGVM attestation, parsing a wrapped response that includes both an AK certificate and host-certification evidence, and persisting both pieces into TPM NV indices with appropriate boot/renewal behavior.
Changes:
- Introduces a new
HostCertifiedAK cert mode and plumbs an opt-in enablement bit/config through DPS management VTL feature flags and Underhill options. - Extends the IGVM attestation AK cert request/response protocol to optionally carry host-certification evidence (capability bitmap + versioned wrapped response).
- Updates TPM NV allocation/renewal behavior to preserve or refresh the attestation-report NV index depending on AK cert mode, and adds unit tests for host-certified persistence.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vm/devices/tpm/tpm_lib/src/lib.rs | Makes attestation index size public and adds optional preservation of the attestation-report NV index across re-allocation. |
| vm/devices/tpm/tpm_device/src/resolver.rs | Adds resolver support for the new HostCertified AK cert resource variant. |
| vm/devices/tpm/tpm_device/src/lib.rs | Adds host-certified NV write validation + dual-index persistence, updates renewal logic, and adds unit tests/serialization guard. |
| vm/devices/tpm/tpm_device/src/ak_cert.rs | Introduces HostCertified mode, refactors attestation-report behaviors, and changes AK cert request return type to include optional evidence. |
| vm/devices/tpm/tpm_device/Cargo.toml | Adds futures as a dev-dependency for async test locking. |
| vm/devices/tpm_resources/src/lib.rs | Adds HostCertified variant to the TPM AK cert type resource model. |
| vm/devices/get/get_protocol/src/dps_json.rs | Adds tvm_host_certification feature bit and a unit test asserting opt-in bit placement. |
| petri/src/vm/hyperv/powershell.rs | Mirrors the new management VTL feature bit in Hyper-V flag plumbing. |
| openhcl/underhill_core/src/worker.rs | Plumbs host-certification enablement from env/options into DPS and AK cert type selection. |
| openhcl/underhill_core/src/options.rs | Adds HCL_TVM_HOST_CERTIFICATION option/env parsing. |
| openhcl/underhill_core/src/lib.rs | Wires the new option into worker launch configuration. |
| openhcl/underhill_core/src/emuplat/tpm.rs | Adds request-time flag propagation and returns structured AK cert + optional evidence from the host agent response. |
| openhcl/underhill_attestation/src/lib.rs | Re-exports the structured AK cert response type for consumers. |
| openhcl/underhill_attestation/src/igvm_attest/mod.rs | Adds a capability bit to request host-certification evidence and includes it in request generation. |
| openhcl/underhill_attestation/src/igvm_attest/ak_cert.rs | Implements parsing/validation for legacy vs wrapped host-certified AK cert responses and adds coverage tests. |
| openhcl/openhcl_attestation_protocol/src/igvm_attest/get.rs | Defines on-wire structs/constants for host-certification evidence wrapper and capability bit; increases AK cert response buffer size. |
| Cargo.lock | Adds futures to the resolved dependency set due to new dev-dependency usage. |
| if let Some(evidence) = evidence { | ||
| self.tpm_engine_helper | ||
| .write_to_nv_index(auth_value, TPM_NV_INDEX_ATTESTATION_REPORT, evidence) | ||
| .map_err(TpmErrorKind::WriteToNvIndex)?; |
| /// Number of pages required by the response buffer of AK_CERT request | ||
| /// Currently the AK cert request only requires 1 page. | ||
| pub const AK_CERT_RESPONSE_BUFFER_SIZE: usize = PAGE_SIZE; | ||
| pub const AK_CERT_RESPONSE_BUFFER_SIZE: usize = 2 * PAGE_SIZE; |
There was a problem hiding this comment.
I don't think this would work.
There was a problem hiding this comment.
Thanks for flagging this. Could you clarify whether the concern is the one page AK_CERT contract or multi GPA handling in the production transport? I’ll verify that constraint before updating
There was a problem hiding this comment.
It's the hard limit --- we currently only reserve one shared page for AK cert request/response.
|
|
||
| let (response_header, _) = TvmHostCertificationResponseHeader::read_from_prefix(payload) | ||
| .map_err(|_| AkCertError::InvalidHostCertificationResponse)?; | ||
| let response_total_size = usize::try_from(response_header.total_size) |
There was a problem hiding this comment.
Are all these type conversions necessary? Can't const match the same type when possible?
| payload[..size_of::<u32>()] | ||
| .try_into() | ||
| .expect("fixed-size slice"), | ||
| ) != TVM_HOST_CERTIFICATION_RESPONSE_MAGIC |
There was a problem hiding this comment.
I'd recommend putting the new logic into a separate helper function.
|
|
||
| /// Returns true if the attestation report must be preserved across boot. | ||
| pub fn preserves_attestation_report(&self) -> bool { | ||
| matches!(self, TpmAkCertType::HostCertified(_, _)) |
There was a problem hiding this comment.
attestation report is only relevant for HwAttested/SwAttested types.
| TPM_NV_INDEX_AIK_CERT, | ||
| response.ak_cert.len(), | ||
| )?; | ||
| self.validate_host_certification_nv_write( |
There was a problem hiding this comment.
does this feature apply to isolated VMs?
| // Parse the response. Empty response indicates that the host agent is unavailable. | ||
| let response = match result { | ||
| Ok(data) if !data.is_empty() => { | ||
| // Set the renew time if successfully receiving the data. |
There was a problem hiding this comment.
we should preserve the comments if it's just a refactoring.
|
Can you clarify if this feature applies to CVMs? |
Summary
Behavior
Validation
cargo checkpassed for all eight modified crates.cargo clippy --all-targetspassed for all eight modified crates.cargo doc --no-depspassed for all eight modified crates.cargo xtask fmt --fixcompleted successfully.