]> git.baikalelectronics.ru Git - kernel.git/commit
tpm: add retry logic
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Wed, 21 Mar 2018 18:43:48 +0000 (11:43 -0700)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Fri, 23 Mar 2018 08:25:09 +0000 (10:25 +0200)
commit405c16566e4a755d5c7987a24b1f6a73b1366cf5
tree96a8523b86c87a01e739314d1760b5cb3a0983d9
parent256e8ff187328e007bf82ba4a44b7338803b0402
tpm: add retry logic

TPM2 can return TPM2_RC_RETRY to any command and when it does we get
unexpected failures inside the kernel that surprise users (this is
mostly observed in the trusted key handling code).  The UEFI 2.6 spec
has advice on how to handle this:

    The firmware SHALL not return TPM2_RC_RETRY prior to the completion
    of the call to ExitBootServices().

    Implementer’s Note: the implementation of this function should check
    the return value in the TPM response and, if it is TPM2_RC_RETRY,
    resend the command. The implementation may abort if a sufficient
    number of retries has been done.

So we follow that advice in our tpm_transmit() code using
TPM2_DURATION_SHORT as the initial wait duration and
TPM2_DURATION_LONG as the maximum wait time.  This should fix all the
in-kernel use cases and also means that user space TSS implementations
don't have to have their own retry handling.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: stable@vger.kernel.org
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
drivers/char/tpm/tpm-interface.c
drivers/char/tpm/tpm.h