MIPS: relocate_code: fix relocation area size
PATCH 1/1 MIPS: relocate_code: fix relocation area size
relocate_code() calculates relocation area size as a sum (barebox_image_size + bss_len). barebox_image_size and bss_len are calculated as (__image_end - __image_start) and (__bss_stop - __bss_start) respectively. This doesn't take into account relocation data placed between __image_end and __bss_start. However relocation preserves BSS position relative to image start, as if relocation data is still there. This causes RAM overflow during BSS initialization in main_entry(). This problem may be hidden due to the alignment of the relocaddr.
--- arch/mips/lib/reloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/lib/reloc.c +1 -1
@@ -121,7 +121,7 @@ void relocate_code(void *fdt, u32 fdt_size, u32 ram_size)memset (__bss_start,0 , bss_len);cpu_probe (); - length = barebox_image_size + bss_len; + length = __bss_stop - __image_start; relocaddr =ALIGN_DOWN (ram_size - length,SZ_64K ); relocaddr =KSEG0ADDR (relocaddr); new_stack = relocaddr -MALLOC_SIZE -16 ;
Signature · 7 lines
2.24.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 8 lines · Peter Mamonov
relocate_code()calculates relocation area size as a sum (barebox_image_size+bss_len).barebox_image_sizeandbss_lenare calculated as (__image_end-__image_start) and (__bss_stop-__bss_start) respectively. This doesn't take into account relocation data placed between__image_endand__bss_start. However relocation preserves BSS position relative to image start, as if relocation data is still there. This causes RAM overflow during BSS initialization inmain_entry(). This problem may be hidden due to the alignment of therelocaddr.
Thx! Works on ar9331
Quoted 27 lines
Signed-off-by Peter Mamonov <[email protected]>--- arch/mips/lib/reloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/lib/reloc.c +1
-1@@ -121,7 +121,7 @@ void relocate_code(void *fdt, u32 fdt_size, u32 ram_size)memset (__bss_start,0 , bss_len);cpu_probe (); - length = barebox_image_size + bss_len; + length = __bss_stop - __image_start; relocaddr =ALIGN_DOWN (ram_size - length,SZ_64K ); relocaddr =KSEG0ADDR (relocaddr); new_stack = relocaddr -MALLOC_SIZE -16 ;Signature · 7 lines
2.24.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 4 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 11 lines · Oleksij Rempel
Quoted 8 lines · Peter Mamonov
relocate_code()calculates relocation area size as a sum (barebox_image_size+bss_len).barebox_image_sizeandbss_lenare calculated as (__image_end-__image_start) and (__bss_stop-__bss_start) respectively. This doesn't take into account relocation data placed between__image_endand__bss_start. However relocation preserves BSS position relative to image start, as if relocation data is still there. This causes RAM overflow during BSS initialization inmain_entry(). This problem may be hidden due to the alignment of therelocaddr.Thx! Works on ar9331
Guess you should squash this patch into "MIPS: remove .bss to __rel_start overlay", since it fixes the issue caused by the latter.
Regards,
Peter
Quoted 25 lines
Tested-by Oleksij Rempel <[email protected]>Quoted 22 lines
Signed-off-by Peter Mamonov <[email protected]>--- arch/mips/lib/reloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/lib/reloc.c +1
-1@@ -121,7 +121,7 @@ void relocate_code(void *fdt, u32 fdt_size, u32 ram_size)memset (__bss_start,0 , bss_len);cpu_probe (); - length = barebox_image_size + bss_len; + length = __bss_stop - __image_start; relocaddr =ALIGN_DOWN (ram_size - length,SZ_64K ); relocaddr =KSEG0ADDR (relocaddr); new_stack = relocaddr -MALLOC_SIZE -16 ;Signature · 1 line
2.24.0
Quoted 11 lines
Quoted 5 lines
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/bareboxSignature · 4 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 11 lines · Peter Mamonov
Quoted 10 lines · Oleksij Rempel
Quoted 8 lines · Peter Mamonov
relocate_code()calculates relocation area size as a sum (barebox_image_size+bss_len).barebox_image_sizeandbss_lenare calculated as (__image_end-__image_start) and (__bss_stop-__bss_start) respectively. This doesn't take into account relocation data placed between__image_endand__bss_start. However relocation preserves BSS position relative to image start, as if relocation data is still there. This causes RAM overflow during BSS initialization inmain_entry(). This problem may be hidden due to the alignment of therelocaddr.
Quoted 4 lines
Quoted 1 line
Thx! Works on ar9331
Guess you should squash this patch into "MIPS: remove .bss to
__rel_startoverlay", since it fixes the issue caused by the latter.
ACK
Quoted 47 lines
Regards,
PeterQuoted 25 lines
Tested-by Oleksij Rempel <[email protected]>Quoted 22 lines
Signed-off-by Peter Mamonov <[email protected]>--- arch/mips/lib/reloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/lib/reloc.c +1
-1@@ -121,7 +121,7 @@ void relocate_code(void *fdt, u32 fdt_size, u32 ram_size)memset (__bss_start,0 , bss_len);cpu_probe (); - length = barebox_image_size + bss_len; + length = __bss_stop - __image_start; relocaddr =ALIGN_DOWN (ram_size - length,SZ_64K ); relocaddr =KSEG0ADDR (relocaddr); new_stack = relocaddr -MALLOC_SIZE -16 ;Signature · 1 line
2.24.0Quoted 11 lines
Quoted 5 lines
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/bareboxSignature · 4 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 4 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox