-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[spi_device] TPM poorly handles aborted transactions #20654
Comments
CC @mazurek-michal |
@jesultra ACK I am actively working on more robust device code for SPI-TPM test. |
I have not yet looked into the details of the SPI TPM device hardware functionality. But at first glance, it sounds as if some of the features we put into the I2C device IP block could be appropriate. Basically, the I2C block has an "incoming" queue of requests received from the AP, which could be reads or writes. For writes, the data is inlined into the same queue as the transaction headers (commands). Then we added a funny feature, which was to make the hardware treat the data read FIFO (outgoing data from OT) as if it was empty, at any time when the incoming queue was non-empty. The intent was the same as clearing the data read FIFO when chip select is deasserted, but as Alex points out, doing so at the edge is insufficient to guard against the software populating a response just after the AP has given up and deasserted CS. If instead the hardware would decide based on the incoming queue being non-empty, then a second read by the AP, which the software has not yet seen or processed, would mean that the incoming queue would be non-empty, with the effect that any stale data put in the data read FIFO by software would be ignored by the hardware, until the software has had a chance to respond to the second read command. Not having a foolproof way of telling requests apart, or guarding against stale data being transmitted, would potentially seriously impact the ability of ChromeOS to use the OT chip in designs that use the SPI bus for TPM. In my opinion, this needs to be addressed before the first production tapeout. |
@jesultra Is it possible to manually abort spi transaction (in-flight) in current hyperdebug firmware? |
HyperDebug firmware just knows about SPI read/write transactions. Opentitantool has low-level commands e.g. You could probably manually compose the SPI sequence to read a TPM register with If you want more advanced things, like aborting a TPM command after doing part of the dance around the STATUS and FIFO register, you may need to implement something in Rust that interfaces with |
The plan currently in motion (and generally completed, except for the WrFIFO buffer release CSR and the little shift in RdFIFO reset release):
I believe this will take care of the two hazards mentioned here. Only one command can be active, and both command types should have the synchronization points necessary to prevent ambiguous associations of commands and data. |
Description
In spi_device, the TPM state machine and FIFOs poorly handle aborted transactions, creating ambiguity and race conditions that cannot be readily solved by the information left behind.
For write commands, if a sequence of two commands enters the command FIFO and data is in the write FIFO, there is no way to know which command is associated with the data. It could be the first or the second command that was aborted, and the separate FIFOs for commands and data cause that association to be dropped.
For read commands, the read data FIFO is reset whenever CSB is de-asserted, allowing it to clear any data written in the FIFO for a past command. However, in a sequence of two read commands, if the first read command is aborted, software can potentially write a response to the first read command while the second is active (CSB is asserted). Thus, the host may see read data for the wrong command.
The text was updated successfully, but these errors were encountered: