git: d7c87526b1c3 - main - tpm: Register TPM as entropy source

From: Kevin Bowling <kbowling_at_FreeBSD.org>
Date: Sat, 31 Aug 2024 17:54:54 UTC
The branch main has been updated by kbowling:

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

commit d7c87526b1c3d32d3ac3fee8c59d92405b7621b9
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-08-31 17:53:02 +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>
    
    MFC after:      1 week
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/1398
---
 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 80f7d9e105a6..876dd0bcc40d 100644
--- a/sys/dev/tpm/tpm20.c
+++ b/sys/dev/tpm/tpm20.c
@@ -206,6 +206,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);
@@ -222,6 +223,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)