tpm: print tpm error code in hex for TPM2.0 devices
PATCH 1/1 tpm: print tpm error code in hex for TPM2.0 devices
For easier decoding, output the error code returned from the tpm device in hex when the device is TPM2.0.
--- drivers/char/tpm/tpm-interface.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm-interface.c +8 -3
@@ -453,9 +453,14 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf,return -EFAULT ; err =be32_to_cpu (header->return_code); -if (err !=0 && desc) -dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , err, - desc); +if (err !=0 && desc) { +if (chip->flags &TPM_CHIP_FLAG_TPM2 ) +dev_err (&chip->dev,"A TPM 2.0 error (0x%x) occurred %s\n" , + err, desc); +else +dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , + err, desc); + }if (err)return err;
Signature · 6 lines
2.13.0.rc0.45.ge2cb6ab84 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 22 lines · Jerry Snitselaar
For easier decoding, output the error code returned from the tpm device in hex when the device is TPM2.0.
Cc Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/[email protected]>Cc Peter Huewe <[email protected]>Cc Marcel Selhorst <[email protected]>Cc Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>Reported-by Ken Goldman <kgoldman-r/[email protected]>Signed-off-by Jerry Snitselaar <[email protected]>--- drivers/char/tpm/tpm-interface.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/char/tpm/tpm-interface.c +0
-1@@ -453,9 +453,14 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf,return -EFAULT ; err =be32_to_cpu (header->return_code); -if (err !=0 && desc)
drivers/char/tpm/tpm-interface.c ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf, · line 463
Quoted 10 lines
drivers/char/tpm/tpm-interface.c +8
-2-dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , err, - desc); +if (err !=0 && desc) { +if (chip->flags &TPM_CHIP_FLAG_TPM2 ) +dev_err (&chip->dev,"A TPM 2.0 error (0x%x) occurred %s\n" , + err, desc); +else +dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , + err, desc); + }
Is there a reason for not to apply this also to TPM 1.2?
/Jarkko
Quoted 6 lines
drivers/char/tpm/tpm-interface.c +0
-0if (err)return err;Signature · 1 line
2.13.0.rc0.45.ge2cb6ab84
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 36 lines · Jarkko Sakkinen
Quoted 22 lines · Jerry Snitselaar
For easier decoding, output the error code returned from the tpm device in hex when the device is TPM2.0.
Cc Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/[email protected]>Cc Peter Huewe <[email protected]>Cc Marcel Selhorst <[email protected]>Cc Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>Reported-by Ken Goldman <kgoldman-r/[email protected]>Signed-off-by Jerry Snitselaar <[email protected]>--- drivers/char/tpm/tpm-interface.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/char/tpm/tpm-interface.c +0
-1@@ -453,9 +453,14 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf,return -EFAULT ; err =be32_to_cpu (header->return_code); -if (err !=0 && desc)drivers/char/tpm/tpm-interface.c ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf, · line 463
Quoted 10 lines
drivers/char/tpm/tpm-interface.c +8
-2-dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , err, - desc); +if (err !=0 && desc) { +if (chip->flags &TPM_CHIP_FLAG_TPM2 ) +dev_err (&chip->dev,"A TPM 2.0 error (0x%x) occurred %s\n" , + err, desc); +else +dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , + err, desc); + }Is there a reason for not to apply this also to TPM 1.2?
Quoted 2 lines
/Jarkko
The 2.0 spec lists the response codes in hex, while the 1.2 spec lists them in decimal. Maybe something like the following instead?
index 158c1db83f05..1f433d56f53c 100644
drivers/char/tpm/tpm-interface.c +2 -2
@@ -526,8 +526,8 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space, err =be32_to_cpu (header->return_code);if (err !=0 && desc) -dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , err, - desc); +dev_err (&chip->dev,"A TPM error (%d (0x%x)) occurred %s\n" , err, + err, desc);if (err)return err;
Quoted 6 lines
Quoted 6 lines
drivers/char/tpm/tpm-interface.c +0
-1if (err)return err; --2.13.0.rc0.45.ge2cb6ab84
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Jarkko Sakkinen
Reviewed-byQuoted 37 lines · Jerry Snitselaar
Quoted 36 lines · Jarkko Sakkinen
Quoted 22 lines · Jerry Snitselaar
For easier decoding, output the error code returned from the tpm device in hex when the device is TPM2.0.
Cc Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/[email protected]>Cc Peter Huewe <[email protected]>Cc Marcel Selhorst <[email protected]>Cc Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>Reported-by Ken Goldman <kgoldman-r/[email protected]>Signed-off-by Jerry Snitselaar <[email protected]>--- drivers/char/tpm/tpm-interface.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/char/tpm/tpm-interface.c +0
-1@@ -453,9 +453,14 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf,return -EFAULT ; err =be32_to_cpu (header->return_code); -if (err !=0 && desc)drivers/char/tpm/tpm-interface.c ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf, · line 463
Quoted 10 lines
drivers/char/tpm/tpm-interface.c +8
-2-dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , err, - desc); +if (err !=0 && desc) { +if (chip->flags &TPM_CHIP_FLAG_TPM2 ) +dev_err (&chip->dev,"A TPM 2.0 error (0x%x) occurred %s\n" , + err, desc); +else +dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , + err, desc); + }Is there a reason for not to apply this also to TPM 1.2?
Quoted 5 lines
Quoted 2 lines
/Jarkko
The 2.0 spec lists the response codes in hex, while the 1.2 spec lists them in decimal. Maybe something like the following instead?
Ah. Well, I thinkthe original patch is fine then.
/Jarkko
Quoted 16 lines
index
158c1db83f05..1f433d56f53c100644drivers/char/tpm/tpm-interface.c +2
-2@@ -526,8 +526,8 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space, err =be32_to_cpu (header->return_code);if (err !=0 && desc) -dev_err (&chip->dev,"A TPM error (%d) occurred %s\n" , err, - desc); +dev_err (&chip->dev,"A TPM error (%d (0x%x)) occurred %s\n" , err, + err, desc);if (err)return err;
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/char/tpm/tpm-interface.c +0
-1if (err)return err; --2.13.0.rc0.45.ge2cb6ab84
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot