Repository navigation
tpm: Unconditionally attempt to create AKCert index (#4646) - #5179
Mike Stunes (stunes-ms) wants to merge 2 commits into
Conversation
OpenHCL needs to handle TLv2 yellowfield VMs (TLv2 VMs created from existing TLv1 artifacts). OpenHCL will refresh the TPM seeds and delete the existing AKCert, leaving the VM with no AKCert. The proposed method of handling this scenario is for OpenHCL to make a best-effort attempt to create a new AKCert index and handle AKCert renewal. OpenHCL will now create an AKCert index in the refresh scenario if the TPM does not contain a TPM-corruption mitigation marker. If the creation fails, OpenHCL will proceed without a certificate; this is existing behavior.
There was a problem hiding this comment.
🟡 Changes recommended
TPM certificate renewal can stop on the next non-refresh boot because newly provisioned indices lose platform ownership or uninitialized allocations are deleted without recreation.
2 open issues
What changed in this PR
This PR extends OpenHCL’s TPM initialization to attempt AKCert provisioning after seed refresh for TLv2 VMs created from existing TLv1 artifacts, while respecting corruption-mitigation markers.
Changes:
- Attempts missing AKCert index creation during eligible seed refreshes and enables renewal for platform-defined indices.
- Tracks whether TPM state recovery occurred and uses it to gate mitigation-marker writes.
- Adds tests covering index creation across storage sizes, refresh settings, and marker states.
| File | Description |
|---|---|
vm/devices/tpm/tpm_lib/tests/common/mod.rs |
Supplies recovery status in allocation tests. |
vm/devices/tpm/tpm_lib/src/lib.rs |
Adds recovery status and gates mitigation-marker writes. |
vm/devices/tpm/tpm_device/src/recover.rs |
Reports whether recovery modified the TPM state. |
vm/devices/tpm/tpm_device/src/lib.rs |
Updates AKCert creation, deletion, and renewal policies; adds scenario tests. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The seed-refresh recovery path can delete a platform-owned AKCert before recording the mitigation marker or applying the certificate-size mitigation, leaving the recovered TPM unmarked and requiring a fix plus a regression test.
1 open issue
2 resolved since last review
Review effort: Balanced
| // Delete any existing AKCert after refreshing seeds. | ||
| if let Err(e) = self | ||
| .tpm_engine_helper | ||
| .nv_undefine_space(TPM20_RH_PLATFORM, TPM_NV_INDEX_AIK_CERT) |
Mike Ebersol (mebersol)
left a comment
There was a problem hiding this comment.
One P2 concern about preserving recovery mitigation across seed refresh. Static review of 98df8ca; no local tests run.
| let create_if_missing = large_vtpm_blob | ||
| || (self.refresh_tpm_seeds | ||
| && match self.tpm_engine_helper.find_nv_index(TPM_NV_INDEX_MITIGATED) { | ||
| Ok(index) => index.is_none(), |
There was a problem hiding this comment.
P2: Preserve the recovery mitigation across seed refresh.
For an unmarked corrupt 16 KiB blob, recover_blob can return recovered = true, but this condition still sets create_if_missing = true when seeds are refreshed. ChangePPS clears platform-owned NV indices, including the old AKCert, before allocate_guest_attestation_nv_indices runs. The allocator therefore takes AkCertType::None and attempts a fresh 4 KiB allocation; its only mitigation-marker write is in AkCertType::PlatformOwned, so the recovered TPM is left unmarked. The explicit AKCert deletion is not the only cause: seed refresh already removes the platform index.
Please include current-boot recovery in the creation decision and preserve the recovery mitigation after seed refresh. A regression test combining corrupt-blob recovery with seed refresh, followed by persist/reload, would cover the missing path. The new matrix currently exercises healthy blobs and pre-existing markers only.


OpenHCL needs to handle TLv2 yellowfield VMs (TLv2 VMs created from existing TLv1 artifacts). OpenHCL will refresh the TPM seeds and delete the existing AKCert, leaving the VM with no AKCert. The proposed method of handling this scenario is for OpenHCL to make a best-effort attempt to create a new AKCert index and handle AKCert renewal.
OpenHCL will now create an AKCert index in the refresh scenario if the TPM does not contain a TPM-corruption mitigation marker. If the creation fails, OpenHCL will proceed without a certificate; this is existing behavior.