Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev do not attach nvme ld as randomness source - device ...
details: https://anonhg.NetBSD.org/src/rev/704080bc6d99
branches: trunk
changeset: 353292:704080bc6d99
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Thu Apr 27 17:07:22 2017 +0000
description:
do not attach nvme ld as randomness source - device is too fast, it overwhelms
the rndq handling code, and causes system crashes; gathering rnd there is
also bad idea from performance perspective
diffstat:
sys/dev/dksubr.c | 21 +++++++++++++--------
sys/dev/dkvar.h | 3 ++-
sys/dev/ic/ld_nvme.c | 6 +++---
sys/dev/ld.c | 7 +++++--
sys/dev/ldvar.h | 3 ++-
5 files changed, 25 insertions(+), 15 deletions(-)
diffs (143 lines):
diff -r 8dacf791b7d0 -r 704080bc6d99 sys/dev/dksubr.c
--- a/sys/dev/dksubr.c Thu Apr 27 16:52:22 2017 +0000
+++ b/sys/dev/dksubr.c Thu Apr 27 17:07:22 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dksubr.c,v 1.96 2017/03/05 23:07:12 mlelstv Exp $ */
+/* $NetBSD: dksubr.c,v 1.97 2017/04/27 17:07:22 jdolecek Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.96 2017/03/05 23:07:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dksubr.c,v 1.97 2017/04/27 17:07:22 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -102,16 +102,20 @@
dksc->sc_flags |= DKF_WARNLABEL | DKF_LABELSANITY;
#endif
- /* Attach the device into the rnd source list. */
- rnd_attach_source(&dksc->sc_rnd_source, dksc->sc_xname,
- RND_TYPE_DISK, RND_FLAG_DEFAULT);
+ if ((dksc->sc_flags & DKF_NO_RND) == 0) {
+ /* Attach the device into the rnd source list. */
+ rnd_attach_source(&dksc->sc_rnd_source, dksc->sc_xname,
+ RND_TYPE_DISK, RND_FLAG_DEFAULT);
+ }
}
void
dk_detach(struct dk_softc *dksc)
{
- /* Unhook the entropy source. */
- rnd_detach_source(&dksc->sc_rnd_source);
+ if ((dksc->sc_flags & DKF_NO_RND) == 0) {
+ /* Unhook the entropy source. */
+ rnd_detach_source(&dksc->sc_rnd_source);
+ }
dksc->sc_flags &= ~DKF_READYFORDUMP;
mutex_destroy(&dksc->sc_iolock);
@@ -458,7 +462,8 @@
if (lock)
mutex_exit(&dksc->sc_iolock);
- rnd_add_uint32(&dksc->sc_rnd_source, bp->b_rawblkno);
+ if ((dksc->sc_flags & DKF_NO_RND) == 0)
+ rnd_add_uint32(&dksc->sc_rnd_source, bp->b_rawblkno);
biodone(bp);
}
diff -r 8dacf791b7d0 -r 704080bc6d99 sys/dev/dkvar.h
--- a/sys/dev/dkvar.h Thu Apr 27 16:52:22 2017 +0000
+++ b/sys/dev/dkvar.h Thu Apr 27 17:07:22 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkvar.h,v 1.28 2016/12/22 13:42:14 mlelstv Exp $ */
+/* $NetBSD: dkvar.h,v 1.29 2017/04/27 17:07:22 jdolecek Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -68,6 +68,7 @@
#define DKF_KLABEL 0x00400000 /* keep label on close */
#define DKF_VLABEL 0x00800000 /* label is valid */
#define DKF_SLEEP 0x80000000 /* dk_start/dk_done may sleep */
+#define DKF_NO_RND 0x01000000 /* do not attach as rnd source */
/* Mask of flags that dksubr.c understands, other flags are fair game */
#define DK_FLAGMASK 0xffff0000
diff -r 8dacf791b7d0 -r 704080bc6d99 sys/dev/ic/ld_nvme.c
--- a/sys/dev/ic/ld_nvme.c Thu Apr 27 16:52:22 2017 +0000
+++ b/sys/dev/ic/ld_nvme.c Thu Apr 27 17:07:22 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld_nvme.c,v 1.15 2017/04/05 20:15:49 jdolecek Exp $ */
+/* $NetBSD: ld_nvme.c,v 1.16 2017/04/27 17:07:22 jdolecek Exp $ */
/*-
* Copyright (C) 2016 NONAKA Kimihiro <nonaka%netbsd.org@localhost>
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.15 2017/04/05 20:15:49 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld_nvme.c,v 1.16 2017/04/27 17:07:22 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -128,7 +128,7 @@
ld->sc_start = ld_nvme_start;
ld->sc_dump = ld_nvme_dump;
ld->sc_ioctl = ld_nvme_ioctl;
- ld->sc_flags = LDF_ENABLED;
+ ld->sc_flags = LDF_ENABLED | LDF_NO_RND;
ldattach(ld, "fcfs");
}
diff -r 8dacf791b7d0 -r 704080bc6d99 sys/dev/ld.c
--- a/sys/dev/ld.c Thu Apr 27 16:52:22 2017 +0000
+++ b/sys/dev/ld.c Thu Apr 27 17:07:22 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ld.c,v 1.100 2017/02/27 21:32:33 jdolecek Exp $ */
+/* $NetBSD: ld.c,v 1.101 2017/04/27 17:07:22 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.100 2017/02/27 21:32:33 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ld.c,v 1.101 2017/04/27 17:07:22 jdolecek Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -149,6 +149,9 @@
sc->sc_disksize512 = sc->sc_secperunit * sc->sc_secsize / DEV_BSIZE;
+ if (sc->sc_flags & LDF_NO_RND)
+ dksc->sc_flags |= DKF_NO_RND;
+
/* Attach dk and disk subsystems */
dk_attach(dksc);
disk_attach(&dksc->sc_dkdev);
diff -r 8dacf791b7d0 -r 704080bc6d99 sys/dev/ldvar.h
--- a/sys/dev/ldvar.h Thu Apr 27 16:52:22 2017 +0000
+++ b/sys/dev/ldvar.h Thu Apr 27 17:07:22 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ldvar.h,v 1.29 2017/02/27 21:32:33 jdolecek Exp $ */
+/* $NetBSD: ldvar.h,v 1.30 2017/04/27 17:07:22 jdolecek Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -67,6 +67,7 @@
/* sc_flags */
#define LDF_ENABLED 0x001 /* device enabled */
#define LDF_DRAIN 0x020 /* maxqueuecnt has changed; drain */
+#define LDF_NO_RND 0x040 /* do not attach rnd source */
int ldadjqparam(struct ld_softc *, int);
void ldattach(struct ld_softc *, const char *);
Home |
Main Index |
Thread Index |
Old Index