On Sat, Aug 23, 2025 at 03:12:48PM +0300, Jarkko Sakkinen wrote:
> Hi
> 
> As of today can we possibly do this:
> 
> 1. drivers/char/tpm (C code)
> 2. drivers/char/tpm/protocol (imported tpm2_protocol)
> 
> ?
> 
> And then build FFI from C to Rust for building commands that we need
> today etc.
> 
> There's one particular challenge where this could help: early boot code
> for D-RTM (i.e., Trenchboot) as given my crate is just a thing in stack
> with no deps, it could be linked also to that payload.
> 
> This would be much better integration step for TPM2 than having a
> separate driver on Rust side. We could start with tpm2-cmd1/cmd2, then
> move on to tpm2-space.c i.e. get all structural processing inside Rust.
> 
> tpm2_protocol is light on definitions and should not need any kernel
> specific Rust shenanigans.
> 
> Consider it as value like integer but just a bit more complex internaal
> represention but in the end it is just a value on stack.
> 
> My goal with tpm2_protocol is to have ACPICA alike model of imports as
> the crate is driven by TCG spec updates and it is very likely to be
> also used by TPM-RS (also via import style process).
 
The source code since 0.10.0 version has been relocated here:

https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/tpm2-protocol.git

The representation of commands and responses defined is pretty well
high-lighted by

https://bsky.app/profile/jarkk0.bsky.social/post/3lx2n2uvxos2h

I'm also working on a test that measures the estimated compile time
size and realized run-time size (suggested by Philip Tricca) so that
we know where we are at on stack usage.

I've started to optimize it after development phase with some
low-hanging fruit cut already in 0.10.0 but this work is barely
starting [1].

There's also a kselftest compatible test that can be run with
"make test" in the repo using only rustc (build + run circa
2 seconds on my laptop).

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/tpm2-protocol.git/commit/?id=cd6641bf9e8c8fde8726bece9eb6cdc630d893c2

BR, Jarkko

Reply via email to