From d7b8dc9cf5978809912dcffefce2eda5937c9653 Mon Sep 17 00:00:00 2001 From: Jon Murphy Date: Tue, 5 Sep 2023 11:36:43 -0600 Subject: treewide: convert to tpm_result_t Convert TPM functions to return TPM error codes(referred to as tpm_result_t) values to match the TCG standard. BUG=b:296439237 TEST=build and boot to Skyrim BRANCH=None Change-Id: Ifdf9ff6c2a1f9b938dbb04d245799391115eb6b1 Signed-off-by: Jon Murphy Reviewed-on: https://review.coreboot.org/c/coreboot/+/77666 Reviewed-by: Raul Rangel Reviewed-by: Matt DeVillier Tested-by: build bot (Jenkins) --- .../eltan/security/verified_boot/vboot_check.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/vendorcode/eltan/security/verified_boot') diff --git a/src/vendorcode/eltan/security/verified_boot/vboot_check.c b/src/vendorcode/eltan/security/verified_boot/vboot_check.c index 9ea31b877c..9d610064c4 100644 --- a/src/vendorcode/eltan/security/verified_boot/vboot_check.c +++ b/src/vendorcode/eltan/security/verified_boot/vboot_check.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -115,24 +116,24 @@ fail: * @retval TPM_SUCCESS Operation completed successfully. * @retval TPM_IOERROR Unexpected device behavior. */ -static int measure_item(uint32_t pcr, uint8_t *hashData, uint32_t hashDataLen, +static tpm_result_t measure_item(uint32_t pcr, uint8_t *hashData, uint32_t hashDataLen, int8_t *event_msg, TCG_EVENTTYPE eventType) { - int status = TPM_SUCCESS; + tpm_result_t rc = TPM_SUCCESS; TCG_PCR_EVENT2_HDR tcgEventHdr; memset(&tcgEventHdr, 0, sizeof(tcgEventHdr)); tcgEventHdr.pcrIndex = pcr; tcgEventHdr.eventType = eventType; if (event_msg) { - status = mboot_hash_extend_log(MBOOT_HASH_PROVIDED, hashData, + rc = mboot_hash_extend_log(MBOOT_HASH_PROVIDED, hashData, hashDataLen, &tcgEventHdr, (uint8_t *)event_msg); - if (status == TPM_SUCCESS) + if (rc == TPM_SUCCESS) printk(BIOS_INFO, "%s: Success! %s measured to pcr %d.\n", __func__, event_msg, pcr); } - return status; + return rc; } static void verified_boot_check_buffer(const char *name, void *start, size_t size, @@ -140,6 +141,7 @@ static void verified_boot_check_buffer(const char *name, void *start, size_t siz { uint8_t digest[DIGEST_SIZE]; vb2_error_t status; + tpm_result_t rc = TPM_SUCCESS; printk(BIOS_DEBUG, "%s: %s HASH verification buffer %p size %d\n", __func__, name, start, (int)size); @@ -166,10 +168,11 @@ static void verified_boot_check_buffer(const char *name, void *start, size_t siz if (pcr != -1) { printk(BIOS_DEBUG, "%s: measuring %s\n", __func__, name); - if (measure_item(pcr, digest, sizeof(digest), - (int8_t *)name, 0)) - printk(BIOS_DEBUG, "%s: measuring failed!\n", - __func__); + rc = measure_item(pcr, digest, sizeof(digest), + (int8_t *)name, 0); + if (rc) + printk(BIOS_DEBUG, "%s: measuring failed with error %#x!\n", + __func__, rc); } } if (CONFIG(VENDORCODE_ELTAN_VBOOT)) -- cgit v1.2.3