Skip to contentSkip to conversation

tpm: WARN_ONCE() -> pr_warn_once() in tpm_tis_status()

PATCH Superseded [email protected] 6 participants 13 messages Feb 2, 2021 – Feb 3, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 tpm: WARN_ONCE() -> pr_warn_once() in tpm_tis_status()

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in tpm_ibmvtpm_probe()")
---
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -1
index 431919d5f48a..21f67c6366cb 100644
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
 		 * acquired.  Usually because tpm_try_get_ops() hasn't
 		 * been called before doing a TPM operation.
 		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n", status);
 		return 0;
 	}
 
Signature · 1 line
2.30.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · On 2/2/21 7:33 AM, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

Quoted 7 lines

In addition: print the status in the log message because it is actually useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in tpm_ibmvtpm_probe()")
Quoted 18 lines
---
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -1
index 431919d5f48a..21f67c6366cb 100644
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
 		 * acquired.  Usually because tpm_try_get_ops() hasn't
 		 * been called before doing a TPM operation.
 		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n", status);
 		return 0;
 	}
 
author maintainer
#2 lore raw
Quoted 10 lines · Guenter Roeck
Quoted 9 lines · On 2/2/21 7:33 AM, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually useful information lacking from the existing log message.

Quoted 6 lines
Quoted 4 lines
Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in tpm_ibmvtpm_probe()")

Thanks.

/Jarkko

Reviewed-by on v1 1/1
#3 lore raw
In reply to [email protected]
Quoted 22 lines · On 2/2/21 10:33 AM, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in tpm_ibmvtpm_probe()")
---
  drivers/char/tpm/tpm_tis_core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +0 -0
index 431919d5f48a..21f67c6366cb 100644

drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 208

Quoted 8 lines
drivers/char/tpm/tpm_tis_core.c +1 -1
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
  		 * acquired.  Usually because tpm_try_get_ops() hasn't
  		 * been called before doing a TPM operation.
  		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n", status);
  		return 0;
  	}
 
author maintainer
#4 lore raw
Quoted 18 lines · Stefan Berger
Quoted 17 lines · On 2/2/21 10:33 AM, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in tpm_ibmvtpm_probe()")
---
  drivers/char/tpm/tpm_tis_core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 207

Quoted 12 lines
drivers/char/tpm/tpm_tis_core.c +1 -1
index 431919d5f48a..21f67c6366cb 100644
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
  		 * acquired.  Usually because tpm_try_get_ops() hasn't
  		 * been called before doing a TPM operation.
  		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n", status);
  		return 0;
  	}

Thank you.

/Jarkko

#5 lore raw
In reply to [email protected]
Quoted 20 lines · On Tue, Feb 02, 2021 at 05:33:17PM +0200, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in tpm_ibmvtpm_probe()")
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 431919d5f48a..21f67c6366cb 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 205

Quoted 5 lines
drivers/char/tpm/tpm_tis_core.c +1 -1
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
 		 * acquired.  Usually because tpm_try_get_ops() hasn't
 		 * been called before doing a TPM operation.
 		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n", status);

Use dev_warn_once since we have a chip->dev here

Jason

author maintainer
#6 lore raw
Quoted 29 lines · Jason Gunthorpe
Quoted 20 lines · On Tue, Feb 02, 2021 at 05:33:17PM +0200, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in tpm_ibmvtpm_probe()")
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -0
index 431919d5f48a..21f67c6366cb 100644
+++ b/drivers/char/tpm/tpm_tis_core.c

drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 205

Quoted 5 lines
drivers/char/tpm/tpm_tis_core.c +1 -1
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
 		 * acquired.  Usually because tpm_try_get_ops() hasn't
 		 * been called before doing a TPM operation.
 		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n", status);

Use dev_warn_once since we have a chip->dev here

Quoted 1 line

Jason

Right obviously that one is best to be preferred. I'll do that. Thanks.

/Jarkko

