Re: tpm for AMD Ryzen

From: Enji Cooper <yaneurabeya_at_gmail.com>
Date: Mon, 19 Jun 2023 18:57:43 UTC
> On Jun 19, 2023, at 11:09 AM, Johannes Totz <jo@bruelltuete.com> wrote:
> 
> 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?

Hi Johannes,
	I just built a Ryzen machine too with an ASUS Motherboard. Could you please post the hack that you did to the if-else statement up on gist so I can take a look at it?
	Also, if you can post "boot -v” and “pciconf -lv” output to separate gists, that would be super helpful :).
Cheers!
-Enji