[openwrt/openwrt] uboot-layerscape: Don't fixup kaslr seed when no node

LEDE Commits lede-commits at lists.infradead.org
Sun May 7 05:51:52 PDT 2023


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/29149a9b35d52081e62a42b7d60336a58e01728e

commit 29149a9b35d52081e62a42b7d60336a58e01728e
Author: Wojciech Dubowik <Wojciech.Dubowik at protonmail.ch>
AuthorDate: Wed Apr 12 14:36:11 2023 +0200

    uboot-layerscape: Don't fixup kaslr seed when no node
    
    There seems to be a difference in firmware calling convention
    between upstream and NXP kernels. On some cpus like ls1028
    it will hang on firmware secure get random when using LF uboot
    with upstream kernel. Instead of commenting it out, don't call
    get radnom seed when "kaslr-seed" is not present in device tree.
    
    Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik at protonmail.ch>
---
 ...ec-firmware-get-random-when-no-kaslr-seed.patch | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/package/boot/uboot-layerscape/patches/0003-avoid-calling-sec-firmware-get-random-when-no-kaslr-seed.patch b/package/boot/uboot-layerscape/patches/0003-avoid-calling-sec-firmware-get-random-when-no-kaslr-seed.patch
new file mode 100644
index 0000000000..681ec90f1c
--- /dev/null
+++ b/package/boot/uboot-layerscape/patches/0003-avoid-calling-sec-firmware-get-random-when-no-kaslr-seed.patch
@@ -0,0 +1,33 @@
+Index: uboot-layerscape-lf-6.1.1-1.0.0/arch/arm/cpu/armv8/sec_firmware.c
+===================================================================
+--- uboot-layerscape-lf-6.1.1-1.0.0.orig/arch/arm/cpu/armv8/sec_firmware.c
++++ uboot-layerscape-lf-6.1.1-1.0.0/arch/arm/cpu/armv8/sec_firmware.c
+@@ -473,12 +473,6 @@ int fdt_fixup_kaslr(void *fdt)
+ 		return 0;
+ 	}
+ 
+-	ret = sec_firmware_get_random(rand, 8);
+-	if (ret < 0) {
+-		printf("WARNING: No random number to set kaslr-seed\n");
+-		return 0;
+-	}
+-
+ 	err = fdt_check_header(fdt);
+ 	if (err < 0) {
+ 		printf("fdt_chosen: %s\n", fdt_strerror(err));
+@@ -490,6 +484,15 @@ int fdt_fixup_kaslr(void *fdt)
+ 	if (nodeoffset < 0)
+ 		return 0;
+ 
++	if (fdt_find_or_add_subnode(fdt, nodeoffset, "kaslr-seed"))
++		return 0;
++
++	ret = sec_firmware_get_random(rand, 8);
++	if (ret < 0) {
++		printf("WARNING: No random number to set kaslr-seed\n");
++		return 0;
++	}
++
+ 	err = fdt_setprop(fdt, nodeoffset, "kaslr-seed", rand,
+ 				  sizeof(rand));
+ 	if (err < 0) {




More information about the lede-commits mailing list