Skip to content

Commit

Permalink
efi_loader: startup the tpm device when installing the protocol
Browse files Browse the repository at this point in the history
Due to U-Boot's lazy binding mentality the TPM is probed but not properly
initialized.  The user can startup the device from the command line
e.g 'tpm2 startup TPM2_SU_CLEAR'.  However we can initialize the TPM during
the TCG protocol installation,  which is easier to use overall.

Signed-off-by: Ilias Apalodimas <[email protected]>
Reviewed-by: Heinrich Schuchardt <[email protected]>
  • Loading branch information
apalos authored and xypron committed Nov 20, 2021
1 parent 5ba0397 commit d6b55a4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/efi_loader/efi_tcg2.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <smbios.h>
#include <version_string.h>
#include <tpm-v2.h>
#include <tpm_api.h>
#include <u-boot/hash-checksum.h>
#include <u-boot/sha1.h>
#include <u-boot/sha256.h>
Expand Down Expand Up @@ -1943,13 +1944,21 @@ efi_status_t efi_tcg2_register(void)
efi_status_t ret = EFI_SUCCESS;
struct udevice *dev;
struct efi_event *event;
u32 err;

ret = platform_get_tpm2_device(&dev);
if (ret != EFI_SUCCESS) {
log_warning("Unable to find TPMv2 device\n");
return EFI_SUCCESS;
}

/* initialize the TPM as early as possible. */
err = tpm_startup(dev, TPM_ST_CLEAR);
if (err) {
log_err("TPM startup failed\n");
goto fail;
}

ret = efi_init_event_log();
if (ret != EFI_SUCCESS)
goto fail;
Expand Down

0 comments on commit d6b55a4

Please sign in to comment.