diff options
Diffstat (limited to 'kexec/arch/m68k/bootinfo.c')
-rw-r--r-- | kexec/arch/m68k/bootinfo.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kexec/arch/m68k/bootinfo.c b/kexec/arch/m68k/bootinfo.c index 18bf2264..086a34bd 100644 --- a/kexec/arch/m68k/bootinfo.c +++ b/kexec/arch/m68k/bootinfo.c @@ -2,6 +2,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sys/random.h> #include "../../kexec.h" @@ -152,6 +153,11 @@ void bootinfo_print(void) printf("BI_COMMAND_LINE: %s\n", bi->string); break; + case BI_RNG_SEED: + /* These are secret, so never print them to the console */ + printf("BI_RNG_SEED: 0x%08x bytes\n", be16_to_cpu(bi->rng_seed.len)); + break; + default: printf("BI tag 0x%04x size %u\n", tag, size); break; @@ -212,6 +218,23 @@ void bootinfo_set_ramdisk(unsigned long ramdisk_addr, bi->mem_info.size = ramdisk_size; } +void bootinfo_add_rng_seed(void) +{ + enum { RNG_SEED_LEN = 32 }; + struct bi_rec *bi; + + /* Remove existing rng seed records */ + bi_remove(BI_RNG_SEED); + + /* Add new rng seed record */ + bi = bi_add(BI_RNG_SEED, sizeof(bi->rng_seed) + RNG_SEED_LEN); + if (getrandom(bi->rng_seed.data, RNG_SEED_LEN, GRND_NONBLOCK) != RNG_SEED_LEN) { + bi_remove(BI_RNG_SEED); + return; + } + bi->rng_seed.len = cpu_to_be16(RNG_SEED_LEN); +} + /* * Check the bootinfo version in the kernel image |