[PATCH v2] board_f: Relocate fdt even if GD_FLG_SKIP_RELOC is set

In case of OF_SEPARATE (!OF_EMBED), the devicetree blob is placed after _end, and fdt_find_separate() always returns _end. There is a .bss section after _end and the section is cleared before relocation.
When GD_FLG_SKIP_RELOC is set, relocation is skipped, so the blob is still in .bss section, but will be cleared. As a result, the devicetree become invalid.
To avoid this issue, should relocate it regardless of GD_FLG_SKIP_RELOC in reloc_fdt().
Signed-off-by: Kunihiko Hayashi hayashi.kunihiko@socionext.com --- common/board_f.c | 2 -- 1 file changed, 2 deletions(-)
Changes since v1: - Remove condition for skipping fdt relocation (always relocate)
diff --git a/common/board_f.c b/common/board_f.c index 1688e27071fc..334d04af197b 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -633,8 +633,6 @@ static int init_post(void) static int reloc_fdt(void) { if (!IS_ENABLED(CONFIG_OF_EMBED)) { - if (gd->flags & GD_FLG_SKIP_RELOC) - return 0; if (gd->new_fdt) { memcpy(gd->new_fdt, gd->fdt_blob, fdt_totalsize(gd->fdt_blob));

On Tue, 20 Jun 2023 at 11:50, Kunihiko Hayashi hayashi.kunihiko@socionext.com wrote:
In case of OF_SEPARATE (!OF_EMBED), the devicetree blob is placed after _end, and fdt_find_separate() always returns _end. There is a .bss section after _end and the section is cleared before relocation.
When GD_FLG_SKIP_RELOC is set, relocation is skipped, so the blob is still in .bss section, but will be cleared. As a result, the devicetree become invalid.
To avoid this issue, should relocate it regardless of GD_FLG_SKIP_RELOC in reloc_fdt().
Signed-off-by: Kunihiko Hayashi hayashi.kunihiko@socionext.com
common/board_f.c | 2 -- 1 file changed, 2 deletions(-)
Changes since v1:
- Remove condition for skipping fdt relocation (always relocate)
Reviewed-by: Simon Glass sjg@chromium.org

On Tue, Jun 20, 2023 at 07:50:48PM +0900, Kunihiko Hayashi wrote:
In case of OF_SEPARATE (!OF_EMBED), the devicetree blob is placed after _end, and fdt_find_separate() always returns _end. There is a .bss section after _end and the section is cleared before relocation.
When GD_FLG_SKIP_RELOC is set, relocation is skipped, so the blob is still in .bss section, but will be cleared. As a result, the devicetree become invalid.
To avoid this issue, should relocate it regardless of GD_FLG_SKIP_RELOC in reloc_fdt().
Signed-off-by: Kunihiko Hayashi hayashi.kunihiko@socionext.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (3)
-
Kunihiko Hayashi
-
Simon Glass
-
Tom Rini