[PATCH v7 05/20] KVM: selftests: Seed libc's RNG before using it to generate a seed for KVM's pRNG
Sean Christopherson
seanjc at google.com
Fri Jun 12 17:20:16 PDT 2026
Seed the RNG used by random() using the de facto standard method of
srand(time(0)), so that a different seed is actually used in each test run.
E.g. without seeding the RNG, literally every test on x86 will use
0x6b8b4567 to seed the KVM RNG.
Signed-off-by: Sean Christopherson <seanjc at google.com>
---
tools/testing/selftests/kvm/lib/kvm_util.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c
index 1016865d3f7a..2e08d9fcefc7 100644
--- a/tools/testing/selftests/kvm/lib/kvm_util.c
+++ b/tools/testing/selftests/kvm/lib/kvm_util.c
@@ -2284,6 +2284,7 @@ void __attribute((constructor)) kvm_selftest_init(void)
sigaction(SIGILL, &sig_sa, NULL);
sigaction(SIGFPE, &sig_sa, NULL);
+ srandom(time(0));
kvm_seed_rng(random());
kvm_selftest_arch_init();
--
2.54.0.1136.gdb2ca164c4-goog
More information about the linux-arm-kernel
mailing list