git: 0b683336b211 - stable/14 - tpm: Register TPM as entropy source

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Sat, 07 Sep 2024 05:13:40 UTC
The branch stable/14 has been updated by kbowling:

URL: https://cgit.FreeBSD.org/src/commit/?id=0b683336b211e74b6d7f21ecf517c6591370b793

commit 0b683336b211e74b6d7f21ecf517c6591370b793
Author:     Jean-François Hren <jean-francois.hren@stormshield.eu>
AuthorDate: 2024-08-31 17:53:02 +0000
Commit:     Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2024-09-07 05:13:14 +0000

    tpm: Register TPM as entropy source
    
    TPM is defined as an entropy and is called every 10 seconds. However it
    was not registered and calls were discarded.
    
    Signed-off-by: Jean-François Hren <jean-francois.hren@stormshield.eu>
    
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1398
    
    (cherry picked from commit d7c87526b1c3d32d3ac3fee8c59d92405b7621b9)
---
 sys/dev/tpm/tpm20.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/tpm/tpm20.c b/sys/dev/tpm/tpm20.c
index da090bc068c9..393552172656 100644
--- a/sys/dev/tpm/tpm20.c
+++ b/sys/dev/tpm/tpm20.c
@@ -203,6 +203,7 @@ tpm20_init(struct tpm_sc *sc)
 		tpm20_release(sc);
 
 #ifdef TPM_HARVEST
+	random_harvest_register_source(RANDOM_PURE_TPM);
 	TIMEOUT_TASK_INIT(taskqueue_thread, &sc->harvest_task, 0,
 	    tpm20_harvest, sc);
 	taskqueue_enqueue_timeout(taskqueue_thread, &sc->harvest_task, 0);
@@ -219,6 +220,7 @@ tpm20_release(struct tpm_sc *sc)
 #ifdef TPM_HARVEST
 	if (device_is_attached(sc->dev))
 		taskqueue_drain_timeout(taskqueue_thread, &sc->harvest_task);
+	random_harvest_deregister_source(RANDOM_PURE_TPM);
 #endif
 
 	if (sc->buf != NULL)