[RFC PATCH v4 7/8] tpm: Show timeouts and durations for TPM 2.0 chips

From: Surendran Kanagaraj

Date: Wed Nov 18 2026 - 02:49:34 EST


The timeouts and durations files exist only for TPM 1.x chips, so a
TPM 2.0 chip exposes none of its wait limits, even when tpm.limits= or
a driver's ->adjust_limits() hook changes them.

Both files read the limits table, so add them to the TPM 2.0 attributes
too. A TPM 2.0 chip reports none of these values, so for it "[adjusted]"
means that tpm.limits= or a driver's ->adjust_limits() hook set one of
the shown values, or that validation changed one. TPM 2.0 chips get no
device/ links, so the files are /sys/class/tpm/tpmX/timeouts and
durations. Document both paths in sysfs-class-tpm.

Signed-off-by: Surendran Kanagaraj <surenkj@xxxxxxxxxx>
---
Documentation/ABI/stable/sysfs-class-tpm | 26 ++++++++++++++++++++++++
drivers/char/tpm/tpm-sysfs.c | 2 ++
drivers/char/tpm/tpm2-cmd.c | 17 ++++++++++++++++
3 files changed, 45 insertions(+)

diff --git a/Documentation/ABI/stable/sysfs-class-tpm b/Documentation/ABI/stable/sysfs-class-tpm
index 73b69f63b298..ada59d147d14 100644
--- a/Documentation/ABI/stable/sysfs-class-tpm
+++ b/Documentation/ABI/stable/sysfs-class-tpm
@@ -184,6 +184,32 @@ Description: The "timeouts" property shows the 4 vendor-specific values
"[adjusted]" if any value differs from what the chip
reported, and "[original]" otherwise.

+What: /sys/class/tpm/tpmX/durations
+Date: November 2026
+KernelVersion: 7.5
+Contact: linux-integrity@xxxxxxxxxxxxxxx
+Description: The "durations" property, in the same format as
+ /sys/class/tpm/tpmX/device/durations. On a TPM 1.x chip,
+ device/durations is a compatibility link to this file. A
+ TPM 2.0 chip has only this path. TPM 2.0 has no command
+ that returns these values, so for a TPM 2.0 chip
+ "[adjusted]" is displayed when the tpm.limits= parameter
+ or the driver set one of the values, or the bounds check
+ changed one.
+
+What: /sys/class/tpm/tpmX/timeouts
+Date: November 2026
+KernelVersion: 7.5
+Contact: linux-integrity@xxxxxxxxxxxxxxx
+Description: The "timeouts" property, in the same format as
+ /sys/class/tpm/tpmX/device/timeouts. On a TPM 1.x chip,
+ device/timeouts is a compatibility link to this file. A
+ TPM 2.0 chip has only this path. TPM 2.0 has no command
+ that returns these values, so for a TPM 2.0 chip
+ "[adjusted]" is displayed when the tpm.limits= parameter
+ or the driver set one of the values, or the bounds check
+ changed one.
+
What: /sys/class/tpm/tpmX/tpm_version_major
Date: October 2019
KernelVersion: 5.5
diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
index b289a7f6f085..6bfc366fa120 100644
--- a/drivers/char/tpm/tpm-sysfs.c
+++ b/drivers/char/tpm/tpm-sysfs.c
@@ -340,6 +340,8 @@ static struct attribute *tpm1_dev_attrs[] = {

static struct attribute *tpm2_dev_attrs[] = {
&dev_attr_tpm_version_major.attr,
+ &dev_attr_durations.attr,
+ &dev_attr_timeouts.attr,
#ifdef CONFIG_TCG_TPM2_HMAC
&dev_attr_null_name.attr,
#endif
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c
index 629caaeffa17..8cc1a262d668 100644
--- a/drivers/char/tpm/tpm2-cmd.c
+++ b/drivers/char/tpm/tpm2-cmd.c
@@ -41,9 +41,26 @@ int tpm2_find_hash_alg(unsigned int crypto_id)
}
EXPORT_SYMBOL_GPL(tpm2_find_hash_alg);

+static bool tpm2_limits_adjusted(struct tpm_chip *chip, unsigned long mask)
+{
+ const struct tpm_limit_entry *e = chip->limits.entry;
+ int limit;
+
+ for_each_set_bit(limit, &mask, TPM_NR_LIMITS) {
+ if (e[limit].src != TPM_LSRC_DEFAULT ||
+ e[limit].flags & TPM_LF_CLAMPED)
+ return true;
+ }
+
+ return false;
+}
+
int tpm2_get_timeouts(struct tpm_chip *chip)
{
tpm_limits_update(chip, NULL);
+ chip->timeout_adjusted = tpm2_limits_adjusted(chip, TPM_LIMIT_INTF_MASK);
+ chip->duration_adjusted =
+ tpm2_limits_adjusted(chip, TPM1_LIMIT_DURATION_MASK);
chip->flags |= TPM_CHIP_FLAG_HAVE_TIMEOUTS;
return 0;
}
--
2.47.3