]> www.infradead.org Git - users/jedix/linux-maple.git/commit
tpm: Lazily flush auth session when getting random data
authorJonathan McDowell <noodles@meta.com>
Fri, 7 Mar 2025 10:58:13 +0000 (10:58 +0000)
committerJarkko Sakkinen <jarkko@kernel.org>
Thu, 27 Mar 2025 13:34:04 +0000 (15:34 +0200)
commit668f953bb4dfeddad854c0141a77b1738cdc1fdf
treecd2480ebb9e1985cb97fadf1c4bf817c8a65b4c1
parentfb3bf46de6d9b00088965db6b3c56a6c18153c9f
tpm: Lazily flush auth session when getting random data

Lazy flushing of TPM auth sessions was introduced to speed up IMA
measurments into the TPM. Make use of it in tpm2_get_random as well,
which has the added benefit of not needlessly cleaning up the session
that IMA is using when there are no userspace accesses taking place.

Command trace before for every call:

hwrng (0x00000161): 14 (52965242 ns)
hwrng (0x00000176): 48 (161612432 ns)
hwrng (0x00000165): 10 (2410494 ns)
hwrng (0x0000017B): 117 (70699883 ns)
hwrng (0x0000017B): 117 (70959666 ns)
hwrng (0x00000165): 10 (2756827 ns)

After, with repeated calls showing no setup:

hwrng (0x00000161): 14 (53044582 ns)
hwrng (0x00000176): 48 (160491333 ns)
hwrng (0x00000165): 10 (2408220 ns)
hwrng (0x0000017B): 117 (70695037 ns)
hwrng (0x0000017B): 117 (70994984 ns)
hwrng (0x0000017B): 117 (70195388 ns)
hwrng (0x0000017B): 117 (70973835 ns)

Signed-off-by: Jonathan McDowell <noodles@meta.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
drivers/char/tpm/tpm2-cmd.c