Page MenuHomeFreeBSD

tpm20: fix suspend/resume and entropy harvesting
ClosedPublic

Authored by kevans on Feb 3 2026, 6:08 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Mar 14, 7:57 AM
Unknown Object (File)
Fri, Mar 13, 12:49 PM
Unknown Object (File)
Sat, Feb 28, 11:59 PM
Unknown Object (File)
Sat, Feb 28, 8:27 PM
Unknown Object (File)
Sat, Feb 28, 1:06 PM
Unknown Object (File)
Feb 25 2026, 7:57 PM
Unknown Object (File)
Feb 23 2026, 2:51 AM
Unknown Object (File)
Feb 12 2026, 10:16 PM
Subscribers

Details

Summary

There were a few problem here:

  • TPM2_Shutdown results in a response that we need to either process or ignore, otherwise any tpm20_write or tpm20_harvest call will trivially hang on an sc->pending_data_length != 0
  • We should have a matching TPM2_Startup upon resume to restore any state that should have persisted
  • We must drain the harvest task before we suspend to avoid problems there

Fixes: 3deb21f1afd5 ("random: TPM_HARVEST should have been [...]")
Co-authored-by: markj (D53835)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kevans requested review of this revision.Feb 3 2026, 6:08 AM

This has been lightly tested, but additional validation would be appreciated.

I'm gonna test it on my laptop but I believe you should uncomment tpm device on GENERIC together with this change

I'm gonna test it on my laptop but I believe you should uncomment tpm device on GENERIC together with this change

Thanks!

re: GENERIC, I'd prefer to evaluate that independently- these fixes are still necessary standalone, and it'd be good to have a clean version for MFC.

Agree with @kevans, we should get this fixed first and re-enable after some wider testing.

It works perfectly here. I've added tpm to kernel and suspended / resumed lots of times. Thank you!

This revision is now accepted and ready to land.Feb 3 2026, 5:33 PM