Source-Changes-HG archive

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

[src-draft/trunk]: src/sys/stand/efiboot Pass 64 bytes of EFI RNG output via ...



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

description:
Pass 64 bytes of EFI RNG output via /chosen/netbsd,efirng.

diffstat:

 sys/stand/efiboot/efiboot.c |   2 ++
 sys/stand/efiboot/efifdt.c  |  15 +++++++++++++++
 sys/stand/efiboot/efifdt.h  |   1 +
 sys/stand/efiboot/exec.c    |   6 ++++++
 4 files changed, 24 insertions(+), 0 deletions(-)

diffs (81 lines):

diff -r ed9b769cdf86 -r 680c94613de7 sys/stand/efiboot/efiboot.c
--- a/sys/stand/efiboot/efiboot.c       Mon May 11 02:10:19 2020 +0000
+++ b/sys/stand/efiboot/efiboot.c       Mon May 11 02:11:09 2020 +0000
@@ -31,6 +31,7 @@
 #include "efiblock.h"
 #include "efifdt.h"
 #include "efiacpi.h"
+#include "efirng.h"
 
 #include <sys/reboot.h>
 
@@ -99,6 +100,7 @@
        efi_net_probe();
        efi_file_system_probe();
        efi_block_probe();
+       efi_rng_probe();
 
        boot();
 
diff -r ed9b769cdf86 -r 680c94613de7 sys/stand/efiboot/efifdt.c
--- a/sys/stand/efiboot/efifdt.c        Mon May 11 02:10:19 2020 +0000
+++ b/sys/stand/efiboot/efifdt.c        Mon May 11 02:11:09 2020 +0000
@@ -412,3 +412,18 @@
        fdt_setprop_u64(fdt_data, chosen, "netbsd,rndseed-end",
            rndseed_addr + rndseed_size);
 }
+
+void
+efi_fdt_efirng(const char *rngdata, u_long nrngdata)
+{
+       int chosen;
+
+       chosen = fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH);
+       if (chosen < 0)
+               chosen = fdt_add_subnode(fdt_data,
+                   fdt_path_offset(fdt_data, "/"),
+                   FDT_CHOSEN_NODE_NAME);
+       if (chosen < 0)
+               panic("FDT: Failed to create " FDT_CHOSEN_NODE_PATH " node");
+       fdt_setprop(fdt_data, chosen, "netbsd,efirng", rngdata, nrngdata);
+}
diff -r ed9b769cdf86 -r 680c94613de7 sys/stand/efiboot/efifdt.h
--- a/sys/stand/efiboot/efifdt.h        Mon May 11 02:10:19 2020 +0000
+++ b/sys/stand/efiboot/efifdt.h        Mon May 11 02:11:09 2020 +0000
@@ -38,5 +38,6 @@
 void efi_fdt_bootargs(const char *);
 void efi_fdt_initrd(u_long, u_long);
 void efi_fdt_rndseed(u_long, u_long);
+void efi_fdt_efirng(const char *, u_long);
 void efi_fdt_init(u_long, u_long);
 void efi_fdt_fini(void);
diff -r ed9b769cdf86 -r 680c94613de7 sys/stand/efiboot/exec.c
--- a/sys/stand/efiboot/exec.c  Mon May 11 02:10:19 2020 +0000
+++ b/sys/stand/efiboot/exec.c  Mon May 11 02:11:09 2020 +0000
@@ -31,6 +31,7 @@
 #include "efienv.h"
 #include "efifdt.h"
 #include "efiacpi.h"
+#include "efirng.h"
 
 #include <sys/reboot.h>
 
@@ -278,6 +279,7 @@
 {
        EFI_PHYSICAL_ADDRESS addr;
        u_long marks[MARK_MAX], alloc_size;
+       char rngdata[64];
        EFI_STATUS status;
        int fd, ohowto;
 
@@ -346,6 +348,10 @@
                load_fdt_overlays();
                efi_fdt_initrd(initrd_addr, initrd_size);
                efi_fdt_rndseed(rndseed_addr, rndseed_size);
+               if (efi_rng(rngdata, sizeof rngdata) == 0) {
+                       efi_fdt_efirng(rngdata, sizeof rngdata);
+                       explicit_memset(rngdata, 0, sizeof rngdata);
+               }
                efi_fdt_bootargs(args);
 #ifdef EFIBOOT_ACPI
                if (efi_acpi_available())



Home | Main Index | Thread Index | Old Index