Skip to contentSkip to conversation

tpm_crb: request and relinquish locality 0

PATCH Superseded Jarkko Sakkinen 2 participants 3 messages Mar 10, 2017 – Mar 11, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm_crb: request and relinquish locality 0

Added two new callbacks to struct tpm_class_ops:

- request_locality
- relinquish_locality

These are called before sending and receiving data from the TPM.

---
 drivers/char/tpm/tpm-interface.c |  9 +++++++++
 drivers/char/tpm/tpm_crb.c       | 41 +++++++++++++++++++++++++++++++++++++++-
 include/linux/tpm.h              |  3 ++-
 3 files changed, 51 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm-interface.c +9 -0
index bd2128e..ae6aafa 100644
@@ -369,6 +369,12 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz,
 	if (chip->dev.parent)
 		pm_runtime_get_sync(chip->dev.parent);
 
+	if (chip->ops->request_locality)  {
+		rc = chip->ops->request_locality(chip);
+		if (rc)
+			goto out;
+	}
+
 	rc = chip->ops->send(chip, (u8 *) buf, count);
 	if (rc < 0) {
 		dev_err(&chip->dev,
@@ -410,6 +416,9 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz,
 		dev_err(&chip->dev,
 			"tpm_transmit: tpm_recv: error %zd\n", rc);
 out:
+	if (chip->ops->relinquish_locality)
+		chip->ops->relinquish_locality(chip);
+
 	if (chip->dev.parent)
 		pm_runtime_put_sync(chip->dev.parent);
 
drivers/char/tpm/tpm_crb.c +40 -1

65 lines not on this page · raw message

include/linux/tpm.h +2 -1
index da158f0..0ac6ea6 100644
@@ -48,7 +48,8 @@ struct tpm_class_ops {
 	u8 (*status) (struct tpm_chip *chip);
 	bool (*update_timeouts)(struct tpm_chip *chip,
 				unsigned long *timeout_cap);
-
+	int (*request_locality)(struct tpm_chip *chip);
+	void (*relinquish_locality)(struct tpm_chip *chip);
 };
 
 #if defined(CONFIG_TCG_TPM) || defined(CONFIG_TCG_TPM_MODULE)
Signature · 6 lines
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 6 lines · Jarkko Sakkinen

Added two new callbacks to struct tpm_class_ops:

- request_locality
- relinquish_locality

These are called before sending and receiving data from the TPM.

If we are going to add new ops, I think we should also adjust the existing drivers to use this mechanism as well?

eg tis just calls its request_locality as the first thing in send..

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 6 lines · Jason Gunthorpe
Quoted 5 lines · Jarkko Sakkinen

Added two new callbacks to struct tpm_class_ops:

- request_locality
- relinquish_locality

Quoted 8 lines
Quoted 1 line

These are called before sending and receiving data from the TPM.

If we are going to add new ops, I think we should also adjust the existing drivers to use this mechanism as well?

eg tis just calls its request_locality as the first thing in send..

Jason

Would it be sufficient to adjust tpm_tis in addition to tpm_crb? Those are the only once where I can edit edit-compile-run cycle.

The original commit I did worked on SKL platform that I tested but fails on KBL but keeping the locality throughout the transmit makes it stable on every platform I've tested.

/Jarkko
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html