mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	BAREBOX <barebox@lists.infradead.org>
Cc: "Claude Opus 4.6" <noreply@anthropic.com>
Subject: Re: [PATCH v2 1/2] ARM: setupc_32: remove relocation code from setup_c
Date: Wed, 4 Mar 2026 10:02:06 +0100	[thread overview]
Message-ID: <359a193e-3087-453b-8628-155cd7d0219c@pengutronix.de> (raw)
In-Reply-To: <20260304-arm-setup-c-v2-1-d26af520ab03@pengutronix.de>



On 3/4/26 8:53 AM, Sascha Hauer wrote:
> All callers of setup_c() already call relocate_to_current_adr() or
> relocate_to_adr() before setup_c(), so the relocation (memcpy) code
> in setup_c is dead and also the sync_caches_for_execution() is unnecessary
> Remove it and reduce setup_c to just clearing BSS.
> 
> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

> ---
>  arch/arm/cpu/setupc_32.S | 27 +++++----------------------
>  1 file changed, 5 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/cpu/setupc_32.S b/arch/arm/cpu/setupc_32.S
> index 0134637f62..c2c3f97528 100644
> --- a/arch/arm/cpu/setupc_32.S
> +++ b/arch/arm/cpu/setupc_32.S
> @@ -7,33 +7,16 @@
>  .section .text.setupc
>  
>  /*
> - * setup_c: copy binary to link address, clear bss and
> - * continue executing at new address.
> - *
> - * This function does not return to the address it is
> - * called from, but to the same location in the copied
> - * binary.
> + * setup_c: clear bss
>   */
>  ENTRY(setup_c)
> -	push	{r4, r5}
> -	mov	r5, lr
> -	bl	get_runtime_offset
> -	subs	r4, r0, #0
> -	beq	1f			/* skip memcpy if already at correct address */
> -	ldr	r0,=_text
> -	ldr	r2,=__bss_start
> -	sub	r2, r2, r0
> -	add	r1, r0, r4
> -	bl	__memcpy			/* memcpy(_text, _text + offset, __bss_start - _text) */
> -1:	ldr	r0, =__bss_start
> +	mov	r4, lr
> +	ldr	r0, =__bss_start
>  	mov	r1, #0
>  	ldr	r2, =__bss_stop
>  	sub	r2, r2, r0
> -	bl	__memset			/* clear bss */
> -	bl	sync_caches_for_execution
> -	sub	lr, r5, r4		/* adjust return address to new location */
> -	pop	{r4, r5}
> -	ret	lr
> +	bl	__memset		/* clear bss */
> +	ret	r4
>  ENDPROC(setup_c)
>  
>  /*
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2026-03-04  9:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04  7:53 [PATCH v2 0/2] ARM: Avoid to clear bss multiple times Sascha Hauer
2026-03-04  7:53 ` [PATCH v2 1/2] ARM: setupc_32: remove relocation code from setup_c Sascha Hauer
2026-03-04  9:02   ` Ahmad Fatoum [this message]
2026-03-04  7:53 ` [PATCH v2 2/2] ARM: setup_c: avoid clearing BSS twice Sascha Hauer
2026-03-04  9:05   ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=359a193e-3087-453b-8628-155cd7d0219c@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=noreply@anthropic.com \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox