diff mbox series

[U-Boot,v4,14/32] tpm: add possible traces to analyze buffers returned by the TPM

Message ID 20180515095728.16572-15-miquel.raynal@bootlin.com
State Accepted
Delegated to: Tom Rini
Headers show
Series Introduce TPMv2.0 support | expand

Commit Message

Miquel Raynal May 15, 2018, 9:57 a.m. UTC
When debugging, it is welcome to get more information about what the TPM
returns. Add the possibility to print the packets received to show their
exact content.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 lib/tpm-common.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Tom Rini May 15, 2018, 3:59 p.m. UTC | #1
On Tue, May 15, 2018 at 11:57:10AM +0200, Miquel Raynal wrote:

> When debugging, it is welcome to get more information about what the TPM
> returns. Add the possibility to print the packets received to show their
> exact content.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini May 26, 2018, 3:54 p.m. UTC | #2
On Tue, May 15, 2018 at 11:57:10AM +0200, Miquel Raynal wrote:

> When debugging, it is welcome to get more information about what the TPM
> returns. Add the possibility to print the packets received to show their
> exact content.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/lib/tpm-common.c b/lib/tpm-common.c
index 0812b73220..57832debf3 100644
--- a/lib/tpm-common.c
+++ b/lib/tpm-common.c
@@ -154,6 +154,7 @@  u32 tpm_sendrecv_command(const void *command, void *response, size_t *size_ptr)
 	int err, ret;
 	u8 response_buffer[COMMAND_BUFFER_SIZE];
 	size_t response_length;
+	int i;
 
 	if (response) {
 		response_length = *size_ptr;
@@ -173,7 +174,14 @@  u32 tpm_sendrecv_command(const void *command, void *response, size_t *size_ptr)
 	if (size_ptr)
 		*size_ptr = response_length;
 
-	return tpm_return_code(response);
+	ret = tpm_return_code(response);
+
+	log(LOGC_NONE, LOGL_DEBUG, "TPM response [ret:%d]: ", ret);
+	for (i = 0; i < response_length; i++)
+		log(LOGC_NONE, LOGL_DEBUG, "%02x ", ((u8 *)response)[i]);
+	log(LOGC_NONE, LOGL_DEBUG, "\n");
+
+	return ret;
 }
 
 int tpm_init(void)