Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/arch/evbarm/fdt Teach arm fdt kernel to use /chose...



details:   https://anonhg.NetBSD.org/src-all/rev/3de73e1e3d3a
branches:  trunk
changeset: 932558:3de73e1e3d3a
user:      Taylor R Campbell <riastradh%NetBSD.org@localhost>
date:      Mon May 11 02:12:09 2020 +0000

description:
Teach arm fdt kernel to use /chosen/netbsd,efirng data.

Feed it in as a separate random source, with zero entropy since this
is a best-effort fallback for devices we really don't know anything
about.

diffstat:

 sys/arch/evbarm/fdt/fdt_machdep.c |  28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diffs (52 lines):

diff -r 9354be028204 -r 3de73e1e3d3a sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Mon May 11 02:11:09 2020 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Mon May 11 02:12:09 2020 +0000
@@ -65,6 +65,7 @@
 #include <sys/md5.h>
 #include <sys/pserialize.h>
 #include <sys/rnd.h>
+#include <sys/rndsource.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
@@ -451,6 +452,30 @@
        rnd_seed(rndseed, rndseed_size);
 }
 
+static void
+fdt_probe_efirng(void)
+{
+       static struct krndsource efirng_source;
+       int chosen, nrngdata;
+       const void *rngdata;
+
+       chosen = OF_finddevice("/chosen");
+       if (chosen < 0)
+               return;
+
+       rngdata = fdtbus_get_prop(chosen, "netbsd,efirng", &nrngdata);
+       if (rngdata == NULL || nrngdata <= 0)
+               return;
+
+       rnd_attach_source(&efirng_source, "efirng", RND_TYPE_RNG,
+           RND_FLAG_DEFAULT);
+       rnd_add_data(&efirng_source, rngdata, nrngdata, 0);
+
+       /* While the fdt is mutable, we can overwrite this in place.  */
+       explicit_memset(__UNCONST(rngdata), 0, nrngdata);
+       fdt_delprop(fdt_data, chosen, "netbsd,efirng");
+}
+
 #ifdef EFI_RUNTIME
 static void
 fdt_map_efi_runtime(const char *prop, enum arm_efirt_mem_type type)
@@ -537,6 +562,9 @@
        VPRINTF("stdout\n");
        fdt_update_stdout_path();
 
+       /* Parse EFI RNG data */
+       fdt_probe_efirng();
+
        /*
         * Done making changes to the FDT.
         */



Home | Main Index | Thread Index | Old Index