summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-09-19 20:19:39 +0300
committerTom Rini <trini@konsulko.com>2022-09-19 23:07:12 +0300
commite9a1ff9724348408144c7f1c5b5cc26130ba46e5 (patch)
tree68b56f117206d121b4a7e567b0209c02283c98e6 /common
parentb6c50e5831f6ce3800d4b3cf3c7aa35dde8c48d9 (diff)
parentf76f3e3b44328fe6229650540109af93750fd5f0 (diff)
downloadu-boot-e9a1ff9724348408144c7f1c5b5cc26130ba46e5.tar.xz
Merge branch 'master' into next
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig14
-rw-r--r--common/console.c10
-rw-r--r--common/fdt_support.c13
3 files changed, 36 insertions, 1 deletions
diff --git a/common/Kconfig b/common/Kconfig
index 3e44acd2be..b776c5ca1e 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -809,6 +809,20 @@ config TPL_STACKPROTECTOR
bool "Stack Protector buffer overflow detection for TPL"
depends on STACKPROTECTOR && TPL
+config BOARD_RNG_SEED
+ bool "Provide /chosen/rng-seed property to the linux kernel"
+ help
+ Selecting this option requires the board to define a
+ board_rng_seed() function, which should return a buffer
+ which will be used to populate the /chosen/rng-seed property
+ in the device tree for the OS being booted.
+
+ It is up to the board code (and more generally the whole
+ BSP) where and how to store (or generate) such a seed, how
+ to ensure a given seed is only used once, how to create a
+ new seed for use on subsequent boots, and whether or not the
+ kernel should account any entropy from the given seed.
+
endmenu
menu "Update support"
diff --git a/common/console.c b/common/console.c
index 66b9813b3a..e5be6ff44b 100644
--- a/common/console.c
+++ b/common/console.c
@@ -600,6 +600,9 @@ static void pre_console_putc(const char c)
{
char *buffer;
+ if (gd->precon_buf_idx < 0)
+ return;
+
buffer = map_sysmem(CONFIG_VAL(PRE_CON_BUF_ADDR), CONFIG_VAL(PRE_CON_BUF_SZ));
buffer[CIRC_BUF_IDX(gd->precon_buf_idx++)] = c;
@@ -609,13 +612,16 @@ static void pre_console_putc(const char c)
static void pre_console_puts(const char *s)
{
+ if (gd->precon_buf_idx < 0)
+ return;
+
while (*s)
pre_console_putc(*s++);
}
static void print_pre_console_buffer(int flushpoint)
{
- unsigned long in = 0, out = 0;
+ long in = 0, out = 0;
char buf_out[CONFIG_VAL(PRE_CON_BUF_SZ) + 1];
char *buf_in;
@@ -632,6 +638,7 @@ static void print_pre_console_buffer(int flushpoint)
buf_out[out] = 0;
+ gd->precon_buf_idx = -1;
switch (flushpoint) {
case PRE_CONSOLE_FLUSHPOINT1_SERIAL:
puts(buf_out);
@@ -640,6 +647,7 @@ static void print_pre_console_buffer(int flushpoint)
console_puts_select(stdout, false, buf_out);
break;
}
+ gd->precon_buf_idx = in;
}
#else
static inline void pre_console_putc(const char c) {}
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 8c18af2ce1..baf7fb7065 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -7,6 +7,7 @@
*/
#include <common.h>
+#include <abuf.h>
#include <env.h>
#include <log.h>
#include <mapmem.h>
@@ -279,6 +280,7 @@ __weak char *board_fdt_chosen_bootargs(void)
int fdt_chosen(void *fdt)
{
+ struct abuf buf = {};
int nodeoffset;
int err;
char *str; /* used to set string properties */
@@ -294,6 +296,17 @@ int fdt_chosen(void *fdt)
if (nodeoffset < 0)
return nodeoffset;
+ if (IS_ENABLED(CONFIG_BOARD_RNG_SEED) && !board_rng_seed(&buf)) {
+ err = fdt_setprop(fdt, nodeoffset, "rng-seed",
+ abuf_data(&buf), abuf_size(&buf));
+ abuf_uninit(&buf);
+ if (err < 0) {
+ printf("WARNING: could not set rng-seed %s.\n",
+ fdt_strerror(err));
+ return err;
+ }
+ }
+
str = board_fdt_chosen_bootargs();
if (str) {