mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 18:53:52 +08:00
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>
This commit is contained in:
parent
e08c6d3b19
commit
55707d531a
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user