]> Git Repo - u-boot.git/blob - cmd/kaslrseed.c
use fdt_kaslrseed function to de-duplicate code
[u-boot.git] / cmd / kaslrseed.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * The 'kaslrseed' command takes bytes from the hardware random number
4  * generator and uses them to set the kaslr-seed value in the chosen node.
5  *
6  * Copyright (c) 2021, Chris Morgan <[email protected]>
7  */
8
9 #include <common.h>
10 #include <command.h>
11 #include <dm.h>
12 #include <hexdump.h>
13 #include <malloc.h>
14 #include <rng.h>
15 #include <fdt_support.h>
16
17 static int do_kaslr_seed(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
18 {
19         int err = CMD_RET_SUCCESS;
20
21         printf("Notice: a /chosen/kaslr-seed is automatically added to the device-tree when booted via booti/bootm/bootz therefore using this command is likely no longer needed\n");
22
23         if (!working_fdt) {
24                 printf("No FDT memory address configured. Please configure\n"
25                        "the FDT address via \"fdt addr <address>\" command.\n"
26                        "Aborting!\n");
27                 err = CMD_RET_FAILURE;
28         } else {
29                 if (fdt_kaslrseed(working_fdt, true) < 0)
30                         err = CMD_RET_FAILURE;
31         }
32
33         return cmd_process_error(cmdtp, err);
34 }
35
36 U_BOOT_LONGHELP(kaslrseed,
37         "[n]\n"
38         "  - append random bytes to chosen kaslr-seed node\n");
39
40 U_BOOT_CMD(
41         kaslrseed, 1, 0, do_kaslr_seed,
42         "feed bytes from the hardware random number generator to the kaslr-seed",
43         kaslrseed_help_text
44 );
This page took 0.027098 seconds and 4 git commands to generate.