From: Sam Edwards Date: Sat, 15 Mar 2025 22:18:12 +0000 (-0700) Subject: spl: riscv: opensbi: Error on misaligned FDT X-Git-Tag: v2025.07-rc1~119^2~15^2~1 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17d830cb4b6cdbac56d41938d455820fd7a96a89;p=pandora-u-boot.git spl: riscv: opensbi: Error on misaligned FDT libfdt 1.6.1+ requires the FDT to be 8-byte aligned and returns an error if not. OpenSBI 1.0+ includes this version of libfdt and will also reject misaligned FDTs. However, OpenSBI cannot indicate the error to the user: since it cannot access the serial console, it can only silently hang. This proved very difficult to diagnose without proper debugging facilities. Therefore, give the U-Boot SPL, which *can* print error messages, an additional check for proper FDT alignment. Hopefully this saves a lot of development cycles if another developer encounters alignment problems. Signed-off-by: Sam Edwards --- diff --git a/common/spl/spl_opensbi.c b/common/spl/spl_opensbi.c index 5a26d7c31a4..0ed6afeacc6 100644 --- a/common/spl/spl_opensbi.c +++ b/common/spl/spl_opensbi.c @@ -57,6 +57,11 @@ void __noreturn spl_invoke_opensbi(struct spl_image_info *spl_image) hang(); } + if (!IS_ALIGNED((uintptr_t)spl_image->fdt_addr, 8)) { + pr_err("SPL image loaded an improperly-aligned device tree\n"); + hang(); + } + /* * Originally, u-boot-spl will place DTB directly after the kernel, * but the size of the kernel did not include the BSS section, which