* [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling
@ 2021-10-10 21:52 marek.vasut
2021-10-10 21:52 ` [PATCH 2/2] arm64: lmb: Reserve U-Boot separately if relocation is disabled marek.vasut
2021-10-14 1:55 ` [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling Peng Fan (OSS)
0 siblings, 2 replies; 5+ messages in thread
From: marek.vasut @ 2021-10-10 21:52 UTC (permalink / raw)
To: u-boot; +Cc: Marek Vasut, Simon Glass, Tom Rini
From: Marek Vasut <marek.vasut+renesas@gmail.com>
In case U-Boot enters relocation with GD_FLG_SKIP_RELOC, skip the
relocation. The code still has to set up new_gd pointer and new
stack pointer.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
arch/arm/lib/crt0_64.S | 4 ++++
lib/asm-offsets.c | 3 +++
2 files changed, 7 insertions(+)
diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S
index 680e674fa3..28c8356aee 100644
--- a/arch/arm/lib/crt0_64.S
+++ b/arch/arm/lib/crt0_64.S
@@ -104,6 +104,10 @@ ENTRY(_main)
bic sp, x0, #0xf /* 16-byte alignment for ABI compliance */
ldr x18, [x18, #GD_NEW_GD] /* x18 <- gd->new_gd */
+ /* Skip relocation in case gd->gd_flags & GD_FLG_SKIP_RELOC */
+ ldr x0, [x18, #GD_FLAGS] /* x0 <- gd->flags */
+ tbnz x0, 11, relocation_return /* GD_FLG_SKIP_RELOC is bit 11 */
+
adr lr, relocation_return
#if CONFIG_POSITION_INDEPENDENT
/* Add in link-vs-runtime offset */
diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c
index c691066332..0808cd4b0c 100644
--- a/lib/asm-offsets.c
+++ b/lib/asm-offsets.c
@@ -29,6 +29,9 @@ int main(void)
DEFINE(GD_SIZE, sizeof(struct global_data));
DEFINE(GD_BD, offsetof(struct global_data, bd));
+
+ DEFINE(GD_FLAGS, offsetof(struct global_data, flags));
+
#if CONFIG_VAL(SYS_MALLOC_F_LEN)
DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base));
#endif
--
2.33.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] arm64: lmb: Reserve U-Boot separately if relocation is disabled
2021-10-10 21:52 [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling marek.vasut
@ 2021-10-10 21:52 ` marek.vasut
2021-10-11 14:00 ` Tom Rini
2021-10-14 1:55 ` [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling Peng Fan (OSS)
1 sibling, 1 reply; 5+ messages in thread
From: marek.vasut @ 2021-10-10 21:52 UTC (permalink / raw)
To: u-boot; +Cc: Marek Vasut, Simon Glass, Tom Rini
From: Marek Vasut <marek.vasut+renesas@gmail.com>
In case U-Boot starts with GD_FLG_SKIP_RELOC, the U-Boot code is
not relocated, however the stack and heap is at the end of DRAM
after relocation. Reserve a LMB area for the non-relocated U-Boot
code so it won't be overwritten.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
arch/arm/lib/stack.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/arch/arm/lib/stack.c b/arch/arm/lib/stack.c
index 656084c7e5..d2e2715ecf 100644
--- a/arch/arm/lib/stack.c
+++ b/arch/arm/lib/stack.c
@@ -14,6 +14,7 @@
#include <init.h>
#include <lmb.h>
#include <asm/global_data.h>
+#include <asm/sections.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -46,4 +47,12 @@ static ulong get_sp(void)
void arch_lmb_reserve(struct lmb *lmb)
{
arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 16384);
+
+#ifdef CONFIG_ARM
+ if (gd->flags & GD_FLG_SKIP_RELOC) {
+ lmb_reserve(lmb, (phys_addr_t)__image_copy_start,
+ (phys_addr_t)__image_copy_end -
+ (phys_addr_t)__image_copy_start);
+ }
+#endif
}
--
2.33.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] arm64: lmb: Reserve U-Boot separately if relocation is disabled
2021-10-10 21:52 ` [PATCH 2/2] arm64: lmb: Reserve U-Boot separately if relocation is disabled marek.vasut
@ 2021-10-11 14:00 ` Tom Rini
0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2021-10-11 14:00 UTC (permalink / raw)
To: marek.vasut; +Cc: u-boot, Marek Vasut, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 1558 bytes --]
On Sun, Oct 10, 2021 at 11:52:09PM +0200, marek.vasut@gmail.com wrote:
> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> In case U-Boot starts with GD_FLG_SKIP_RELOC, the U-Boot code is
> not relocated, however the stack and heap is at the end of DRAM
> after relocation. Reserve a LMB area for the non-relocated U-Boot
> code so it won't be overwritten.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> arch/arm/lib/stack.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/arch/arm/lib/stack.c b/arch/arm/lib/stack.c
> index 656084c7e5..d2e2715ecf 100644
> --- a/arch/arm/lib/stack.c
> +++ b/arch/arm/lib/stack.c
> @@ -14,6 +14,7 @@
> #include <init.h>
> #include <lmb.h>
> #include <asm/global_data.h>
> +#include <asm/sections.h>
>
> DECLARE_GLOBAL_DATA_PTR;
>
> @@ -46,4 +47,12 @@ static ulong get_sp(void)
> void arch_lmb_reserve(struct lmb *lmb)
> {
> arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 16384);
> +
> +#ifdef CONFIG_ARM
> + if (gd->flags & GD_FLG_SKIP_RELOC) {
> + lmb_reserve(lmb, (phys_addr_t)__image_copy_start,
> + (phys_addr_t)__image_copy_end -
> + (phys_addr_t)__image_copy_start);
> + }
> +#endif
> }
Erm, this is in the arm code, the patch subject says arm64 and you're
testing for CONFIG_ARM (which will always be true here). Can you please
respin? Also, the whitespace of the new code is too indented. Thanks.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling
2021-10-10 21:52 [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling marek.vasut
2021-10-10 21:52 ` [PATCH 2/2] arm64: lmb: Reserve U-Boot separately if relocation is disabled marek.vasut
@ 2021-10-14 1:55 ` Peng Fan (OSS)
2021-10-15 14:00 ` Marek Vasut
1 sibling, 1 reply; 5+ messages in thread
From: Peng Fan (OSS) @ 2021-10-14 1:55 UTC (permalink / raw)
To: marek.vasut, u-boot; +Cc: Marek Vasut, Simon Glass, Tom Rini
On 2021/10/11 5:52, marek.vasut@gmail.com wrote:
> From: Marek Vasut <marek.vasut+renesas@gmail.com>
>
> In case U-Boot enters relocation with GD_FLG_SKIP_RELOC, skip the
> relocation. The code still has to set up new_gd pointer and new
> stack pointer.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> arch/arm/lib/crt0_64.S | 4 ++++
> lib/asm-offsets.c | 3 +++
> 2 files changed, 7 insertions(+)
>
> diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S
> index 680e674fa3..28c8356aee 100644
> --- a/arch/arm/lib/crt0_64.S
> +++ b/arch/arm/lib/crt0_64.S
> @@ -104,6 +104,10 @@ ENTRY(_main)
> bic sp, x0, #0xf /* 16-byte alignment for ABI compliance */
> ldr x18, [x18, #GD_NEW_GD] /* x18 <- gd->new_gd */
>
> + /* Skip relocation in case gd->gd_flags & GD_FLG_SKIP_RELOC */
> + ldr x0, [x18, #GD_FLAGS] /* x0 <- gd->flags */
You are using new_gd, that means bit 11 needs to be set after
new_gd has been filled with gd.
I would prefer use gd, not new_gd.
Thanks,
Peng.
> + tbnz x0, 11, relocation_return /* GD_FLG_SKIP_RELOC is bit 11 */
> +
> adr lr, relocation_return
> #if CONFIG_POSITION_INDEPENDENT
> /* Add in link-vs-runtime offset */
> diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c
> index c691066332..0808cd4b0c 100644
> --- a/lib/asm-offsets.c
> +++ b/lib/asm-offsets.c
> @@ -29,6 +29,9 @@ int main(void)
> DEFINE(GD_SIZE, sizeof(struct global_data));
>
> DEFINE(GD_BD, offsetof(struct global_data, bd));
> +
> + DEFINE(GD_FLAGS, offsetof(struct global_data, flags));
> +
> #if CONFIG_VAL(SYS_MALLOC_F_LEN)
> DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base));
> #endif
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling
2021-10-14 1:55 ` [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling Peng Fan (OSS)
@ 2021-10-15 14:00 ` Marek Vasut
0 siblings, 0 replies; 5+ messages in thread
From: Marek Vasut @ 2021-10-15 14:00 UTC (permalink / raw)
To: Peng Fan (OSS), u-boot; +Cc: Simon Glass, Tom Rini
On 10/14/21 3:55 AM, Peng Fan (OSS) wrote:
[...]
>> diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S
>> index 680e674fa3..28c8356aee 100644
>> --- a/arch/arm/lib/crt0_64.S
>> +++ b/arch/arm/lib/crt0_64.S
>> @@ -104,6 +104,10 @@ ENTRY(_main)
>> bic sp, x0, #0xf /* 16-byte alignment for ABI compliance */
>> ldr x18, [x18, #GD_NEW_GD] /* x18 <- gd->new_gd */
>> + /* Skip relocation in case gd->gd_flags & GD_FLG_SKIP_RELOC */
>> + ldr x0, [x18, #GD_FLAGS] /* x0 <- gd->flags */
>
> You are using new_gd, that means bit 11 needs to be set after
> new_gd has been filled with gd.
>
> I would prefer use gd, not new_gd.
Both gd and newgd have GD_FLG_SKIP_RELOC set very early on, in u-boot
that's currently done by one board in mach_cpu_init, so that should be
no problem. Moreover, both gd and newgd flags must be identical as far
as I can tell.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-15 15:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-10 21:52 [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling marek.vasut
2021-10-10 21:52 ` [PATCH 2/2] arm64: lmb: Reserve U-Boot separately if relocation is disabled marek.vasut
2021-10-11 14:00 ` Tom Rini
2021-10-14 1:55 ` [PATCH 1/2] arm64: Add missing GD_FLG_SKIP_RELOC handling Peng Fan (OSS)
2021-10-15 14:00 ` Marek Vasut
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).