MIPS: relocation issue
Hi!
Since 28ed10d6a6 ("MIPS: relocation: add relocation support") iomem output on memory regions is invalid,
all the code that rely on registered sdram memory regions after relocation can fail. E.g. the memtest commands fails on barebox.
How to reproduce the problem ov v2020.01.0:
$ wget https://www.barebox.org/download/barebox-2020.01.0.tar.bz2 ... $ tar fx barebox-2020.01.0.tar.bz2 $ cd barebox-2020.01.0 $ export ARCH=mips $ export CROSS_COMPILE=mips-linux-gnu- $ make qemu-malta_defconfig $ sed -i "s/^.*CONFIG_CMD_MEMTEST.*/CONFIG_CMD_MEMTEST=y/" .config $ make $ qemu-system-mips -nodefaults -M malta -m 256 -nographic -serial stdio -monitor null -bios barebox-flash-image ... barebox@qemu malta:/ memtest Start iteration 1 of 1. Testing memory space: 0xa0865000 -> 0xafffffff: Starting data line test. Check for address bits stuck high. Check for address bits stuck low or shorted. Starting moving inversions test of RAM: Fill with address, compare, fill with inverted address, compare again [########################################## ] FAILURE (read/write): expected 0x03cca9f2, actual 0xa08126c4 at address 0xafb8f7c4.
Ooops, TLB miss on load or ifetch!
$ 0 : 00000000 00000000 fffffffb a085c900 $ 4 : a0407e90 0000000a b80003f8 00000001 $ 8 : a0858f28 00000000 00000053 00000008 $12 : 00000000 00000000 0000005c 00000001 $16 : 03ccab3c 03ccab3d a0825c48 00000000 $20 : 00000000 00000001 a0853518 a085352c $24 : 00000018 a08124b8 $28 : 00000000 8fb8fcf8 a0860000 03ccab3e Hi : 0000000a Lo : 00000000 epc : 03ccab3e ra : 03ccab3e Status: 00000002 Cause : 00000408 Config: 80008482
### ERROR ### Please RESET the board ###
memtest for qemu-malta can be repaired by disabling relocation, e.g.
arch/mips/boot/start.S +1 -1
@@ -34,7 +34,7 @@ EXPORT(_start) move a0, s0 move a1, s1 move a2, s2 - la v0, relocate_code + la v0, main_entry jal v0 nop
Additional testing on real hardware has to be done.
Signature · 7 lines
Best regards, Antony Pavlov _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Antony,
thank you for your bug report. Can you please test my patch "[PATCH v1] MIPS: remove .bss to __rel_start overlay" with MMU enabled.
If it works, then we need to decide what should be done with MMU dependency.
Quoted 69 lines · Antony Pavlov
Hi!
Since
28ed10d6a6("MIPS: relocation: add relocation support") iomem output on memory regions is invalid,
all the code that rely on registered sdram memory regions after relocation can fail. E.g. the memtest commands fails on barebox.How to reproduce the problem ov v2020.01.0:
$ wget https://www.barebox.org/download/barebox-2020.01.0.tar.bz2 ... $ tar fx barebox-2020.01.0.tar.bz2 $ cd barebox-2020.01.0 $ export ARCH=mips $ export CROSS_COMPILE=mips-linux-gnu- $ make qemu-malta_defconfig $ sed -i "s/^.*CONFIG_CMD_MEMTEST.*/CONFIG_CMD_MEMTEST=y/" .config $ make $ qemu-system-mips -nodefaults -M malta -m 256 -nographic -serial stdio -monitor null -bios barebox-flash-image ... barebox@qemu malta:/ memtest Start iteration 1 of 1. Testing memory space: 0xa0865000 -> 0xafffffff: Starting data line test. Check for address bits stuck high. Check for address bits stuck low or shorted. Starting moving inversions test of RAM: Fill with address, compare, fill with inverted address, compare again [########################################## ] FAILURE (read/write): expected 0x03cca9f2, actual 0xa08126c4 at address 0xafb8f7c4.Ooops, TLB miss on load or ifetch!
$ 0 : 00000000 00000000 fffffffb a085c900 $ 4 : a0407e90 0000000a b80003f8 00000001 $ 8 : a0858f28 00000000 00000053 00000008 $12 : 00000000 00000000 0000005c 00000001 $16 : 03ccab3c 03ccab3d a0825c48 00000000 $20 : 00000000 00000001 a0853518 a085352c $24 : 00000018 a08124b8 $28 : 00000000 8fb8fcf8 a0860000 03ccab3e Hi : 0000000a Lo : 00000000 epc : 03ccab3e ra : 03ccab3e Status: 00000002 Cause : 00000408 Config: 80008482### ERROR ### Please RESET the board ###
memtest for qemu-malta can be repaired by disabling relocation, e.g.
arch/mips/boot/start.S +1
-1@@ -34,7 +34,7 @@ EXPORT(_start) move a0, s0 move a1, s1 move a2, s2 - la v0, relocate_code + la v0, main_entry jal v0 nop
Quoted 2 lines
Additional testing on real hardware has to be done.
Kind regards,
Oleksij Rempel
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 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
Hi Oleksij,
Below you will find the patch, which adds the whereami command. The command prints several addresses belonging to code, data, bss, heap and stack areas. I've run it on qemu/malta with relocations enabled and disabled as per Antony's mail. Output comparison shows that only the stack is relocated. Looks like relocation doesn't work as expected. Also note that the stack was relocated from the uncached KSEG1 to the cached KSEG0 segment, which is inconsistent at least.
Relocation enabled:
barebox@qemu malta:/ whereami code @ a0829bcc (a0829bc0) data @ a085f3c0 bss @ a0861ae0 heap @ a0428c38 stack @ 8fb8fd50 barebox@qemu malta:/ version barebox 2020.01.0-00104-gfe12ba2776 #3 Tue Jan 28 13:34:06 MSK 2020
Relocation disabled:
barebox@qemu malta:/ whereami code @ a0829bcc (a0829bc0) data @ a085f1e0 bss @ a0861900 heap @ a0428c38 stack @ a03ffd50
Regards,
Peter
--- commands/Kconfig | 5 +++++ commands/Makefile | 1 + commands/whereami.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 commands/whereami.c
commands/Kconfig +5 -0
@@ -2217,6 +2217,11 @@ config CMD_UBSAN This is a test command for the undefined behavior sanitizer. It triggers various undefined behavior, and detect it. +config CMD_WHEREAMI + tristate "whereami" + depends on MIPS + default y + # end Miscellaneous commands endmenu
commands/Makefile +1 -0
@@ -128,6 +128,7 @@ obj-$(CONFIG_CMD_NAND_BITFLIP) += nand-bitflip.o obj-$(CONFIG_CMD_SEED) += seed.o obj-$(CONFIG_CMD_IP_ROUTE_GET) += ip-route-get.o obj-$(CONFIG_CMD_UBSAN) += ubsan.o +obj-$(CONFIG_CMD_WHEREAMI) += whereami.o UBSAN_SANITIZE_ubsan.o := y
commands/whereami.c new file +45 -0
45 lines not on this page · raw message
Signature · 7 lines
2.24.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 10 lines · Peter Mamonov
Hi Oleksij,
Below you will find the patch, which adds the
whereamicommand. The command prints several addresses belonging to code, data, bss, heap and stack areas. I've run it on qemu/malta with relocations enabled and disabled as per Antony's mail. Output comparison shows that only the stack is relocated. Looks like relocation doesn't work as expected. Also note that the stack was relocated from the uncached KSEG1 to the cached KSEG0 segment, which is inconsistent at least.
ACK. The patch "MIPS: remove .bss to __rel_start overlay" should fix it. Please test :)
Quoted 13 lines
Relocation enabled:
barebox@qemu malta:/ whereami code @ a0829bcc (a0829bc0) data @ a085f3c0 bss @ a0861ae0 heap @ a0428c38 stack @ 8fb8fd50 barebox@qemu malta:/ version barebox 2020.01.0-00104-gfe12ba2776 #3 Tue Jan 28 13:34:06 MSK 2020
Quoted 8 lines
Relocation disabled:
barebox@qemu malta:/ whereami code @ a0829bcc (a0829bc0) data @ a085f1e0 bss @ a0861900 heap @ a0428c38 stack @ a03ffd50
This functionality is available with command iomem.
Quoted 79 lines
Regards,
Peter--- commands/Kconfig | 5 +++++ commands/Makefile | 1 + commands/whereami.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+)create mode 100644
commands/whereami.ccommands/Kconfig +5
-0@@ -2217,6 +2217,11 @@ config CMD_UBSAN This is a test command for the undefined behavior sanitizer. It triggers various undefined behavior, and detect it. +config CMD_WHEREAMI + tristate "whereami" + depends on MIPS + default y + # end Miscellaneous commands endmenucommands/Makefile +1
-0@@ -128,6 +128,7 @@ obj-$(CONFIG_CMD_NAND_BITFLIP) += nand-bitflip.o obj-$(CONFIG_CMD_SEED) += seed.o obj-$(CONFIG_CMD_IP_ROUTE_GET) += ip-route-get.o obj-$(CONFIG_CMD_UBSAN) += ubsan.o +obj-$(CONFIG_CMD_WHEREAMI) += whereami.o UBSAN_SANITIZE_ubsan.o := ycommands/whereami.c new file +35
-0@@ -0,0 +1,45 @@ +#include <common.h> +#include <command.h> +#include <complete.h> + +static volatile int data =1 ; +static volatile int bss; + +static void *code (); +static noinline void* code() +{ +void *ret; + __asm__ __volatile__( +".set push\n" +".set noreorder\n" +".set noat\n" +" move $1, $31\n" +" bal 255f\n" +" nop\n" +"255: move %0, $31\n" +" move $31, $1\n" +".set pop\n" + :"=r" (ret) + ); +return ret; +} + +static int do_whereami (int argc,char *argv[]) +{ +volatile int stack; +int *heapp =malloc (sizeof (int )); + +printf ("code @ %p (%p)\n" ,code (), &code); +printf ("data @ %p\n" , &data); +printf ("bss @ %p\n" , &bss); +printf ("heap @ %p\n" , heapp);
commands/whereami.c line 45
Quoted 10 lines
commands/whereami.c new file +10
-0+printf ("stack @ %p\n" , &stack); +return 0 ; +} + +BAREBOX_CMD_START (whereami) + .cmd = do_whereami, + BAREBOX_CMD_DESC("print addresses from code, stack, heap and data sections") + BAREBOX_CMD_GROUP(CMD_GRP_INFO) + BAREBOX_CMD_COMPLETE(empty_complete) +BAREBOX_CMD_END
Kind regards,
Oleksij Rempel
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 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 14 lines · Oleksij Rempel
Quoted 10 lines · Peter Mamonov
Hi Oleksij,
Below you will find the patch, which adds the
whereamicommand. The command prints several addresses belonging to code, data, bss, heap and stack areas. I've run it on qemu/malta with relocations enabled and disabled as per Antony's mail. Output comparison shows that only the stack is relocated. Looks like relocation doesn't work as expected. Also note that the stack was relocated from the uncached KSEG1 to the cached KSEG0 segment, which is inconsistent at least.
Quoted 1 line
ACK. The patch "MIPS: remove .bss to
__rel_startoverlay" should fix it. Please test :)
Ok, will report back soon.
Quoted 16 lines
Quoted 16 lines
Relocation enabled:
barebox@qemu malta:/ whereami code @ a0829bcc (a0829bc0) data @ a085f3c0 bss @ a0861ae0 heap @ a0428c38 stack @ 8fb8fd50 barebox@qemu malta:/ version barebox 2020.01.0-00104-gfe12ba2776 #3 Tue Jan 28 13:34:06 MSK 2020Relocation disabled:
Quoted 8 lines
Quoted 6 lines
barebox@qemu malta:/ whereami code @ a0829bcc (a0829bc0) data @ a085f1e0 bss @ a0861900 heap @ a0428c38 stack @ a03ffd50This functionality is available with command iomem.
At the moment iomem's output is inconsistent in case of the stack at least:
barebox@qemu malta:/ iomem
...
0xa0000000 - 0xafffffff (size 0x10000000) kseg1_ram0
0xa03f9000 - 0xa03fffff (size 0x00007000) stack <<<<<<<<<<<<<<<<<<< !!!!
0xa0400000 - 0xa07fffff (size 0x00400000) malloc space
0xa0800000 - 0xa085ae9f (size 0x0005aea0) barebox
0xa085aea0 - 0xa085fadf (size 0x00004c40) barebox data
0xa085fae0 - 0xa0863bdf (size 0x00004100) bss
barebox@qemu malta:/ whereami
code @ a0829bcc (a0829bc0)
data @ a085f3c0
bss @ a0861ae0
heap @ a0429518
stack @ 8fb8fd50 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< !!!barebox@qemu malta:/
Regards,
Peter
Quoted 78 lines
Quoted 78 lines
--- commands/Kconfig | 5 +++++ commands/Makefile | 1 + commands/whereami.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+)create mode 100644
commands/whereami.ccommands/Kconfig +5
-0@@ -2217,6 +2217,11 @@ config CMD_UBSAN This is a test command for the undefined behavior sanitizer. It triggers various undefined behavior, and detect it. +config CMD_WHEREAMI + tristate "whereami" + depends on MIPS + default y + # end Miscellaneous commands endmenucommands/Makefile +1
-0@@ -128,6 +128,7 @@ obj-$(CONFIG_CMD_NAND_BITFLIP) += nand-bitflip.o obj-$(CONFIG_CMD_SEED) += seed.o obj-$(CONFIG_CMD_IP_ROUTE_GET) += ip-route-get.o obj-$(CONFIG_CMD_UBSAN) += ubsan.o +obj-$(CONFIG_CMD_WHEREAMI) += whereami.o UBSAN_SANITIZE_ubsan.o := ycommands/whereami.c new file +41
-0@@ -0,0 +1,45 @@ +#include <common.h> +#include <command.h> +#include <complete.h> + +static volatile int data =1 ; +static volatile int bss; + +static void *code (); +static noinline void* code() +{ +void *ret; + __asm__ __volatile__( +".set push\n" +".set noreorder\n" +".set noat\n" +" move $1, $31\n" +" bal 255f\n" +" nop\n" +"255: move %0, $31\n" +" move $31, $1\n" +".set pop\n" + :"=r" (ret) + ); +return ret; +} + +static int do_whereami (int argc,char *argv[]) +{ +volatile int stack; +int *heapp =malloc (sizeof (int )); + +printf ("code @ %p (%p)\n" ,code (), &code); +printf ("data @ %p\n" , &data); +printf ("bss @ %p\n" , &bss); +printf ("heap @ %p\n" , heapp); +printf ("stack @ %p\n" , &stack); +return 0 ; +} + +BAREBOX_CMD_START (whereami) + .cmd = do_whereami,
Quoted 14 lines
commands/whereami.c line 45
Quoted 5 lines
commands/whereami.c new file +4
-0+ BAREBOX_CMD_DESC("print addresses from code, stack, heap and data sections") + BAREBOX_CMD_GROUP(CMD_GRP_INFO) + BAREBOX_CMD_COMPLETE(empty_complete) +BAREBOX_CMD_ENDKind regards,
Oleksij RempelSignature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 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
maeling list issue
In reply to Antony PavlovHi all,
starting from 24.01.2020 i do not get barebox mails to my current mail address. Current impact and reason are unknown. Do any one else is affected by this?
I included to cc at two devs.. since, affect won't be able to respond anyway... :)
I do not know if it is a good idea to ask not affected receivers to pong on this ping.
--
Regards,
Oleksij
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Re: maeling list issue
Quoted 8 lines · Oleksij Rempel
Hi all,
starting from 24.01.2020 i do not get barebox mails to my current mail address. Current impact and reason are unknown. Do any one else is affected by this?
I included to cc at two devs.. since, affect won't be able to respond anyway... :)
I do not know if it is a good idea to ask not affected receivers to pong on this ping.
Your status was set to "nomail" due to exceesive bounces. I enabled mails for you again.
Sascha
Signature · 9 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