diff options
author | Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com> | 2024-01-17 08:50:13 +0530 |
---|---|---|
committer | Michal Simek <michal.simek@amd.com> | 2024-01-17 08:12:20 +0100 |
commit | a270099e83c49f80f0f2f10cb8b6f23e3b3a6f6d (patch) | |
tree | 61a9b0ce64afa5ebe26164cc2d4e5f9e77aef76a | |
parent | ef67a04e7e8c7f37594d225b0694f2e4d0bb0c0d (diff) | |
download | u-boot-a270099e83c49f80f0f2f10cb8b6f23e3b3a6f6d.zip u-boot-a270099e83c49f80f0f2f10cb8b6f23e3b3a6f6d.tar.gz u-boot-a270099e83c49f80f0f2f10cb8b6f23e3b3a6f6d.tar.bz2 |
xilinx: board: Update the kaslr-seed property
Create a ft_board_setup() api that gets called as part
of bootm/booti before jumping to kernel. In this
ft_board_setup() callback that will inspect the DTB
and insert the device tree blob with the "kaslr-seed" property.
Signed-off-by: Venkatesh Yadav Abbarapu <venkatesh.abbarapu@amd.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/20240117032014.1014084-2-venkatesh.abbarapu@amd.com
-rw-r--r-- | board/xilinx/common/board.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 12a877c..9641ed3 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -25,6 +25,7 @@ #include <i2c_eeprom.h> #include <net.h> #include <generated/dt.h> +#include <rng.h> #include <slre.h> #include <soc.h> #include <linux/ctype.h> @@ -682,3 +683,51 @@ phys_addr_t board_get_usable_ram_top(phys_size_t total_size) return reg + size; } #endif + +#ifdef CONFIG_OF_BOARD_SETUP +#define MAX_RAND_SIZE 8 +int ft_board_setup(void *blob, struct bd_info *bd) +{ + size_t n = MAX_RAND_SIZE; + struct udevice *dev; + u8 buf[MAX_RAND_SIZE]; + int nodeoffset, ret; + + if (uclass_get_device(UCLASS_RNG, 0, &dev) || !dev) { + debug("No RNG device\n"); + return 0; + } + + if (dm_rng_read(dev, buf, n)) { + debug("Reading RNG failed\n"); + return 0; + } + + if (!blob) { + debug("No FDT memory address configured. Please configure\n" + "the FDT address via \"fdt addr <address>\" command.\n" + "Aborting!\n"); + return 0; + } + + ret = fdt_check_header(blob); + if (ret < 0) { + debug("fdt_chosen: %s\n", fdt_strerror(ret)); + return ret; + } + + nodeoffset = fdt_find_or_add_subnode(blob, 0, "chosen"); + if (nodeoffset < 0) { + debug("Reading chosen node failed\n"); + return nodeoffset; + } + + ret = fdt_setprop(blob, nodeoffset, "kaslr-seed", buf, sizeof(buf)); + if (ret < 0) { + debug("Unable to set kaslr-seed on chosen node: %s\n", fdt_strerror(ret)); + return ret; + } + + return 0; +} +#endif |