From 5787bd21c7f61d983dfcd6ef90cd5c6b6f10f33a Mon Sep 17 00:00:00 2001 From: Yu-Ping Wu Date: Fri, 7 Jul 2023 11:30:12 +0800 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/76330 Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai Reviewed-by: Yidi Lin --- src/security/vboot/secdata_tpm.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/security/vboot/secdata_tpm.c b/src/security/vboot/secdata_tpm.c index 45851a09f4..bc9d3d5070 100644 --- a/src/security/vboot/secdata_tpm.c +++ b/src/security/vboot/secdata_tpm.c @@ -28,14 +28,6 @@ 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) { if (!CONFIG(TPM2)) { @@ -672,14 +664,13 @@ uint32_t antirollback_read_space_firmware(struct vb2_context *ctx) { uint32_t rv; - /* Read the firmware space. */ - rv = read_space_firmware(ctx); + rv = tlcl_read(FIRMWARE_NV_INDEX, ctx->secdata_firmware, VB2_SECDATA_FIRMWARE_SIZE); if (rv == TPM_E_BADINDEX) { /* 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)); } 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; }