[Concept,01/15] board_f: Skip the FDT relocation when not relocating

Message ID 20260212001410.1919749-2-sjg@u-boot.org
State New
Headers
Series riscv: Add EFI-application support |

Commit Message

Simon Glass Feb. 12, 2026, 12:13 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

When GD_FLG_SKIP_RELOC is set (e.g. for EFI applications), U-Boot does
not relocate itself, so the reserved FDT destination address is not
valid. Attempting to memcpy the FDT to this address causes a page fault
on RISC-V EFI apps.

Add a GD_FLG_SKIP_RELOC check before the FDT copy in
reloc_and_fix_fdt() so the FDT blob pointer is left unchanged when
relocation is skipped.

Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 common/board_f.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/common/board_f.c b/common/board_f.c
index ec0bdee7321..448cf2e319a 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -665,7 +665,8 @@  static int init_post(void)
 static int reloc_and_fix_fdt(void)
 {
 	if (!IS_ENABLED(CONFIG_OF_EMBED)) {
-		if (gd->boardf->new_fdt) {
+		if (!(gd->flags & GD_FLG_SKIP_RELOC) &&
+		    gd->boardf->new_fdt) {
 			memcpy(gd->boardf->new_fdt, gd->fdt_blob,
 			       fdt_totalsize(gd->fdt_blob));
 			gd->fdt_blob = gd->boardf->new_fdt;