mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: pbl: uncompress: add comment explaining order of operations
@ 2021-04-03  7:03 Ahmad Fatoum
  2021-04-13  7:48 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2021-04-03  7:03 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

When the PBL runs from flash, it relocates to RAM prior to extracting
barebox proper. It does the sneaky thing of _not_ relocating the piggy
data though, so read from flash and uncompression may latter happen
at the same time.

For this to work, it's critical that the variables pointing at the piggy
data are evaluated before relocation. ARM does so and carefully uses
them to derive the address of the PBL size later on instead of
evaluating image_data_end again.

When I ported the same code for RISC-V use, this got lost. Add a comment
explaining the criticality of maintaining this order of operations.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 arch/arm/cpu/uncompress.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index db0fe98e0d83..2250b8ccd375 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -52,6 +52,7 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
 	void *pg_start, *pg_end;
 	unsigned long pc = get_pc();
 
+	/* piggy data is not relocated, so determine the bounds now */
 	pg_start = input_data + global_variable_offset();
 	pg_end = input_data_end + global_variable_offset();
 
-- 
2.30.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

* Re: [PATCH] ARM: pbl: uncompress: add comment explaining order of operations
  2021-04-03  7:03 [PATCH] ARM: pbl: uncompress: add comment explaining order of operations Ahmad Fatoum
@ 2021-04-13  7:48 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2021-04-13  7:48 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Sat, Apr 03, 2021 at 09:03:46AM +0200, Ahmad Fatoum wrote:
> When the PBL runs from flash, it relocates to RAM prior to extracting
> barebox proper. It does the sneaky thing of _not_ relocating the piggy
> data though, so read from flash and uncompression may latter happen
> at the same time.
> 
> For this to work, it's critical that the variables pointing at the piggy
> data are evaluated before relocation. ARM does so and carefully uses
> them to derive the address of the PBL size later on instead of
> evaluating image_data_end again.
> 
> When I ported the same code for RISC-V use, this got lost. Add a comment
> explaining the criticality of maintaining this order of operations.
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
>  arch/arm/cpu/uncompress.c | 1 +
>  1 file changed, 1 insertion(+)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
> index db0fe98e0d83..2250b8ccd375 100644
> --- a/arch/arm/cpu/uncompress.c
> +++ b/arch/arm/cpu/uncompress.c
> @@ -52,6 +52,7 @@ void __noreturn barebox_pbl_start(unsigned long membase, unsigned long memsize,
>  	void *pg_start, *pg_end;
>  	unsigned long pc = get_pc();
>  
> +	/* piggy data is not relocated, so determine the bounds now */
>  	pg_start = input_data + global_variable_offset();
>  	pg_end = input_data_end + global_variable_offset();
>  
> -- 
> 2.30.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

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

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


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

end of thread, other threads:[~2021-04-13  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-03  7:03 [PATCH] ARM: pbl: uncompress: add comment explaining order of operations Ahmad Fatoum
2021-04-13  7:48 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox