Skip to content

tpm: Unconditionally attempt to create AKCert index (#4646) - #5179

Open
Mike Stunes (stunes-ms) wants to merge 2 commits into
microsoft:release/1.8.2607from
stunes-ms:user/mikestunes/tlv2-yellowfield-1.8
Open

Mike Stunes (stunes-ms) wants to merge 2 commits into
microsoft:release/1.8.2607from
stunes-ms:user/mikestunes/tlv2-yellowfield-1.8

Conversation

@stunes-ms

Copy link
Copy Markdown
Contributor

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.

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.
@stunes-ms
Mike Stunes (stunes-ms) requested a review from a team as a code owner November 20, 2026 17:14
Copilot AI balanced review requested due to automatic review settings November 20, 2026 17:14
@github-actions github-actions Bot added the release_1.8.2607 Targets the release/1.8.2607 branch. label Nov 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread vm/devices/tpm/tpm_lib/src/lib.rs Resolved
Comment thread vm/devices/tpm/tpm_device/src/lib.rs Resolved
Copilot AI balanced review requested due to automatic review settings November 20, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment on lines +742 to +745
// 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)

@mebersol Mike Ebersol (mebersol) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One P2 concern about preserving recovery mitigation across seed refresh. Static review of 98df8ca; no local tests run.

Comment on lines +717 to +720
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(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_1.8.2607 Targets the release/1.8.2607 branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants