Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys rnd_attach_source calls the callback itself now.



details:   https://anonhg.NetBSD.org/src/rev/950ad1f1e8e4
branches:  trunk
changeset: 1009661:950ad1f1e8e4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Apr 30 03:40:52 2020 +0000

description:
rnd_attach_source calls the callback itself now.

No need for every driver to explicitly call it to prime the pool.

Eliminate now-unused <sys/rndpool.h>.

diffstat:

 sys/arch/arm/amlogic/meson_rng.c         |   7 +---
 sys/arch/arm/broadcom/bcm2835_rng.c      |   8 +----
 sys/arch/arm/nvidia/tegra124_car.c       |   6 +--
 sys/arch/arm/nvidia/tegra210_car.c       |   5 +--
 sys/arch/arm/omap/am335x_trng.c          |   7 +---
 sys/arch/arm/sunxi/sun8i_crypto.c        |   5 +--
 sys/arch/arm/ti/ti_rng.c                 |   7 +---
 sys/arch/mips/ingenic/ingenic_rng.c      |   7 +---
 sys/arch/x86/x86/cpu_rng.c               |  36 +++++++++++-------------
 sys/dev/ic/amdccp.c                      |   6 +--
 sys/dev/ic/rng200.c                      |   5 +--
 sys/dev/pci/amdpm.c                      |   7 +---
 sys/dev/pci/hifn7751.c                   |   9 +----
 sys/dev/pci/ubsec.c                      |   9 +----
 sys/dev/pci/viornd.c                     |   3 +-
 sys/dev/usb/ualea.c                      |  41 ++++++---------------------
 sys/rump/librump/rumpkern/hyperentropy.c |  17 ++++------
 sys/sys/rndpool.h                        |  46 --------------------------------
 18 files changed, 60 insertions(+), 171 deletions(-)

diffs (truncated from 738 to 300 lines):

diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/arm/amlogic/meson_rng.c
--- a/sys/arch/arm/amlogic/meson_rng.c  Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/arm/amlogic/meson_rng.c  Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meson_rng.c,v 1.2 2019/04/21 14:13:55 jmcneill Exp $ */
+/* $NetBSD: meson_rng.c,v 1.3 2020/04/30 03:40:52 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2019 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: meson_rng.c,v 1.2 2019/04/21 14:13:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: meson_rng.c,v 1.3 2020/04/30 03:40:52 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -35,7 +35,6 @@
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/mutex.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 
 #include <dev/fdt/fdtvar.h>
@@ -107,8 +106,6 @@
        rndsource_setcb(&sc->sc_rndsource, meson_rng_get, sc);
        rnd_attach_source(&sc->sc_rndsource, device_xname(self), RND_TYPE_RNG,
            RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
-
-       meson_rng_get(RND_POOLBITS / NBBY, sc);
 }
 
 static void
diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/arm/broadcom/bcm2835_rng.c
--- a/sys/arch/arm/broadcom/bcm2835_rng.c       Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_rng.c       Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bcm2835_rng.c,v 1.13 2017/12/10 21:38:26 skrll Exp $ */
+/*     $NetBSD: bcm2835_rng.c,v 1.14 2020/04/30 03:40:52 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -30,14 +30,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_rng.c,v 1.13 2017/12/10 21:38:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_rng.c,v 1.14 2020/04/30 03:40:52 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/kernel.h>
 #include <sys/bus.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 
 #include <arm/broadcom/bcm2835reg.h>
@@ -122,9 +121,6 @@
        rndsource_setcb(&sc->sc_rndsource, &bcmrng_get, sc);
        rnd_attach_source(&sc->sc_rndsource, device_xname(self), RND_TYPE_RNG,
            RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
-
-       /* get some initial entropy ASAP */
-       bcmrng_get(RND_POOLBITS / NBBY, sc);
 }
 
 static void
diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/arm/nvidia/tegra124_car.c
--- a/sys/arch/arm/nvidia/tegra124_car.c        Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/arm/nvidia/tegra124_car.c        Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra124_car.c,v 1.19 2019/10/13 06:11:31 skrll Exp $ */
+/* $NetBSD: tegra124_car.c,v 1.20 2020/04/30 03:40:52 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra124_car.c,v 1.19 2019/10/13 06:11:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra124_car.c,v 1.20 2020/04/30 03:40:52 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -35,7 +35,6 @@
 #include <sys/intr.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 #include <sys/atomic.h>
 #include <sys/kmem.h>
@@ -919,7 +918,6 @@
        rndsource_setcb(&sc->sc_rndsource, tegra124_car_rnd_callback, sc);
        rnd_attach_source(&sc->sc_rndsource, device_xname(sc->sc_dev),
            RND_TYPE_RNG, RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
-       tegra124_car_rnd_callback(RND_POOLBITS / NBBY, sc);
 }
 
 static void
diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/arm/nvidia/tegra210_car.c
--- a/sys/arch/arm/nvidia/tegra210_car.c        Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/arm/nvidia/tegra210_car.c        Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra210_car.c,v 1.25 2019/10/13 06:11:31 skrll Exp $ */
+/* $NetBSD: tegra210_car.c,v 1.26 2020/04/30 03:40:52 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra210_car.c,v 1.25 2019/10/13 06:11:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra210_car.c,v 1.26 2020/04/30 03:40:52 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -35,7 +35,6 @@
 #include <sys/intr.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 #include <sys/atomic.h>
 #include <sys/kmem.h>
diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/arm/omap/am335x_trng.c
--- a/sys/arch/arm/omap/am335x_trng.c   Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/arm/omap/am335x_trng.c   Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: am335x_trng.c,v 1.2 2016/12/17 15:24:35 riastradh Exp $ */
+/* $NetBSD: am335x_trng.c,v 1.3 2020/04/30 03:40:52 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am335x_trng.c,v 1.2 2016/12/17 15:24:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am335x_trng.c,v 1.3 2020/04/30 03:40:52 riastradh Exp $");
 
 #include "opt_omap.h"
 
@@ -36,7 +36,6 @@
 #include <sys/conf.h>
 #include <sys/mutex.h>
 #include <sys/bus.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 
 #include <arm/omap/am335x_prcm.h>
@@ -119,8 +118,6 @@
 
        aprint_naive("\n");
        aprint_normal("\n");
-
-       trng_callback(RND_POOLBITS / NBBY, sc);
 }
 
 static void
diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/arm/sunxi/sun8i_crypto.c
--- a/sys/arch/arm/sunxi/sun8i_crypto.c Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/arm/sunxi/sun8i_crypto.c Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sun8i_crypto.c,v 1.12 2020/02/06 19:52:09 riastradh Exp $      */
+/*     $NetBSD: sun8i_crypto.c,v 1.13 2020/04/30 03:40:53 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.12 2020/02/06 19:52:09 riastradh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun8i_crypto.c,v 1.13 2020/04/30 03:40:53 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -55,7 +55,6 @@
 #include <sys/kernel.h>
 #include <sys/kmem.h>
 #include <sys/mutex.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 #include <sys/sysctl.h>
 #include <sys/workqueue.h>
diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/arm/ti/ti_rng.c
--- a/sys/arch/arm/ti/ti_rng.c  Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/arm/ti/ti_rng.c  Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_rng.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $ */
+/* $NetBSD: ti_rng.c,v 1.3 2020/04/30 03:40:53 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ti_rng.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_rng.c,v 1.3 2020/04/30 03:40:53 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -34,7 +34,6 @@
 #include <sys/conf.h>
 #include <sys/mutex.h>
 #include <sys/bus.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 
 #include <dev/fdt/fdtvar.h>
@@ -119,8 +118,6 @@
 
        aprint_naive("\n");
        aprint_normal(": RNG\n");
-
-       ti_rng_callback(RND_POOLBITS / NBBY, sc);
 }
 
 static void
diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/mips/ingenic/ingenic_rng.c
--- a/sys/arch/mips/ingenic/ingenic_rng.c       Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/mips/ingenic/ingenic_rng.c       Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ingenic_rng.c,v 1.4 2016/02/17 20:12:42 macallan Exp $ */
+/*     $NetBSD: ingenic_rng.c,v 1.5 2020/04/30 03:40:53 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 Michael McConville
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ingenic_rng.c,v 1.4 2016/02/17 20:12:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ingenic_rng.c,v 1.5 2020/04/30 03:40:53 riastradh Exp $");
 
 /*
  * adapted from Jared McNeill's amlogic_rng.c
@@ -40,7 +40,6 @@
 #include <sys/kernel.h>
 #include <sys/mutex.h>
 #include <sys/bus.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 
 #include <mips/ingenic/ingenic_var.h>
@@ -103,8 +102,6 @@
        rndsource_setcb(&sc->sc_rndsource, ingenic_rng_get, sc);
        rnd_attach_source(&sc->sc_rndsource, device_xname(self), RND_TYPE_RNG,
            RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);
-
-       ingenic_rng_get(RND_POOLBITS / NBBY, sc);
 }
 
 static void
diff -r c56251b2d943 -r 950ad1f1e8e4 sys/arch/x86/x86/cpu_rng.c
--- a/sys/arch/x86/x86/cpu_rng.c        Thu Apr 30 03:30:10 2020 +0000
+++ b/sys/arch/x86/x86/cpu_rng.c        Thu Apr 30 03:40:52 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_rng.c,v 1.12 2020/04/30 03:30:10 riastradh Exp $ */
+/* $NetBSD: cpu_rng.c,v 1.13 2020/04/30 03:40:53 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -48,7 +48,6 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/cpu.h>
-#include <sys/rndpool.h>
 #include <sys/rndsource.h>
 #include <sys/sha2.h>
 
@@ -250,27 +249,26 @@
 static void
 cpu_rng_get(size_t nbytes, void *cookie)
 {
-       const unsigned N = howmany(RND_POOLBITS, 64);
+       const unsigned N = howmany(256, 64);
        uint64_t buf[2*N];
        unsigned i, nbits = 0;
 
-       /*
-        * Draw a sample large enough to (a) fill the pool if it had
-        * full entropy, and (b) run a repeated-output test; then test
-        * it.  If RND_POOLBITS is at least 256, the fraction of
-        * outputs this rejects in correct operation is 1/2^256, which
-        * is close enough to zero that we round it to having no effect
-        * on the number of bits of entropy.
-        */
-       for (i = 0; i < __arraycount(buf); i++)
-               nbits += cpu_rng(cpu_rng_mode, &buf[i]);
-       if (consttime_memequal(buf, buf + N, N)) {
-               printf("cpu_rng %s: failed repetition test\n",
-                   cpu_rng_name[cpu_rng_mode]);



Home | Main Index | Thread Index | Old Index