diff options
author | James Bottomley <James.Bottomley@HansenPartnership.com> | 2020-09-28 11:00:12 -0700 |
---|---|---|
committer | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> | 2020-10-02 00:21:03 +0300 |
commit | 55707d531af62bd87c1b7e8d66fd9798094f9b3b (patch) | |
tree | 4c874510faad3ff787284e22459493d82e7d1883 /drivers/char/tpm | |
parent | e08c6d3b19930f84a8da8c18710eefdfa48a9ceb (diff) | |
download | linux-stable-55707d531af62bd87c1b7e8d66fd9798094f9b3b.tar.gz linux-stable-55707d531af62bd87c1b7e8d66fd9798094f9b3b.tar.bz2 linux-stable-55707d531af62bd87c1b7e8d66fd9798094f9b3b.zip |
tpm_tis: Add a check for invalid status
Some TIS based TPMs can return 0xff to status reads if the locality
hasn't been properly requested. Detect this condition by checking the
bits that the TIS spec specifies must return zero are clear and return
zero in that case. Also drop a warning so the problem can be
identified in the calling path and fixed (usually a missing
try_get_ops()).
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Diffstat (limited to 'drivers/char/tpm')
-rw-r--r-- | drivers/char/tpm/tpm_tis_core.c | 11 | ||||
-rw-r--r-- | drivers/char/tpm/tpm_tis_core.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 65ab1b027949..92c51c6cfd1b 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -239,6 +239,17 @@ static u8 tpm_tis_status(struct tpm_chip *chip) if (rc < 0) return 0; + if (unlikely((status & TPM_STS_READ_ZERO) != 0)) { + /* + * If this trips, the chances are the read is + * returning 0xff because the locality hasn't been + * acquired. Usually because tpm_try_get_ops() hasn't + * been called before doing a TPM operation. + */ + WARN_ONCE(1, "TPM returned invalid status\n"); + return 0; + } + return status; } diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h index 7337819f5d7b..9b2d32a59f67 100644 --- a/drivers/char/tpm/tpm_tis_core.h +++ b/drivers/char/tpm/tpm_tis_core.h @@ -34,6 +34,7 @@ enum tis_status { TPM_STS_GO = 0x20, TPM_STS_DATA_AVAIL = 0x10, TPM_STS_DATA_EXPECT = 0x08, + TPM_STS_READ_ZERO = 0x23, /* bits that must be zero on read */ }; enum tis_int_flags { |