aboutsummaryrefslogtreecommitdiff
path: root/libstb/drivers
AgeCommit message (Collapse)AuthorFilesLines
2017-05-12tpm_i2c_nuvoton: fix use-after-free in tpm_register_chip failure pathStewart Smith1-1/+3
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-12-02i2c: Add nuvoton quirk, disallowing i2cdetect as it locks TPMStewart Smith1-0/+28
In TPM 2.0 Firmware 1.3.0.1 and 1.3.1.0 (at least) there exists a bug where if you send the wrong thing to the TPM it may lock the bus, with no way of recovery except powering the TPM off/on. On our current systems, the only way to power the TPM off/on is to pull the power on the system (*NOT* just power off/on to host from BMC). So, this patch adds the ability to do things to the i2c request really early on, well before it hits any hardware, such as quickly drop it. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: work out the polling time using mftb()Claudio Carvalho1-26/+45
Currently, the polling time is calculated by adding the sleep time to it. This calculates the polling time by taking timestamps with mftb() before calling the i2c-interface to send an i2c request to the tpm. Thus having a much more accurate polling time. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: handle errors after reading the tpm fifoClaudio Carvalho1-1/+11
This adds code to handle errors after reading the tpm fifo in tpm_read_fifo(). Fixes: 56ad053c3e8bf0764ad5878cb018f00a389d30cf Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: cleanup variables in tpm_read_fifo()Claudio Carvalho1-17/+11
The tpm_read_fifo() has unnecessary and not so intuitive variables. This cleans up these variables. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: handle errors after writting the tpm fifoClaudio Carvalho1-2/+11
This adds code to handle errors after writting the tpm fifo in tpm_write_fifo(). Fixes: 56ad053c3e8bf0764ad5878cb018f00a389d30cf Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: cleanup variables in tpm_write_fifo()Claudio Carvalho1-27/+23
The tpm_write_fifo() has unnecessary and not so intuitive variables. This cleans up these variables. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: handle errors after writing sts.commandReady in step 5Claudio Carvalho1-1/+11
This adds code to handle errors after writting the sts.commandReady to release the tpm. Fixes: 56ad053c3e8bf0764ad5878cb018f00a389d30cf Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: handle errors after writing sts.goClaudio Carvalho1-2/+11
This handles errors returned by the tpm-i2c interface after writing sts.go in tpm_transmit(). Fixes: 56ad053c3e8bf0764ad5878cb018f00a389d30cf Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: handle errors after checking the tpm fifo statusClaudio Carvalho1-66/+86
The functions tpm_is_expecting() and tpm_is_data_avail() ignore the errors returned by the tpm-i2c interface. This adds code to handle erros after checking the tpm fifo status. The tpm_is_expecting() and tpm_is_data_avail() functions are replaced by tpm_wait_for_fifo_status(). Fixes: 56ad053c3e8bf0764ad5878cb018f00a389d30cf Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: return burst_count in tpm_read_burst_count()Claudio Carvalho1-21/+19
This returns burst_count as opposed to pass it as a parameter. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: isolate the code that handles the TPM_TIMEOUT_D timeoutClaudio Carvalho1-124/+95
TPM_TIMEOUT_D timeout is only related to burst_count polling. This moves the burstCount polling code to tpm_read_burst_count() in order to isolate the code that is related to TPM_TIMEOUT_D. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: handle errors after reading sts.commandReadyClaudio Carvalho1-32/+50
This adds code to handle errors after reading sts.commandReady. The nested loop in tpm_poll_for_command_ready() is splitted in two functions. Fixes: 56ad053c3e8bf0764ad5878cb018f00a389d30cf Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: add tpm_status_read_byte()Claudio Carvalho1-9/+10
The tpm status register is read from multiple places by calling the tpm-i2c-interface. This adds the tpm_status_read_byte() to be the only function that directly calls the tpm-i2c interface to read the tpm status register Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: add tpm_check_status()Claudio Carvalho1-10/+16
This adds the tpm_check_status(), which makes the code more easy to read and also allows the use of a mask to check status. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-29tpm_i2c_nuvoton: rename defines to shorter namesClaudio Carvalho1-49/+44
This shorten some defines to better fit in 80 columms. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-24tpm_i2c_interface: decouple rc from being done with i2c requestStewart Smith1-4/+14
This ensures the i2c subsystem is done with the i2c request before we continue. Since it handles timeouts, we don't have to here. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Tested-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-24tpm_i2c_interface: set timeout before each requestStewart Smith1-1/+1
The i2c code manipulates req->timeout, so it has to be reset before re-sending. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Tested-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-24i2c: Add i2c_run_req() to crank the state machine for a requestStewart Smith1-5/+9
Doing everything asynchronously is brilliant, it's exactly what we want to do. Except... the tpm driver wants to do things synchronously, which isn't so cool. For reasons that are not yet completely known, we spend an awful lot of time in the main thread *not* running pollers (potentially seconds), which doesn't bode well for I2C timeouts. Since the TPM measure is done in a secondary thread, we do *not* run pollers there either (as of 323c8aeb54bd4e0b9004091fcbb4a9daeda2f576 - which is roughly as of skiboot 2.1.1). But we still need to crank the i2c state machine, so we introduce a call to do just that. It will return how long the poll interval should be, so that we can time_wait() for a more appropriate time for whatever i2c implementation is sitting behind things. Without this, it was "easy" to get to a situation where the i2c state machine wasn't cranked at all, and you'd hit the i2c timeout (for the issued operation) before the poller to crank i2c was ever called. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com> Tested-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-11-11libstb: bump up the byte timeout for tpm i2c requestsClaudio Carvalho1-1/+1
This bumps up the byte timeout for tpm i2c requests from 10ms to 30ms. Some p8dtu systems are getting i2c request timeout. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-10Add software STB "ROM" implementation for MamboStewart Smith5-1/+722
Pass SKIBOOT_ENABLE_MAMBO_STB=1 as environment variable to skiboot.tcl and the tcl will enable the /ibm,secureboot node, enabling hash and signature "verification" for that mambo session. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-10Add i2c Nuvoton TPM 2.0 DriverClaudio Carvalho3-1/+527
This adds the 1/5 step performed by the TPM I2C Nuvoton driver to transmit a command to the TPM device. In this step the driver checks if the TPM device is ready to receive a new command. This adds the 2/5 step performed by the TPM I2C Nuvoton driver to transmit a command to the TPM device. In this step the driver writes a given command to master I2C FIFO. This adds the 3/5 step performed by the TPM I2C Nuvoton driver to transmit a command to the TPM device. In this step the driver sets the TPMGO bit in the I2C master status register to indicate that the command stored in the FIFO can be sent to the TPM device. This adds the 4/5 step performed by the TPM I2C Nuvoton driver to transmit a command to the TPM device. In this step the driver reads from the I2C master FIFO the result that the TPM device returned for the last command sent. This adds the 5/5 step performed by the TPM I2C Nuvoton driver to transmit a command to the TPM device. In this step the driver sets the COMMAND_READY bit in the status register to indicate that the TPM device is ready to receive a new command. This adds the probe function to the TPM Nuvoton driver and also updates the tpm_init() in tpm_chip.c to call the probe function. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> [stewart@linux.vnet.ibm.com: squash commits into one] Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-10libstb/drivers: add tpm_i2c interfaceClaudio Carvalho3-1/+158
This adds the functions that TPM I2C drivers can use to send requests to I2C master. Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
2016-10-10libstb/drivers: add romcode driverClaudio Carvalho3-0/+173
This adds a driver for the ROM verification code. The driver is compatible with 'ibm,secureboot-v1'. The presense of a verification code in the platform is indicated by the presence of the ibm,secureboot node in the device tree. The ibm,secureboot node is documented in 'doc/device-tree/ibm,secureboot.rst' Signed-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>