diff options
author | Randall Spangler <rspangler@chromium.org> | 2017-01-20 14:54:47 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-01-20 22:40:31 -0800 |
commit | a609478d1a1e9bc11a2122797ed4eb336d5dbdee (patch) | |
tree | b1341da92313a4f37fc05ecb06a396c9345f0d88 /firmware/lib/tpm2_lite | |
parent | 1a03740bb094585a6aeba7c1bd83077d5f219c9f (diff) | |
download | vboot-a609478d1a1e9bc11a2122797ed4eb336d5dbdee.tar.gz |
2lib: add VB2_DEBUG_RAW() to print without function name
Currently, VB2_DEBUG() will print the function name as a prefix to the
debug output. Add VB2_DEBUG_RAW() to print without that, so that it's
possible to print little bits of debug output. Use this in ec_sync to
hex dump the hashes.
And then clean up all of the debug calls which explicitly did things like:
VB2_DEBUG("%s: foo", __func__);
to just:
VB2_DEBUG("foo");
so they don't double-print the function name
BUG=chromium:683391
BRANCH=none
TEST=build_packages --board=reef chromeos-firmware &&
DEBUG=1 make -j runtests
CQ-DEPEND=CL:430978,CL:431111
Change-Id: I0c35519d2e670d55d65d01eaa60d61f3e3edf419
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/431171
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'firmware/lib/tpm2_lite')
-rw-r--r-- | firmware/lib/tpm2_lite/marshaling.c | 69 | ||||
-rw-r--r-- | firmware/lib/tpm2_lite/tlcl.c | 14 |
2 files changed, 35 insertions, 48 deletions
diff --git a/firmware/lib/tpm2_lite/marshaling.c b/firmware/lib/tpm2_lite/marshaling.c index f51e4764..93beaf70 100644 --- a/firmware/lib/tpm2_lite/marshaling.c +++ b/firmware/lib/tpm2_lite/marshaling.c @@ -113,9 +113,8 @@ static void unmarshal_TPM2B_MAX_NV_BUFFER(void **buffer, { nv_buffer->t.size = unmarshal_u16(buffer, size); if (nv_buffer->t.size > *size) { - VB2_DEBUG("%s:%d - " - "size mismatch: expected %d, remaining %d\n", - __func__, __LINE__, nv_buffer->t.size, *size); + VB2_DEBUG("size mismatch: expected %d, remaining %d\n", + nv_buffer->t.size, *size); return; } @@ -133,9 +132,8 @@ static void unmarshal_authorization_section(void **buffer, int *size, * just confirm that this is the case and report any discrepancy. */ if (*size != 5) - VB2_DEBUG("%s:%d - unexpected authorisation section size %d " - "for %s\n", - __func__, __LINE__, *size, cmd_name); + VB2_DEBUG("unexpected authorisation section size %d for %s\n", + *size, cmd_name); *buffer = ((uint8_t *)(*buffer)) + *size; *size = 0; @@ -150,9 +148,8 @@ static void unmarshal_nv_read(void **buffer, int *size, if (nvr->params_size != (nvr->buffer.t.size + sizeof(nvr->buffer.t.size))) { - VB2_DEBUG("%s:%d - parameter/buffer %d/%d size mismatch", - __func__, __LINE__, nvr->params_size, - nvr->buffer.t.size); + VB2_DEBUG("parameter/buffer %d/%d size mismatch", + nvr->params_size, nvr->buffer.t.size); return; } @@ -168,9 +165,8 @@ static void unmarshal_TPM2B(void **buffer, { tpm2b->size = unmarshal_u16(buffer, size); if (tpm2b->size > *size) { - VB2_DEBUG("%s:%d - " - "size mismatch: expected %d, remaining %d\n", - __func__, __LINE__, tpm2b->size, *size); + VB2_DEBUG("size mismatch: expected %d, remaining %d\n", + tpm2b->size, *size); *size = -1; return; } @@ -187,9 +183,8 @@ static void unmarshal_TPMS_NV_PUBLIC(void **buffer, { int tpm2b_size = unmarshal_u16(buffer, size); if (tpm2b_size > *size) { - VB2_DEBUG("%s:%d - " - "size mismatch: expected %d, remaining %d\n", - __func__, __LINE__, tpm2b_size, *size); + VB2_DEBUG("size mismatch: expected %d, remaining %d\n", + tpm2b_size, *size); *size = -1; return; } @@ -202,9 +197,7 @@ static void unmarshal_TPMS_NV_PUBLIC(void **buffer, pub->dataSize = unmarshal_u16(buffer, &tpm2b_size); if (tpm2b_size != 0) { - VB2_DEBUG("%s:%d - " - "TPMS_NV_PUBLIC size doesn't match the size field\n", - __func__, __LINE__); + VB2_DEBUG("TPMS_NV_PUBLIC size doesn't match size field\n"); *size = -1; return; } @@ -217,9 +210,7 @@ static void unmarshal_nv_read_public(void **buffer, int *size, unmarshal_TPM2B(buffer, size, &nv_pub->nvName); if (*size > 0) { - VB2_DEBUG("%s:%d - " - "extra %d bytes after nvName\n", - __func__, __LINE__, *size); + VB2_DEBUG("extra %d bytes after nvName\n", *size); *size = -1; return; } @@ -232,9 +223,9 @@ static void unmarshal_TPML_TAGGED_TPM_PROPERTY(void **buffer, int *size, if (prop->count != 1) { *size = -1; - VB2_DEBUG("%s:%d:Request to unmarshal unsupported " + VB2_DEBUG("Request to unmarshal unsupported " "number of properties: %u\n", - __FILE__, __LINE__, prop->count); + prop->count); return; } @@ -257,9 +248,8 @@ static void unmarshal_TPMS_CAPABILITY_DATA(void **buffer, int *size, default: *size = -1; - VB2_DEBUG("%s:%d:Request to unmarshal unsupported " - "capability %#x\n", - __FILE__, __LINE__, cap_data->capability); + VB2_DEBUG("Request to unmarshal unsupported capability %#x\n", + cap_data->capability); } } @@ -354,8 +344,7 @@ static void marshal_reserve_size_field(void **buffer, int *buffer_space) { if (field_size != sizeof(uint32_t) && field_size != sizeof(uint16_t)) { - VB2_DEBUG("%s:%d:Unsupported size field size: %d\n", - __FILE__, __LINE__, field_size); + VB2_DEBUG("Unsupported size field size: %d\n", field_size); *buffer_space = -1; return; } @@ -709,8 +698,8 @@ int tpm_marshal_command(TPM_CC command, void *tpm_command_body, default: body_size = -1; - VB2_DEBUG("%s:%d:Request to marshal unsupported command %#x\n", - __FILE__, __LINE__, command); + VB2_DEBUG("Request to marshal unsupported command %#x\n", + command); } if (body_size > 0) { @@ -743,9 +732,8 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command, if (!cr_size) { if (tpm2_resp.hdr.tpm_size != sizeof(tpm2_resp.hdr)) - VB2_DEBUG("%s: " - "size mismatch in response to command %#x\n", - __func__, command); + VB2_DEBUG("size mismatch in response to command %#x\n", + command); return &tpm2_resp; } @@ -782,17 +770,16 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command, { int i; - VB2_DEBUG("%s:%d:" - "Request to unmarshal unexpected command %#x," + VB2_DEBUG("Request to unmarshal unexpected command %#x," " code %#x", - __func__, __LINE__, command, + command, tpm2_resp.hdr.tpm_code); for (i = 0; i < cr_size; i++) { if (!(i % 16)) - VB2_DEBUG("\n"); - VB2_DEBUG("%2.2x ", - ((uint8_t *)response_body)[i]); + VB2_DEBUG_RAW("\n"); + VB2_DEBUG_RAW("%2.2x ", + ((uint8_t *)response_body)[i]); } } VB2_DEBUG("\n"); @@ -800,9 +787,9 @@ struct tpm2_response *tpm_unmarshal_response(TPM_CC command, } if (cr_size) { - VB2_DEBUG("%s:%d got %d bytes back in response to %#x," + VB2_DEBUG("got %d bytes back in response to %#x," " failed to parse (%d)\n", - __func__, __LINE__, tpm2_resp.hdr.tpm_size, + tpm2_resp.hdr.tpm_size, command, cr_size); return NULL; } diff --git a/firmware/lib/tpm2_lite/tlcl.c b/firmware/lib/tpm2_lite/tlcl.c index 7a9f68e0..0af34d08 100644 --- a/firmware/lib/tpm2_lite/tlcl.c +++ b/firmware/lib/tpm2_lite/tlcl.c @@ -39,7 +39,7 @@ static struct tpm2_response *tpm_process_command(TPM_CC command, response = tpm_unmarshal_response(command, cr_buffer, in_size); - VB2_DEBUG("%s: command %#x, return code %#x\n", __func__, command, + VB2_DEBUG("command %#x, return code %#x\n", command, response ? response->hdr.tpm_code : -1); return response; @@ -210,13 +210,13 @@ uint32_t TlclForceClear(void) uint32_t TlclSetDeactivated(uint8_t flag) { - VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__); + VB2_DEBUG("NOT YET IMPLEMENTED\n"); return TPM_SUCCESS; } uint32_t TlclSetEnable(void) { - VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__); + VB2_DEBUG("NOT YET IMPLEMENTED\n"); return TPM_SUCCESS; } @@ -236,13 +236,13 @@ uint32_t TlclGetFlags(uint8_t* disable, int TlclIsOwned(void) { - VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__); + VB2_DEBUG("NOT YET IMPLEMENTED\n"); return 0; } uint32_t TlclExtend(int pcr_num, const uint8_t *in_digest, uint8_t *out_digest) { - VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__); + VB2_DEBUG("NOT YET IMPLEMENTED\n"); return TPM_SUCCESS; } @@ -476,7 +476,7 @@ uint32_t TlclWrite(uint32_t index, const void *data, uint32_t length) uint32_t TlclPCRRead(uint32_t index, void *data, uint32_t length) { - VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__); + VB2_DEBUG("NOT YET IMPLEMENTED\n"); return TPM_SUCCESS; } @@ -519,6 +519,6 @@ uint32_t TlclReadLock(uint32_t index) uint32_t TlclGetRandom(uint8_t *data, uint32_t length, uint32_t *size) { *size = 0; - VB2_DEBUG("%s called, NOT YET IMPLEMENTED\n", __func__); + VB2_DEBUG("NOT YET IMPLEMENTED\n"); return TPM_E_IOERROR; } |