tpm for AMD Ryzen

From: Johannes Totz <jo_at_bruelltuete.com>
Date: Mon, 19 Jun 2023 18:09:41 UTC
Hi everyone,

I'm trying to get the (f)TPM that comes with AMD's Zen2 to work.
BIOS config screen says it's doing CRB mode.

So I start poking in tpm_crb.c 
https://github.com/freebsd/freebsd-src/blob/main/sys/dev/tpm/tpm_crb.c

Out of the box, it does not attach. The TPM2 ACPI table says its start 
method is 2 (aka ACPI). That's easy to hack around, just mess with the 
if-condition at 
https://github.com/freebsd/freebsd-src/blob/main/sys/dev/tpm/tpm_crb.c#L115

With that adjusted, tpmcrb now probes successfully but does not attach.

As far as I can tell the register values it tries to read from the 
ACPI-provided memory window are just bogus.

That makes me suspect that the BIOS has misconfigured it. The TPM2 table 
has a different address than what's reported at runtime.
The table says 0xfd210510 is the (physical) address, but acpi says it's 
0xbd13f000.

Fiddling about with hint.tpmcrb.0.maddr and friends does not yield 
anything fruitful: anything I try to override with hints is just ignored.
Hacking in a
bus_set_resource(dev, SYS_RES_MEMORY, ... 0xfd210510 ...);
ends up giving me that override but still no dice re actual tpm 
functionality.

Has anyone gotten the tpm to work on (consumer) Ryzen?


thanks,

Johannes