Fix Atmel TPM crash caused by too frequent queries
Subsystems (2)
PATCH 1/1 Fix Atmel TPM crash caused by too frequent queries
Since kernel 4.14, we fixed the TPM sleep logic
from msleep to usleep_range, so that the TPM
sleeps exactly with TPM_TIMEOUT (=5ms) afterward.
Before that fix, msleep(5) actually sleeps for
around 15ms.
The fix is https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
That fix uncovered that the TPM_TIMEOUT was not properly set previously. We recently found the TPM driver in kernel 4.14+ (including 5.9-rc4) crashes Atmel TPM chips with
too frequent TPM queries.
The TPM crash signature is
``` $ tpm_sealdata -z Tspi_Key_LoadKey failed: 0x00001087 - layer=tddl, code=0087 (135), I/O error $ sudo dmesg | grep tpm0 [59154.665549] tpm tpm0: tpm_try_transmit: send(): error -62 [59154.809532] tpm tpm0: tpm_try_transmit: send(): error -62 ```
From the error code "-62", it looks similar to another bug
https://patchwork.kernel.org/patch/10520247/
where the "TPM_TIMEOUT_USECS_MAX" and "TPM_TIMEOUT_USEC_MIN" is too small, which causes TPM get queried too frequently, and thus crashes.
We finally found the root cause is related to
the sleep timeout used in wait_for_tpm_stat
In the 4.16, commit
https://github.com/torvalds/linux/commit/cf151a9a44d52a63332e8e926234574fe5a5d784
uses TPM_POLL_SLEEP instead of TPM_TIMEOUT for wait_for_tpm_stat and set TPM_POLL_SLEEP (1ms).
Since 4.18 commits
https://github.com/torvalds/linux/commit/59f5a6b07f6434efac0057dc2f303a96b871811b
https://github.com/torvalds/linux/commit/424eaf910c329ab06ad03a527ef45dcf6a328f00
further reduced the timeout in wait_for_tpm_stat to less than 1ms.
Our patch here defines a TPM_TIMEOUT_WAIT_STAT (15ms) just for wait_for_tpm_stat the to fix the crash in Atmel chips, but not introduce unnecessary performance regression in other workflows.
15ms is the actual timeout TPM chips use before the 4.14 fix from msleep to usleep_range. Thus fixed the crash.
Exploring smaller TPM_TIMEOUT_WAIT_STAT should be a separate thing to revisit later. This patch meant to fix the regression introduced since 4.14
Test Plan:
- Run fixed kernel on system with Atmel TPM chips and ensure crash does not happen
- Run fixed kernel on system with other TPM chips (IFX / WEC / STM) ensure not breakages from tpm-tool
--- drivers/char/tpm/tpm.h | 1 + drivers/char/tpm/tpm_tis_core.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm.h +1 -0
@@ -41,6 +41,7 @@ enum tpm_timeout {TPM_TIMEOUT_RETRY =100 ,/* msecs */ TPM_TIMEOUT_RANGE_US =300 ,/* usecs */ TPM_TIMEOUT_POLL =1 ,/* msecs */ +TPM_TIMEOUT_WAIT_STAT =15 ,/* msecs */ TPM_TIMEOUT_USECS_MIN =100 ,/* usecs */ TPM_TIMEOUT_USECS_MAX = 500 /* usecs */ };
drivers/char/tpm/tpm_tis_core.c +1 -2
@@ -80,8 +80,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, } }else { do { - usleep_range(TPM_TIMEOUT_USECS_MIN, - TPM_TIMEOUT_USECS_MAX); + tpm_msleep(TPM_TIMEOUT_WAIT_STAT); status = chip->ops->status(chip); if ((status & mask) == mask) return 0;
Signature · 1 line
2.17.1
James Bottomley
maintainerQuoted 8 lines · Hao Wu
Since kernel 4.14, we fixed the TPM sleep logic
from msleep tousleep_range, so that the TPM
sleeps exactly withTPM_TIMEOUT(=5ms) afterward.
Before that fix, msleep(5) actually sleeps for
around 15ms.
The fix is
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
Quoted 4 lines
That fix uncovered that the
TPM_TIMEOUTwas not properly set previously. We recently found the TPM driver in kernel 4.14+ (including 5.9-rc4) crashes Atmel TPM chips with
too frequent TPM queries.
I've seen this with my nuvoton too ... although it seems to be because my chip is somewhat experimental (SW upgrade from 1.2 to 2.0). The problem with your patch is it reintroduces the massive delays that msleep has ... that's why usleep was used. The patch I use locally to fix this keeps usleep, can you try it (attached).
James
---
From d40a8c7691a72de28ea66a78bd177db36a79710a Mon Sep 17 00:00:00 2001
From: James Bottomley <[email protected]>
Date: Wed, 11 Jul 2018 10:11:14 -0700
Subject: [PATCH] tpm.h: increase poll timings to fix tpm_tis regression
tpm_tis regressed recently to the point where the TPM being driven by it falls off the bus and cannot be contacted after some hours of use. This is the failure trace:
jejb@jarvis:~> dmesg|grep tpm
[ 3.282605] tpm_tis MSFT0101:00: 2.0 TPM (device-id 0xFE, rev-id 2) [14566.626614] tpm tpm0: Operation Timed out [14566.626621] tpm tpm0: tpm2_load_context: failed with a system error -62 [14568.626607] tpm tpm0: tpm_try_transmit: tpm_send: error -62 [14570.626594] tpm tpm0: tpm_try_transmit: tpm_send: error -62 [14570.626605] tpm tpm0: tpm2_load_context: failed with a system error -62 [14572.626526] tpm tpm0: tpm_try_transmit: tpm_send: error -62 [14577.710441] tpm tpm0: tpm_try_transmit: tpm_send: error -62
...
The problem is caused by a change that caused us to poke the TPM far more often to see if it's ready. Apparently something about the bus its on and the TPM means that it crashes or falls off the bus if you poke it too often and once this happens, only a reboot will recover it.
The fix I've come up with is to adjust the timings so the TPM no longer falls of the bus. Obviously, this fix works for my Nuvoton NPCT6xxx but that's the only TPM I've tested it with.
--- drivers/char/tpm/tpm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm.h +2 -2
@@ -41,8 +41,8 @@ enum tpm_timeout {TPM_TIMEOUT_RETRY =100 ,/* msecs */ TPM_TIMEOUT_RANGE_US =300 ,/* usecs */ TPM_TIMEOUT_POLL =1 ,/* msecs */ -TPM_TIMEOUT_USECS_MIN =100 ,/* usecs */ - TPM_TIMEOUT_USECS_MAX = 500 /* usecs */ +TPM_TIMEOUT_USECS_MIN =750 ,/* usecs */ + TPM_TIMEOUT_USECS_MAX = 1000, /* usecs */ };/* TPM addresses */
Signature · 1 line
2.26.2
Resending following email in plaintext.
----
Hi James,
Thanks for following up.
We have actually tried changeTPM_TIMEOUT_USECS_MIN / TPM_TIMEOUT_USECS_MAX
according to https://patchwork.kernel.org/patch/10520247/
It does not solve the problem for ATMEL chip. The chips facing crash is not experimental, but happens commonly in
the production systems we and our customers are using.
It is widely found in Cisco 220 / 240 systems which are using Ateml chips.
Thanks
Hao
Quoted 81 lines · James Bottomley
Quoted 8 lines · Hao Wu
Since kernel 4.14, we fixed the TPM sleep logic
from msleep tousleep_range, so that the TPM
sleeps exactly withTPM_TIMEOUT(=5ms) afterward.
Before that fix, msleep(5) actually sleeps for
around 15ms.
The fix is
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3Quoted 4 lines
That fix uncovered that the
TPM_TIMEOUTwas not properly set previously. We recently found the TPM driver in kernel 4.14+ (including 5.9-rc4) crashes Atmel TPM chips with
too frequent TPM queries.I've seen this with my nuvoton too ... although it seems to be because my chip is somewhat experimental (SW upgrade from 1.2 to 2.0). The problem with your patch is it reintroduces the massive delays that msleep has ... that's why usleep was used. The patch I use locally to fix this keeps usleep, can you try it (attached).
James
---
From
d40a8c7691a72de28ea66a78bd177db36a79710aMon Sep 17 00:00:00 2001
From: James Bottomley <[email protected]>
Date: Wed, 11 Jul 2018 10:11:14 -0700
Subject: [PATCH]tpm.h: increase poll timings to fixtpm_tisregression
tpm_tisregressed recently to the point where the TPM being driven by it falls off the bus and cannot be contacted after some hours of use. This is the failure trace:jejb@jarvis:~> dmesg|grep tpm
[ 3.282605] tpm_tis MSFT0101:00: 2.0 TPM (device-id 0xFE, rev-id 2) [14566.626614] tpm tpm0: Operation Timed out [14566.626621] tpm tpm0: tpm2_load_context: failed with a system error -62 [14568.626607] tpm tpm0: tpm_try_transmit: tpm_send: error -62 [14570.626594] tpm tpm0: tpm_try_transmit: tpm_send: error -62 [14570.626605] tpm tpm0: tpm2_load_context: failed with a system error -62 [14572.626526] tpm tpm0: tpm_try_transmit: tpm_send: error -62 [14577.710441] tpm tpm0: tpm_try_transmit: tpm_send: error -62...
The problem is caused by a change that caused us to poke the TPM far more often to see if it's ready. Apparently something about the bus its on and the TPM means that it crashes or falls off the bus if you poke it too often and once this happens, only a reboot will recover it.
The fix I've come up with is to adjust the timings so the TPM no longer falls of the bus. Obviously, this fix works for my Nuvoton NPCT6xxx but that's the only TPM I've tested it with.
Fixes 424eaf910c32 tpm: reduce polling time to usecs for even finer granularitySigned-off-by James Bottomley <[email protected]>---
drivers/char/tpm/tpm.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/char/tpm/tpm.h +2
-2@@ -41,8 +41,8 @@ enum tpm_timeout {TPM_TIMEOUT_RETRY =100 ,/* msecs */ TPM_TIMEOUT_RANGE_US =300 ,/* usecs */ TPM_TIMEOUT_POLL =1 ,/* msecs */ -TPM_TIMEOUT_USECS_MIN =100 ,/* usecs */ - TPM_TIMEOUT_USECS_MAX = 500 /* usecs */ +TPM_TIMEOUT_USECS_MIN =750 ,/* usecs */ + TPM_TIMEOUT_USECS_MAX = 1000, /* usecs */ };/* TPM addresses */ Signature · 1 line
2.26.2
James Bottomley
maintainerQuoted 8 lines · Hao Wu
Resending following email in plaintext.
----
Hi James,
Thanks for following up.
Quoted 9 lines
We have actually tried change
TPM_TIMEOUT_USECS_MIN/TPM_TIMEOUT_USECS_MAX
according to https://patchwork.kernel.org/patch/10520247/
It does not solve the problem for ATMEL chip. The chips facing crash is
not experimental, but happens commonly in
the production systems we and our customers are using.
It is widely found in Cisco 220 / 240 systems which are using Ateml chips.
Well, I came up with the values in that patch by trial and error .... all I know is they work for my nuvoton. If they're not right for you, see if you can find what values actually do work for your TPM. The difference between msleep and usleep_range is that the former can have an indefinitely long timeout and the latter has a range bounded one. If you think msleep works for you, the chances are it doesn't and you're relying on the large upper bound to make the bug infrequent enough for you not to see it. Playing with the values in usleep range will help you find what the actual timeout is and eliminate the problem for good.
James
Hi James,
Maybe there is a misunderstanding. Here I am using tpm_msleep, not msleep. tpm_msleep is using usleep underlaying. See
https://github.com/torvalds/linux/blob/master/drivers/char/tpm/tpm.h#L188
The reasons I choose 15ms, is because before
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
(Where msleep is changed to tpm_msleep (which is essentially usleep)), The actual sleep time is 15ms, thus here we change this back to 15ms to fix regression.
Thanks
Hao
Quoted 33 lines · James Bottomley
Quoted 8 lines · Hao Wu
Resending following email in plaintext.
----
Hi James,
Thanks for following up.
Quoted 9 lines
We have actually tried change
TPM_TIMEOUT_USECS_MIN/TPM_TIMEOUT_USECS_MAX
according to https://patchwork.kernel.org/patch/10520247/
It does not solve the problem for ATMEL chip. The chips facing crash is
not experimental, but happens commonly in
the production systems we and our customers are using.
It is widely found in Cisco 220 / 240 systems which are using Ateml chips.Well, I came up with the values in that patch by trial and error .... all I know is they work for my nuvoton. If they're not right for you, see if you can find what values actually do work for your TPM. The difference between msleep and
usleep_rangeis that the former can have an indefinitely long timeout and the latter has a range bounded one. If you think msleep works for you, the chances are it doesn't and you're relying on the large upper bound to make the bug infrequent enough for you not to see it. Playing with the values in usleep range will help you find what the actual timeout is and eliminate the problem for good.James
I am attaching the original bug report to this thread for new reviewers to get better context
---
Hi TPM Driver Maintainers,
We are from Rubrik engineering team. We found a TPM driver update since kernel 4.14 causing atmel TPM chips crash. We have root caused it and have a patch on the kernel used by Rubrik products. Given the “bug” has impact on not just Rubrik products, but all atmel TPM chips, we are asking to fix the issue in the kernel upstream.
The commit that introduced the bug since 4.14
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
Effected platform / system:
- Cisco UCS C220 M5 with atmel TPM chip
- Ubuntu 16.04
- Kernel 4.14 / 4.15 / 4.18 / 4.20 / 5.8 / 5.9-rc4
- Cisco UCS C240 M5 with atmel TPM chip
- Ubuntu 16.04
- Kernel 4.14 / 4.15 / 4.18 / 4.20 / 5.8 / 5.9-rc4
``` # TPM chip used in the problematic platform $ tpm_version TPM 1.2 Version Info: Chip Version: 1.2.66.1 Spec Level: 2 Errata Revision: 3 TPM Vendor ID: ATML TPM Version: 01010000 Manufacturer Info: 41544d4c ```
Not all Cisco server nodes are facing the crash, but there are a good amount of portion (around 50% from nodes in Rubrik) are persistently having the TPM crash issue.
Our other platforms using TPM chips from other vendors do not have issue. These platform are running the same software as the problematic platforms run. Those TPM non-effected vendors are
- IFX
- STM
- WEC
TPM crash signature:
``` # error when running tpm tool $ tpm_sealdata -z Tspi_Key_LoadKey failed: 0x00001087 - layer=tddl, code=0087 (135), I/O error # tpm driver sends error $ sudo dmesg | grep tpm0 [59154.665549] tpm tpm0: tpm_try_transmit: send(): error -62 [59154.809532] tpm tpm0: tpm_try_transmit: send(): error -62 ```
Our Root Cause Analysis
From the error code “-62”, it looks similar to another bug https://patchwork.kernel.org/patch/10520247/
where the “TPM_TIMEOUT_USECS_MAX” and “TPM_TIMEOUT_USEC_MIN” is too small, which causes TPM get queried too frequently, and thus crashes.
The issue for atmel TPM chip crash is similar the commit https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3 changed TPM sleep logic from using msleep to tpm_msleep, in which usleep_range is used.
As what https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3 intended to do, using usleep_range can make the sleep period shorter, because msleep actually sleeps longer when the sleep perioid is within 20ms, and usleep_range can make it more precise.
According to our experiments,
- usleep_range makes the TPM sleep precisely for TPM_TIMEOUT (i.e. 5ms https://github.com/torvalds/linux/blob/v4.14/drivers/char/tpm/tpm.h#L52)
- msleep(TPM_TIMEOUT) actually sleeps around 15ms
Thus the TPM get queried more frequently than before, which is likely the root cause of the atmel chip crash. We fix it by bumping up the TPM_TIMEOUT to 15ms.
Rubrik Patch (patch only for 4.14)
```
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 72d3ce4..9b8f3f8 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -49,7 +49,15 @@ enum tpm_const {
};
enum tpm_timeout {
- TPM_TIMEOUT = 5, /* msecs */
+ TPM_TIMEOUT = 15, /* msecs */
TPM_TIMEOUT_RETRY = 100, /* msecs */
TPM_TIMEOUT_RANGE_US = 300 /* usecs */
};
```With the patch, the atmel TPM chip crash is fixed.
Proposal
We want the kernel upstream to adopt the fix or have a better fix for the atmel chip while not bring performance regression for other TPM chips. We understand that https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3 was intended to shorten the TPM respond time, but it does not work well for atmel TPM chips. Probably we should override TPM_TIMEOUT value for atmel chips at least.
Thanks
Hao
Quoted 51 lines · Hao Wu
Hi James,
Maybe there is a misunderstanding. Here I am using
tpm_msleep, not msleep.tpm_msleepis using usleep underlaying. See
https://github.com/torvalds/linux/blob/master/drivers/char/tpm/tpm.h#L188The reasons I choose 15ms, is because before
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
(Where msleep is changed totpm_msleep(which is essentially usleep)), The actual sleep time is 15ms, thus here we change this back to 15ms to fix regression.Thanks
HaoQuoted 33 lines · James Bottomley
Quoted 8 lines · Hao Wu
Resending following email in plaintext.
----
Hi James,
Thanks for following up.
Quoted 9 lines
We have actually tried change
TPM_TIMEOUT_USECS_MIN/TPM_TIMEOUT_USECS_MAX
according to https://patchwork.kernel.org/patch/10520247/
It does not solve the problem for ATMEL chip. The chips facing crash is
not experimental, but happens commonly in
the production systems we and our customers are using.
It is widely found in Cisco 220 / 240 systems which are using Ateml chips.Well, I came up with the values in that patch by trial and error .... all I know is they work for my nuvoton. If they're not right for you, see if you can find what values actually do work for your TPM. The difference between msleep and
usleep_rangeis that the former can have an indefinitely long timeout and the latter has a range bounded one. If you think msleep works for you, the chances are it doesn't and you're relying on the large upper bound to make the bug infrequent enough for you not to see it. Playing with the values in usleep range will help you find what the actual timeout is and eliminate the problem for good.James
James Bottomley
maintainerQuoted 5 lines · Hao Wu
Hi James,
Maybe there is a misunderstanding. Here I am using
tpm_msleep, not msleep.tpm_msleepis using usleep underlaying. See
https://github.com/torvalds/linux/blob/master/drivers/char/tpm/tpm.h#L188
Right, I had missed that.
Quoted 5 lines
The reasons I choose 15ms, is because before
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
(Where msleep is changed totpm_msleep(which is essentially usleep)), The actual sleep time is 15ms, thus here we change this back to 15ms to fix regression.
Right now most TIS TPMs operate successfully with a sleep in there of the range 0.1-0.5ms. Upping that to 15ms introduces a 100x delay in our status wait for the TPM to become ready, potentially slowing down all TIS TPM operations by 100x, which will hit us most with the PCR writes we do for IMA logging ... that seems like a bad bargain for a single TPM family manufacturer.
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in tpm_tis_status() allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.
James
Hi James,
Quoted 5 lines
Upping that to 15ms introduces a 100x delay in
our status wait for the TPM to become ready, potentially slowing down all TIS TPM operations by 100x, which will hit us most with the PCR writes we do for IMA logging ... that seems like a bad bargain for a single TPM family manufacturer.
1. It is unlike to be 100x delay
According to
https://github.com/torvalds/linux/commit/59f5a6b07f6434efac0057dc2f303a96b871811b
https://github.com/torvalds/linux/commit/424eaf910c329ab06ad03a527ef45dcf6a328f00
It only optimize from 14sec to 7sec. Which is only a 2x speed up by using sleep time from 5ms to >1ms. Here we change it back to 15 ms is very unlikely to have 100x delay.
The optimization does not worth to have a breakage on chip from one manufacturer.
2. In my opinion, the kernel should support all manufacturers which were supported before. Not supporting any of them would lead to kernel divergence, because those chip users have to Use it anyway. Maybe we can see the maintainers’ opinion on this.
3. I am kind of opposing to coming up smaller values without doing comprehensive qualification on all supported manufacturers. Stable is probably more important for such software. Looking back to these commits that introduced the breakages, only one or two
chips are tested. If that is a common case, probably we should refactor
the TPM driver to better support per-manufacturer configuration?
Quoted 7 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Thanks
Hao
Quoted 35 lines · James Bottomley
Quoted 5 lines · Hao Wu
Hi James,
Maybe there is a misunderstanding. Here I am using
tpm_msleep, not msleep.tpm_msleepis using usleep underlaying. See
https://github.com/torvalds/linux/blob/master/drivers/char/tpm/tpm.h#L188Right, I had missed that.
Quoted 5 lines
The reasons I choose 15ms, is because before
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
(Where msleep is changed totpm_msleep(which is essentially usleep)), The actual sleep time is 15ms, thus here we change this back to 15ms to fix regression.Right now most TIS TPMs operate successfully with a sleep in there of the range 0.1-0.5ms. Upping that to 15ms introduces a 100x delay in our status wait for the TPM to become ready, potentially slowing down all TIS TPM operations by 100x, which will hit us most with the PCR writes we do for IMA logging ... that seems like a bad bargain for a single TPM family manufacturer.
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.James
James Bottomley
maintainerOn Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]
Quoted 11 lines
Quoted 7 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
James
---
drivers/char/tpm/tpm_tis_core.c +2 -2
@@ -233,9 +233,9 @@ static u8 tpm_tis_status(struct tpm_chip *chip) {struct tpm_tis_data *priv =dev_get_drvdata (&chip->dev);int rc; -u8 status; +u32 status; - rc =tpm_tis_read8 (priv,TPM_STS (priv->locality), &status); + rc =tpm_tis_read32 (priv,TPM_STS (priv->locality), &status);if (rc <0 )return 0 ;
Quoted 35 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 11 lines
Quoted 7 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
James
---
drivers/char/tpm/tpm_tis_core.c +0
-0@@ -233,9 +233,9 @@ static u8 tpm_tis_status(struct tpm_chip *chip) {
drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 241
Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2
-2struct tpm_tis_data *priv =dev_get_drvdata (&chip->dev);int rc; -u8 status; +u32 status; - rc =tpm_tis_read8 (priv,TPM_STS (priv->locality), &status); + rc =tpm_tis_read32 (priv,TPM_STS (priv->locality), &status);if (rc <0 )return 0 ;
Thanks James for the quick patch.
I will apply it this week any see whether it helps or not.
Hao
Quoted 14 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 11 lines
Quoted 7 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Quoted 7 lines
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
James
OK, so the bus does not like one byte reads but prefers full (32-bit) word reads? I.e. what's the context?
Quoted 9 lines
---
drivers/char/tpm/tpm_tis_core.c +0
-0@@ -233,9 +233,9 @@ static u8 tpm_tis_status(struct tpm_chip *chip) {
drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 241
Quoted 10 lines
drivers/char/tpm/tpm_tis_core.c +2
-2struct tpm_tis_data *priv =dev_get_drvdata (&chip->dev);int rc; -u8 status; +u32 status; - rc =tpm_tis_read8 (priv,TPM_STS (priv->locality), &status); + rc =tpm_tis_read32 (priv,TPM_STS (priv->locality), &status);if (rc <0 )return 0 ;
/Jarkko
James Bottomley
maintainerQuoted 23 lines · Jarkko Sakkinen
Quoted 22 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 9 lines
Quoted 8 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.Quoted 3 lines
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
Quoted 4 lines
Quoted 1 line
James
OK, so the bus does not like one byte reads but prefers full (32-bit) word reads? I.e. what's the context?
It's not supported by anything in the spec just empirical observation. However, the spec says the status register is 24 bits: the upper 16 being the burst count. When we read the whole status register, including the burst count, we do a read32. I observed that the elongated timing was only added for the read8 code not the read32 which supports the theory that the former causes the Atmel to crash but the latter doesn't. Of course it's always possible that probabilistically the Atmel is going to crash on the burst count read, but that's exercised far less than the status only read.
James
Quoted 29 lines · James Bottomley
Quoted 23 lines · Jarkko Sakkinen
Quoted 22 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 9 lines
Quoted 8 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.Quoted 3 lines
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
Quoted 4 lines
Quoted 1 line
James
OK, so the bus does not like one byte reads but prefers full (32-bit) word reads? I.e. what's the context?
Quoted 9 lines
It's not supported by anything in the spec just empirical observation. However, the spec says the status register is 24 bits: the upper 16 being the burst count. When we read the whole status register, including the burst count, we do a read32. I observed that the elongated timing was only added for the read8 code not the read32 which supports the theory that the former causes the Atmel to crash but the latter doesn't. Of course it's always possible that probabilistically the Atmel is going to crash on the burst count read, but that's exercised far less than the status only read.
This paragraph is good enough explanation for me. Can you include it to the final commit as soon as we hear how your fix works for Hao?
/Jarkko
James Bottomley
maintainerQuoted 41 lines · Jarkko Sakkinen
Quoted 29 lines · James Bottomley
Quoted 23 lines · Jarkko Sakkinen
Quoted 22 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 9 lines
Quoted 8 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.Quoted 3 lines
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
Quoted 4 lines
Quoted 1 line
James
OK, so the bus does not like one byte reads but prefers full (32- bit) word reads? I.e. what's the context?
Quoted 10 lines
It's not supported by anything in the spec just empirical observation. However, the spec says the status register is 24
bits: the upper 16 being the burst count. When we read the whole status register, including the burst count, we do a read32. I observed that the elongated timing was only added for the read8 code not the read32 which supports the theory that the former causes the Atmel to crash but the latter doesn't. Of course it's always possible that probabilistically the Atmel is going to crash on the burst count read, but that's exercised far less than the status only read.
Quoted 2 lines
This paragraph is good enough explanation for me. Can you include it to the final commit as soon as we hear how your fix works for Hao?
Sure. I'm afraid I have to report that it didn't work for me. My Nuvoton is definitely annoyed by the frequency of the prodding rather than the register width.
James
Quoted 42 lines · James Bottomley
Quoted 41 lines · Jarkko Sakkinen
Quoted 39 lines · James Bottomley
Quoted 23 lines · Jarkko Sakkinen
Quoted 22 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 9 lines
Quoted 8 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.Quoted 3 lines
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
Quoted 4 lines
Quoted 1 line
James
OK, so the bus does not like one byte reads but prefers full (32- bit) word reads? I.e. what's the context?
It's not supported by anything in the spec just empirical observation. However, the spec says the status register is 24
bits: the upper 16 being the burst count. When we read the whole status register, including the burst count, we do a read32. I observed that the elongated timing was only added for the read8 code not the read32 which supports the theory that the former causes the Atmel to crash but the latter doesn't. Of course it's always possible that probabilistically the Atmel is going to crash on the burst count read, but that's exercised far less than the status only read.
Quoted 6 lines
Quoted 2 lines
This paragraph is good enough explanation for me. Can you include it to the final commit as soon as we hear how your fix works for Hao?
Sure. I'm afraid I have to report that it didn't work for me. My Nuvoton is definitely annoyed by the frequency of the prodding rather than the register width.
Sorry, this might have been stated at some point but what type of bus is it connected with?
Does it help in any way to tune the frequency?
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
/Jarkko
James Bottomley
maintainerQuoted 61 lines · Jarkko Sakkinen
Quoted 60 lines · James Bottomley
Quoted 58 lines · Jarkko Sakkinen
Quoted 39 lines · James Bottomley
Quoted 32 lines · Jarkko Sakkinen
Quoted 30 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 13 lines
Quoted 4 lines
However, there is another possibility: it's something to do
with the byte read; I notice you don't require the same slowdown for the burst count read, which actually readsQuoted 8 lines
the
status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away intpm_tis_status()allow us to keep the current timings? I
can actually try doing this and see if it fixes my nuvoton.Quoted 4 lines
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the
timings reverted to being those in the vanilla kernel. So far
it hasn't crashed, but I haven't run it for long enough to be
sure yet.Quoted 5 lines
Quoted 1 line
James
OK, so the bus does not like one byte reads but prefers full (32-
bit) word reads? I.e. what's the context?Quoted 13 lines
It's not supported by anything in the spec just empirical observation. However, the spec says the status register is 24
bits: the upper 16 being the burst count. When we read the whole
status register, including the burst count, we do a read32. I observed that the elongated timing was only added for the read8 code not the read32 which supports the theory that the former causes the Atmel to crash but the latter doesn't. Of course it's
always possible that probabilistically the Atmel is going to crash
on the burst count read, but that's exercised far less than the status only read.This paragraph is good enough explanation for me. Can you include it
to the final commit as soon as we hear how your fix works for Hao?
Quoted 7 lines
Quoted 4 lines
Sure. I'm afraid I have to report that it didn't work for me. My Nuvoton is definitely annoyed by the frequency of the prodding rather
than the register width.Sorry, this might have been stated at some point but what type of bus is it connected with?
It's hard to tell: this is my Dell Laptop, but I'd have to bet LPC.
Quoted 1 line
Does it help in any way to tune the frequency?
Of the bus? We simply don't have access: a TIS TPM is projected at a specific memory mapped address and all the conversion to the LPC back end is done by memory read/write operations. The TPM itself has a clock but doesn't give the TIS interface software control.
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
James
Quoted 70 lines · James Bottomley
Quoted 61 lines · Jarkko Sakkinen
Quoted 60 lines · James Bottomley
Quoted 58 lines · Jarkko Sakkinen
Quoted 39 lines · James Bottomley
Quoted 32 lines · Jarkko Sakkinen
Quoted 30 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 13 lines
Quoted 4 lines
However, there is another possibility: it's something to do
with the byte read; I notice you don't require the same slowdown for the burst count read, which actually readsQuoted 8 lines
the
status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away intpm_tis_status()allow us to keep the current timings? I
can actually try doing this and see if it fixes my nuvoton.Quoted 4 lines
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the
timings reverted to being those in the vanilla kernel. So far
it hasn't crashed, but I haven't run it for long enough to be
sure yet.Quoted 5 lines
Quoted 1 line
James
OK, so the bus does not like one byte reads but prefers full (32-
bit) word reads? I.e. what's the context?Quoted 13 lines
It's not supported by anything in the spec just empirical observation. However, the spec says the status register is 24
bits: the upper 16 being the burst count. When we read the whole
status register, including the burst count, we do a read32. I observed that the elongated timing was only added for the read8 code not the read32 which supports the theory that the former causes the Atmel to crash but the latter doesn't. Of course it's
always possible that probabilistically the Atmel is going to crash
on the burst count read, but that's exercised far less than the status only read.This paragraph is good enough explanation for me. Can you include it
to the final commit as soon as we hear how your fix works for Hao?Quoted 7 lines
Quoted 4 lines
Sure. I'm afraid I have to report that it didn't work for me. My Nuvoton is definitely annoyed by the frequency of the prodding rather
than the register width.Sorry, this might have been stated at some point but what type of bus is it connected with?
Quoted 8 lines
It's hard to tell: this is my Dell Laptop, but I'd have to bet LPC.
Quoted 1 line
Does it help in any way to tune the frequency?
Of the bus? We simply don't have access: a TIS TPM is projected at a specific memory mapped address and all the conversion to the LPC back end is done by memory read/write operations. The TPM itself has a clock but doesn't give the TIS interface software control.
Some TPM's use tpm_tis_spi instead of MMIO.
Quoted 9 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works (the fallback latency could be the existing latency).
4. Set the legit latency.
/Jarkko
James Bottomley
maintainerQuoted 64 lines · Jarkko Sakkinen
Quoted 63 lines · James Bottomley
Quoted 53 lines · Jarkko Sakkinen
Quoted 52 lines · James Bottomley
Quoted 50 lines · Jarkko Sakkinen
Quoted 33 lines · James Bottomley
Quoted 27 lines · Jarkko Sakkinen
Quoted 25 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 11 lines
Quoted 10 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.Quoted 4 lines
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
Quoted 4 lines
Quoted 1 line
James
OK, so the bus does not like one byte reads but prefers full (32-bit) word reads? I.e. what's the context?
Quoted 11 lines
It's not supported by anything in the spec just empirical observation. However, the spec says the status register is 24 bits: the upper 16 being the burst count. When we read the whole status register, including the burst count, we do a read32. I observed that the elongated timing was only added for the read8 code not the read32 which supports the theory that the former causes the Atmel to crash but the latter doesn't. Of course it's always possible that probabilistically the Atmel is going to crash on the burst count read, but that's exercised far less than the status only read.
This paragraph is good enough explanation for me. Can you include it to the final commit as soon as we hear how your fix works for Hao?
Quoted 6 lines
Quoted 3 lines
Sure. I'm afraid I have to report that it didn't work for me. My Nuvoton is definitely annoyed by the frequency of the prodding rather than the register width.
Sorry, this might have been stated at some point but what type of bus is it connected with?
It's hard to tell: this is my Dell Laptop, but I'd have to bet LPC.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Does it help in any way to tune the frequency?
specific memory mapped address and all the conversion to the LPC back end is done by memory read/write operations. The TPM itself has a clock but doesn't give the TIS interface software control.
Some TPM's use
tpm_tis_spiinstead of MMIO.
Yes, but I'm fairly certain mine's not SPI.
Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
Quoted 8 lines
A quickly scraped idea probably with some holes in it but I was thinking something like
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works (the fallback latency could be the existing latency).
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 1 line
4. Set the legit latency.
James
Quoted 81 lines · James Bottomley
Quoted 54 lines · Jarkko Sakkinen
Quoted 53 lines · James Bottomley
Quoted 52 lines · Jarkko Sakkinen
Quoted 43 lines · James Bottomley
Quoted 42 lines · Jarkko Sakkinen
Quoted 40 lines · James Bottomley
Quoted 20 lines · Jarkko Sakkinen
Quoted 18 lines · James Bottomley
On Sun, 2020-09-27 at 22:59 -0700, Hao Wu wrote:
[...]Quoted 10 lines
Quoted 10 lines
However, there is another possibility: it's something to do with the byte read; I notice you don't require the same slowdown for the burst count read, which actually reads the status register and burst count as a read32. If that really is the case, for the atmel would substituting a read32 and just throwing the upper bytes away in
tpm_tis_status()allow us to keep the current timings? I can actually try doing this and see if it fixes my nuvoton.Quoted 4 lines
If would be helpful if you can find the solution without reducing performance. I think it is a separate problem to address though. Maybe not worth to mix them in the same fix.
Well, if it works, no other fix is needed.
Quoted 8 lines
Quoted 6 lines
This is what I'm currently trying out on my nuvoton with the timings reverted to being those in the vanilla kernel. So far it hasn't crashed, but I haven't run it for long enough to be sure yet.
James
OK, so the bus does not like one byte reads but prefers full (32-bit) word reads? I.e. what's the context?
It's not supported by anything in the spec just empirical observation. However, the spec says the status register is 24 bits: the upper 16 being the burst count. When we read the whole status register, including the burst count, we do a read32. I observed that the elongated timing was only added for the read8 code not the read32 which supports the theory that the former causes the Atmel to crash but the latter doesn't. Of course it's always possible that probabilistically the Atmel is going to crash on the burst count read, but that's exercised far less than the status only read.
Quoted 6 lines
Quoted 3 lines
This paragraph is good enough explanation for me. Can you include it to the final commit as soon as we hear how your fix works for Hao?
Sure. I'm afraid I have to report that it didn't work for me. My Nuvoton is definitely annoyed by the frequency of the prodding rather than the register width.
Sorry, this might have been stated at some point but what type of bus is it connected with?
Quoted 7 lines
Quoted 6 lines
It's hard to tell: this is my Dell Laptop, but I'd have to bet LPC.
Quoted 1 line
Does it help in any way to tune the frequency?
specific memory mapped address and all the conversion to the LPC back end is done by memory read/write operations. The TPM itself has a clock but doesn't give the TIS interface software control.
Some TPM's use
tpm_tis_spiinstead of MMIO.Yes, but I'm fairly certain mine's not SPI.
Quoted 9 lines
Quoted 9 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
Quoted 8 lines
A quickly scraped idea probably with some holes in it but I was thinking something like
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works (the fallback latency could be the existing latency).
Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I was also thinking how will we decide the lookup table values for each vendor ?
Thanks & Regards,
- Nayna
James Bottomley
maintainerQuoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit 424eaf910c329ab06ad03a527ef45dcf6a328f00
Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400
tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
James
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
/Jarkko
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Is there anything I can help from Rubrik side.
Thanks
Hao
Quoted 77 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Quoted 6 lines
Should we revert the changes or introduce the lookup table for chips.
Is there anything I can help from Rubrik side.
Thanks
Hao
There is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
/Jarkko
Quoted 82 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Quoted 95 lines · Hao Wu
Quoted 83 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
Quoted 7 lines
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Hi Jarkko and folks,
It’s being a while since our last discussion. I want to push a fix in the upstream for ateml chip. It looks like we currently have following choices:
1. generic fix for all vendors: have a lookup table for sleep time of wait_for_tpm_stat (i.e. TPM_TIMEOUT_WAIT_STAT in my proposed patch)
2. quick fix for the regression: change the sleep time of wait_for_tpm_stat back to 15ms. It is the current proposed patch
3. Fix regression by making exception for ateml chip.
Should we reach consensus on which one we want to pursue before dig into implementation of the patch? In my opinion, I prefer to fix the regression with 2, and then pursue 1 as long-term solution. 3 is hacky.
Let me know what do you guys think
Hao
Quoted 113 lines · Hao Wu
Quoted 95 lines · Hao Wu
Quoted 83 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
Quoted 7 lines
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Hi Jarkko and folks,
It’s being a while since our last discussion. I want to push a fix in the upstream for ateml chip. It looks like we currently have following choices:
1. generic fix for all vendors: have a lookup table for sleep time ofwait_for_tpm_stat(i.e.TPM_TIMEOUT_WAIT_STATin my proposed patch)
2. quick fix for the regression: change the sleep time ofwait_for_tpm_statback to 15ms. It is the current proposed patch
3. Fix regression by making exception for ateml chip.
Quoted 4 lines
Should we reach consensus on which one we want to pursue before dig into implementation of the patch? In my opinion, I prefer to fix the regression with 2, and then pursue 1 as long-term solution. 3 is hacky.
What does option 1 fix for *all* vendors?
Quoted 3 lines
Let me know what do you guys think
Hao
/Jarkko
Quoted 121 lines · Jarkko Sakkinen
Quoted 113 lines · Hao Wu
Quoted 95 lines · Hao Wu
Quoted 83 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
Quoted 7 lines
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Hi Jarkko and folks,
It’s being a while since our last discussion. I want to push a fix in the upstream for ateml chip. It looks like we currently have following choices:
1. generic fix for all vendors: have a lookup table for sleep time ofwait_for_tpm_stat(i.e.TPM_TIMEOUT_WAIT_STATin my proposed patch)
2. quick fix for the regression: change the sleep time ofwait_for_tpm_statback to 15ms. It is the current proposed patch
3. Fix regression by making exception for ateml chip.Quoted 4 lines
Should we reach consensus on which one we want to pursue before dig into implementation of the patch? In my opinion, I prefer to fix the regression with 2, and then pursue 1 as long-term solution. 3 is hacky.
Quoted 7 lines
What does option 1 fix for *all* vendors?
Quoted 3 lines
Let me know what do you guys think
Hao
/Jarkko
I meant timing is potentially sensitive per vendor,
the option 1 is a solution for all vendor if this issue happening again. The option 1 is just what you mentioned in the earlier discussion:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
I'd add a table and fallback.
Hao
Quoted 121 lines · Jarkko Sakkinen
Quoted 113 lines · Hao Wu
Quoted 95 lines · Hao Wu
Quoted 83 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically. I.e. start with optimistic value and lower it until finding the sweet spot.
The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
Quoted 7 lines
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Hi Jarkko and folks,
It’s being a while since our last discussion. I want to push a fix in the upstream for ateml chip. It looks like we currently have following choices:
1. generic fix for all vendors: have a lookup table for sleep time ofwait_for_tpm_stat(i.e.TPM_TIMEOUT_WAIT_STATin my proposed patch)
2. quick fix for the regression: change the sleep time ofwait_for_tpm_statback to 15ms. It is the current proposed patch
3. Fix regression by making exception for ateml chip.Quoted 4 lines
Should we reach consensus on which one we want to pursue before dig into implementation of the patch? In my opinion, I prefer to fix the regression with 2, and then pursue 1 as long-term solution. 3 is hacky.
Quoted 7 lines
What does option 1 fix for *all* vendors?
Quoted 3 lines
Let me know what do you guys think
Hao
/Jarkko
Hi Jarkko and folks,
It has been a while again. In my previous message I answered Jarkko’s question about the option 1. Jarkko, let me know if it is clear to you or you have further questions and suggestions on next to do. Somehow I couldn’t found the last message I sent but it is in
https://patchwork.kernel.org/project/linux-integrity/patch/[email protected]/
In high-level, the option 1 is to add a timing lookup table for each manufacture, hence we can configure timing for each chip respectively. Then we don’t need to worry about fixing ATMEL timing may cause performance degradation for other chips.
I do want to push the fix in TPM driver, which is likely to be hit going forward again when people are doing refactoring without testing chips from all manufacturing.
Let me know how should I push this forward.
Thanks
Hao
Quoted 142 lines · Hao Wu
Quoted 122 lines · Jarkko Sakkinen
Quoted 113 lines · Hao Wu
Quoted 95 lines · Hao Wu
Quoted 83 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
Quoted 3 lines
I also wonder if we could adjust the frequency dynamically.
I.e. start with optimistic value and lower it until finding
the sweet spot.The problem is the way this crashes: the TPM seems to be unrecoverable. If it were recoverable without a hard reset of the entire machine, we could certainly play around with it. I can try alternative mechanisms to see if anything's viable, but to all intents and purposes, it looks like my TPM simply stops responding to the TIS interface.
A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
Quoted 7 lines
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Hi Jarkko and folks,
It’s being a while since our last discussion. I want to push a fix in the upstream for ateml chip. It looks like we currently have following choices:
1. generic fix for all vendors: have a lookup table for sleep time ofwait_for_tpm_stat(i.e.TPM_TIMEOUT_WAIT_STATin my proposed patch)
2. quick fix for the regression: change the sleep time ofwait_for_tpm_statback to 15ms. It is the current proposed patch
3. Fix regression by making exception for ateml chip.Quoted 4 lines
Should we reach consensus on which one we want to pursue before dig into implementation of the patch? In my opinion, I prefer to fix the regression with 2, and then pursue 1 as long-term solution. 3 is hacky.
Quoted 7 lines
What does option 1 fix for *all* vendors?
Quoted 3 lines
Let me know what do you guys think
Hao
/Jarkko
Hi Jarkko and folks,
It has been a while again. In my previous message I answered Jarkko’s question about the option 1. Jarkko, let me know if it is clear to you or you have further questions and suggestions on next to do. Somehow I couldn’t found the last message I sent but it is in
https://patchwork.kernel.org/project/linux-integrity/patch/[email protected]/In high-level, the option 1 is to add a timing lookup table for each manufacture, hence we can configure timing for each chip respectively. Then we don’t need to worry about fixing ATMEL timing may cause performance degradation for other chips.
Quoted 8 lines
I do want to push the fix in TPM driver, which is likely to be hit going forward again when people are doing refactoring without testing chips from all manufacturing.
Let me know how should I push this forward.
Thanks
Hao
It looks like Jarkko’s email address ([email protected]) is unreachable now, can other TPM maintainer / reviewer help make a call and unblock this ?
Thanks
Hao
Mimi Zohar
maintainer[Cc'ing Jarkko Sakkinen <[email protected]>]
Quoted 145 lines · Hao Wu
Quoted 145 lines · Hao Wu
Quoted 122 lines · Jarkko Sakkinen
Quoted 113 lines · Hao Wu
Quoted 95 lines · Hao Wu
Quoted 83 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:
[...]
Quoted 26 lines
Quoted 21 lines
Quoted 14 lines
Quoted 10 lines
I also wonder if we could adjust the frequency dynamically.
I.e. start with optimistic value and lower it until finding
the sweet spot.The problem is the way this crashes: the TPM seems to be
unrecoverable. If it were recoverable without a hard reset of
the entire machine, we could certainly play around with it. I
can try alternative mechanisms to see if anything's viable, but
to all intents and purposes, it looks like my TPM simply stops
responding to the TIS interface.A quickly scraped idea probably with some holes in it but I was thinking something like
Quoted 6 lines
1. Initially set slow value for latency, this could be the original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
Quoted 7 lines
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Hi Jarkko and folks,
It’s being a while since our last discussion. I want to push a fix in the upstream for ateml chip. It looks like we currently have following choices:
1. generic fix for all vendors: have a lookup table for sleep time ofwait_for_tpm_stat(i.e.TPM_TIMEOUT_WAIT_STATin my proposed patch)
2. quick fix for the regression: change the sleep time ofwait_for_tpm_statback to 15ms. It is the current proposed patch
3. Fix regression by making exception for ateml chip.Quoted 4 lines
Should we reach consensus on which one we want to pursue before dig into implementation of the patch? In my opinion, I prefer to fix the regression with 2, and then pursue 1 as long-term solution. 3 is hacky.
Quoted 7 lines
What does option 1 fix for *all* vendors?
Quoted 3 lines
Let me know what do you guys think
Hao
/Jarkko
Hi Jarkko and folks,
It has been a while again. In my previous message I answered Jarkko’s question about the option 1. Jarkko, let me know if it is clear to you or you have further questions and suggestions on next to do. Somehow I couldn’t found the last message I sent but it is in
https://patchwork.kernel.org/project/linux-integrity/patch/[email protected]/In high-level, the option 1 is to add a timing lookup table for each manufacture, hence we can configure timing for each chip respectively. Then we don’t need to worry about fixing ATMEL timing may cause performance degradation for other chips.
I do want to push the fix in TPM driver, which is likely to be hit going forward again when people are doing refactoring without testing chips from all manufacturing.
Quoted 7 lines
Quoted 5 lines
Let me know how should I push this forward.
Thanks
HaoIt looks like Jarkko’s email address ([email protected]) is unreachable now, can other TPM maintainer / reviewer help make a call and unblock this ?
A while ago Jarkko asked everyone to use his kernel.org address.
Mimi
Quoted 155 lines · Mimi Zohar
[Cc'ing Jarkko Sakkinen <[email protected]>]
Quoted 150 lines · Hao Wu
Quoted 150 lines · Hao Wu
Quoted 122 lines · Jarkko Sakkinen
Quoted 113 lines · Hao Wu
Quoted 95 lines · Hao Wu
Quoted 83 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
On Wed, Sep 30, 2020 at 03:31:20PM -0700, James Bottomley wrote:
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:[...]
Quoted 26 lines
Quoted 21 lines
Quoted 20 lines
I also wonder if we could adjust the frequency dynamically.
I.e. start with optimistic value and lower it until finding
the sweet spot.The problem is the way this crashes: the TPM seems to be
unrecoverable. If it were recoverable without a hard reset of
the entire machine, we could certainly play around with it. I
can try alternative mechanisms to see if anything's viable, but
to all intents and purposes, it looks like my TPM simply stops
responding to the TIS interface.A quickly scraped idea probably with some holes in it but I was
thinking something like1. Initially set slow value for latency, this could be the
original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that
works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
Quoted 7 lines
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Hi Jarkko and folks,
It’s being a while since our last discussion. I want to push a fix in the upstream for ateml chip. It looks like we currently have following choices:
1. generic fix for all vendors: have a lookup table for sleep time ofwait_for_tpm_stat(i.e.TPM_TIMEOUT_WAIT_STATin my proposed patch)
2. quick fix for the regression: change the sleep time ofwait_for_tpm_statback to 15ms. It is the current proposed patch
3. Fix regression by making exception for ateml chip.Quoted 4 lines
Should we reach consensus on which one we want to pursue before dig into implementation of the patch? In my opinion, I prefer to fix the regression with 2, and then pursue 1 as long-term solution. 3 is hacky.
Quoted 7 lines
What does option 1 fix for *all* vendors?
Quoted 3 lines
Let me know what do you guys think
Hao
/Jarkko
Hi Jarkko and folks,
It has been a while again. In my previous message I answered Jarkko’s question about the option 1. Jarkko, let me know if it is clear to you or you have further questions and suggestions on next to do. Somehow I couldn’t found the last message I sent but it is in
https://patchwork.kernel.org/project/linux-integrity/patch/[email protected]/In high-level, the option 1 is to add a timing lookup table for each manufacture, hence we can configure timing for each chip respectively. Then we don’t need to worry about fixing ATMEL timing may cause performance degradation for other chips.
I do want to push the fix in TPM driver, which is likely to be hit going forward again when people are doing refactoring without testing chips from all manufacturing.
Let me know how should I push this forward.
Thanks
Hao
Quoted 6 lines
Quoted 2 lines
It looks like Jarkko’s email address ([email protected]) is unreachable now, can other TPM maintainer / reviewer help make a call and unblock this ?
A while ago Jarkko asked everyone to use his kernel.org address.
Mimi
Ah thanks Mimi, just found Jarkko’s address.
Jarkko please check the message above when you have a chance.
Hao
Jarkko Sakkinen
maintainerQuoted 150 lines · Mimi Zohar
[Cc'ing Jarkko Sakkinen <[email protected]>]
Quoted 147 lines · Hao Wu
Quoted 147 lines · Hao Wu
Quoted 122 lines · Jarkko Sakkinen
Quoted 113 lines · Hao Wu
Quoted 95 lines · Hao Wu
Quoted 83 lines · Jarkko Sakkinen
Quoted 79 lines · Hao Wu
Quoted 62 lines · Jarkko Sakkinen
Quoted 59 lines · James Bottomley
Quoted 4 lines · Nayna
Quoted 3 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
On Wed, Sep 30, 2020 at 03:31:20PM -0700, James Bottomley wrote:
On Thu, 2020-10-01 at 00:09 +0300, Jarkko Sakkinen wrote:[...]
Quoted 26 lines
Quoted 21 lines
Quoted 20 lines
I also wonder if we could adjust the frequency dynamically.
I.e. start with optimistic value and lower it until finding
the sweet spot.The problem is the way this crashes: the TPM seems to be
unrecoverable. If it were recoverable without a hard reset of
the entire machine, we could certainly play around with it. I
can try alternative mechanisms to see if anything's viable, but
to all intents and purposes, it looks like my TPM simply stops
responding to the TIS interface.A quickly scraped idea probably with some holes in it but I was
thinking something like1. Initially set slow value for latency, this could be the
original 15 ms.
2. Use this to read TPM_PT_VENDOR_STRING_*.
3. Lookup based vendor string from a fixup table a latency that
works
(the fallback latency could be the existing latency).Quoted 4 lines
Well, yes, that was sort of what I was thinking of doing for the Atmel ... except I was thinking of using the TIS VID (16 byte assigned vendor ID) which means we can get the information to set the timeout before we have to do any TPM operations.
Quoted 8 lines
I wonder if the timeout issue exists for all TPM commands for the same manufacturer. For example, does the ATMEL TPM also crash when extending PCRs ?
In addition to defining a per TPM vendor based lookup table for timeout, would it be a good idea to also define a Kconfig/boot param option to allow timeout setting. This will enable to set the timeout based on the specific use.
I don't think we need go that far (yet). The timing change has been in upstream since:
commit
424eaf910c329ab06ad03a527ef45dcf6a328f00Author: Nayna Jain <[email protected]> Date: Wed May 16 01:51:25 2018 -0400tpm: reduce polling time to usecs for even finer granularity
Which was in the released kernel 4.18: over two years ago. In all that time we've discovered two problems: mine which looks to be an artifact of an experimental upgrade process in a new nuvoton and the Atmel. That means pretty much every other TPM simply works with the existing timings
Quoted 2 lines
I was also thinking how will we decide the lookup table values for each vendor ?
Quoted 9 lines
Quoted 6 lines
I wasn't thinking we would. I was thinking I'd do a simple exception for the Atmel and nothing else. I don't think my Nuvoton is in any way characteristic. Indeed my pluggable TPM rainbow bridge system works just fine with a Nuvoton and the current timings.
We can add additional exceptions if they actually turn up.
I'd add a table and fallback.
Hi folks,
I want to follow up this a bit and check whether we reached a consensus on how to fix the timeout issue for Atmel chip.
Should we revert the changes or introduce the lookup table for chips.
Quoted 8 lines
Quoted 4 lines
Is there anything I can help from Rubrik side.
Thanks
HaoThere is nothing to revert as the previous was not applied but I'm of course ready to review any new attempts.
Hi Jarkko,
Quoted 7 lines
By “revert” I meant we revert the timeout value changes by applying the patch I proposed, as the timeout value discussed does cause issues.
Why don’t we apply the patch and improve the perf in the way of not breaking TPMs ?
Hao
Hi Jarkko and folks,
It’s being a while since our last discussion. I want to push a fix in the upstream for ateml chip. It looks like we currently have following choices:
1. generic fix for all vendors: have a lookup table for sleep time ofwait_for_tpm_stat(i.e.TPM_TIMEOUT_WAIT_STATin my proposed patch)
2. quick fix for the regression: change the sleep time ofwait_for_tpm_statback to 15ms. It is the current proposed patch
3. Fix regression by making exception for ateml chip.Quoted 4 lines
Should we reach consensus on which one we want to pursue before dig into implementation of the patch? In my opinion, I prefer to fix the regression with 2, and then pursue 1 as long-term solution. 3 is hacky.
Quoted 7 lines
What does option 1 fix for *all* vendors?
Quoted 3 lines
Let me know what do you guys think
Hao
/Jarkko
Hi Jarkko and folks,
It has been a while again. In my previous message I answered Jarkko’s question about the option 1. Jarkko, let me know if it is clear to you or you have further questions and suggestions on next to do. Somehow I couldn’t found the last message I sent but it is in
https://patchwork.kernel.org/project/linux-integrity/patch/[email protected]/In high-level, the option 1 is to add a timing lookup table for each manufacture, hence we can configure timing for each chip respectively. Then we don’t need to worry about fixing ATMEL timing may cause performance degradation for other chips.
I do want to push the fix in TPM driver, which is likely to be hit going forward again when people are doing refactoring without testing chips from all manufacturing.
Let me know how should I push this forward.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Thanks
HaoIt looks like Jarkko’s email address ([email protected]) is unreachable now, can other TPM maintainer / reviewer help make a call and unblock this ?
A while ago Jarkko asked everyone to use his kernel.org address.
Hao, I cannot really say that much about patch that does not exist.
The whole consesus thing based on a plan is just semantically wrong way to look at things. If you have an idea for a patch, make your own choice and just send the patch.
/Jarkko
Quoted 30 lines · James Bottomley
Quoted 8 lines · Hao Wu
Resending following email in plaintext.
----
Hi James,
Thanks for following up.
Quoted 9 lines
We have actually tried change
TPM_TIMEOUT_USECS_MIN/TPM_TIMEOUT_USECS_MAX
according to https://patchwork.kernel.org/patch/10520247/
It does not solve the problem for ATMEL chip. The chips facing crash is
not experimental, but happens commonly in
the production systems we and our customers are using.
It is widely found in Cisco 220 / 240 systems which are using Ateml chips.Well, I came up with the values in that patch by trial and error .... all I know is they work for my nuvoton. If they're not right for you, see if you can find what values actually do work for your TPM. The difference between msleep and
usleep_rangeis that the former can have an indefinitely long timeout and the latter has a range bounded one. If you think msleep works for you, the chances are it doesn't and you're relying on the large upper bound to make the bug infrequent enough for you not to see it. Playing with the values in usleep range will help you find what the actual timeout is and eliminate the problem for good.
Quoted 1 line
James
I think I should revert 424eaf910c329, up until more legit values are found.
/Jarkko
Hi Jarkko,
Just to be clear it is not caused by that single commit, but a few accumulated commits
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
https://github.com/torvalds/linux/commit/cf151a9a44d52a63332e8e926234574fe5a5d784
https://github.com/torvalds/linux/commit/59f5a6b07f6434efac0057dc2f303a96b871811b
https://github.com/torvalds/linux/commit/424eaf910c329ab06ad03a527ef45dcf6a328f00
The easy way is probably just apply the patch I provided, and then revisit the value for TPM_TIMEOUT_WAIT_STAT
Thanks
Hao
Quoted 4 lines
I think I should revert
424eaf910c329, up until more legit values are found./Jarkko
Quoted 10 lines · Hao Wu
Hi Jarkko,
Just to be clear it is not caused by that single commit, but a few accumulated commits
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
https://github.com/torvalds/linux/commit/cf151a9a44d52a63332e8e926234574fe5a5d784
https://github.com/torvalds/linux/commit/59f5a6b07f6434efac0057dc2f303a96b871811b
https://github.com/torvalds/linux/commit/424eaf910c329ab06ad03a527ef45dcf6a328f00The easy way is probably just apply the patch I provided, and then revisit the value for
TPM_TIMEOUT_WAIT_STAT
When you response, please quote properly, and do not top post. The discussion is impossible to follow this way.
I'm not sure if I buy that. Which one is the first failing commit?
/Jarkko
Hi Jarkko,
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
Is the one introducing the issue since 4.14. Then the other three commits changed the relevant code a bit. Probably you can check the timestamp / release version on each commit to understand the relationship.
I think the original patch commit message can help you understand the root cause. Attaching the commit here for your convenience.
Thanks
Hao
-----
Since kernel 4.14, we fixed the TPM sleep logic
from msleep to usleep_range, so that the TPM
sleeps exactly with TPM_TIMEOUT (=5ms) afterward.
Before that fix, msleep(5) actually sleeps for
around 15ms.
The fix is https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
That fix uncovered that the TPM_TIMEOUT was not properly set previously. We recently found the TPM driver in kernel 4.14+ (including 5.9-rc4) crashes Atmel TPM chips with
too frequent TPM queries.
The TPM crash signature is
``` $ tpm_sealdata -z Tspi_Key_LoadKey failed: 0x00001087 - layer=tddl, code=0087 (135), I/O error $ sudo dmesg | grep tpm0 [59154.665549] tpm tpm0: tpm_try_transmit: send(): error -62 [59154.809532] tpm tpm0: tpm_try_transmit: send(): error -62 ```
From the error code "-62", it looks similar to another bug
https://patchwork.kernel.org/patch/10520247/
where the "TPM_TIMEOUT_USECS_MAX" and "TPM_TIMEOUT_USEC_MIN" is too small, which causes TPM get queried too frequently, and thus crashes.
We finally found the root cause is related to
the sleep timeout used in wait_for_tpm_stat
In the 4.16, commit
https://github.com/torvalds/linux/commit/cf151a9a44d52a63332e8e926234574fe5a5d784
uses TPM_POLL_SLEEP instead of TPM_TIMEOUT for wait_for_tpm_stat and set TPM_POLL_SLEEP (1ms).
Since 4.18 commits
https://github.com/torvalds/linux/commit/59f5a6b07f6434efac0057dc2f303a96b871811b
https://github.com/torvalds/linux/commit/424eaf910c329ab06ad03a527ef45dcf6a328f00
further reduced the timeout in wait_for_tpm_stat to less than 1ms.
Our patch here defines a TPM_TIMEOUT_WAIT_STAT (15ms) just for wait_for_tpm_stat the to fix the crash in Atmel chips, but not introduce unnecessary performance regression in other workflows.
15ms is the actual timeout TPM chips use before the 4.14 fix from msleep to usleep_range. Thus fixed the crash.
Exploring smaller TPM_TIMEOUT_WAIT_STAT should be a separate thing to revisit later. This patch meant to fix the regression introduced since 4.14
Test Plan:
- Run fixed kernel on system with Atmel TPM chips and ensure crash does not happen
- Run fixed kernel on system with other TPM chips (IFX / WEC / STM) ensure not breakages from tpm-tool
---drivers/char/tpm/tpm.h | 1 +drivers/char/tpm/tpm_tis_core.c | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm.h +0 -0
@@ -41,6 +41,7 @@ enum tpm_timeout {
TPM_TIMEOUT_RETRY = 100, /* msecs */ TPM_TIMEOUT_RANGE_US = 300, /* usecs */ TPM_TIMEOUT_POLL = 1, /* msecs */ + TPM_TIMEOUT_WAIT_STAT = 15, /* msecs */ TPM_TIMEOUT_USECS_MIN = 100, /* usecs */ TPM_TIMEOUT_USECS_MAX = 500 /* usecs */ };
drivers/char/tpm/tpm_tis_core.c +0 -0
@@ -80,8 +80,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
}
} else {
do {
- usleep_range(TPM_TIMEOUT_USECS_MIN,
- TPM_TIMEOUT_USECS_MAX);
+ tpm_msleep(TPM_TIMEOUT_WAIT_STAT);
status = chip->ops->status(chip);
if ((status & mask) == mask)
return 0;Signature · 1 line
2.17.1
Quoted 20 lines · Jarkko Sakkinen
Quoted 10 lines · Hao Wu
Hi Jarkko,
Just to be clear it is not caused by that single commit, but a few accumulated commits
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
https://github.com/torvalds/linux/commit/cf151a9a44d52a63332e8e926234574fe5a5d784
https://github.com/torvalds/linux/commit/59f5a6b07f6434efac0057dc2f303a96b871811b
https://github.com/torvalds/linux/commit/424eaf910c329ab06ad03a527ef45dcf6a328f00The easy way is probably just apply the patch I provided, and then revisit the value for
TPM_TIMEOUT_WAIT_STATWhen you response, please quote properly, and do not top post. The discussion is impossible to follow this way.
I'm not sure if I buy that. Which one is the first failing commit?
/Jarkko
Quoted 7 lines · Hao Wu
Hi Jarkko,
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
Is the one introducing the issue since 4.14. Then the other three commits changed the relevant code a bit. Probably you can check the timestamp / release version on each commit to understand the relationship.
Quoted 5 lines
I think the original patch commit message can help you understand the root cause. Attaching the commit here for your convenience.
Thanks
Hao
Please, again, when you respond quote properly instead of putting your response on top. Thank you.
Yes, I know the issue and it is already documented also in the James' earlier patch that did a similar change. I.e. for some reason some TPM's (or the bus itself) do not like poking it too often.
So: what if you revert on using msleep(TPM_TIMEOUT) in wait_for_tpm_stat(), i.e. revert to the behaviour before the aformentioned commit?
/Jarkko
Quoted 18 lines · Jarkko Sakkinen
Quoted 7 lines · Hao Wu
Hi Jarkko,
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
Is the one introducing the issue since 4.14. Then the other three commits changed the relevant code a bit. Probably you can check the timestamp / release version on each commit to understand the relationship.Quoted 5 lines
I think the original patch commit message can help you understand the root cause. Attaching the commit here for your convenience.
Thanks
Hao
Quoted 6 lines
Please, again, when you respond quote properly instead of putting your response on top. Thank you.
Yes, I know the issue and it is already documented also in the James' earlier patch that did a similar change. I.e. for some reason some TPM's (or the bus itself) do not like poking it too often.
Yes, probably. Although the issue James’s patch fixes has the same error code, it is about a different issue which is similar.
Quoted 3 lines
So: what if you revert on using
msleep(TPM_TIMEOUT)inwait_for_tpm_stat(), i.e. revert to the behaviour before the aformentioned commit?
I believe that should resolve the issue as well
Thanks
Hao
Quoted 18 lines · Hao Wu
Quoted 18 lines · Jarkko Sakkinen
Quoted 12 lines · Hao Wu
Hi Jarkko,
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
Is the one introducing the issue since 4.14. Then the other three commits changed the relevant code a bit. Probably you can check the timestamp / release version on each commit to understand the relationship.I think the original patch commit message can help you understand the root cause. Attaching the commit here for your convenience.
Thanks
Hao
Quoted 8 lines
Quoted 6 lines
Please, again, when you respond quote properly instead of putting your response on top. Thank you.
Yes, I know the issue and it is already documented also in the James' earlier patch that did a similar change. I.e. for some reason some TPM's (or the bus itself) do not like poking it too often.
Yes, probably. Although the issue James’s patch fixes has the same error code, it is about a different issue which is similar.
OK, great.
Quoted 4 lines
Quoted 3 lines
So: what if you revert on using
msleep(TPM_TIMEOUT)inwait_for_tpm_stat(), i.e. revert to the behaviour before the aformentioned commit?I believe that should resolve the issue as well
I'd return to the old code that works instead of doing something new along the lines. James?
Anyway, thanks a lot for coming with this. I think we are making at least some progress sorting this out.
Also want to underline that my comments about quoting emails did not have anything to do that I would not appreciate this feedback. It is just a "protocol thing".
Quoted 2 lines
Thanks
Hao
/Jarkko
Quoted 33 lines · Jarkko Sakkinen
Quoted 18 lines · Hao Wu
Quoted 18 lines · Jarkko Sakkinen
Quoted 12 lines · Hao Wu
Hi Jarkko,
https://github.com/torvalds/linux/commit/9f3fc7bcddcb51234e23494531f93ab60475e1c3
Is the one introducing the issue since 4.14. Then the other three commits changed the relevant code a bit. Probably you can check the timestamp / release version on each commit to understand the relationship.I think the original patch commit message can help you understand the root cause. Attaching the commit here for your convenience.
Thanks
HaoQuoted 8 lines
Quoted 6 lines
Please, again, when you respond quote properly instead of putting your response on top. Thank you.
Yes, I know the issue and it is already documented also in the James' earlier patch that did a similar change. I.e. for some reason some TPM's (or the bus itself) do not like poking it too often.
Yes, probably. Although the issue James’s patch fixes has the same error code, it is about a different issue which is similar.
OK, great.
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
So: what if you revert on using
msleep(TPM_TIMEOUT)inwait_for_tpm_stat(), i.e. revert to the behaviour before the aformentioned commit?I believe that should resolve the issue as well
I'd return to the old code that works instead of doing something new along the lines. James?
I would not use msleep back which is actually wrong way to do. We don’t know the actual time it sleeps on different system in the future. Currently, my measurement over msleep(TPM_TIMEOUT) , i.e. msleep(5) sleeps 15ms. Maybe we should use tpm_msleep to precisely do the sleep.
I will test out James’ patch and your proposal this week and get you back anyway.
Quoted 6 lines
Anyway, thanks a lot for coming with this. I think we are making at least some progress sorting this out.
Also want to underline that my comments about quoting emails did not have anything to do that I would not appreciate this feedback. It is just a "protocol thing".
No worries. I am not familiar with the rules here. Thank you for corrections.
Quoted 5 lines
Quoted 3 lines
Thanks
Hao/Jarkko
Hao
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mimi Zohar
maintainerHi Hao,
When posting to the mailing list, please respond using plain text and inline/bottom post.
Quoted 28 lines · Hao Wu
7.1
- Jarkko’s proposal: Using
msleep(TPM_TIMEOUT)forwait_for_tpm_stat(), resolve the Atmel crash as we expect.--- drivers/char/tpm/tpm_tis_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/char/tpm/tpm_tis_core.c +3
-3@@ -80,8 +80,9 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask, } }else { do { - usleep_range(TPM_TIMEOUT_USECS_MIN, - TPM_TIMEOUT_USECS_MAX); + msleep(TPM_TIMEOUT); + // usleep_range(TPM_TIMEOUT_USECS_MIN, + // TPM_TIMEOUT_USECS_MAX); status = chip->ops->status(chip); if ((status & mask) == mask) return 0; --2.17.1
Quoted 1 line
But I think
tpm_msleep(15)is still the right way to go.
Using msleep is definitely not the right way of going. Please refer
to commit a233a0289cf9 ("tpm: msleep() delays - replace with usleep_range() in i2c nuvoton driver") for a detailed explanation.
thanks,
Mimi