lib/tlcl: Ensure tlcl library is initialized only once
Since tlcl library is used other than just vboot driver, ensure that the library is initialized only once per stage. BUG=chrome-os-partner:59355 BRANCH=None TEST=Verified in recovery mode on reef, tlcl library is initialized only once in romstage. Change-Id: I6245fe9ed34f5c174341b7eea8db456b45113287 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/17364 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
parent
ffae746c37
commit
8b5d04e1ab
3 changed files with 22 additions and 23 deletions
|
@ -12,7 +12,6 @@
|
|||
*/
|
||||
|
||||
#include <antirollback.h>
|
||||
#include <arch/early_variables.h>
|
||||
#include <arch/io.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <arch/symbols.h>
|
||||
|
@ -34,22 +33,6 @@
|
|||
#include <vboot/vboot_common.h>
|
||||
#include <vb2_api.h>
|
||||
|
||||
static uint8_t tpm_init_done CAR_GLOBAL;
|
||||
|
||||
static int mrc_cache_tpm_init(void)
|
||||
{
|
||||
uint8_t done = car_get_var(tpm_init_done);
|
||||
|
||||
if (done)
|
||||
return 0;
|
||||
|
||||
if (tlcl_lib_init() != VB2_SUCCESS)
|
||||
return -1;
|
||||
|
||||
car_set_var(tpm_init_done, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mrc_cache_update_tpm_hash(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t data_hash[VB2_SHA256_DIGEST_SIZE];
|
||||
|
@ -74,7 +57,7 @@ static void mrc_cache_update_tpm_hash(const uint8_t *data, size_t size)
|
|||
return;
|
||||
|
||||
/* Initialize TPM driver. */
|
||||
if (mrc_cache_tpm_init()) {
|
||||
if (tlcl_lib_init() != VB2_SUCCESS) {
|
||||
printk(BIOS_ERR, "MRC: TPM driver initialization failed.\n");
|
||||
return;
|
||||
}
|
||||
|
@ -206,7 +189,7 @@ static int mrc_cache_verify_tpm_hash(const uint8_t *data, size_t size)
|
|||
}
|
||||
|
||||
/* Initialize TPM driver. */
|
||||
if (mrc_cache_tpm_init()) {
|
||||
if (tlcl_lib_init() != VB2_SUCCESS) {
|
||||
printk(BIOS_ERR, "MRC: TPM driver initialization failed.\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
* time.
|
||||
*/
|
||||
|
||||
#include <arch/early_variables.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <tpm_lite/tlcl.h>
|
||||
|
@ -139,11 +140,20 @@ static uint32_t send(const uint8_t* command) {
|
|||
|
||||
/* Exported functions. */
|
||||
|
||||
static uint8_t tlcl_init_done CAR_GLOBAL;
|
||||
|
||||
uint32_t tlcl_lib_init(void) {
|
||||
uint8_t done = car_get_var(tlcl_init_done);
|
||||
if (done)
|
||||
return VB2_SUCCESS;
|
||||
|
||||
if (tis_init())
|
||||
return VB2_ERROR_UNKNOWN;
|
||||
if (tis_open())
|
||||
return VB2_ERROR_UNKNOWN;
|
||||
|
||||
car_set_var(tlcl_init_done, 1);
|
||||
|
||||
return VB2_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,16 +157,22 @@ uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated,
|
|||
return TPM_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t tlcl_init_done CAR_GLOBAL;
|
||||
|
||||
/* This function is called directly by vboot, uses vboot return types. */
|
||||
uint32_t tlcl_lib_init(void)
|
||||
{
|
||||
/*
|
||||
* This function is called directly by vboot, uses vboot return
|
||||
* types.
|
||||
*/
|
||||
uint8_t done = car_get_var(tlcl_init_done);
|
||||
if (done)
|
||||
return VB2_SUCCESS;
|
||||
|
||||
if (tis_init())
|
||||
return VB2_ERROR_UNKNOWN;
|
||||
if (tis_open())
|
||||
return VB2_ERROR_UNKNOWN;
|
||||
|
||||
car_set_var(tlcl_init_done, 1);
|
||||
|
||||
return VB2_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue