[PATCH v9 3/8] tpm: tpm_tis: Add retry in case of protocol failure or data integrity (on I2C only) failure.

2020-05-26 Thread amirmizi6
From: Amir Mizinski The FIFO protocol described in the TCG PC Client Device Driver Design Principles for TPM 2.0 advises retrying sending a command or receiving a response using the FIFO protocol in case of any error in the protocol. Add a retry mechanism on any protocol error. In addition, in

[PATCH v9 5/8] tpm: Handle an exception for TPM Firmware Update mode.

2020-05-26 Thread amirmizi6
From: Amir Mizinski An extra precaution for TPM Firmware Update Mode. For example if TPM power was cut while in Firmware update, platform should ignore "selftest" failure and skip TPM initialization sequence. Suggested-by: Benoit Houyere Signed-off-by: Amir Mizinski ---

[PATCH v9 7/8] tpm: Add YAML schema for TPM TIS I2C options

2020-05-26 Thread amirmizi6
From: Amir Mizinski Added a YAML schema to support tpm tis i2c related dt-bindings for the I2c PTP based physical layer. This patch adds the documentation for corresponding device tree bindings of I2C based Physical TPM. Refer to the 'I2C Interface Definition' section in 'TCG PC Client

[PATCH v9 2/8] tpm: tpm_tis: Fix expected bit handling and send all bytes in one shot without last byte in exception

2020-05-26 Thread amirmizi6
From: Amir Mizinski Incorrect implementation of send message was detected. We polled only TPM_STS.stsValid bit and then we single-checked the TPM_STS.expect bit value. TPM_STS.expected bit should be checked at the same time as TPM_STS.stsValid bit, and this should be repeated until timeout_A.

[PATCH v9 1/8] tpm: tpm_tis: Make implementation of read16, read32 and write32 optional

2020-05-26 Thread amirmizi6
From: Amir Mizinski Only tpm_tis can use memory-mapped I/O, which is truly mapped into the kernel's memory space. Therefore, using ioread16/ioread32/iowrite32 turns into a straightforward pointer dereference. Every other driver requires more complicated operations to read more than one byte at a

[PATCH v9 0/8] Add tpm i2c ptp driver

2020-05-26 Thread amirmizi6
From: Amir Mizinski This patch set adds support for TPM devices that implement the I2C. Interface defined by TCG PTP specification: https://trustedcomputinggroup.org/wp-content/uploads/TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22.pdf The driver was tested on Raspberry-Pie 3, using

[PATCH v9 4/8] tpm: tpm_tis: Rewrite "tpm_tis_req_canceled()"

2020-05-26 Thread amirmizi6
From: Amir Mizinski Using this function while reading/writing data resulted in an aborted operation. After investigating the issue according to the TCG TPM Profile (PTP) Specifications, I found that "request to cancel" should occur only if TPM_STS.commandReady bit is lit. Note that i couldn't

[PATCH v9 8/8] tpm: tpm_tis: add tpm_tis_i2c driver

2020-05-26 Thread amirmizi6
From: Amir Mizinski Implements the functionality needed to communicate with an I2C TPM according to the TCG TPM I2C Interface Specification. Signed-off-by: Amir Mizinski Tested-by: Eddie James Tested-by: Joel Stanley --- drivers/char/tpm/Kconfig | 12 ++ drivers/char/tpm/Makefile

[PATCH v9 6/8] tpm: tpm_tis: verify TPM_STS register is valid after locality request

2020-05-26 Thread amirmizi6
From: Amir Mizinski Issue could result when the TPM does not update TPM_STS register after a locality request (TPM_STS Initial value = 0xFF) and a TPM_STS register read occurs (tpm_tis_status(chip)). Checking the next condition("if ((status & TPM_STS_COMMAND_READY) == 0)"), the status will be

[PATCH v12 0/9] Add tpm i2c ptp driver

2020-06-25 Thread amirmizi6
From: Amir Mizinski This patch set adds support for TPM devices that implement the I2C. Interface defined by TCG PTP specification: https://trustedcomputinggroup.org/wp-content/uploads/TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22.pdf The driver was tested on Raspberry-Pie 3, using

[PATCH v12 1/9] tpm: Make read{16, 32}() and write32() in tpm_tis_phy_ops optional

2020-06-25 Thread amirmizi6
From: Amir Mizinski Only tpm_tis can use memory-mapped I/O, which is truly mapped into the kernel's memory space. Therefore, using ioread16/ioread32/iowrite32 turns into a straightforward pointer dereference. Every other driver requires more complicated operations to read more than one byte at a

[PATCH v12 9/9] tpm: tpm_tis: add tpm_tis_i2c driver

2020-06-25 Thread amirmizi6
From: Amir Mizinski Implements the functionality needed to communicate with an I2C TPM according to the TCG TPM I2C Interface Specification. Signed-off-by: Amir Mizinski Tested-by: Eddie James Tested-by: Joel Stanley --- drivers/char/tpm/Kconfig | 12 ++ drivers/char/tpm/Makefile

[PATCH v12 6/9] tpm: Handle an exception for TPM Firmware Update mode.

2020-06-25 Thread amirmizi6
From: Amir Mizinski An extra precaution for TPM Firmware Update Mode. For example if TPM power was cut while in Firmware update, platform should ignore "selftest" failure and skip TPM initialization sequence. Suggested-by: Benoit Houyere Signed-off-by: Amir Mizinski ---

[PATCH v12 2/9] tpm: tpm_tis: Fix expected bit handling and send all bytes in one shot without last byte in exception

2020-06-25 Thread amirmizi6
From: Amir Mizinski Detected the following incorrect implementation of the send command: polling on the TPM_STS.stsValid field followed by checking the TPM_STS.expect field only once. Since TPM_STS.stsValid represents the TPM_STS.expect validity, both fields should be polled at the same time.

[PATCH v12 8/9] tpm: Add YAML schema for TPM TIS I2C options

2020-06-25 Thread amirmizi6
From: Amir Mizinski Added a YAML schema to support tpm tis i2c related dt-bindings for the I2c PTP based physical layer. This patch adds the documentation for corresponding device tree bindings of I2C based Physical TPM. Refer to the 'I2C Interface Definition' section in 'TCG PC Client

[PATCH v12 3/9] tpm: tpm_tis: Add retry in case of protocol failure.

2020-06-25 Thread amirmizi6
From: Amir Mizinski Added a retry mechanism on any protocol error when sending a command or receiving a response. This was changed to comply with the TCG PC Client Device Driver Design Principles for TPM 2.0. When sending a command, a loop is added in "tpm_tis_send_main()" that calls

[PATCH v12 5/9] tpm: tpm_tis: Rewrite "tpm_tis_req_canceled()"

2020-06-25 Thread amirmizi6
From: Amir Mizinski Using this function while reading/writing data resulted in an aborted operation. After investigating the issue according to the TCG TPM Profile (PTP) Specifications, I found that "request to cancel" should occur only if TPM_STS.commandReady bit is lit. Note that i couldn't

[PATCH v12 7/9] tpm: tpm_tis: verify TPM_STS register is valid after locality request

2020-06-25 Thread amirmizi6
From: Amir Mizinski Issue could result when the TPM does not update TPM_STS register after a locality request (TPM_STS Initial value = 0xFF) and a TPM_STS register read occurs (tpm_tis_status(chip)). Checking the next condition("if ((status & TPM_STS_COMMAND_READY) == 0)"), the status will be

[PATCH v12 4/9] tpm: tpm_tis: Add verify_data_integrity handle to tpm_tis_phy_ops

2020-06-25 Thread amirmizi6
From: Amir Mizinski 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

[PATCH v1] make implementation of read16, read32 and write32 optional fix

2020-05-14 Thread amirmizi6
From: Amir Mizinski This patch fix compilation error for newly added CR50 SPI driver found in previous submission. Amir Mizinski (1): tpm: tpm_tis: make implementation of read16, read32 and write32 optional fix drivers/char/tpm/tpm_tis_spi.h | 4

[PATCH v1] tpm: tpm_tis: make implementation of read16, read32 and write32 optional fix

2020-05-14 Thread amirmizi6
From: Amir Mizinski Removed SPI extern function definitions and unused callback functions for CR50 driver. Fixes: fa05dc792ea0 ("tpm: tpm_tis: make implementation of read16, read32 and write32 optional") Reported-by: kbuild test robot Signed-off-by: Amir Mizinski ---

[PATCH v8 1/8] tpm: tpm_tis: Make implementation of read16, read32 and write32 optional

2020-05-12 Thread amirmizi6
From: Amir Mizinski Only tpm_tis can use memory-mapped I/O, which is truly mapped into the kernel's memory space. Therefore, using ioread16/ioread32/iowrite32 turns into a straightforward pointer dereference. Every other driver requires more complicated operations to read more than one byte at a

[PATCH v8 6/8] verify TPM_STS register is valid after locality request

2020-05-12 Thread amirmizi6
From: Amir Mizinski Issue could result when the TPM does not update TPM_STS register after a locality request (TPM_STS Initial value = 0xFF) and a TPM_STS register read occurs (tpm_tis_status(chip)). Checking the next condition("if ((status & TPM_STS_COMMAND_READY) == 0)"), the status will be

[PATCH v8 8/8] tpm: tpm_tis: add tpm_tis_i2c driver

2020-05-12 Thread amirmizi6
From: Amir Mizinski Implements the functionality needed to communicate with an I2C TPM according to the TCG TPM I2C Interface Specification. Signed-off-by: Amir Mizinski Tested-by: Eddie James Tested-by: Joel Stanley --- drivers/char/tpm/Kconfig | 12 ++ drivers/char/tpm/Makefile

[PATCH v8 5/8] tpm: Handle an exception for TPM Firmware Update mode.

2020-05-12 Thread amirmizi6
From: Amir Mizinski An extra precaution for TPM Firmware Update Mode. For example if TPM power was cut while in Firmware update, platform should ignore "selftest" failure and skip TPM initialization sequence. Suggested-by: Benoit Houyere Signed-off-by: Amir Mizinski ---

[PATCH v8 7/8] tpm: Add YAML schema for TPM TIS I2C options

2020-05-12 Thread amirmizi6
From: Amir Mizinski Added a YAML schema to support tpm tis i2c related dt-bindings for the I2c PTP based physical layer. This patch adds the documentation for corresponding device tree bindings of I2C based Physical TPM. Refer to the 'I2C Interface Definition' section in 'TCG PC Client

[PATCH v8 3/8] tpm: tpm_tis: Rewrite "tpm_tis_req_canceled()"

2020-05-12 Thread amirmizi6
From: Amir Mizinski Using this function while reading/writing data resulted in an aborted operation. After investigating the issue according to the TCG TPM Profile (PTP) Specifications, I found that "request to cancel" should occur only if TPM_STS.commandReady bit is lit. Note that i couldn't

[PATCH v8 2/8] tpm: tpm_tis: Add verify_data_integrity handle toy tpm_tis_phy_ops

2020-05-12 Thread amirmizi6
From: Amir Mizinski To validate data integrity we need to compute the CRC over the data sent at a lower layer (I2C for instance). To do this, tpm_tis_verify_data_integrity() calls a "verify_data_integrity" operation (if available). If the data integrity check fails, a retry to save the

[PATCH v8 0/8] Add tpm i2c ptp driver

2020-05-12 Thread amirmizi6
From: Amir Mizinski This patch set adds support for TPM devices that implement the I2C. Interface defined by TCG PTP specification: https://trustedcomputinggroup.org/wp-content/uploads/TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22.pdf The driver was tested on Raspberry-Pie 3, using

[PATCH v8 4/8] tpm: tpm_tis: Fix expected bit handling and send all bytes in one shot without last byte in exception

2020-05-12 Thread amirmizi6
From: Amir Mizinski Incorrect implementation of send message was detected. We polled only TPM_STS.stsValid bit and then we single-checked the TPM_STS.expect bit value. TPM_STS.expected bit should be checked at the same time as TPM_STS.stsValid bit, and this should be repeated until timeout_A.

[PATCH v11 4/8] tpm: tpm_tis: Rewrite "tpm_tis_req_canceled()"

2020-06-18 Thread amirmizi6
From: Amir Mizinski Using this function while reading/writing data resulted in an aborted operation. After investigating the issue according to the TCG TPM Profile (PTP) Specifications, I found that "request to cancel" should occur only if TPM_STS.commandReady bit is lit. Note that i couldn't

[PATCH v11 7/8] tpm: Add YAML schema for TPM TIS I2C options

2020-06-18 Thread amirmizi6
From: Amir Mizinski Added a YAML schema to support tpm tis i2c related dt-bindings for the I2c PTP based physical layer. This patch adds the documentation for corresponding device tree bindings of I2C based Physical TPM. Refer to the 'I2C Interface Definition' section in 'TCG PC Client

[PATCH v11 0/8] Add tpm i2c ptp driver

2020-06-18 Thread amirmizi6
From: Amir Mizinski This patch set adds support for TPM devices that implement the I2C. Interface defined by TCG PTP specification: https://trustedcomputinggroup.org/wp-content/uploads/TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22.pdf The driver was tested on Raspberry-Pie 3, using

[PATCH v11 2/8] tpm: tpm_tis: Fix expected bit handling and send all bytes in one shot without last byte in exception

2020-06-18 Thread amirmizi6
From: Amir Mizinski Detected the following incorrect implementation of the send command: polling on the TPM_STS.stsValid field followed by checking the TPM_STS.expect field only once. Since TPM_STS.stsValid represents the TPM_STS.expect validity, both fields should be polled at the same time.

[PATCH v11 1/8] tpm: Make read{16, 32}() and write32() in tpm_tis_phy_ops optional

2020-06-18 Thread amirmizi6
From: Amir Mizinski Only tpm_tis can use memory-mapped I/O, which is truly mapped into the kernel's memory space. Therefore, using ioread16/ioread32/iowrite32 turns into a straightforward pointer dereference. Every other driver requires more complicated operations to read more than one byte at a

[PATCH v11 6/8] tpm: tpm_tis: verify TPM_STS register is valid after locality request

2020-06-18 Thread amirmizi6
From: Amir Mizinski Issue could result when the TPM does not update TPM_STS register after a locality request (TPM_STS Initial value = 0xFF) and a TPM_STS register read occurs (tpm_tis_status(chip)). Checking the next condition("if ((status & TPM_STS_COMMAND_READY) == 0)"), the status will be

[PATCH v11 5/8] tpm: Handle an exception for TPM Firmware Update mode.

2020-06-18 Thread amirmizi6
From: Amir Mizinski An extra precaution for TPM Firmware Update Mode. For example if TPM power was cut while in Firmware update, platform should ignore "selftest" failure and skip TPM initialization sequence. Suggested-by: Benoit Houyere Signed-off-by: Amir Mizinski ---

[PATCH v11 8/8] tpm: tpm_tis: add tpm_tis_i2c driver

2020-06-18 Thread amirmizi6
From: Amir Mizinski Implements the functionality needed to communicate with an I2C TPM according to the TCG TPM I2C Interface Specification. Signed-off-by: Amir Mizinski Tested-by: Eddie James Tested-by: Joel Stanley --- drivers/char/tpm/Kconfig | 12 ++ drivers/char/tpm/Makefile

[PATCH v11 3/8] tpm: tpm_tis: Add retry in case of protocol failure or data integrity (on I2C only) failure.

