Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch x86: Move RNG initialization to after consinit.
details: https://anonhg.NetBSD.org/src/rev/b056c8e4cbe2
branches: trunk
changeset: 990467:b056c8e4cbe2
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Oct 28 10:46:05 2021 +0000
description:
x86: Move RNG initialization to after consinit.
This ensures we have the opportunity to get feedback about early
entropy.
diffstat:
sys/arch/amd64/amd64/machdep.c | 15 +++++++++++----
sys/arch/i386/i386/machdep.c | 15 +++++++++++----
2 files changed, 22 insertions(+), 8 deletions(-)
diffs (86 lines):
diff -r 779cfe76a26d -r b056c8e4cbe2 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Thu Oct 28 10:45:48 2021 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Thu Oct 28 10:46:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.359 2021/10/28 10:45:48 riastradh Exp $ */
+/* $NetBSD: machdep.c,v 1.360 2021/10/28 10:46:05 riastradh Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.359 2021/10/28 10:45:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.360 2021/10/28 10:46:05 riastradh Exp $");
#include "opt_modular.h"
#include "opt_user_ldt.h"
@@ -1718,8 +1718,6 @@
svs_init();
#endif
cpu_init_msrs(&cpu_info_primary, true);
- cpu_rng_init();
- x86_rndseed();
#ifndef XENPV
cpu_speculation_init(&cpu_info_primary);
#endif
@@ -1743,6 +1741,15 @@
consinit(); /* XXX SHOULD NOT BE DONE HERE */
/*
+ * Initialize RNG to get entropy ASAP either from CPU
+ * RDRAND/RDSEED or from seed on disk. Must happen after
+ * cpu_init_msrs. Prefer to happen after consinit so we have
+ * the opportunity to print useful feedback.
+ */
+ cpu_rng_init();
+ x86_rndseed();
+
+ /*
* Initialize PAGE_SIZE-dependent variables.
*/
uvm_md_init();
diff -r 779cfe76a26d -r b056c8e4cbe2 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Thu Oct 28 10:45:48 2021 +0000
+++ b/sys/arch/i386/i386/machdep.c Thu Oct 28 10:46:05 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.832 2021/10/28 10:45:48 riastradh Exp $ */
+/* $NetBSD: machdep.c,v 1.833 2021/10/28 10:46:05 riastradh Exp $ */
/*
* Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.832 2021/10/28 10:45:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.833 2021/10/28 10:46:05 riastradh Exp $");
#include "opt_beep.h"
#include "opt_compat_freebsd.h"
@@ -1161,8 +1161,6 @@
cpu_probe(&cpu_info_primary);
cpu_init_msrs(&cpu_info_primary, true);
- cpu_rng_init();
- x86_rndseed();
#ifndef XENPV
cpu_speculation_init(&cpu_info_primary);
#endif
@@ -1243,6 +1241,15 @@
consinit(); /* XXX SHOULD NOT BE DONE HERE */
+ /*
+ * Initialize RNG to get entropy ASAP either from CPU
+ * RDRAND/RDSEED or from seed on disk. Must happen after
+ * cpu_init_msrs. Prefer to happen after consinit so we have
+ * the opportunity to print useful feedback.
+ */
+ cpu_rng_init();
+ x86_rndseed();
+
#ifdef DEBUG_MEMLOAD
printf("mem_cluster_count: %d\n", mem_cluster_cnt);
#endif
Home |
Main Index |
Thread Index |
Old Index