diff mbox

[tpmdd-devel] What does error code 38 mean? -> hex vs. decimal

Message ID 20170426191808.kkvbg4iynbwysu6k@rhwork
State New
Headers show

Commit Message

Jerry Snitselaar April 26, 2017, 7:18 p.m. UTC
On Wed Apr 26 17, Ken Goldman wrote:
>On 4/23/2017 9:32 PM, Peter Huewe wrote:
>> 38=0x26= invalid post init, which means tpm did not receive tpm_startup
>> command after reset.
>
>A minor observation:
>
>While the TPM 1.2 specification listed error codes in decimal, TPM 2.0
>uses hex, and further has a lot of bit level encoding.
>
>Thus, for TPM 2.0, it would be easier if error messages printed TPM
>errors in hex.
>
>
>
>------------------------------------------------------------------------------
>Check out the vibrant tech community on one of the world's most
>engaging tech sites, Slashdot.org! http://sdm.link/slashdot
>_______________________________________________
>tpmdd-devel mailing list
>tpmdd-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

Maybe the following?

--8<--

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

Comments

Kenneth Goldman April 26, 2017, 8:57 p.m. UTC | #1
On 4/26/2017 3:18 PM, Jerry Snitselaar wrote:
>
> Maybe the following?
>
>
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index bd2128e0b56c..e6e60f9f428c 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -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 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;
>

I think that's a good idea.

I have a utility that parses the fields out of the TPM 2.0 error codes 
and prints the text.  It expects hex values, as does the specification.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index bd2128e0b56c..e6e60f9f428c 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -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 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;