Commit 1f71ada86d for qemu.org
commit 1f71ada86d7ad43c7241a6ae96912139ec3a6a7e
Author: Warner Losh <imp@bsdimp.com>
Date: Fri Jun 19 20:56:18 2026 -0600
bsd-user Update random_seed on thread creation
Initialize / update cpu->random_seed in similar locations to the
linux-user code. Set it just before we create the thread, and update it
in the thread startup code.
Reported-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Warner Losh <imp@bsdimp.com>
diff --git a/bsd-user/freebsd/os-thread.c b/bsd-user/freebsd/os-thread.c
index 63c17e10d0..15872f03fd 100644
--- a/bsd-user/freebsd/os-thread.c
+++ b/bsd-user/freebsd/os-thread.c
@@ -14,6 +14,7 @@
#include "signal-common.h"
#include "target_arch_cpu.h"
#include "target_arch_thread.h"
+#include "qemu/guest-random.h"
#include "tcg/startup.h"
#include "exec/tb-flush.h"
@@ -142,7 +143,7 @@ void *new_freebsd_thread_start(void *arg)
target_thread_set_upcall(env, info->param.start_func, info->param.arg,
info->param.stack_base, info->param.stack_size);
target_cpu_set_tls(env, info->param.tls_base);
-
+ qemu_guest_random_seed_thread_part2(cpu->random_seed);
/* Enable signals */
sigprocmask(SIG_SETMASK, &info->sigmask, NULL);
/* Signal to the parent that we're ready. */
@@ -1657,6 +1658,7 @@ abi_long do_freebsd_thr_new(CPUArchState *env,
*/
sigfillset(&sigmask);
sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask);
+ cpu->random_seed = qemu_guest_random_seed_thread_part1();
ret = pthread_create(&info.thread, &attr, new_freebsd_thread_start, &info);