[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 27/42] bsd-user: Implement --seed and initialize random state
From: |
imp |
Subject: |
[PULL 27/42] bsd-user: Implement --seed and initialize random state |
Date: |
Tue, 7 Sep 2021 15:53:17 -0600 |
From: Warner Losh <imp@FreeBSD.org>
Copy --seed implementation (translated from linux-user's newer command
line scheme to the older one bsd-user still uses). Initialize the
randomness with the glib if a specific seed is specified or use the
qcrypto library if not.
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/main.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 19bf3a09a7..71fd9d5aba 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -45,6 +45,8 @@
#include "qemu/cutils.h"
#include "exec/log.h"
#include "trace/control.h"
+#include "crypto/init.h"
+#include "qemu/guest-random.h"
#include "host-os.h"
#include "target_arch_cpu.h"
@@ -203,6 +205,7 @@ int main(int argc, char **argv)
const char *cpu_type;
const char *log_file = NULL;
const char *log_mask = NULL;
+ const char *seed_optarg = NULL;
struct target_pt_regs regs1, *regs = ®s1;
struct image_info info1, *info = &info1;
struct bsd_binprm bprm;
@@ -331,6 +334,8 @@ int main(int argc, char **argv)
usage();
}
optind++;
+ } else if (!strcmp(r, "seed")) {
+ seed_optarg = optarg;
} else if (!strcmp(r, "singlestep")) {
singlestep = 1;
} else if (!strcmp(r, "strace")) {
@@ -403,6 +408,19 @@ int main(int argc, char **argv)
target_environ = envlist_to_environ(envlist, NULL);
envlist_free(envlist);
+ {
+ Error *err = NULL;
+ if (seed_optarg != NULL) {
+ qemu_guest_random_seed_main(seed_optarg, &err);
+ } else {
+ qcrypto_init(&err);
+ }
+ if (err) {
+ error_reportf_err(err, "cannot initialize crypto: ");
+ exit(1);
+ }
+ }
+
/*
* Now that page sizes are configured we can do
* proper page alignment for guest_base.
--
2.32.0
- [PULL 10/42] bsd-user: implement path searching, (continued)
- [PULL 10/42] bsd-user: implement path searching, imp, 2021/09/07
- [PULL 15/42] bsd-user: assume pthreads and support of __thread, imp, 2021/09/07
- [PULL 14/42] bsd-user: elfload: simplify bswap a bit., imp, 2021/09/07
- [PULL 16/42] bsd-user: add host-os.h, imp, 2021/09/07
- [PULL 18/42] bsd-user: save the path to the qemu emulator, imp, 2021/09/07
- [PULL 19/42] bsd-user: start to move target CPU functions to target_arch*, imp, 2021/09/07
- [PULL 29/42] bsd-user: Add architecture specific signal tramp code, imp, 2021/09/07
- [PULL 23/42] bsd-user: define max args in terms of pages, imp, 2021/09/07
- [PULL 25/42] bsd-user: Add system independent stack, data and text limiting, imp, 2021/09/07
- [PULL 21/42] bsd-user: pull in target_arch_thread.h update target_arch_elf.h, imp, 2021/09/07
- [PULL 27/42] bsd-user: Implement --seed and initialize random state,
imp <=
- [PULL 26/42] bsd-user: *BSD specific siginfo defintions, imp, 2021/09/07
- [PULL 30/42] bsd-user: elf cleanup, imp, 2021/09/07
- [PULL 32/42] bsd-user: Rewrite target system call definintion glue, imp, 2021/09/07
- [PULL 11/42] bsd-user: Eliminate elf personality, imp, 2021/09/07
- [PULL 24/42] bsd-user: Create target specific vmparam.h, imp, 2021/09/07
- [PULL 20/42] bsd-user: Move per-cpu code into target_arch_cpu.h, imp, 2021/09/07
- [PULL 31/42] bsd-user: Remove dead #ifdefs from elfload.c, imp, 2021/09/07
- [PULL 33/42] bsd-user: update debugging in mmap.c, imp, 2021/09/07
- [PULL 36/42] bsd-user: add stubbed out core dump support, imp, 2021/09/07
- [PULL 35/42] bsd-user: Add target_os_user.h to capture the user/kernel structures, imp, 2021/09/07