From 53fc667943052bd592b8406bdf4bf652c6c9cd3a Mon Sep 17 00:00:00 2001 From: Jon Murphy Date: Tue, 26 Sep 2023 21:05:37 -0600 Subject: treewide: convert to %#x hex prints Convert hex print values to use the %#x qualifier to print 0x{value}. BUG=b:296439237 TEST=build and boot to Skyrim BRANCH=None Change-Id: I0d1ac4b920530635fb758c5165a6a99c11b414c8 Signed-off-by: Jon Murphy Reviewed-on: https://review.coreboot.org/c/coreboot/+/78183 Reviewed-by: Raul Rangel Reviewed-by: Karthik Ramasubramanian Tested-by: build bot (Jenkins) --- src/security/tpm/tss/tcg-1.2/tss.c | 10 +++++----- src/security/tpm/tss/tcg-2.0/tss.c | 22 +++++++++++----------- src/security/tpm/tss/vendor/cr50/cr50.c | 2 +- src/security/vboot/mrc_cache_hash_tpm.c | 4 ++-- src/security/vboot/secdata_tpm.c | 16 ++++++++-------- src/security/vboot/vbios_cache_hash_tpm.c | 4 ++-- src/security/vboot/vboot_logic.c | 6 +++--- 7 files changed, 32 insertions(+), 32 deletions(-) (limited to 'src/security') diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c index b6527a64829e..076b8a7562b4 100644 --- a/src/security/tpm/tss/tcg-1.2/tss.c +++ b/src/security/tpm/tss/tcg-1.2/tss.c @@ -82,7 +82,7 @@ static uint32_t tlcl_send_receive_no_retry(const uint8_t *request, response, &response_length); if (rc != 0) { /* Communication with TPM failed, so response is garbage */ - VBDEBUG("TPM: command 0x%x send/receive failed: 0x%x\n", + VBDEBUG("TPM: command %#x send/receive failed: %#x\n", tpm_command_code(request), rc); return rc; } @@ -93,7 +93,7 @@ static uint32_t tlcl_send_receive_no_retry(const uint8_t *request, * (and possibly expected length from the response header). See * crosbug.com/17017 */ - VBDEBUG("TPM: command 0x%x returned 0x%x\n", + VBDEBUG("TPM: command %#x returned %#x\n", tpm_command_code(request), rc); return rc; @@ -193,7 +193,7 @@ uint32_t tlcl_continue_self_test(void) uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size) { struct s_tpm_nv_definespace_cmd cmd; - VBDEBUG("TPM: TlclDefineSpace(0x%x, 0x%x, %d)\n", index, perm, size); + VBDEBUG("TPM: TlclDefineSpace(%#x, %#x, %d)\n", index, perm, size); memcpy(&cmd, &tpm_nv_definespace_cmd, sizeof(cmd)); to_tpm_uint32(cmd.buffer + tpm_nv_definespace_cmd.index, index); to_tpm_uint32(cmd.buffer + tpm_nv_definespace_cmd.perm, perm); @@ -208,7 +208,7 @@ uint32_t tlcl_write(uint32_t index, const void *data, uint32_t length) const int total_length = kTpmRequestHeaderLength + kWriteInfoLength + length; - VBDEBUG("TPM: %s(0x%x, %d)\n", __func__, index, length); + VBDEBUG("TPM: %s(%#x, %d)\n", __func__, index, length); memcpy(&cmd, &tpm_nv_write_cmd, sizeof(cmd)); assert(total_length <= TPM_LARGE_ENOUGH_COMMAND_SIZE); set_tpm_command_size(cmd.buffer, total_length); @@ -228,7 +228,7 @@ uint32_t tlcl_read(uint32_t index, void *data, uint32_t length) uint32_t result_length; uint32_t rc; - VBDEBUG("TPM: %s(0x%x, %d)\n", __func__, index, length); + VBDEBUG("TPM: %s(%#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); diff --git a/src/security/tpm/tss/tcg-2.0/tss.c b/src/security/tpm/tss/tcg-2.0/tss.c index 5b9aab82bf9c..e780bd24d3be 100644 --- a/src/security/tpm/tss/tcg-2.0/tss.c +++ b/src/security/tpm/tss/tcg-2.0/tss.c @@ -60,7 +60,7 @@ static uint32_t tlcl_send_startup(TPM_SU type) return TPM_IOERROR; } - printk(BIOS_INFO, "%s: Startup return code is %x\n", + printk(BIOS_INFO, "%s: Startup return code is %#x\n", __func__, response->hdr.tpm_code); switch (response->hdr.tpm_code) { @@ -94,7 +94,7 @@ static uint32_t tlcl_send_shutdown(TPM_SU type) return TPM_IOERROR; } - printk(BIOS_INFO, "%s: Shutdown return code is %x\n", + printk(BIOS_INFO, "%s: Shutdown return code is %#x\n", __func__, response->hdr.tpm_code); if (response->hdr.tpm_code == TPM2_RC_SUCCESS) @@ -155,7 +155,7 @@ uint32_t tlcl_extend(int pcr_num, const uint8_t *digest_data, response = tpm_process_command(TPM2_PCR_Extend, &pcr_ext_cmd); - printk(BIOS_INFO, "%s: response is %x\n", + printk(BIOS_INFO, "%s: response is %#x\n", __func__, response ? response->hdr.tpm_code : -1); if (!response || response->hdr.tpm_code) return TPM_IOERROR; @@ -175,7 +175,7 @@ uint32_t tlcl_force_clear(void) struct tpm2_response *response; response = tpm_process_command(TPM2_Clear, NULL); - printk(BIOS_INFO, "%s: response is %x\n", + printk(BIOS_INFO, "%s: response is %#x\n", __func__, response ? response->hdr.tpm_code : -1); if (!response || response->hdr.tpm_code) @@ -192,7 +192,7 @@ uint32_t tlcl_clear_control(bool disable) }; response = tpm_process_command(TPM2_ClearControl, &cc); - printk(BIOS_INFO, "%s: response is %x\n", + printk(BIOS_INFO, "%s: response is %#x\n", __func__, response ? response->hdr.tpm_code : -1); if (!response || response->hdr.tpm_code) @@ -246,7 +246,7 @@ uint32_t tlcl_read(uint32_t index, void *data, uint32_t length) if (!response) return TPM_CB_READ_FAILURE; - printk(BIOS_INFO, "%s:%d index %#x return code %x\n", + printk(BIOS_INFO, "%s:%d index %#x return code %#x\n", __FILE__, __LINE__, index, response->hdr.tpm_code); switch (response->hdr.tpm_code) { case 0: @@ -287,7 +287,7 @@ uint32_t tlcl_self_test_full(void) st.yes_no = 1; response = tpm_process_command(TPM2_SelfTest, &st); - printk(BIOS_INFO, "%s: response is %x\n", + printk(BIOS_INFO, "%s: response is %#x\n", __func__, response ? response->hdr.tpm_code : -1); return TPM_SUCCESS; } @@ -302,7 +302,7 @@ uint32_t tlcl_lock_nv_write(uint32_t index) response = tpm_process_command(TPM2_NV_WriteLock, &nv_wl); - printk(BIOS_INFO, "%s: response is %x\n", + printk(BIOS_INFO, "%s: response is %#x\n", __func__, response ? response->hdr.tpm_code : -1); if (!response || response->hdr.tpm_code) @@ -329,7 +329,7 @@ uint32_t tlcl_write(uint32_t index, const void *data, uint32_t length) response = tpm_process_command(TPM2_NV_Write, &nv_writec); - printk(BIOS_INFO, "%s: response is %x\n", + printk(BIOS_INFO, "%s: response is %#x\n", __func__, response ? response->hdr.tpm_code : -1); /* Need to map tpm error codes into internal values. */ @@ -352,7 +352,7 @@ uint32_t tlcl_set_bits(uint32_t index, uint64_t bits) response = tpm_process_command(TPM2_NV_SetBits, &nvsb_cmd); - printk(BIOS_INFO, "%s: response is %x\n", + printk(BIOS_INFO, "%s: response is %#x\n", __func__, response ? response->hdr.tpm_code : -1); /* Need to map tpm error codes into internal values. */ @@ -388,7 +388,7 @@ uint32_t tlcl_define_space(uint32_t space_index, size_t space_size, } response = tpm_process_command(TPM2_NV_DefineSpace, &nvds_cmd); - printk(BIOS_INFO, "%s: response is %x\n", __func__, + printk(BIOS_INFO, "%s: response is %#x\n", __func__, response ? response->hdr.tpm_code : -1); if (!response) diff --git a/src/security/tpm/tss/vendor/cr50/cr50.c b/src/security/tpm/tss/vendor/cr50/cr50.c index 5dbf0148bbf8..17115013232c 100644 --- a/src/security/tpm/tss/vendor/cr50/cr50.c +++ b/src/security/tpm/tss/vendor/cr50/cr50.c @@ -20,7 +20,7 @@ uint32_t tlcl_cr50_enable_nvcommits(void) if (!response || (response && response->hdr.tpm_code)) { if (response) - printk(BIOS_INFO, "%s: failed %x\n", __func__, + printk(BIOS_INFO, "%s: failed %#x\n", __func__, response->hdr.tpm_code); else printk(BIOS_INFO, "%s: failed\n", __func__); diff --git a/src/security/vboot/mrc_cache_hash_tpm.c b/src/security/vboot/mrc_cache_hash_tpm.c index f67eae48cb39..07baed7eba44 100644 --- a/src/security/vboot/mrc_cache_hash_tpm.c +++ b/src/security/vboot/mrc_cache_hash_tpm.c @@ -41,7 +41,7 @@ void mrc_cache_update_hash(uint32_t index, const uint8_t *data, size_t size) return; } - printk(BIOS_INFO, "MRC: TPM MRC hash idx 0x%x updated successfully.\n", index); + printk(BIOS_INFO, "MRC: TPM MRC hash idx %#x updated successfully.\n", index); } int mrc_cache_verify_hash(uint32_t index, const uint8_t *data, size_t size) @@ -67,7 +67,7 @@ int mrc_cache_verify_hash(uint32_t index, const uint8_t *data, size_t size) return 0; } - printk(BIOS_INFO, "MRC: Hash idx 0x%x comparison successful.\n", index); + printk(BIOS_INFO, "MRC: Hash idx %#x comparison successful.\n", index); return 1; } diff --git a/src/security/vboot/secdata_tpm.c b/src/security/vboot/secdata_tpm.c index fdf98cc41cba..d19b47e60968 100644 --- a/src/security/vboot/secdata_tpm.c +++ b/src/security/vboot/secdata_tpm.c @@ -436,8 +436,8 @@ uint32_t antirollback_lock_space_firmware(void) uint32_t antirollback_read_space_mrc_hash(uint32_t index, uint8_t *data, uint32_t size) { if (size != HASH_NV_SIZE) { - VBDEBUG("TPM: Incorrect buffer size for hash idx 0x%x. " - "(Expected=0x%x Actual=0x%x).\n", index, HASH_NV_SIZE, + VBDEBUG("TPM: Incorrect buffer size for hash idx %#x. " + "(Expected=%#x Actual=%#x).\n", index, HASH_NV_SIZE, size); return TPM_CB_READ_FAILURE; } @@ -450,8 +450,8 @@ uint32_t antirollback_write_space_mrc_hash(uint32_t index, const uint8_t *data, uint32_t rc; if (size != HASH_NV_SIZE) { - VBDEBUG("TPM: Incorrect buffer size for hash idx 0x%x. " - "(Expected=0x%x Actual=0x%x).\n", index, HASH_NV_SIZE, + VBDEBUG("TPM: Incorrect buffer size for hash idx %#x. " + "(Expected=%#x Actual=%#x).\n", index, HASH_NV_SIZE, size); return TPM_CB_WRITE_FAILURE; } @@ -486,8 +486,8 @@ static uint32_t read_space_vbios_hash(uint8_t *data) uint32_t antirollback_read_space_vbios_hash(uint8_t *data, uint32_t size) { if (size != HASH_NV_SIZE) { - VBDEBUG("TPM: Incorrect buffer size for hash idx 0x%x. " - "(Expected=0x%x Actual=0x%x).\n", VBIOS_CACHE_NV_INDEX, HASH_NV_SIZE, + VBDEBUG("TPM: Incorrect buffer size for hash idx %#x. " + "(Expected=%#x Actual=%#x).\n", VBIOS_CACHE_NV_INDEX, HASH_NV_SIZE, size); return TPM_CB_READ_FAILURE; } @@ -500,8 +500,8 @@ uint32_t antirollback_write_space_vbios_hash(const uint8_t *data, uint32_t size) uint32_t rc; if (size != HASH_NV_SIZE) { - VBDEBUG("TPM: Incorrect buffer size for hash idx 0x%x. " - "(Expected=0x%x Actual=0x%x).\n", VBIOS_CACHE_NV_INDEX, HASH_NV_SIZE, + VBDEBUG("TPM: Incorrect buffer size for hash idx %#x. " + "(Expected=%#x Actual=%#x).\n", VBIOS_CACHE_NV_INDEX, HASH_NV_SIZE, size); return TPM_CB_WRITE_FAILURE; } diff --git a/src/security/vboot/vbios_cache_hash_tpm.c b/src/security/vboot/vbios_cache_hash_tpm.c index aa54f19e4c90..6ad09ace8e17 100644 --- a/src/security/vboot/vbios_cache_hash_tpm.c +++ b/src/security/vboot/vbios_cache_hash_tpm.c @@ -41,7 +41,7 @@ void vbios_cache_update_hash(const uint8_t *data, size_t size) return; } - printk(BIOS_INFO, "VBIOS_CACHE: TPM NV idx 0x%x updated successfully.\n", + printk(BIOS_INFO, "VBIOS_CACHE: TPM NV idx %#x updated successfully.\n", VBIOS_CACHE_NV_INDEX); } @@ -68,7 +68,7 @@ enum cb_err vbios_cache_verify_hash(const uint8_t *data, size_t size) return CB_ERR; } - printk(BIOS_INFO, "VBIOS_CACHE: Hash idx 0x%x comparison successful.\n", + printk(BIOS_INFO, "VBIOS_CACHE: Hash idx %#x comparison successful.\n", VBIOS_CACHE_NV_INDEX); return CB_SUCCESS; diff --git a/src/security/vboot/vboot_logic.c b/src/security/vboot/vboot_logic.c index 69cfaf80476c..f6d8bad2e3d1 100644 --- a/src/security/vboot/vboot_logic.c +++ b/src/security/vboot/vboot_logic.c @@ -318,7 +318,7 @@ void verstage_main(void) * For any other error code, save context if needed and reboot. */ if (rv == VB2_ERROR_API_PHASE1_RECOVERY) { - printk(BIOS_INFO, "Recovery requested (%x)\n", rv); + printk(BIOS_INFO, "Recovery requested (%#x)\n", rv); vboot_save_data(ctx); extend_pcrs(ctx); /* ignore failures */ goto verstage_main_exit; @@ -376,7 +376,7 @@ void verstage_main(void) timestamp_add_now(TS_TPMLOCK_START); rv = antirollback_lock_space_firmware(); if (rv) { - printk(BIOS_INFO, "Failed to lock TPM (%x)\n", rv); + printk(BIOS_INFO, "Failed to lock TPM (%#x)\n", rv); vboot_fail_and_reboot(ctx, VB2_RECOVERY_RO_TPM_L_ERROR, 0); } timestamp_add_now(TS_TPMLOCK_END); @@ -385,7 +385,7 @@ void verstage_main(void) if (CONFIG(VBOOT_HAS_REC_HASH_SPACE)) { rv = antirollback_lock_space_mrc_hash(MRC_REC_HASH_NV_INDEX); if (rv) { - printk(BIOS_INFO, "Failed to lock rec hash space(%x)\n", rv); + printk(BIOS_INFO, "Failed to lock rec hash space(%#x)\n", rv); vboot_fail_and_reboot(ctx, VB2_RECOVERY_RO_TPM_REC_HASH_L_ERROR, rv); } } -- cgit v1.2.3