linux/drivers/char/tpm
Duncan Laurie 32d33b29ba TPM: Retry SaveState command in suspend path
If the TPM has already been sent a SaveState command before the driver
is loaded it may have problems sending that same command again later.

This issue is seen with the Chromebook Pixel due to a firmware bug in
the legacy mode boot path which is sending the SaveState command
before booting the kernel.  More information is available at
http://crbug.com/203524

This change introduces a retry of the SaveState command in the suspend
path in order to work around this issue.  A future firmware update
should fix this but this is also a trivial workaround in the driver
that has no effect on systems that do not show this problem.

When this does happen the TPM responds with a non-fatal TPM_RETRY code
that is defined in the specification:

  The TPM is too busy to respond to the command immediately, but the
  command could be resubmitted at a later time.  The TPM MAY return
  TPM_RETRY for any command at any time.

It can take several seconds before the TPM will respond again.  I
measured a typical time between 3 and 4 seconds and the timeout is set
at a safe 5 seconds.

It is also possible to reproduce this with commands via /dev/tpm0.
The bug linked above has a python script attached which can be used to
test for this problem.  I tested a variety of TPMs from Infineon,
Nuvoton, Atmel, and STMicro but was only able to reproduce this with
LPC and I2C TPMs from Infineon.

The TPM specification only loosely defines this behavior:

  TPM Main Level 2 Part 3 v1.2 r116, section 3.3. TPM_SaveState:
  The TPM MAY declare all preserved values invalid in response to any
  command other than TPM_Init.

  TCG PC Client BIOS Spec 1.21 section 8.3.1.
  After issuing a TPM_SaveState command, the OS SHOULD NOT issue TPM
  commands before transitioning to S3 without issuing another
  TPM_SaveState command.

  TCG PC Client TIS 1.21, section 4. Power Management:
  The TPM_SaveState command allows a Static OS to indicate to the TPM
  that the platform may enter a low power state where the TPM will be
  required to enter into the D3 power state.  The use of the term "may"
  is significant in that there is no requirement for the platform to
  actually enter the low power state after sending the TPM_SaveState
  command.  The software may, in fact, send subsequent commands after
  sending the TPM_SaveState command.

Change-Id: I52b41e826412688e5b6c8ddd3bb16409939704e9
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
2013-04-17 09:31:32 -05:00
..
Kconfig tpm/ibmvtpm: build only when IBM pseries is configured 2013-02-14 09:36:50 -06:00
Makefile TPM: STMicroelectronics ST33 I2C BUILD STUFF 2013-02-05 09:38:23 -06:00
tpm.c TPM: Retry SaveState command in suspend path 2013-04-17 09:31:32 -05:00
tpm.h TPM: Retry SaveState command in suspend path 2013-04-17 09:31:32 -05:00
tpm_acpi.c TPM: Switch to __packed instead of __attribute__((packed)) 2013-02-05 09:38:22 -06:00
tpm_atmel.c tpm: Fix cancellation of TPM commands (polling mode) 2013-02-05 09:38:24 -06:00
tpm_atmel.h tpmdd maintainers 2007-08-22 19:52:44 -07:00
tpm_eventlog.c tpm: modularize event log collection 2012-08-22 11:11:25 -05:00
tpm_eventlog.h drivers/char/tpm: Add securityfs support for event log 2012-08-22 16:22:47 -05:00
tpm_i2c_infineon.c tpm/tpm_i2c_infineon: Add small comment about return value of __i2c_transfer 2013-04-12 12:17:29 -05:00
tpm_i2c_stm_st33.c tpm_i2c_stm_st33: Remove duplicate inclusion of header files 2013-04-12 12:17:29 -05:00
tpm_i2c_stm_st33.h tpm_i2c_stm_st33: fix oops when i2c client is unavailable 2013-02-05 09:38:24 -06:00
tpm_ibmvtpm.c tpm: Fix cancellation of TPM commands (polling mode) 2013-02-05 09:38:24 -06:00
tpm_ibmvtpm.h drivers/char/tpm: remove tasklet and cleanup 2012-11-01 15:23:14 -05:00
tpm_infineon.c Char/Misc driver merge for 3.8-rc1 2012-12-11 13:56:38 -08:00
tpm_nsc.c tpm: Fix cancellation of TPM commands (polling mode) 2013-02-05 09:38:24 -06:00
tpm_of.c drivers/char/tpm: Add securityfs support for event log 2012-08-22 16:22:47 -05:00
tpm_ppi.c drivers/char/tpm/tpm_ppi: use strlcpy instead of strncpy 2013-04-12 12:17:28 -05:00
tpm_tis.c tpm_tis: check pnp_acpi_device return code 2013-02-05 09:38:26 -06:00