[PATCH] board_f: Copy GD to new GD even if relocation disabled

Even if U-Boot has relocation disabled via GD_FLG_SKIP_RELOC , the relocated stage of U-Boot still picks GD from new_gd location. The U-Boot itself is not relocated, but GD might be, so copy the GD to new GD location even if relocation is disabled.
Signed-off-by: Marek Vasut marek.vasut+renesas@gmail.com Cc: Simon Glass sjg@chromium.org Cc: Tom Rini trini@konsulko.com --- common/board_f.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/common/board_f.c b/common/board_f.c index 3dc0eaa59c..2161a7411d 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -674,6 +674,7 @@ static int reloc_bloblist(void) static int setup_reloc(void) { if (gd->flags & GD_FLG_SKIP_RELOC) { + memcpy(gd->new_gd, (char *)gd, sizeof(gd_t)); debug("Skipping relocation due to flag\n"); return 0; }

On 2021/10/11 5:44, Marek Vasut wrote:
Even if U-Boot has relocation disabled via GD_FLG_SKIP_RELOC , the relocated stage of U-Boot still picks GD from new_gd location. The U-Boot itself is not relocated, but GD might be, so copy the GD to new GD location even if relocation is disabled.
Signed-off-by: Marek Vasut marek.vasut+renesas@gmail.com Cc: Simon Glass sjg@chromium.org Cc: Tom Rini trini@konsulko.com
common/board_f.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/common/board_f.c b/common/board_f.c index 3dc0eaa59c..2161a7411d 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -674,6 +674,7 @@ static int reloc_bloblist(void) static int setup_reloc(void) { if (gd->flags & GD_FLG_SKIP_RELOC) {
debug("Skipping relocation due to flag\n"); return 0; }memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
I still think my patch is better :) https://patchwork.ozlabs.org/project/uboot/patch/20211013095445.18428-1-peng...
But anyway if you prefer, you could have a v2 to include dtb relocation.
Regards, Peng.

Hi,
On Wed, 13 Oct 2021 at 19:52, Peng Fan (OSS) peng.fan@oss.nxp.com wrote:
On 2021/10/11 5:44, Marek Vasut wrote:
Even if U-Boot has relocation disabled via GD_FLG_SKIP_RELOC , the relocated stage of U-Boot still picks GD from new_gd location. The U-Boot itself is not relocated, but GD might be, so copy the GD to new GD location even if relocation is disabled.
Signed-off-by: Marek Vasut marek.vasut+renesas@gmail.com Cc: Simon Glass sjg@chromium.org Cc: Tom Rini trini@konsulko.com
common/board_f.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/common/board_f.c b/common/board_f.c index 3dc0eaa59c..2161a7411d 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -674,6 +674,7 @@ static int reloc_bloblist(void) static int setup_reloc(void) { if (gd->flags & GD_FLG_SKIP_RELOC) {
memcpy(gd->new_gd, (char *)gd, sizeof(gd_t)); debug("Skipping relocation due to flag\n"); return 0; }
I still think my patch is better :) https://patchwork.ozlabs.org/project/uboot/patch/20211013095445.18428-1-peng...
Yes, better to avoid duplicating the memcpy() as you have done Peng.
But anyway if you prefer, you could have a v2 to include dtb relocation.
Regards, Simon

On 10/14/21 3:52 AM, Peng Fan (OSS) wrote: [...]
diff --git a/common/board_f.c b/common/board_f.c index 3dc0eaa59c..2161a7411d 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -674,6 +674,7 @@ static int reloc_bloblist(void) static int setup_reloc(void) { if (gd->flags & GD_FLG_SKIP_RELOC) { + memcpy(gd->new_gd, (char *)gd, sizeof(gd_t)); debug("Skipping relocation due to flag\n"); return 0; }
I still think my patch is better :) https://patchwork.ozlabs.org/project/uboot/patch/20211013095445.18428-1-peng...
But anyway if you prefer, you could have a v2 to include dtb relocation.
Your patch does not reflect the gd->reloc_off update in new_gd in case GD_SKIP_RELOC_FLAG is NOT set, that's a bug. This patch does not have that problem. I thought about expanding the if above to deduplicate the memcpy, but that looked rather ugly, but we can try that instead.
participants (4)
-
Marek Vasut
-
Marek Vasut
-
Peng Fan (OSS)
-
Simon Glass