2020-06-18 Thread amirmizi6
From: Amir Mizinski Added a retry mechanism on any protocol error. In addition, a retry is added in case of a data integrity issue in the I2C bus protocol. The check is performed after sending a command to the TPM and after receiving a response from the TPM. Data integrity is checked if a

[PATCH v10 6/8] tpm: tpm_tis: verify TPM_STS register is valid after locality request

2020-06-04 Thread amirmizi6
From: Amir Mizinski Issue could result when the TPM does not update TPM_STS register after a locality request (TPM_STS Initial value = 0xFF) and a TPM_STS register read occurs (tpm_tis_status(chip)). Checking the next condition("if ((status & TPM_STS_COMMAND_READY) == 0)"), the status will be

[PATCH v10 2/8] tpm: tpm_tis: Fix expected bit handling and send all bytes in one shot without last byte in exception

2020-06-04 Thread amirmizi6
From: Amir Mizinski Detected the following incorrect implementation of the send command: polling on the TPM_STS.stsValid field followed by checking the TPM_STS.expect field only once. Since TPM_STS.stsValid represents the TPM_STS.expect validity, both fields should be polled at the same time.

[PATCH v10 4/8] tpm: tpm_tis: Rewrite "tpm_tis_req_canceled()"

2020-06-04 Thread amirmizi6
From: Amir Mizinski Using this function while reading/writing data resulted in an aborted operation. After investigating the issue according to the TCG TPM Profile (PTP) Specifications, I found that "request to cancel" should occur only if TPM_STS.commandReady bit is lit. Note that i couldn't

[PATCH v10 1/8] tpm: Make read{16, 32}() and write32() in tpm_tis_phy_ops optional

2020-06-04 Thread amirmizi6
From: Amir Mizinski Only tpm_tis can use memory-mapped I/O, which is truly mapped into the kernel's memory space. Therefore, using ioread16/ioread32/iowrite32 turns into a straightforward pointer dereference. Every other driver requires more complicated operations to read more than one byte at a

[PATCH v10 5/8] tpm: Handle an exception for TPM Firmware Update mode.

2020-06-04 Thread amirmizi6
From: Amir Mizinski An extra precaution for TPM Firmware Update Mode. For example if TPM power was cut while in Firmware update, platform should ignore "selftest" failure and skip TPM initialization sequence. Suggested-by: Benoit Houyere Signed-off-by: Amir Mizinski ---

[PATCH v10 7/8] tpm: Add YAML schema for TPM TIS I2C options

2020-06-04 Thread amirmizi6
From: Amir Mizinski Added a YAML schema to support tpm tis i2c related dt-bindings for the I2c PTP based physical layer. This patch adds the documentation for corresponding device tree bindings of I2C based Physical TPM. Refer to the 'I2C Interface Definition' section in 'TCG PC Client

[PATCH v10 8/8] tpm: tpm_tis: add tpm_tis_i2c driver

2020-06-04 Thread amirmizi6
From: Amir Mizinski Implements the functionality needed to communicate with an I2C TPM according to the TCG TPM I2C Interface Specification. Signed-off-by: Amir Mizinski Tested-by: Eddie James Tested-by: Joel Stanley --- drivers/char/tpm/Kconfig | 12 ++ drivers/char/tpm/Makefile

[PATCH v10 0/8] Add tpm i2c ptp driver

2020-06-04 Thread amirmizi6
From: Amir Mizinski This patch set adds support for TPM devices that implement the I2C. Interface defined by TCG PTP specification: https://trustedcomputinggroup.org/wp-content/uploads/TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22.pdf The driver was tested on Raspberry-Pie 3, using

[PATCH v10 3/8] tpm: tpm_tis: Add retry in case of protocol failure or data integrity (on I2C only) failure.

2020-06-04 Thread amirmizi6
From: Amir Mizinski The FIFO protocol described in the TCG PC Client Device Driver Design Principles for TPM 2.0 advises retrying sending a command or receiving a response using the FIFO protocol in case of any error in the protocol. Add a retry mechanism on any protocol error. In addition, in