random: do not export add_vmfork_randomness() unless needed
authorJason A. Donenfeld <Jason@zx2c4.com>
Tue, 1 Mar 2022 14:14:04 +0000 (15:14 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Sun, 13 Mar 2022 01:00:56 +0000 (18:00 -0700)
commita4107d34f960df99ca07fa8eb022425a804f59f3
tree2e13e4c5cf1ef5cb52b27a992ac3fb35acf33fd5
parentaf6b54e2b5baa54c844573b6d49cc91157bcdd7e
random: do not export add_vmfork_randomness() unless needed

Since add_vmfork_randomness() is only called from vmgenid.o, we can
guard it in CONFIG_VMGENID, similarly to how we do with
add_disk_randomness() and CONFIG_BLOCK. If we ever have multiple things
calling into add_vmfork_randomness(), we can add another shared Kconfig
symbol for that, but for now, this is good enough. Even though
add_vmfork_randomess() is a pretty small function, removing it means
that there are only calls to crng_reseed(false) and none to
crng_reseed(true), which means the compiler can constant propagate the
false, removing branches from crng_reseed() and its descendants.

Additionally, we don't even need the symbol to be exported if
CONFIG_VMGENID is not a module, so conditionalize that too.

Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
drivers/char/random.c
include/linux/random.h