From: Tom Rini Date: Fri, 28 Jun 2024 23:31:28 +0000 (-0600) Subject: Merge patch series "automatically add /chosen/kaslr-seed and deduplicate code" X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=48641bfab793b5ffbf481ee2085fb8c0432da5fa;p=u-boot.git Merge patch series "automatically add /chosen/kaslr-seed and deduplicate code" Tim Harvey says: This series will automatically add /chosen/kaslr-seed to the dt if DM_RNG is enabled during the boot process. If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to randomize the virtual address at which the kernel image is loaded, it expects entropy to be provided by the bootloader by populating /chosen/kaslr-seed with a 64-bit value from source of entropy at boot. If we have DM_RNG enabled populate this value automatically when fdt_chosen is called. We skip this if ARMV8_SEC_FIRMWARE_SUPPORT is enabled as its implementation uses a different source of entropy that is not yet implemented as DM_RNG. We also skip this if MEASURED_BOOT is enabled as in that case any modifications to the dt will cause measured boot to fail (although there are many other places the dt is altered). As this fdt node is added elsewhere create a library function and use it to deduplicate code. We will provide a parameter to overwrite the node if present. For our automatic injection, we will use the first rng device and not overwrite if already present with a non-zero value (which may have been populated by an earlier boot stage). This way if a board specific ft_board_setup() function wants to customize this behavior it can call fdt_kaslrseed with a rng device index of its choosing and set overwrite true. Note that the kalsrseed command (CMD_KASLRSEED) is likely pointless now but left in place in case boot scripts exist that rely on this command existing and returning success. An informational message is printed to alert users of this command that it is likely no longer needed. Note that the Kernel's EFI STUB only relies on EFI_RNG_PROTOCOL for randomization and completely ignores the kaslr-seed for its own randomness needs (i.e the randomization of the physical placement of the kernel). It gets weeded out from the DTB that gets handed over via efi_install_fdt() as it would also mess up the measured boot DTB TPM measurements as well. --- 48641bfab793b5ffbf481ee2085fb8c0432da5fa diff --cc boot/fdt_support.c index 874ca4d6f5,4559adcd5e..2392027d40 --- a/boot/fdt_support.c +++ b/boot/fdt_support.c @@@ -6,6 -6,8 +6,7 @@@ * Copyright 2010-2011 Freescale Semiconductor, Inc. */ -#include + #include #include #include #include