security/vboot/secdata_tpm: Simplify antirollback_read_space_firmware()

The static function read_space_firmware() is used only once, so merge it
into antirollback_read_space_firmware(). Also change a debug log to
error.

BUG=none
TEST=emerge-geralt coreboot
BRANCH=none

Change-Id: I8abcb8b90e82c3e1b01a2144070a5fde6fe7157f
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76330
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <eric_lai@quanta.corp-partner.google.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
This commit is contained in:
Yu-Ping Wu 2023-07-07 11:30:12 +08:00 committed by Felix Held
parent ffe2ced6e4
commit 5787bd21c7
1 changed files with 3 additions and 12 deletions

View File

@ -28,14 +28,6 @@
static uint32_t safe_write(uint32_t index, const void *data, uint32_t length); static uint32_t safe_write(uint32_t index, const void *data, uint32_t length);
static uint32_t read_space_firmware(struct vb2_context *ctx)
{
RETURN_ON_FAILURE(tlcl_read(FIRMWARE_NV_INDEX,
ctx->secdata_firmware,
VB2_SECDATA_FIRMWARE_SIZE));
return TPM_SUCCESS;
}
uint32_t antirollback_read_space_kernel(struct vb2_context *ctx) uint32_t antirollback_read_space_kernel(struct vb2_context *ctx)
{ {
if (!CONFIG(TPM2)) { if (!CONFIG(TPM2)) {
@ -672,14 +664,13 @@ uint32_t antirollback_read_space_firmware(struct vb2_context *ctx)
{ {
uint32_t rv; uint32_t rv;
/* Read the firmware space. */ rv = tlcl_read(FIRMWARE_NV_INDEX, ctx->secdata_firmware, VB2_SECDATA_FIRMWARE_SIZE);
rv = read_space_firmware(ctx);
if (rv == TPM_E_BADINDEX) { if (rv == TPM_E_BADINDEX) {
/* This seems the first time we've run. Initialize the TPM. */ /* This seems the first time we've run. Initialize the TPM. */
VBDEBUG("TPM: Not initialized yet.\n"); VBDEBUG("TPM: Not initialized yet\n");
RETURN_ON_FAILURE(factory_initialize_tpm(ctx)); RETURN_ON_FAILURE(factory_initialize_tpm(ctx));
} else if (rv != TPM_SUCCESS) { } else if (rv != TPM_SUCCESS) {
VBDEBUG("TPM: Firmware space in a bad state; giving up.\n"); printk(BIOS_ERR, "TPM: Failed to read firmware space: %#x\n", rv);
return TPM_E_CORRUPTED_STATE; return TPM_E_CORRUPTED_STATE;
} }