vboot_api_kernel: check TPM mode on normal boot

When booting into Alt OS legacy mode, we plan to disable TPM
before handing off control to the OS.  On a warm reboot back
to Chrome OS, we must check the TPM mode.  If it is disabled,
a hard reboot should be triggered to restore TPM functionality.

Add this check to VbBootNormal.  Only accept the TPM mode
VB2_TPM_MODE_ENABLED_TENTATIVE (0).

BUG=b:119203340
TEST=compile, flash, and boot eve
TEST=run `gsctool -a -m disable`
     validate that the following messages show up on boot:
       Calling VbSelectAndLoadKernel().
       VbCheckTPM: Checking if TPM needs resetting (TPM_MODE)
       cr50 TPM 2.0 (i2c 0x50 id 0x28)
       tpm_internal_mode: Invalid header code: 1286
       VbCheckTPM: TPM encountered some error; reset Cr50
       tpm_internal_cr50_reset: Asking Cr50 to reset after 500 ms
       VbCheckTPM: Shut down AP and wait for Cr50 reset
       VbSelectAndLoadKernel: Returning 65549
       Powering off.
       Exiting depthcharge with code 2 at timestamp: 6603861

Change-Id: If6097aa67eb135e24c735bd7948ec25091bed3be
Reviewed-on: https://chromium-review.googlesource.com/c/1354140
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Namyoon Woo <namyoon@chromium.org>
Commit-Queue: Joel Kitching <kitching@chromium.org>
1 file changed