SecurityPkg: Fix Tcg2SubmitCommand in TPM field upgrade scenario #11750
+51
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fix Tcg2SubmitCommand in TPM field upgrade scenario.
There's a bug that after the device was forced shut down during the tpm firmware update process,
then the TPM will stay in field upgrade mode and refuse to work properly. This will block TPM startup and cause the device to bootloop.
Now in the TCG_DXE_DATA struct we don’t have a flag to indicate the current TPM mode, and we will simply treat the upper
Scenario with this DEVICE_ERROR and set the TPMPresentFlag to FALSE.
Later in Tcg2SubmitCommand we will just return DEVICE_ERROR and skip the actual TPM recovery.
We should have an extra flag that check for the TPM response code and if it's TPM_RC_UPGRADE, we knew the device is in field upgrade mode and should continue the workflow.
After I commented out the TpmPresentFlag check, the device will be able to continue with the TPM recovery using the data stashed in persisted blob and finish the TPM capsule update successfully, and I can boot to the OS with TPM working.
We should only return EFI_DEVICE_ERROR when both TPMPresentFlag and TpmUpdateFlag are false.
The field upgrade is part of TCG spec, and the capsule update/recovery is part of UEFI spec.
Make this PR to bring in the fix for this corner case.
How This Was Tested
Tested with a device running dTPM, force shutdown the device during TPM capsule update, and in the reboot it can go into tpm recovery flow and update the TPM firmware correctly. Checked in Device Manager, version has been updated.