[PATCH linux dev-5.8 4/9] tpm: tpm_tis: Add verify_data_integrity handle to tpm_tis_phy_ops
Klaus Heinrich Kiwi
klaus at linux.vnet.ibm.com
Sat Jan 16 02:10:43 AEDT 2021
From: Amir Mizinski <amirmizi6 at gmail.com>
When using I2C bus protocol, the TPM has the ability to report data
integrity on incoming or outgoing command parameter bytes.
According to the TCG specs, if this data validation functionality is
enabled via the TPM_DATA_CSUM_ENABLE register, the TPM will update the
TPM_DATA_CSUM register after reception of the last command byte and after
the last response byte has been read.
Data integrity is checked if a "verify_data_integrity" handle is defined in
"tpm_tis_phy_ops".
Co-developed-by: Christophe Ricard <christophe-h.ricard at st.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard at st.com>
Signed-off-by: Amir Mizinski <amirmizi6 at gmail.com>
---
drivers/char/tpm/tpm_tis_core.c | 14 ++++++++++++++
drivers/char/tpm/tpm_tis_core.h | 2 ++
2 files changed, 16 insertions(+)
diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
index 931240674579..419a36835c23 100644
--- a/drivers/char/tpm/tpm_tis_core.c
+++ b/drivers/char/tpm/tpm_tis_core.c
@@ -347,6 +347,13 @@ static int __tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count)
return size;
}
+ if (priv->phy_ops->verify_data_integrity)
+ if (!priv->phy_ops->verify_data_integrity(priv, buf,
+ size)) {
+ size = -EIO;
+ return size;
+ }
+
return size;
}
@@ -419,6 +426,13 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)
return rc;
}
+ if (priv->phy_ops->verify_data_integrity) {
+ if (!priv->phy_ops->verify_data_integrity(priv, buf, len)) {
+ rc = -EIO;
+ return rc;
+ }
+ }
+
return 0;
}
diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h
index 6cc6b761a095..cd97c018c27b 100644
--- a/drivers/char/tpm/tpm_tis_core.h
+++ b/drivers/char/tpm/tpm_tis_core.h
@@ -107,6 +107,8 @@ struct tpm_tis_phy_ops {
int (*read16)(struct tpm_tis_data *data, u32 addr, u16 *result);
int (*read32)(struct tpm_tis_data *data, u32 addr, u32 *result);
int (*write32)(struct tpm_tis_data *data, u32 addr, u32 src);
+ bool (*verify_data_integrity)(struct tpm_tis_data *data, const u8 *buf,
+ size_t len);
};
static inline int tpm_tis_read_bytes(struct tpm_tis_data *data, u32 addr,
--
2.20.1
More information about the openbmc
mailing list