#7 lore raw
In reply to [email protected]
Quoted 22 lines · On Tue, Feb 02, 2021 at 05:33:17PM +0200, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in tpm_ibmvtpm_probe()")
---
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +0 -0
index 431919d5f48a..21f67c6366cb 100644

drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 207

Quoted 7 lines
drivers/char/tpm/tpm_tis_core.c +1 -1
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
 		 * acquired.  Usually because tpm_try_get_ops() hasn't
 		 * been called before doing a TPM operation.
 		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n", status);
 		return 0;
 	}

Actually in this case I don't understand why _once, especially based on the comment. Would ratelimited not be better? So we can see if it happens repeatedly? Even better would be if we could see when it next gave a valid status after an invalid one.

maintainer
#8 lore raw
Quoted 32 lines · Serge E. Hallyn
Quoted 31 lines · On Tue, Feb 02, 2021 at 05:33:17PM +0200, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the
kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually
useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in

tpm_ibmvtpm_probe()")

---
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -1
index 431919d5f48a..21f67c6366cb 100644
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
 		 * acquired.  Usually because tpm_try_get_ops() hasn't
 		 * been called before doing a TPM operation.
 		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n",
Quoted 8 lines

drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 207

Quoted 3 lines
drivers/char/tpm/tpm_tis_core.c +0 -0
 status);
 		return 0;
 	}

Actually in this case I don't understand why _once, especially based on the comment. Would ratelimited not be better? So we can see if it happens repeatedly? Even better would be if we could see when it next gave a valid status after an invalid one.

The reason was that we're trying to catch and kill paths to the status where the locality is incorrect. If you do some operation that finds an incorrect path the likelihood is you'll exercise it more than once, but all we need to identify it is the call trace from a single access. The symptom the user space process sees is a TPM timeout, but we still have the in-kernel trace to tell us why.

James

author maintainer
#9 lore raw
Quoted 42 lines · James Bottomley
Quoted 32 lines · Serge E. Hallyn
Quoted 31 lines · On Tue, Feb 02, 2021 at 05:33:17PM +0200, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the
kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually
useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in

tpm_ibmvtpm_probe()")

---
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -1
index 431919d5f48a..21f67c6366cb 100644
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
 		 * acquired.  Usually because tpm_try_get_ops() hasn't
 		 * been called before doing a TPM operation.
 		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n",
Quoted 8 lines

drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 207

Quoted 3 lines
drivers/char/tpm/tpm_tis_core.c +0 -0
 status);
 		return 0;
 	}

Actually in this case I don't understand why _once, especially based on the comment. Would ratelimited not be better? So we can see if it happens repeatedly? Even better would be if we could see when it next gave a valid status after an invalid one.

Quoted 6 lines

The reason was that we're trying to catch and kill paths to the status where the locality is incorrect. If you do some operation that finds an incorrect path the likelihood is you'll exercise it more than once, but all we need to identify it is the call trace from a single access. The symptom the user space process sees is a TPM timeout, but we still have the in-kernel trace to tell us why.

I don't agree with this reasoning. This warn could spun off also from chip not following TCG spec. The patch does provide the status code, which is always useful information.

/Jarkko

author maintainer
#10 lore raw
Quoted 50 lines · Jarkko Sakkinen
Quoted 42 lines · James Bottomley
Quoted 32 lines · Serge E. Hallyn
Quoted 31 lines · On Tue, Feb 02, 2021 at 05:33:17PM +0200, [email protected] wrote:

From: Jarkko Sakkinen <[email protected]>

An unexpected status from TPM chip is not irrecovable failure of the
kernel. It's only undesirable situation. Thus, change the WARN_ONCE instance inside tpm_tis_status() to pr_warn_once().

In addition: print the status in the log message because it is actually
useful information lacking from the existing log message.

Fixes 6f4f57f0b909 ("tpm: ibmvtpm: fix error return code in

tpm_ibmvtpm_probe()")

---
 drivers/char/tpm/tpm_tis_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_tis_core.c +1 -1
index 431919d5f48a..21f67c6366cb 100644
@@ -202,7 +202,7 @@ static u8 tpm_tis_status(struct tpm_chip *chip)
 		 * acquired.  Usually because tpm_try_get_ops() hasn't
 		 * been called before doing a TPM operation.
 		 */
-		WARN_ONCE(1, "TPM returned invalid status\n");
+		pr_warn_once("TPM returned invalid status: 0x%x\n",
Quoted 8 lines

drivers/char/tpm/tpm_tis_core.c static u8 tpm_tis_status(struct tpm_chip *chip) · line 207

Quoted 3 lines
drivers/char/tpm/tpm_tis_core.c +0 -0
 status);
 		return 0;
 	}

Actually in this case I don't understand why _once, especially based on the comment. Would ratelimited not be better? So we can see if it happens repeatedly? Even better would be if we could see when it next gave a valid status after an invalid one.

Quoted 6 lines

The reason was that we're trying to catch and kill paths to the status where the locality is incorrect. If you do some operation that finds an incorrect path the likelihood is you'll exercise it more than once, but all we need to identify it is the call trace from a single access. The symptom the user space process sees is a TPM timeout, but we still have the in-kernel trace to tell us why.

Quoted 3 lines

I don't agree with this reasoning. This warn could spun off also from chip not following TCG spec. The patch does provide the status code, which is always useful information.

I.e. WARN() implies usually that there is something wrong in the kernel state risking its stability which *is not* case here. Thus, it's best to make the status code visible, not the stack trace, and make rest of the conclusions from that.

/Jarkko

maintainer
#11 lore raw
In reply to Jarkko Sakkinen
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley

On Tue, 2021-02-02 at 11:26 -0600, Serge E. Hallyn wrote:

[...]

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines

Actually in this case I don't understand why _once, especially based on the comment. Would ratelimited not be better? So we can see if it happens repeatedly? Even better would be if we could see when it next gave a valid status after an invalid one.

Quoted 6 lines

The reason was that we're trying to catch and kill paths to the status where the locality is incorrect. If you do some operation that finds an incorrect path the likelihood is you'll exercise it more than once, but all we need to identify it is the call trace from a single access. The symptom the user space process sees is a TPM timeout, but we still have the in-kernel trace to tell us why.

Quoted 2 lines

I don't agree with this reasoning. This warn could spun off also from chip not following TCG spec.

If it doesn't follow this basic part of the spec, the chip is unusable by us anyway because we need the status to proceed with command handling.

Quoted 2 lines

The patch does provide the status code, which is always useful
information.

In the wrong locality that will be bus not connected, so likely 0xff. The most useful thing to know is what path triggered the condition because the most likely cause is coding error.

James

author maintainer
#12 lore raw
Quoted 24 lines · James Bottomley
Quoted 2 lines · Jarkko Sakkinen
Quoted 1 line · James Bottomley

On Tue, 2021-02-02 at 11:26 -0600, Serge E. Hallyn wrote:

[...]

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines

Actually in this case I don't understand why _once, especially based on the comment. Would ratelimited not be better? So we can see if it happens repeatedly? Even better would be if we could see when it next gave a valid status after an invalid one.

Quoted 6 lines

The reason was that we're trying to catch and kill paths to the status where the locality is incorrect. If you do some operation that finds an incorrect path the likelihood is you'll exercise it more than once, but all we need to identify it is the call trace from a single access. The symptom the user space process sees is a TPM timeout, but we still have the in-kernel trace to tell us why.

Quoted 2 lines

I don't agree with this reasoning. This warn could spun off also from chip not following TCG spec.

If it doesn't follow this basic part of the spec, the chip is unusable by us anyway because we need the status to proceed with command handling.

Quoted 8 lines
Quoted 2 lines

The patch does provide the status code, which is always useful
information.

In the wrong locality that will be bus not connected, so likely 0xff. The most useful thing to know is what path triggered the condition because the most likely cause is coding error.

James

I tend to agree for now. Let's focus on collecting the fixes. Thanks.

/Jarkko