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
This commit is contained in:
jdolecek 2017-04-27 17:07:22 +00:00
parent 39132b9e2d
commit c9280efe81
5 changed files with 25 additions and 15 deletions

View File

@ -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 @@ dk_attach(struct dk_softc *dksc)
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 @@ dk_done1(struct dk_softc *dksc, struct buf *bp, bool lock)
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);
}

View File

@ -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 @@ struct dk_softc {
#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

View File

@ -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>
@ -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_nvme_attach(device_t parent, device_t self, void *aux)
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");
}

View File

@ -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 @@ ldattach(struct ld_softc *sc, const char *default_strategy)
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);

View File

@ -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 @@ struct ld_softc {
/* 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 *);