diff --git a/src/drivers/crb/tis.c b/src/drivers/crb/tis.c index a7d4fa73473..40a3513511c 100644 --- a/src/drivers/crb/tis.c +++ b/src/drivers/crb/tis.c @@ -122,14 +122,14 @@ static int tpm_get_cap(uint32_t property, uint32_t *value) { TPMS_CAPABILITY_DATA cap_data; int i; - uint32_t status; + uint32_t rc; if (!value) return -1; - status = tlcl_get_capability(TPM_CAP_TPM_PROPERTIES, property, 1, &cap_data); + rc = tlcl_get_capability(TPM_CAP_TPM_PROPERTIES, property, 1, &cap_data); - if (status) + if (rc) return -1; for (i = 0 ; i < cap_data.data.tpmProperties.count; i++) { diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c index ff1b3a0e3f6..75b235e1798 100644 --- a/src/drivers/i2c/tpm/cr50.c +++ b/src/drivers/i2c/tpm/cr50.c @@ -132,7 +132,7 @@ static int cr50_i2c_write(uint8_t addr, const uint8_t *buffer, size_t len) static int process_reset(void) { struct stopwatch sw; - int rv = 0; + int rc = 0; uint8_t access; /* @@ -148,9 +148,9 @@ static int process_reset(void) const uint8_t mask = TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY; - rv = cr50_i2c_read(TPM_ACCESS(0), + rc = cr50_i2c_read(TPM_ACCESS(0), &access, sizeof(access)); - if (rv || ((access & mask) == mask)) { + if (rc || ((access & mask) == mask)) { /* * Don't bombard the chip with traffic, let it keep * processing the command. @@ -165,7 +165,7 @@ static int process_reset(void) return 0; } while (!stopwatch_expired(&sw)); - if (rv) + if (rc) printk(BIOS_ERR, "Failed to read TPM\n"); else printk(BIOS_ERR, diff --git a/src/mainboard/facebook/fbg1701/romstage.c b/src/mainboard/facebook/fbg1701/romstage.c index 7a31309a06f..19cf867e798 100644 --- a/src/mainboard/facebook/fbg1701/romstage.c +++ b/src/mainboard/facebook/fbg1701/romstage.c @@ -73,7 +73,7 @@ static const uint8_t crtm_version[] = int mb_crtm(void) { - int status = TPM_E_IOERROR; + int rc = TPM_E_IOERROR; TCG_PCR_EVENT2_HDR tcgEventHdr; /* Use FirmwareVersion string to represent CRTM version. */ @@ -84,13 +84,13 @@ int mb_crtm(void) tcgEventHdr.eventSize = sizeof(crtm_version); printk(BIOS_DEBUG, "%s: EventSize - %u\n", __func__, tcgEventHdr.eventSize); - status = mboot_hash_extend_log(0, (uint8_t *)crtm_version, + rc = mboot_hash_extend_log(0, (uint8_t *)crtm_version, tcgEventHdr.eventSize, &tcgEventHdr, (uint8_t *)crtm_version); - if (status) { - printk(BIOS_DEBUG, "Measure CRTM Version returned 0x%x\n", status); + if (rc) { + printk(BIOS_DEBUG, "Measure CRTM Version returned 0x%x\n", rc); } - return status; + return rc; } #endif diff --git a/src/mainboard/google/brya/mainboard.c b/src/mainboard/google/brya/mainboard.c index 966f19eef42..a4603371af7 100644 --- a/src/mainboard/google/brya/mainboard.c +++ b/src/mainboard/google/brya/mainboard.c @@ -34,11 +34,11 @@ static void mainboard_smbios_strings(struct device *dev, struct smbios_type11 *t void mainboard_update_soc_chip_config(struct soc_intel_alderlake_config *config) { - int ret; + int rc; - ret = tlcl_lib_init(); - if (ret != VB2_SUCCESS) { - printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", ret); + rc = tlcl_lib_init(); + if (rc != VB2_SUCCESS) { + printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", rc); return; } diff --git a/src/mainboard/google/dedede/mainboard.c b/src/mainboard/google/dedede/mainboard.c index cc0137dda29..444eef8be7a 100644 --- a/src/mainboard/google/dedede/mainboard.c +++ b/src/mainboard/google/dedede/mainboard.c @@ -14,11 +14,11 @@ static void mainboard_update_soc_chip_config(void) { struct soc_intel_jasperlake_config *cfg = config_of_soc(); - int ret; + int rc; - ret = tlcl_lib_init(); - if (ret != VB2_SUCCESS) { - printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", ret); + rc = tlcl_lib_init(); + if (rc != VB2_SUCCESS) { + printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", rc); return; } diff --git a/src/mainboard/google/volteer/mainboard.c b/src/mainboard/google/volteer/mainboard.c index 4b15e1be045..7409a5bb35c 100644 --- a/src/mainboard/google/volteer/mainboard.c +++ b/src/mainboard/google/volteer/mainboard.c @@ -82,7 +82,7 @@ static void mainboard_enable(struct device *dev) void mainboard_update_soc_chip_config(struct soc_intel_tigerlake_config *cfg) { - int ret; + int rc; if (!CONFIG(TPM_GOOGLE_CR50) || !CONFIG(SPI_TPM)) { /* * Negotiation of long interrupt pulses is only supported via SPI. I2C is only @@ -93,9 +93,9 @@ void mainboard_update_soc_chip_config(struct soc_intel_tigerlake_config *cfg) return; } - ret = tlcl_lib_init(); - if (ret != VB2_SUCCESS) { - printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", ret); + rc = tlcl_lib_init(); + if (rc != VB2_SUCCESS) { + printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", rc); return; } diff --git a/src/security/tpm/tspi/crtm.c b/src/security/tpm/tspi/crtm.c index 36dffb85763..4f29ad134b2 100644 --- a/src/security/tpm/tspi/crtm.c +++ b/src/security/tpm/tspi/crtm.c @@ -192,11 +192,11 @@ int tspi_measure_cache_to_pcr(void) i = 0; while (!tpm_log_get(i++, &pcr, &digest_data, &digest_algo, &event_name)) { printk(BIOS_DEBUG, "TPM: Write digest for %s into PCR %d\n", event_name, pcr); - int result = tlcl_extend(pcr, digest_data, digest_algo); - if (result != TPM_SUCCESS) { + int rc = tlcl_extend(pcr, digest_data, digest_algo); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Writing digest of %s into PCR failed with error %d\n", - event_name, result); + event_name, rc); return VB2_ERROR_UNKNOWN; } } diff --git a/src/security/tpm/tspi/tspi.c b/src/security/tpm/tspi/tspi.c index ec695819fd8..22383d40276 100644 --- a/src/security/tpm/tspi/tspi.c +++ b/src/security/tpm/tspi/tspi.c @@ -15,49 +15,49 @@ static uint32_t tpm1_invoke_state_machine(void) { uint8_t disabled; uint8_t deactivated; - uint32_t result = TPM_SUCCESS; + uint32_t rc = TPM_SUCCESS; /* Check that the TPM is enabled and activated. */ - result = tlcl_get_flags(&disabled, &deactivated, NULL); - if (result != TPM_SUCCESS) { + rc = tlcl_get_flags(&disabled, &deactivated, NULL); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't read capabilities.\n"); - return result; + return rc; } if (disabled) { printk(BIOS_INFO, "TPM: is disabled. Enabling...\n"); - result = tlcl_set_enable(); - if (result != TPM_SUCCESS) { + rc = tlcl_set_enable(); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't set enabled state.\n"); - return result; + return rc; } } if (!!deactivated != CONFIG(TPM_DEACTIVATE)) { printk(BIOS_INFO, "TPM: Unexpected TPM deactivated state. Toggling...\n"); - result = tlcl_set_deactivated(!deactivated); - if (result != TPM_SUCCESS) { + rc = tlcl_set_deactivated(!deactivated); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't toggle deactivated state.\n"); - return result; + return rc; } deactivated = !deactivated; - result = TPM_E_MUST_REBOOT; + rc = TPM_E_MUST_REBOOT; } - return result; + return rc; } #endif static uint32_t tpm_setup_s3_helper(void) { - uint32_t result; + uint32_t rc; - result = tlcl_resume(); - switch (result) { + rc = tlcl_resume(); + switch (rc) { case TPM_SUCCESS: break; @@ -67,25 +67,25 @@ static uint32_t tpm_setup_s3_helper(void) * in S3, so it's already initialized. */ printk(BIOS_INFO, "TPM: Already initialized.\n"); - result = TPM_SUCCESS; + rc = TPM_SUCCESS; break; default: - printk(BIOS_ERR, "TPM: Resume failed (%#x).\n", result); + printk(BIOS_ERR, "TPM: Resume failed (%#x).\n", rc); break; } - return result; + return rc; } -static uint32_t tpm_setup_epilogue(uint32_t result) +static uint32_t tpm_setup_epilogue(uint32_t rc) { - if (result != TPM_SUCCESS) + if (rc != TPM_SUCCESS) post_code(POSTCODE_TPM_FAILURE); else printk(BIOS_INFO, "TPM: setup succeeded\n"); - return result; + return rc; } static int tpm_is_setup; @@ -135,12 +135,12 @@ static inline int tspi_tpm_is_setup(void) */ uint32_t tpm_setup(int s3flag) { - uint32_t result; + uint32_t rc; - result = tlcl_lib_init(); - if (result != TPM_SUCCESS) { + rc = tlcl_lib_init(); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't initialize.\n"); - return tpm_setup_epilogue(result); + return tpm_setup_epilogue(rc); } /* Handle special init for S3 resume path */ @@ -149,69 +149,69 @@ uint32_t tpm_setup(int s3flag) return tpm_setup_epilogue(tpm_setup_s3_helper()); } - result = tlcl_startup(); + rc = tlcl_startup(); if (CONFIG(TPM_STARTUP_IGNORE_POSTINIT) - && result == TPM_E_INVALID_POSTINIT) { + && rc == TPM_E_INVALID_POSTINIT) { printk(BIOS_DEBUG, "TPM: ignoring invalid POSTINIT\n"); - result = TPM_SUCCESS; + rc = TPM_SUCCESS; } - if (result != TPM_SUCCESS) { + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't run startup command.\n"); - return tpm_setup_epilogue(result); + return tpm_setup_epilogue(rc); } - result = tlcl_assert_physical_presence(); - if (result != TPM_SUCCESS) { + rc = tlcl_assert_physical_presence(); + if (rc != TPM_SUCCESS) { /* * It is possible that the TPM was delivered with the physical * presence command disabled. This tries enabling it, then * tries asserting PP again. */ - result = tlcl_physical_presence_cmd_enable(); - if (result != TPM_SUCCESS) { + rc = tlcl_physical_presence_cmd_enable(); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't enable physical presence command.\n"); - return tpm_setup_epilogue(result); + return tpm_setup_epilogue(rc); } - result = tlcl_assert_physical_presence(); - if (result != TPM_SUCCESS) { + rc = tlcl_assert_physical_presence(); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't assert physical presence.\n"); - return tpm_setup_epilogue(result); + return tpm_setup_epilogue(rc); } } #if CONFIG(TPM1) - result = tpm1_invoke_state_machine(); + rc = tpm1_invoke_state_machine(); #endif if (CONFIG(TPM_MEASURED_BOOT)) - result = tspi_measure_cache_to_pcr(); + rc = tspi_measure_cache_to_pcr(); tpm_is_setup = 1; - return tpm_setup_epilogue(result); + return tpm_setup_epilogue(rc); } uint32_t tpm_clear_and_reenable(void) { - uint32_t result; + uint32_t rc; printk(BIOS_INFO, "TPM: Clear and re-enable\n"); - result = tlcl_force_clear(); - if (result != TPM_SUCCESS) { + rc = tlcl_force_clear(); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't initiate a force clear.\n"); - return result; + return rc; } #if CONFIG(TPM1) - result = tlcl_set_enable(); - if (result != TPM_SUCCESS) { + rc = tlcl_set_enable(); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't set enabled state.\n"); - return result; + return rc; } - result = tlcl_set_deactivated(0); - if (result != TPM_SUCCESS) { + rc = tlcl_set_deactivated(0); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't set deactivated state.\n"); - return result; + return rc; } #endif @@ -221,24 +221,24 @@ uint32_t tpm_clear_and_reenable(void) uint32_t tpm_extend_pcr(int pcr, enum vb2_hash_algorithm digest_algo, const uint8_t *digest, size_t digest_len, const char *name) { - uint32_t result; + uint32_t rc; if (!digest) return TPM_E_IOERROR; if (tspi_tpm_is_setup()) { - result = tlcl_lib_init(); - if (result != TPM_SUCCESS) { + rc = tlcl_lib_init(); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Can't initialize library.\n"); - return result; + return rc; } printk(BIOS_DEBUG, "TPM: Extending digest for `%s` into PCR %d\n", name, pcr); - result = tlcl_extend(pcr, digest, digest_algo); - if (result != TPM_SUCCESS) { + rc = tlcl_extend(pcr, digest, digest_algo); + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "TPM: Extending hash for `%s` into PCR %d failed.\n", name, pcr); - return result; + return rc; } } diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c index 39c44eca9f3..9c19f7f3cbc 100644 --- a/src/security/tpm/tss/tcg-1.2/tss.c +++ b/src/security/tpm/tss/tcg-1.2/tss.c @@ -57,9 +57,9 @@ static inline int tpm_command_size(const uint8_t *buffer) /* Gets the code field of a TPM command. */ static inline int tpm_command_code(const uint8_t *buffer) { - uint32_t code; - from_tpm_uint32(buffer + sizeof(uint16_t) + sizeof(uint32_t), &code); - return code; + uint32_t rc; + from_tpm_uint32(buffer + sizeof(uint16_t) + sizeof(uint32_t), &rc); + return rc; } /* Gets the return code field of a TPM result. */ @@ -76,27 +76,27 @@ static uint32_t tlcl_send_receive_no_retry(const uint8_t *request, uint8_t *response, int max_length) { uint32_t response_length = max_length; - uint32_t result; + uint32_t rc; - result = tpm_send_receive(request, tpm_command_size(request), + rc = tpm_send_receive(request, tpm_command_size(request), response, &response_length); - if (result != 0) { + if (rc != 0) { /* Communication with TPM failed, so response is garbage */ VBDEBUG("TPM: command 0x%x send/receive failed: 0x%x\n", - tpm_command_code(request), result); - return result; + tpm_command_code(request), rc); + return rc; } /* Otherwise, use the result code from the response */ - result = tpm_return_code(response); + rc = tpm_return_code(response); /* TODO: add paranoia about returned response_length vs. max_length * (and possibly expected length from the response header). See * crosbug.com/17017 */ VBDEBUG("TPM: command 0x%x returned 0x%x\n", - tpm_command_code(request), result); + tpm_command_code(request), rc); -return result; +return rc; } /* Sends a TPM command and gets a response. Returns 0 if success or the TPM @@ -104,17 +104,17 @@ return result; uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response, int max_length) { - uint32_t result = tlcl_send_receive_no_retry(request, response, + uint32_t rc = tlcl_send_receive_no_retry(request, response, max_length); /* If the command fails because the self test has not completed, try it * again after attempting to ensure that the self test has completed. */ - if (result == TPM_E_NEEDS_SELFTEST || result == TPM_E_DOING_SELFTEST) { - result = tlcl_continue_self_test(); - if (result != TPM_SUCCESS) - return result; + if (rc == TPM_E_NEEDS_SELFTEST || rc == TPM_E_DOING_SELFTEST) { + rc = tlcl_continue_self_test(); + if (rc != TPM_SUCCESS) + return rc; #if defined(TPM_BLOCKING_CONTINUESELFTEST) || defined(VB_RECOVERY_MODE) /* Retry only once */ - result = tlcl_send_receive_no_retry(request, response, + rc = tlcl_send_receive_no_retry(request, response, max_length); #else /* This needs serious testing. The TPM specification says: "iii. @@ -123,12 +123,12 @@ uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response, * ContinueSelfTest is non-blocking, how do we know that the * actions have completed other than trying again? */ do { - result = tlcl_send_receive_no_retry(request, response, + rc = tlcl_send_receive_no_retry(request, response, max_length); - } while (result == TPM_E_DOING_SELFTEST); + } while (rc == TPM_E_DOING_SELFTEST); #endif } - return result; + return rc; } /* Sends a command and returns the error code. */ @@ -226,15 +226,15 @@ uint32_t tlcl_read(uint32_t index, void *data, uint32_t length) struct s_tpm_nv_read_cmd cmd; uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; uint32_t result_length; - uint32_t result; + uint32_t rc; VBDEBUG("TPM: %s(0x%x, %d)\n", __func__, index, length); memcpy(&cmd, &tpm_nv_read_cmd, sizeof(cmd)); to_tpm_uint32(cmd.buffer + tpm_nv_read_cmd.index, index); to_tpm_uint32(cmd.buffer + tpm_nv_read_cmd.length, length); - result = tlcl_send_receive(cmd.buffer, response, sizeof(response)); - if (result == TPM_SUCCESS && length > 0) { + rc = tlcl_send_receive(cmd.buffer, response, sizeof(response)); + if (rc == TPM_SUCCESS && length > 0) { uint8_t *nv_read_cursor = response + kTpmResponseHeaderLength; from_tpm_uint32(nv_read_cursor, &result_length); if (result_length > length) @@ -243,7 +243,7 @@ uint32_t tlcl_read(uint32_t index, void *data, uint32_t length) memcpy(data, nv_read_cursor, result_length); } - return result; + return rc; } uint32_t tlcl_assert_physical_presence(void) @@ -295,24 +295,24 @@ uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags) { uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; uint32_t size; - uint32_t result = tlcl_send_receive(tpm_getflags_cmd.buffer, response, + uint32_t rc = tlcl_send_receive(tpm_getflags_cmd.buffer, response, sizeof(response)); - if (result != TPM_SUCCESS) - return result; + if (rc != TPM_SUCCESS) + return rc; from_tpm_uint32(response + kTpmResponseHeaderLength, &size); if (size != sizeof(TPM_PERMANENT_FLAGS)) return TPM_E_IOERROR; memcpy(pflags, response + kTpmResponseHeaderLength + sizeof(size), sizeof(TPM_PERMANENT_FLAGS)); - return result; + return rc; } uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated, uint8_t *nvlocked) { TPM_PERMANENT_FLAGS pflags; - uint32_t result = tlcl_get_permanent_flags(&pflags); - if (result == TPM_SUCCESS) { + uint32_t rc = tlcl_get_permanent_flags(&pflags); + if (rc == TPM_SUCCESS) { if (disable) *disable = pflags.disable; if (deactivated) @@ -322,7 +322,7 @@ uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated, VBDEBUG("TPM: flags disable=%d, deactivated=%d, nvlocked=%d\n", pflags.disable, pflags.deactivated, pflags.nvLocked); } - return result; + return rc; } uint32_t tlcl_set_global_lock(void) @@ -352,16 +352,16 @@ uint32_t tlcl_get_permissions(uint32_t index, uint32_t *permissions) struct s_tpm_getpermissions_cmd cmd; uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE]; uint8_t *nvdata; - uint32_t result; + uint32_t rc; uint32_t size; memcpy(&cmd, &tpm_getpermissions_cmd, sizeof(cmd)); to_tpm_uint32(cmd.buffer + tpm_getpermissions_cmd.index, index); - result = tlcl_send_receive(cmd.buffer, response, sizeof(response)); - if (result != TPM_SUCCESS) - return result; + rc = tlcl_send_receive(cmd.buffer, response, sizeof(response)); + if (rc != TPM_SUCCESS) + return rc; nvdata = response + kTpmResponseHeaderLength + sizeof(size); from_tpm_uint32(nvdata + kNvDataPublicPermissionsOffset, permissions); - return result; + return rc; } diff --git a/src/security/vboot/secdata_tpm.c b/src/security/vboot/secdata_tpm.c index 3229dd022f0..27d16e1776f 100644 --- a/src/security/vboot/secdata_tpm.c +++ b/src/security/vboot/secdata_tpm.c @@ -18,11 +18,11 @@ printk(BIOS_INFO, "%s():%d: " format, __func__, __LINE__, ## args) #define RETURN_ON_FAILURE(tpm_cmd) do { \ - uint32_t result_; \ - if ((result_ = (tpm_cmd)) != TPM_SUCCESS) { \ + uint32_t rc_; \ + if ((rc_ = (tpm_cmd)) != TPM_SUCCESS) { \ VBDEBUG("Antirollback: %08x returned by " #tpm_cmd \ - "\n", (int)result_); \ - return result_; \ + "\n", (int)rc_); \ + return rc_; \ } \ } while (0) @@ -51,17 +51,17 @@ uint32_t antirollback_read_space_kernel(struct vb2_context *ctx) } uint8_t size = VB2_SECDATA_KERNEL_SIZE; - uint32_t ret; + uint32_t rc; /* Start with the version 1.0 size used by all modern Cr50/Ti50 boards. */ - ret = tlcl_read(KERNEL_NV_INDEX, ctx->secdata_kernel, size); - if (ret == TPM_E_RANGE) { + rc = tlcl_read(KERNEL_NV_INDEX, ctx->secdata_kernel, size); + if (rc == TPM_E_RANGE) { /* Fallback to version 0.2(minimum) size and re-read. */ VBDEBUG("Antirollback: NV read out of range, trying min size\n"); size = VB2_SECDATA_KERNEL_MIN_SIZE; - ret = tlcl_read(KERNEL_NV_INDEX, ctx->secdata_kernel, size); + rc = tlcl_read(KERNEL_NV_INDEX, ctx->secdata_kernel, size); } - RETURN_ON_FAILURE(ret); + RETURN_ON_FAILURE(rc); if (vb2api_secdata_kernel_check(ctx, &size) == VB2_ERROR_SECDATA_KERNEL_INCOMPLETE) /* Re-read. vboot will run the check and handle errors. */ @@ -206,11 +206,11 @@ static uint32_t define_space(const char *name, uint32_t index, uint32_t length, const TPMA_NV nv_attributes, const uint8_t *nv_policy, size_t nv_policy_size) { - uint32_t rv; + uint32_t rc; - rv = tlcl_define_space(index, length, nv_attributes, nv_policy, + rc = tlcl_define_space(index, length, nv_attributes, nv_policy, nv_policy_size); - if (rv == TPM_E_NV_DEFINED) { + if (rc == TPM_E_NV_DEFINED) { /* * Continue with writing: it may be defined, but not written * to. In that case a subsequent tlcl_read() would still return @@ -220,10 +220,10 @@ static uint32_t define_space(const char *name, uint32_t index, uint32_t length, * in writing once again even if it was written already. */ VBDEBUG("%s: %s space already exists\n", __func__, name); - rv = TPM_SUCCESS; + rc = TPM_SUCCESS; } - return rv; + return rc; } /* Nothing special in the TPM2 path yet. */ @@ -236,12 +236,12 @@ static uint32_t setup_space(const char *name, uint32_t index, const void *data, uint32_t length, const TPMA_NV nv_attributes, const uint8_t *nv_policy, size_t nv_policy_size) { - uint32_t rv; + uint32_t rc; - rv = define_space(name, index, length, nv_attributes, nv_policy, + rc = define_space(name, index, length, nv_attributes, nv_policy, nv_policy_size); - if (rv != TPM_SUCCESS) - return rv; + if (rc != TPM_SUCCESS) + return rc; return safe_write(index, data, length); } @@ -291,7 +291,7 @@ static uint32_t set_mrc_hash_space(uint32_t index, const uint8_t *data) */ static uint32_t setup_zte_spaces(void) { - uint32_t rv; + uint32_t rc; uint64_t rma_bytes_counter_default = 0; uint8_t rma_sn_bits_default[16]; uint8_t board_id_default[12]; @@ -302,47 +302,47 @@ static uint32_t setup_zte_spaces(void) memset(board_id_default, 0xFF, ARRAY_SIZE(board_id_default)); /* Set up RMA + SN Bits */ - rv = setup_space("RMA + SN Bits", ZTE_RMA_SN_BITS_INDEX, + rc = setup_space("RMA + SN Bits", ZTE_RMA_SN_BITS_INDEX, rma_sn_bits_default, sizeof(rma_sn_bits_default), zte_attr, unsatisfiable_policy, sizeof(unsatisfiable_policy)); - if (rv != TPM_SUCCESS) { + if (rc != TPM_SUCCESS) { VBDEBUG("%s: Failed to set up RMA + SN Bits space\n", __func__); - return rv; + return rc; } - rv = setup_space("Board ID", ZTE_BOARD_ID_NV_INDEX, + rc = setup_space("Board ID", ZTE_BOARD_ID_NV_INDEX, board_id_default, sizeof(board_id_default), zte_attr, unsatisfiable_policy, sizeof(unsatisfiable_policy)); - if (rv != TPM_SUCCESS) { + if (rc != TPM_SUCCESS) { VBDEBUG("%s: Failed to set up Board ID space\n", __func__); - return rv; + return rc; } /* Set up RMA Bytes counter */ - rv = define_space("RMA Bytes Counter", ZTE_RMA_BYTES_COUNTER_INDEX, + rc = define_space("RMA Bytes Counter", ZTE_RMA_BYTES_COUNTER_INDEX, sizeof(rma_bytes_counter_default), zte_rma_bytes_attr, unsatisfiable_policy, sizeof(unsatisfiable_policy)); - if (rv != TPM_SUCCESS) { + if (rc != TPM_SUCCESS) { VBDEBUG("%s: Failed to define RMA Bytes space\n", __func__); - return rv; + return rc; } /* * Since the RMA counter has the BITS attribute, we need to call * TPM2_NV_SetBits() in order to initialize it. */ - rv = tlcl_set_bits(ZTE_RMA_BYTES_COUNTER_INDEX, + rc = tlcl_set_bits(ZTE_RMA_BYTES_COUNTER_INDEX, rma_bytes_counter_default); - if (rv != TPM_SUCCESS) { + if (rc != TPM_SUCCESS) { VBDEBUG("%s: Failed to init RMA Bytes counter space\n", __func__); - return rv; + return rc; } - return rv; + return rc; } /* @@ -363,13 +363,17 @@ static uint32_t enterprise_rollback_create_space(void) static uint32_t setup_widevine_counter_spaces(void) { - uint32_t index, rv; + uint32_t index, rc; for (index = 0; index < NUM_WIDEVINE_COUNTERS; index++) { - rv = define_space(WIDEVINE_COUNTER_NAME, WIDEVINE_COUNTER_NV_INDEX(index), - WIDEVINE_COUNTER_SIZE, rw_orderly_counter_attributes, NULL, 0); - if (rv != TPM_SUCCESS) - return rv; + rc = define_space(WIDEVINE_COUNTER_NAME, + WIDEVINE_COUNTER_NV_INDEX(index), + WIDEVINE_COUNTER_SIZE, + rw_orderly_counter_attributes, + NULL, + 0); + if (rc != TPM_SUCCESS) + return rc; } return TPM_SUCCESS; } @@ -443,7 +447,7 @@ uint32_t antirollback_read_space_mrc_hash(uint32_t index, uint8_t *data, uint32_ uint32_t antirollback_write_space_mrc_hash(uint32_t index, const uint8_t *data, uint32_t size) { uint8_t spc_data[HASH_NV_SIZE]; - uint32_t rv; + uint32_t rc; if (size != HASH_NV_SIZE) { VBDEBUG("TPM: Incorrect buffer size for hash idx 0x%x. " @@ -452,8 +456,8 @@ uint32_t antirollback_write_space_mrc_hash(uint32_t index, const uint8_t *data, return TPM_E_WRITE_FAILURE; } - rv = read_space_mrc_hash(index, spc_data); - if (rv == TPM_E_BADINDEX) { + rc = read_space_mrc_hash(index, spc_data); + if (rc == TPM_E_BADINDEX) { /* * If space is not defined already for hash, define * new space. @@ -462,8 +466,8 @@ uint32_t antirollback_write_space_mrc_hash(uint32_t index, const uint8_t *data, return set_mrc_hash_space(index, data); } - if (rv != TPM_SUCCESS) - return rv; + if (rc != TPM_SUCCESS) + return rc; return safe_write(index, data, size); } @@ -493,7 +497,7 @@ uint32_t antirollback_read_space_vbios_hash(uint8_t *data, uint32_t size) uint32_t antirollback_write_space_vbios_hash(const uint8_t *data, uint32_t size) { uint8_t spc_data[HASH_NV_SIZE]; - uint32_t rv; + uint32_t rc; if (size != HASH_NV_SIZE) { VBDEBUG("TPM: Incorrect buffer size for hash idx 0x%x. " @@ -502,8 +506,8 @@ uint32_t antirollback_write_space_vbios_hash(const uint8_t *data, uint32_t size) return TPM_E_WRITE_FAILURE; } - rv = read_space_vbios_hash(spc_data); - if (rv == TPM_E_BADINDEX) { + rc = read_space_vbios_hash(spc_data); + if (rc == TPM_E_BADINDEX) { /* * If space is not defined already for hash, define * new space. @@ -513,8 +517,8 @@ uint32_t antirollback_write_space_vbios_hash(const uint8_t *data, uint32_t size) rw_space_attributes, NULL, 0); } - if (rv != TPM_SUCCESS) - return rv; + if (rc != TPM_SUCCESS) + return rc; return safe_write(VBIOS_CACHE_NV_INDEX, data, size); } @@ -530,12 +534,12 @@ uint32_t antirollback_write_space_vbios_hash(const uint8_t *data, uint32_t size) static uint32_t safe_write(uint32_t index, const void *data, uint32_t length) { - uint32_t result = tlcl_write(index, data, length); - if (result == TPM_E_MAXNVWRITES) { + uint32_t rc = tlcl_write(index, data, length); + if (rc == TPM_E_MAXNVWRITES) { RETURN_ON_FAILURE(tpm_clear_and_reenable()); return tlcl_write(index, data, length); } else { - return result; + return rc; } } @@ -547,26 +551,26 @@ static uint32_t safe_write(uint32_t index, const void *data, uint32_t length) */ static uint32_t safe_define_space(uint32_t index, uint32_t perm, uint32_t size) { - uint32_t result = tlcl_define_space(index, perm, size); - if (result == TPM_E_MAXNVWRITES) { + uint32_t rc = tlcl_define_space(index, perm, size); + if (rc == TPM_E_MAXNVWRITES) { RETURN_ON_FAILURE(tpm_clear_and_reenable()); return tlcl_define_space(index, perm, size); } else { - return result; + return rc; } } static uint32_t _factory_initialize_tpm(struct vb2_context *ctx) { TPM_PERMANENT_FLAGS pflags; - uint32_t result; + uint32_t rc; vb2api_secdata_firmware_create(ctx); vb2api_secdata_kernel_create_v0(ctx); - result = tlcl_get_permanent_flags(&pflags); - if (result != TPM_SUCCESS) - return result; + rc = tlcl_get_permanent_flags(&pflags); + if (rc != TPM_SUCCESS) + return rc; /* * TPM may come from the factory without physical presence finalized. @@ -630,7 +634,7 @@ uint32_t antirollback_lock_space_firmware(void) */ static uint32_t factory_initialize_tpm(struct vb2_context *ctx) { - uint32_t result; + uint32_t rc; VBDEBUG("TPM: factory initialization\n"); @@ -642,13 +646,13 @@ static uint32_t factory_initialize_tpm(struct vb2_context *ctx) * test---specifically the ones that set lifetime flags, and are only * executed once per physical TPM. */ - result = tlcl_self_test_full(); - if (result != TPM_SUCCESS) - return result; + rc = tlcl_self_test_full(); + if (rc != TPM_SUCCESS) + return rc; - result = _factory_initialize_tpm(ctx); - if (result != TPM_SUCCESS) - return result; + rc = _factory_initialize_tpm(ctx); + if (rc != TPM_SUCCESS) + return rc; /* _factory_initialize_tpm() writes initial secdata values to TPM immediately, so let vboot know that it's up to date now. */ @@ -662,15 +666,15 @@ static uint32_t factory_initialize_tpm(struct vb2_context *ctx) uint32_t antirollback_read_space_firmware(struct vb2_context *ctx) { - uint32_t rv; + uint32_t rc; - rv = tlcl_read(FIRMWARE_NV_INDEX, ctx->secdata_firmware, VB2_SECDATA_FIRMWARE_SIZE); - if (rv == TPM_E_BADINDEX) { + rc = tlcl_read(FIRMWARE_NV_INDEX, ctx->secdata_firmware, VB2_SECDATA_FIRMWARE_SIZE); + if (rc == TPM_E_BADINDEX) { /* This seems the first time we've run. Initialize the TPM. */ VBDEBUG("TPM: Not initialized yet\n"); RETURN_ON_FAILURE(factory_initialize_tpm(ctx)); - } else if (rv != TPM_SUCCESS) { - printk(BIOS_ERR, "TPM: Failed to read firmware space: %#x\n", rv); + } else if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "TPM: Failed to read firmware space: %#x\n", rc); return TPM_E_CORRUPTED_STATE; } @@ -706,10 +710,10 @@ uint32_t antirollback_write_space_kernel(struct vb2_context *ctx) vb2_error_t vb2ex_tpm_clear_owner(struct vb2_context *ctx) { - uint32_t rv; + uint32_t rc; printk(BIOS_INFO, "Clearing TPM owner\n"); - rv = tpm_clear_and_reenable(); - if (rv) + rc = tpm_clear_and_reenable(); + if (rc) return VB2_ERROR_EX_TPM_CLEAR_OWNER; return VB2_SUCCESS; } diff --git a/src/security/vboot/tpm_common.c b/src/security/vboot/tpm_common.c index e67cc013222..ad333c6f9ba 100644 --- a/src/security/vboot/tpm_common.c +++ b/src/security/vboot/tpm_common.c @@ -10,13 +10,13 @@ uint32_t vboot_setup_tpm(struct vb2_context *ctx) { - uint32_t result; + uint32_t rc; - result = tpm_setup(ctx->flags & VB2_CONTEXT_S3_RESUME); - if (result == TPM_E_MUST_REBOOT) + rc = tpm_setup(ctx->flags & VB2_CONTEXT_S3_RESUME); + if (rc == TPM_E_MUST_REBOOT) ctx->flags |= VB2_CONTEXT_SECDATA_WANTS_REBOOT; - return result; + return rc; } vb2_error_t vboot_extend_pcr(struct vb2_context *ctx, int pcr, diff --git a/src/security/vboot/vboot_logic.c b/src/security/vboot/vboot_logic.c index 8494a1ba66d..213ebcce996 100644 --- a/src/security/vboot/vboot_logic.c +++ b/src/security/vboot/vboot_logic.c @@ -127,7 +127,7 @@ static vb2_error_t hash_body(struct vb2_context *ctx, const size_t hash_digest_sz = sizeof(hash_digest); size_t block_size = sizeof(block); size_t offset; - vb2_error_t rv; + vb2_error_t rc; /* Clear the full digest so that any hash digests less than the * max have trailing zeros. */ @@ -146,9 +146,9 @@ static vb2_error_t hash_body(struct vb2_context *ctx, offset = 0; /* Start the body hash */ - rv = vb2api_init_hash(ctx, VB2_HASH_TAG_FW_BODY); - if (rv) - return rv; + rc = vb2api_init_hash(ctx, VB2_HASH_TAG_FW_BODY); + if (rc) + return rc; /* Extend over the body */ while (remaining) { @@ -161,9 +161,9 @@ static vb2_error_t hash_body(struct vb2_context *ctx, return VB2_ERROR_UNKNOWN; load_ts += timestamp_get() - temp_ts; - rv = vb2api_extend_hash(ctx, block, block_size); - if (rv) - return rv; + rc = vb2api_extend_hash(ctx, block, block_size); + if (rc) + return rc; remaining -= block_size; offset += block_size; @@ -173,9 +173,9 @@ static vb2_error_t hash_body(struct vb2_context *ctx, timestamp_add_now(TS_HASHING_END); /* Check the result (with RSA signature verification) */ - rv = vb2api_check_hash_get_digest(ctx, hash_digest, hash_digest_sz); - if (rv) - return rv; + rc = vb2api_check_hash_get_digest(ctx, hash_digest, hash_digest_sz); + if (rc) + return rc; timestamp_add_now(TS_HASH_BODY_END); @@ -210,10 +210,10 @@ static const char *get_boot_mode_string(uint8_t boot_mode) static void check_boot_mode(struct vb2_context *ctx) { uint8_t boot_mode; - int rv; + int rc; - rv = tlcl_cr50_get_boot_mode(&boot_mode); - switch (rv) { + rc = tlcl_cr50_get_boot_mode(&boot_mode); + switch (rc) { case TPM_E_NO_SUCH_COMMAND: printk(BIOS_WARNING, "GSC does not support GET_BOOT_MODE.\n"); /* Proceed to legacy boot model. */ @@ -223,7 +223,7 @@ static void check_boot_mode(struct vb2_context *ctx) default: printk(BIOS_ERR, "Communication error in getting GSC boot mode.\n"); - vb2api_fail(ctx, VB2_RECOVERY_GSC_BOOT_MODE, rv); + vb2api_fail(ctx, VB2_RECOVERY_GSC_BOOT_MODE, rc); return; } diff --git a/src/soc/amd/common/psp_verstage/psp_verstage.c b/src/soc/amd/common/psp_verstage/psp_verstage.c index cc710fae617..c9058192d3c 100644 --- a/src/soc/amd/common/psp_verstage/psp_verstage.c +++ b/src/soc/amd/common/psp_verstage/psp_verstage.c @@ -208,7 +208,7 @@ static uint32_t save_buffers(void) */ static void psp_verstage_s0i3_resume(void) { - uint32_t rv; + uint32_t rc; post_code(POSTCODE_VERSTAGE_S0I3_RESUME); @@ -217,15 +217,15 @@ static void psp_verstage_s0i3_resume(void) if (!CONFIG(PSP_INIT_TPM_ON_S0I3_RESUME)) return; - rv = tpm_setup(true); - if (rv != TPM_SUCCESS) { - printk(BIOS_ERR, "tpm_setup failed rv:%d\n", rv); + rc = tpm_setup(true); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "tpm_setup failed rc:%d\n", rc); reboot_into_recovery(vboot_get_context(), POSTCODE_INIT_TPM_FAILED); } - rv = tlcl_disable_platform_hierarchy(); - if (rv != TPM_SUCCESS) { - printk(BIOS_ERR, "tlcl_disable_platform_hierarchy failed rv:%d\n", rv); + rc = tlcl_disable_platform_hierarchy(); + if (rc != TPM_SUCCESS) { + printk(BIOS_ERR, "tlcl_disable_platform_hierarchy failed rc:%d\n", rc); reboot_into_recovery(vboot_get_context(), POSTCODE_INIT_TPM_FAILED); } } diff --git a/src/vendorcode/eltan/security/mboot/mboot.c b/src/vendorcode/eltan/security/mboot/mboot.c index cb371401aa0..5fe20601912 100644 --- a/src/vendorcode/eltan/security/mboot/mboot.c +++ b/src/vendorcode/eltan/security/mboot/mboot.c @@ -13,14 +13,14 @@ */ EFI_TCG2_EVENT_ALGORITHM_BITMAP tpm2_get_active_pcrs(void) { - int status; + int rc; TPML_PCR_SELECTION Pcrs; EFI_TCG2_EVENT_ALGORITHM_BITMAP tpmHashAlgorithmBitmap = 0; uint32_t activePcrBanks = 0; uint32_t index; - status = tpm2_get_capability_pcrs(&Pcrs); - if (status != TPM_SUCCESS) { + rc = tpm2_get_capability_pcrs(&Pcrs); + if (rc != TPM_SUCCESS) { tpmHashAlgorithmBitmap = EFI_TCG2_BOOT_HASH_ALG_SHA1; activePcrBanks = EFI_TCG2_BOOT_HASH_ALG_SHA1; } else { @@ -78,11 +78,11 @@ EFI_TCG2_EVENT_ALGORITHM_BITMAP tpm2_get_active_pcrs(void) int tpm2_get_capability_pcrs(TPML_PCR_SELECTION *Pcrs) { TPMS_CAPABILITY_DATA TpmCap; - int status; + int rc; int index; - status = tlcl_get_capability(TPM_CAP_PCRS, 0, 1, &TpmCap); - if (status == TPM_SUCCESS) { + rc = tlcl_get_capability(TPM_CAP_PCRS, 0, 1, &TpmCap); + if (rc == TPM_SUCCESS) { Pcrs->count = TpmCap.data.assignedPCR.count; printk(BIOS_DEBUG, "Pcrs->count = %d\n", Pcrs->count); for (index = 0; index < Pcrs->count; index++) { @@ -97,7 +97,7 @@ int tpm2_get_capability_pcrs(TPML_PCR_SELECTION *Pcrs) Pcrs->pcrSelections[index].sizeofSelect); } } - return status; + return rc; } /* @@ -149,7 +149,7 @@ int mboot_hash_extend_log(uint64_t flags, uint8_t *hashData, uint32_t hashDataLe void invalidate_pcrs(void) { int pcr; - int status; + int rc; TCG_PCR_EVENT2_HDR tcgEventHdr; uint8_t invalidate = 1; @@ -161,12 +161,12 @@ void invalidate_pcrs(void) tcgEventHdr.eventType = EV_NO_ACTION; tcgEventHdr.eventSize = (uint32_t) sizeof(invalidate); - status = mboot_hash_extend_log(0, (uint8_t *)&invalidate, + rc = mboot_hash_extend_log(0, (uint8_t *)&invalidate, tcgEventHdr.eventSize, &tcgEventHdr, (uint8_t *)"Invalidate PCR"); - if (status != TPM_SUCCESS) + if (rc != TPM_SUCCESS) printk(BIOS_DEBUG, "%s: invalidating pcr %d returned" - " 0x%x\n", __func__, pcr, status); + " 0x%x\n", __func__, pcr, rc); } } @@ -230,7 +230,7 @@ void mboot_print_buffer(uint8_t *buffer, uint32_t bufferSize) int mb_measure_log_worker(const char *name, uint32_t type, uint32_t pcr, TCG_EVENTTYPE eventType, const char *event_msg) { - int status; + int rc; TCG_PCR_EVENT2_HDR tcgEventHdr; uint8_t *base; size_t size; @@ -250,8 +250,8 @@ int mb_measure_log_worker(const char *name, uint32_t type, uint32_t pcr, if (event_msg) tcgEventHdr.eventSize = (uint32_t) strlen(event_msg); - status = mboot_hash_extend_log(0, base, size, &tcgEventHdr, (uint8_t *)event_msg); - return status; + rc = mboot_hash_extend_log(0, base, size, &tcgEventHdr, (uint8_t *)event_msg); + return rc; } /* @@ -273,7 +273,7 @@ int mb_measure_log_worker(const char *name, uint32_t type, uint32_t pcr, __weak int mb_entry(int wake_from_s3) { - int status; + int rc; /* Initialize TPM driver. */ printk(BIOS_DEBUG, "%s: tlcl_lib_init\n", __func__); @@ -284,16 +284,16 @@ __weak int mb_entry(int wake_from_s3) if (wake_from_s3) { printk(BIOS_DEBUG, "%s: tlcl_resume\n", __func__); - status = tlcl_resume(); + rc = tlcl_resume(); } else { printk(BIOS_DEBUG, "%s: tlcl_startup\n", __func__); - status = tlcl_startup(); + rc = tlcl_startup(); } - if (status) - printk(BIOS_ERR, "%s: StartUp failed 0x%x!\n", __func__, status); + if (rc) + printk(BIOS_ERR, "%s: StartUp failed 0x%x!\n", __func__, rc); - return status; + return rc; } /* @@ -317,25 +317,25 @@ __weak int mb_entry(int wake_from_s3) __weak int mb_measure(int wake_from_s3) { - uint32_t status; + uint32_t rc; - status = mb_entry(wake_from_s3); - if (status == TPM_SUCCESS) { + rc = mb_entry(wake_from_s3); + if (rc == TPM_SUCCESS) { printk(BIOS_DEBUG, "%s: StartUp, successful!\n", __func__); - status = mb_measure_log_start(); - if (status == TPM_SUCCESS) { + rc = mb_measure_log_start(); + if (rc == TPM_SUCCESS) { printk(BIOS_DEBUG, "%s: Measuring, successful!\n", __func__); } else { invalidate_pcrs(); printk(BIOS_ERR, "%s: Measuring returned 0x%x unsuccessful! PCRs invalidated.\n", - __func__, status); + __func__, rc); } } else { invalidate_pcrs(); printk(BIOS_ERR, "%s: StartUp returned 0x%x, unsuccessful! PCRs invalidated.\n", __func__, - status); + rc); } - return status; + return rc; } /* @@ -359,7 +359,7 @@ __weak int mb_measure(int wake_from_s3) */ __weak int mb_measure_log_start(void) { - int status; + int rc; uint32_t i; if ((tpm2_get_active_pcrs() & EFI_TCG2_BOOT_HASH_ALG_SHA256) == 0x0) { @@ -368,32 +368,32 @@ __weak int mb_measure_log_start(void) return TPM_E_IOERROR; } - status = mb_crtm(); - if (status != TPM_SUCCESS) { + rc = mb_crtm(); + if (rc != TPM_SUCCESS) { printk(BIOS_DEBUG, "%s: Fail! CRTM Version can't be measured." " ABORTING!!!\n", __func__); - return status; + return rc; } printk(BIOS_DEBUG, "%s: Success! CRTM Version measured.\n", __func__); /* Log the items defined by the mainboard */ for (i = 0; i < ARRAY_SIZE(mb_log_list); i++) { - status = mb_measure_log_worker( + rc = mb_measure_log_worker( mb_log_list[i].cbfs_name, mb_log_list[i].cbfs_type, mb_log_list[i].pcr, mb_log_list[i].eventType, mb_log_list[i].event_msg); - if (status != TPM_SUCCESS) { + if (rc != TPM_SUCCESS) { printk(BIOS_DEBUG, "%s: Fail! %s can't be measured." "ABORTING!!!\n", __func__, mb_log_list[i].cbfs_name); - return status; + return rc; } printk(BIOS_DEBUG, "%s: Success! %s measured to pcr" "%d.\n", __func__, mb_log_list[i].cbfs_name, mb_log_list[i].pcr); } - return status; + return rc; } static const uint8_t crtm_version[] = @@ -416,7 +416,7 @@ static const uint8_t crtm_version[] = **/ __weak int mb_crtm(void) { - int status; + int rc; TCG_PCR_EVENT2_HDR tcgEventHdr; uint8_t hash[VB2_SHA256_DIGEST_SIZE]; uint8_t *msgPtr; @@ -430,18 +430,18 @@ __weak int mb_crtm(void) printk(BIOS_DEBUG, "%s: EventSize - %u\n", __func__, tcgEventHdr.eventSize); - status = mboot_hash_extend_log(0, (uint8_t *)crtm_version, tcgEventHdr.eventSize, + rc = mboot_hash_extend_log(0, (uint8_t *)crtm_version, tcgEventHdr.eventSize, &tcgEventHdr, (uint8_t *)crtm_version); - if (status) { - printk(BIOS_DEBUG, "Measure CRTM Version returned 0x%x\n", status); - return status; + if (rc) { + printk(BIOS_DEBUG, "Measure CRTM Version returned 0x%x\n", rc); + return rc; } - status = get_intel_me_hash(hash); - if (status) { - printk(BIOS_DEBUG, "get_intel_me_hash returned 0x%x\n", status); - status = TPM_E_IOERROR; - return status; + rc = get_intel_me_hash(hash); + if (rc) { + printk(BIOS_DEBUG, "get_intel_me_hash returned 0x%x\n", rc); + rc = TPM_E_IOERROR; + return rc; } /* Add the me hash */ @@ -453,10 +453,10 @@ __weak int mb_crtm(void) msgPtr = NULL; tcgEventHdr.eventSize = 0; - status = mboot_hash_extend_log(MBOOT_HASH_PROVIDED, hash, sizeof(hash), &tcgEventHdr, + rc = mboot_hash_extend_log(MBOOT_HASH_PROVIDED, hash, sizeof(hash), &tcgEventHdr, msgPtr); - if (status) - printk(BIOS_DEBUG, "Add ME hash returned 0x%x\n", status); + if (rc) + printk(BIOS_DEBUG, "Add ME hash returned 0x%x\n", rc); - return status; + return rc; } diff --git a/src/vendorcode/google/chromeos/cr50_enable_update.c b/src/vendorcode/google/chromeos/cr50_enable_update.c index 551c56a9154..155769f545a 100644 --- a/src/vendorcode/google/chromeos/cr50_enable_update.c +++ b/src/vendorcode/google/chromeos/cr50_enable_update.c @@ -25,27 +25,27 @@ void __weak mainboard_prepare_cr50_reset(void) {} */ static int cr50_is_reset_needed(void) { - int ret; + int rc; uint8_t tpm_mode; - ret = tlcl_cr50_get_tpm_mode(&tpm_mode); + rc = tlcl_cr50_get_tpm_mode(&tpm_mode); - if (ret == TPM_E_NO_SUCH_COMMAND) { + if (rc == TPM_E_NO_SUCH_COMMAND) { printk(BIOS_INFO, "Cr50 does not support TPM mode command\n"); /* Older Cr50 firmware, assume no Cr50 reset is required */ return 0; } - if (ret == TPM_E_MUST_REBOOT) { + if (rc == TPM_E_MUST_REBOOT) { /* * Cr50 indicated a reboot is required to restore TPM * functionality. */ return 1; - } else if (ret != TPM_SUCCESS) { + } else if (rc != TPM_SUCCESS) { /* TPM command failed, continue booting. */ - printk(BIOS_ERR, "Attempt to get CR50 TPM mode failed: %x\n", ret); + printk(BIOS_ERR, "Attempt to get CR50 TPM mode failed: %x\n", rc); return 0; } @@ -70,7 +70,7 @@ static int cr50_is_reset_needed(void) static void enable_update(void *unused) { - int ret; + int rc; int cr50_reset_reqd = 0; uint8_t num_restored_headers; @@ -82,23 +82,23 @@ static void enable_update(void *unused) if (vboot_get_context()->flags & VB2_CONTEXT_FORCE_RECOVERY_MODE) return; - ret = tlcl_lib_init(); + rc = tlcl_lib_init(); - if (ret != VB2_SUCCESS) { + if (rc != VB2_SUCCESS) { printk(BIOS_ERR, "tlcl_lib_init() failed for CR50 update: %x\n", - ret); + rc); return; } timestamp_add_now(TS_TPM_ENABLE_UPDATE_START); /* Reboot in 1000 ms if necessary. */ - ret = tlcl_cr50_enable_update(CR50_RESET_DELAY_MS, + rc = tlcl_cr50_enable_update(CR50_RESET_DELAY_MS, &num_restored_headers); - if (ret != TPM_SUCCESS) { + if (rc != TPM_SUCCESS) { printk(BIOS_ERR, "Attempt to enable CR50 update failed: %x\n", - ret); + rc); return; } @@ -142,16 +142,16 @@ static void enable_update(void *unused) * the mainboard specific code runs. */ if (cr50_reset_reqd) { - ret = tlcl_cr50_immediate_reset(CR50_RESET_DELAY_MS); + rc = tlcl_cr50_immediate_reset(CR50_RESET_DELAY_MS); - if (ret != TPM_SUCCESS) { + if (rc != TPM_SUCCESS) { /* * Reset request failed due to TPM error, continue * booting but the current boot will likely end up at * the recovery screen. */ printk(BIOS_ERR, "Attempt to reset CR50 failed: %x\n", - ret); + rc); return; } } diff --git a/src/vendorcode/google/chromeos/cse_board_reset.c b/src/vendorcode/google/chromeos/cse_board_reset.c index 9efc4e61f65..7d19408726d 100644 --- a/src/vendorcode/google/chromeos/cse_board_reset.c +++ b/src/vendorcode/google/chromeos/cse_board_reset.c @@ -13,7 +13,7 @@ void cse_board_reset(void) { - int ret; + int rc; struct cr50_firmware_version version; if (CONFIG(CSE_RESET_CLEAR_EC_AP_IDLE_FLAG)) @@ -21,9 +21,9 @@ void cse_board_reset(void) if (CONFIG(TPM2) && CONFIG(TPM_GOOGLE_CR50)) { /* Initialize TPM and get the cr50 firmware version. */ - ret = tlcl_lib_init(); - if (ret != VB2_SUCCESS) { - printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", ret); + rc = tlcl_lib_init(); + if (rc != VB2_SUCCESS) { + printk(BIOS_ERR, "tlcl_lib_init() failed: 0x%x\n", rc); return; } diff --git a/src/vendorcode/google/chromeos/tpm2.c b/src/vendorcode/google/chromeos/tpm2.c index 98fd81522ba..a28b02eeaf5 100644 --- a/src/vendorcode/google/chromeos/tpm2.c +++ b/src/vendorcode/google/chromeos/tpm2.c @@ -7,7 +7,7 @@ static void disable_platform_hierarchy(void *unused) { - int ret; + int rc; if (!CONFIG(TPM2)) return; @@ -15,17 +15,17 @@ static void disable_platform_hierarchy(void *unused) if (!CONFIG(RESUME_PATH_SAME_AS_BOOT)) return; - ret = tlcl_lib_init(); + rc = tlcl_lib_init(); - if (ret != VB2_SUCCESS) { - printk(BIOS_ERR, "tlcl_lib_init() failed: %x\n", ret); + if (rc != VB2_SUCCESS) { + printk(BIOS_ERR, "tlcl_lib_init() failed: %x\n", rc); return; } - ret = tlcl_disable_platform_hierarchy(); - if (ret != TPM_SUCCESS) + rc = tlcl_disable_platform_hierarchy(); + if (rc != TPM_SUCCESS) printk(BIOS_ERR, "Platform hierarchy disablement failed: %x\n", - ret); + rc); } BOOT_STATE_INIT_ENTRY(BS_OS_RESUME, BS_ON_ENTRY, disable_platform_hierarchy,