u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: Properly clear BSS
@ 2025-09-02  6:08 Ilias Apalodimas
  2025-09-02  6:57 ` brock.zheng
  0 siblings, 1 reply; 3+ messages in thread
From: Ilias Apalodimas @ 2025-09-02  6:08 UTC (permalink / raw)
  To: trini
  Cc: heinrich.schuchardt, Ilias Apalodimas, brock_zheng, Simon Glass,
	Marek Vasut, u-boot

Brock reports a breakage on an RK3568 SoC. His patch is
correct but he never followed up on the requested changes.

We currently use ldr to calculate the address of __bss_start and
__bss_end. However the absolute addresses of the literal pool are never
relocated and we end up clearing the wrong memory section. Use
PC-relative addressing instead.

Link: https://lore.kernel.org/u-boot/zfknlzcemnnaka5w2er5wjwefwoidrpndc4gjhx6d5xr6nlcjr@pasfayjiutii/

Suggested-by: brock_zheng <yzheng@techyauld.com>
Reported-by: brock_zheng <yzheng@techyauld.com>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
 arch/arm/lib/crt0_64.S | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S
index f3f279f2c39c..3e7627aa389b 100644
--- a/arch/arm/lib/crt0_64.S
+++ b/arch/arm/lib/crt0_64.S
@@ -158,8 +158,10 @@ relocation_return:
 /*
  * Clear BSS section
  */
-	ldr	x0, =__bss_start		/* this is auto-relocated! */
-	ldr	x1, =__bss_end			/* this is auto-relocated! */
+	adrp	x0, __bss_start
+	add	x0, x0, #:lo12:__bss_start
+	adrp	x1, __bss_end
+	add	x1, x1, #:lo12:__bss_end
 clear_loop:
 	str	xzr, [x0], #8
 	cmp	x0, x1
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: Properly clear BSS
  2025-09-02  6:08 [PATCH] arm64: Properly clear BSS Ilias Apalodimas
@ 2025-09-02  6:57 ` brock.zheng
  2025-09-03  7:02   ` Ilias Apalodimas
  0 siblings, 1 reply; 3+ messages in thread
From: brock.zheng @ 2025-09-02  6:57 UTC (permalink / raw)
  To: Ilias Apalodimas
  Cc: trini, heinrich.schuchardt, Simon Glass, Marek Vasut, u-boot

i am glad to see my patch been reviewed.

I can not access the international network easily.
so any of you can fix / rewrite / change that patch.

If I can see the fixup in the offical git repo, I will be very very glad.


On 2025-09-02 09:08:12, Ilias Apalodimas wrote:
> Date: Tue,  2 Sep 2025 09:08:12 +0300
> From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> To: trini@konsulko.com
> Cc: heinrich.schuchardt@canonical.com,  Ilias Apalodimas
>  <ilias.apalodimas@linaro.org>, brock_zheng <yzheng@techyauld.com>,  Simon
>  Glass <sjg@chromium.org>, Marek Vasut <marek.vasut+renesas@mailbox.org>,
>   u-boot@lists.denx.de
> Subject: [PATCH] arm64: Properly clear BSS
> X-Mailer: git-send-email 2.50.1
> 
> Brock reports a breakage on an RK3568 SoC. His patch is
> correct but he never followed up on the requested changes.
> 
> We currently use ldr to calculate the address of __bss_start and
> __bss_end. However the absolute addresses of the literal pool are never
> relocated and we end up clearing the wrong memory section. Use
> PC-relative addressing instead.
> 
> Link: https://lore.kernel.org/u-boot/zfknlzcemnnaka5w2er5wjwefwoidrpndc4gjhx6d5xr6nlcjr@pasfayjiutii/
> 
> Suggested-by: brock_zheng <yzheng@techyauld.com>
> Reported-by: brock_zheng <yzheng@techyauld.com>
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
>  arch/arm/lib/crt0_64.S | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S
> index f3f279f2c39c..3e7627aa389b 100644
> --- a/arch/arm/lib/crt0_64.S
> +++ b/arch/arm/lib/crt0_64.S
> @@ -158,8 +158,10 @@ relocation_return:
>  /*
>   * Clear BSS section
>   */
> -	ldr	x0, =__bss_start		/* this is auto-relocated! */
> -	ldr	x1, =__bss_end			/* this is auto-relocated! */
> +	adrp	x0, __bss_start
> +	add	x0, x0, #:lo12:__bss_start
> +	adrp	x1, __bss_end
> +	add	x1, x1, #:lo12:__bss_end
>  clear_loop:
>  	str	xzr, [x0], #8
>  	cmp	x0, x1
> -- 
> 2.50.1
> 
> 
> 

-- 
Brock Zheng <yzheng@techyauld.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] arm64: Properly clear BSS
  2025-09-02  6:57 ` brock.zheng
@ 2025-09-03  7:02   ` Ilias Apalodimas
  0 siblings, 0 replies; 3+ messages in thread
From: Ilias Apalodimas @ 2025-09-03  7:02 UTC (permalink / raw)
  To: brock.zheng; +Cc: trini, heinrich.schuchardt, Simon Glass, Marek Vasut, u-boot

Hi Brock

On Tue, 2 Sept 2025 at 09:57, brock.zheng <yzheng@techyauld.com> wrote:
>
> i am glad to see my patch been reviewed.
>
> I can not access the international network easily.
> so any of you can fix / rewrite / change that patch.

No worries, I fixed up the comments.

>
> If I can see the fixup in the offical git repo, I will be very very glad.

Tom, I know this is late in the cycle, but this is an obvious bug fix.
Any chance we can pull it early in -master so people can test?

Thanks
/Ilias
>
>
> On 2025-09-02 09:08:12, Ilias Apalodimas wrote:
> > Date: Tue,  2 Sep 2025 09:08:12 +0300
> > From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> > To: trini@konsulko.com
> > Cc: heinrich.schuchardt@canonical.com,  Ilias Apalodimas
> >  <ilias.apalodimas@linaro.org>, brock_zheng <yzheng@techyauld.com>,  Simon
> >  Glass <sjg@chromium.org>, Marek Vasut <marek.vasut+renesas@mailbox.org>,
> >   u-boot@lists.denx.de
> > Subject: [PATCH] arm64: Properly clear BSS
> > X-Mailer: git-send-email 2.50.1
> >
> > Brock reports a breakage on an RK3568 SoC. His patch is
> > correct but he never followed up on the requested changes.
> >
> > We currently use ldr to calculate the address of __bss_start and
> > __bss_end. However the absolute addresses of the literal pool are never
> > relocated and we end up clearing the wrong memory section. Use
> > PC-relative addressing instead.
> >
> > Link: https://lore.kernel.org/u-boot/zfknlzcemnnaka5w2er5wjwefwoidrpndc4gjhx6d5xr6nlcjr@pasfayjiutii/
> >
> > Suggested-by: brock_zheng <yzheng@techyauld.com>
> > Reported-by: brock_zheng <yzheng@techyauld.com>
> > Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> > ---
> >  arch/arm/lib/crt0_64.S | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S
> > index f3f279f2c39c..3e7627aa389b 100644
> > --- a/arch/arm/lib/crt0_64.S
> > +++ b/arch/arm/lib/crt0_64.S
> > @@ -158,8 +158,10 @@ relocation_return:
> >  /*
> >   * Clear BSS section
> >   */
> > -     ldr     x0, =__bss_start                /* this is auto-relocated! */
> > -     ldr     x1, =__bss_end                  /* this is auto-relocated! */
> > +     adrp    x0, __bss_start
> > +     add     x0, x0, #:lo12:__bss_start
> > +     adrp    x1, __bss_end
> > +     add     x1, x1, #:lo12:__bss_end
> >  clear_loop:
> >       str     xzr, [x0], #8
> >       cmp     x0, x1
> > --
> > 2.50.1
> >
> >
> >
>
> --
> Brock Zheng <yzheng@techyauld.com>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-03  7:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-02  6:08 [PATCH] arm64: Properly clear BSS Ilias Apalodimas
2025-09-02  6:57 ` brock.zheng
2025-09-03  7:02   ` Ilias Apalodimas

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).