Skip to content
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

Slow execution of TPM stack #23

Open
krystian-hebel opened this issue Jan 16, 2024 · 0 comments
Open

Slow execution of TPM stack #23

krystian-hebel opened this issue Jan 16, 2024 · 0 comments
Assignees

Comments

@krystian-hebel
Copy link
Collaborator

TPM stack executes way too slow. This is mostly caused by lack of cache in our current NEORV32 implementation. For example, a call to TPM2_SelfTest() takes few dozen minutes, and this function is called on every boot. Functions for creating keys take even more.

We had to cheat a bit in order to get current test results:

  • TPM2_SelfTest() was hardcoded to return success without actually testing anything.
  • Instruction cache was enabled (great improvement, and probably will be added in later stages).
  • 64 KB DMEM was enabled. RAM is much slower and without data cache many accesses are suboptimal.
  • Linker script was modified to move data below code whenever possible. That way it was mostly located in DMEM, and code had the cache enabled so it wasn't impacted as much by reading from RAM.
  • Many internal buffers were shrunk as much as possible to further reduce amount of data in RAM.
  • Tests that called TPM2_CreatePrimary() were disabled. Even after much heavier modifications to memory layout, that function took about 4.5 minutes, barely below tpm2_createprimary timeout of 5 minutes. TPM2_Create() behaved similarly, but there is not enough memory available to make both pass at the same time.

Unfortunately, enabling data cache breaks execution. Data saved on stack isn't the same when read from it at a later point. Sometimes data that should be read somehow is executed as an instruction, or at least it looks that way in panic messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant