All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tpm: don't return bool from update_timeouts
@ 2019-01-30 22:43 Jerry Snitselaar
  2019-01-30 22:43 ` [PATCH 2/2] tpm: don't print error message in tpm_transmit_cmd when tpm still testing Jerry Snitselaar
  0 siblings, 1 reply; 4+ messages in thread
From: Jerry Snitselaar @ 2019-01-30 22:43 UTC (permalink / raw)
  To: linux-integrity; +Cc: linux-kernel, linux-security-module, Jarkko Sakkinen

Set tpm_chip->timeouts_adjusted directly in the update_timeouts
code instead of returning bool. In case of tpm read failing
print warning that the read failed and continue on.

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
 drivers/char/tpm/tpm1-cmd.c     |  3 +--
 drivers/char/tpm/tpm_tis_core.c | 15 +++++++++------
 include/linux/tpm.h             |  2 +-
 3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c
index 6f306338953b..bda9a16b44f6 100644
--- a/drivers/char/tpm/tpm1-cmd.c
+++ b/drivers/char/tpm/tpm1-cmd.c
@@ -380,8 +380,7 @@ int tpm1_get_timeouts(struct tpm_chip *chip)
 	 * of misreporting.
 	 */
 	if (chip->ops->update_timeouts)
-		chip->timeout_adjusted =
-			chip->ops->update_timeouts(chip, timeout_eff);
+		chip->ops->update_timeouts(chip, timeout_eff);
 
 	if (!chip->timeout_adjusted) {
 		/* Restore default if chip reported 0 */
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index bf7e49cfa643..45e29fd1f5d7 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -521,35 +521,38 @@ static const struct tis_vendor_timeout_override vendor_timeout_overrides[] = {
 			(TIS_SHORT_TIMEOUT*1000), (TIS_SHORT_TIMEOUT*1000) } },
 };
 
-static bool tpm_tis_update_timeouts(struct tpm_chip *chip,
+static void tpm_tis_update_timeouts(struct tpm_chip *chip,
 				    unsigned long *timeout_cap)
 {
 	struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
 	int i, rc;
 	u32 did_vid;
 
+	chip->timeout_adjusted = false;
+
 	if (chip->ops->clk_enable != NULL)
 		chip->ops->clk_enable(chip, true);
 
 	rc = tpm_tis_read32(priv, TPM_DID_VID(0), &did_vid);
-	if (rc < 0)
+	if (rc < 0) {
+		dev_warn(&chip->dev, "%s: failed to read did_vid: %d\n",
+			 __func__, rc);
 		goto out;
+	}
 
 	for (i = 0; i != ARRAY_SIZE(vendor_timeout_overrides); i++) {
 		if (vendor_timeout_overrides[i].did_vid != did_vid)
 			continue;
 		memcpy(timeout_cap, vendor_timeout_overrides[i].timeout_us,
 		       sizeof(vendor_timeout_overrides[i].timeout_us));
-		rc = true;
+		chip->timeout_adjusted = true;
 	}
 
-	rc = false;
-
 out:
 	if (chip->ops->clk_enable != NULL)
 		chip->ops->clk_enable(chip, false);
 
-	return rc;
+	return;
 }
 
 /*
diff --git a/include/linux/tpm.h b/include/linux/tpm.h
index b49a55cf775f..13563b8c0c3a 100644
--- a/include/linux/tpm.h
+++ b/include/linux/tpm.h
@@ -41,7 +41,7 @@ struct tpm_class_ops {
 	int (*send) (struct tpm_chip *chip, u8 *buf, size_t len);
 	void (*cancel) (struct tpm_chip *chip);
 	u8 (*status) (struct tpm_chip *chip);
-	bool (*update_timeouts)(struct tpm_chip *chip,
+	void (*update_timeouts)(struct tpm_chip *chip,
 				unsigned long *timeout_cap);
 	int (*go_idle)(struct tpm_chip *chip);
 	int (*cmd_ready)(struct tpm_chip *chip);
-- 
2.20.1.98.gecbdaf0899


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tpm: don't print error message in tpm_transmit_cmd when tpm still testing
  2019-01-30 22:43 [PATCH 1/2] tpm: don't return bool from update_timeouts Jerry Snitselaar
@ 2019-01-30 22:43 ` Jerry Snitselaar
  2019-01-31 16:08   ` Jarkko Sakkinen
  0 siblings, 1 reply; 4+ messages in thread
From: Jerry Snitselaar @ 2019-01-30 22:43 UTC (permalink / raw)
  To: linux-integrity; +Cc: linux-kernel, linux-security-module, Jarkko Sakkinen

Currently tpm_transmit_cmd will print an error message if the tpm
returns something other than TPM2_RC_SUCCESS. This means that if the
tpm returns that it is testing an error message will be printed, and
this can cause confusion for the end user. So avoid printing the error
message if TPM2_RC_TESTING is the return code.

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
 drivers/char/tpm/tpm-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index d9439f9abe78..6339a2e289ae 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -397,7 +397,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space,
 
 	err = be32_to_cpu(header->return_code);
 	if (err != 0 && err != TPM_ERR_DISABLED && err != TPM_ERR_DEACTIVATED
-	    && desc)
+	    && err != TPM2_RC_TESTING && desc)
 		dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err,
 			desc);
 	if (err)
-- 
2.20.1.98.gecbdaf0899


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] tpm: don't print error message in tpm_transmit_cmd when tpm still testing
  2019-01-30 22:43 ` [PATCH 2/2] tpm: don't print error message in tpm_transmit_cmd when tpm still testing Jerry Snitselaar
