Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tpm: provide a way to override the chip returned durations

Patch adds method ->update_durations to override returned
durations in case TPM chip misbehaves for TPM 1.2 drivers.

Cc: Peter Huewe <peterhuewe@gmx.de>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Signed-off-by: Alexey Klimov <aklimov@redhat.com>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> (!update_durations path)
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

authored by

Jerry Snitselaar and committed by
Jarkko Sakkinen
15d0b22c f2f5820e

+17
+15
drivers/char/tpm/tpm1-cmd.c
··· 343 343 { 344 344 cap_t cap; 345 345 unsigned long timeout_old[4], timeout_chip[4], timeout_eff[4]; 346 + unsigned long durations[3]; 346 347 ssize_t rc; 347 348 348 349 rc = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, NULL, ··· 427 426 chip->duration[TPM_LONG] = 428 427 usecs_to_jiffies(be32_to_cpu(cap.duration.tpm_long)); 429 428 chip->duration[TPM_LONG_LONG] = 0; /* not used under 1.2 */ 429 + 430 + /* 431 + * Provide the ability for vendor overrides of duration values in case 432 + * of misreporting. 433 + */ 434 + if (chip->ops->update_durations) 435 + chip->ops->update_durations(chip, durations); 436 + 437 + if (chip->duration_adjusted) { 438 + dev_info(&chip->dev, HW_ERR "Adjusting reported durations."); 439 + chip->duration[TPM_SHORT] = durations[0]; 440 + chip->duration[TPM_MEDIUM] = durations[1]; 441 + chip->duration[TPM_LONG] = durations[2]; 442 + } 430 443 431 444 /* The Broadcom BCM0102 chipset in a Dell Latitude D820 gets the above 432 445 * value wrong and apparently reports msecs rather than usecs. So we
+2
include/linux/tpm.h
··· 67 67 u8 (*status) (struct tpm_chip *chip); 68 68 void (*update_timeouts)(struct tpm_chip *chip, 69 69 unsigned long *timeout_cap); 70 + void (*update_durations)(struct tpm_chip *chip, 71 + unsigned long *duration_cap); 70 72 int (*go_idle)(struct tpm_chip *chip); 71 73 int (*cmd_ready)(struct tpm_chip *chip); 72 74 int (*request_locality)(struct tpm_chip *chip, int loc);