lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240906060947.4844-2-wahrenst@gmx.net>
Date: Fri,  6 Sep 2024 08:09:46 +0200
From: Stefan Wahren <wahrenst@....net>
To: Peter Huewe <peterhuewe@....de>,
	Jarkko Sakkinen <jarkko@...nel.org>,
	Jason Gunthorpe <jgg@...pe.ca>
Cc: linux-integrity@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Stefan Berger <stefanb@...ux.ibm.com>,
	Stefan Wahren <wahrenst@....net>
Subject: [PATCH RFC 1/2] tpm: tpm_tis_spi: Ensure SPI mode 0

According to TCG PC Client Platform TPM Profile (PTP) Specification
only SPI mode 0 is supported. In order to ensure the SPI controller
supports the necessary settings, call spi_setup() and bail out
as soon as possible in error case.

This change should affect all supported TPM SPI devices, because
tpm_tis_spi_probe is either called direct or indirectly.

Signed-off-by: Stefan Wahren <wahrenst@....net>
---
 drivers/char/tpm/tpm_tis_spi_main.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c
index 61b42c83ced8..e62d297b040e 100644
--- a/drivers/char/tpm/tpm_tis_spi_main.c
+++ b/drivers/char/tpm/tpm_tis_spi_main.c
@@ -248,6 +248,17 @@ static int tpm_tis_spi_write_bytes(struct tpm_tis_data *data, u32 addr,
 int tpm_tis_spi_init(struct spi_device *spi, struct tpm_tis_spi_phy *phy,
 		     int irq, const struct tpm_tis_phy_ops *phy_ops)
 {
+	int ret;
+
+	spi->mode &= ~SPI_MODE_X_MASK;
+	spi->mode |= SPI_MODE_0;
+
+	ret = spi_setup(spi);
+	if (ret < 0) {
+		dev_err(&spi->dev, "SPI setup failed: %d\n", ret);
+		return ret;
+	}
+
 	phy->iobuf = devm_kmalloc(&spi->dev, SPI_HDRSIZE + MAX_SPI_FRAMESIZE, GFP_KERNEL);
 	if (!phy->iobuf)
 		return -ENOMEM;
--
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