@ 2019-01-31 16:08   ` Jarkko Sakkinen
  0 siblings, 0 replies; 4+ messages in thread
From: Jarkko Sakkinen @ 2019-01-31 16:08 UTC (permalink / raw)
  To: Jerry Snitselaar; +Cc: linux-integrity, linux-kernel, linux-security-module

On Wed, Jan 30, 2019 at 03:43:33PM -0700, Jerry Snitselaar wrote:
> Currently tpm_transmit_cmd will print an error message if the tpm
> returns something other than TPM2_RC_SUCCESS. This means that if the
> tpm returns that it is testing an error message will be printed, and
> this can cause confusion for the end user. So avoid printing the error
> message if TPM2_RC_TESTING is the return code.
> 
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>

Tags in wrong order but, but don't worry about it. I'll apply this
patch and include to the next PR. Thanks.

/Jarkko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tpm: don't print error message in tpm_transmit_cmd when tpm still testing
  2019-01-30 22:06 [PATCH 1/2] tpm: don't return bool from update_timeouts Jerry Snitselaar
@ 2019-01-30 22:06 ` Jerry Snitselaar
  0 siblings, 0 replies; 4+ messages in thread
From: Jerry Snitselaar @ 2019-01-30 22:06 UTC (permalink / raw)
  To: linux-integrity; +Cc: linux-kernel, Jarkko Sakkinen

Currently tpm_transmit_cmd will print an error message if the tpm
returns something other than TPM2_RC_SUCCESS. This means that if the
tpm returns that it is testing an error message will be printed, and
this can cause confusion for the end user. So avoid printing the error
message if TPM2_RC_TESTING is the return code.

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>
---
 drivers/char/tpm/tpm-interface.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
index d9439f9abe78..6339a2e289ae 100644
--- a/drivers/char/tpm/tpm-interface.c
+++ b/drivers/char/tpm/tpm-interface.c
@@ -397,7 +397,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space,
 
 	err = be32_to_cpu(header->return_code);
 	if (err != 0 && err != TPM_ERR_DISABLED && err != TPM_ERR_DEACTIVATED
-	    && desc)
+	    && err != TPM2_RC_TESTING && desc)
 		dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err,
 			desc);
 	if (err)
-- 
2.20.1.98.gecbdaf0899


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-01-31 16:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30 22:43 [PATCH 1/2] tpm: don't return bool from update_timeouts Jerry Snitselaar
2019-01-30 22:43 ` [PATCH 2/2] tpm: don't print error message in tpm_transmit_cmd when tpm still testing Jerry Snitselaar
2019-01-31 16:08   ` Jarkko Sakkinen
  -- strict thread matches above, loose matches on Subject: below --
2019-01-30 22:06 [PATCH 1/2] tpm: don't return bool from update_timeouts Jerry Snitselaar
2019-01-30 22:06 ` [PATCH 2/2] tpm: don't print error message in tpm_transmit_cmd when tpm still testing Jerry Snitselaar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.