hw/mips_malta: Fix YAMON API print routine
PATCH 1/1 hw/mips_malta: Fix YAMON API print routine
The print routine provided as part of the in-built bootloader had a bug in that it attempted to use a jump instruction as part of a loop, but the target has its upper bits zeroed leading to control flow transferring to 0xb0000814 rather than the intended 0xbfc00814. Fix this by using a branch instruction instead, which seems more fit for purpose.
A simple way to test this is to build a Linux kernel with EVA enabled & attempt to boot it in QEMU. It will attempt to print a message indicating the configuration mismatch but QEMU would previously incorrectly jump & wind up printing a continuous stream of the letter E.
--- hw/mips/mips_malta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/mips/mips_malta.c +1 -1
@@ -727,7 +727,7 @@ static void write_bootloader(uint8_t *base, int64_t run_addr,stl_p (p++,0x00000000 );/* nop */ stl_p (p++,0x0ff0021c );/* jal 870 */ stl_p (p++,0x00000000 );/* nop */ -stl_p (p++,0x08000205 );/* j 814 */ +stl_p (p++,0x1000fff9 );/* b 814 */ stl_p (p++,0x00000000 );/* nop */ stl_p (p++,0x01a00009 );/* jalr t5 */ stl_p (p++,0x01602021 );/* move a0,t3 */
Signature · 1 line
2.9.0
Quoted 23 lines · Paul Burton
The print routine provided as part of the in-built bootloader had a bug in that it attempted to use a jump instruction as part of a loop, but the target has its upper bits zeroed leading to control flow transferring to
0xb0000814rather than the intended0xbfc00814. Fix this by using a branch instruction instead, which seems more fit for purpose.A simple way to test this is to build a Linux kernel with EVA enabled & attempt to boot it in QEMU. It will attempt to print a message indicating the configuration mismatch but QEMU would previously incorrectly jump & wind up printing a continuous stream of the letter E.
Signed-off-by Paul Burton <[email protected]>Cc Aurelien Jarno <[email protected]>Cc Leon Alrae <[email protected]>--- hw/mips/mips_malta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/mips/mips_malta.c +0
-0
hw/mips/mips_malta.c static void write_bootloader(uint8_t *base, int64_t run_addr, · line 733
Quoted 8 lines
hw/mips/mips_malta.c +1
-1@@ -727,7 +727,7 @@ static void write_bootloader(uint8_t *base, int64_t run_addr,stl_p (p++,0x00000000 );/* nop */ stl_p (p++,0x0ff0021c );/* jal 870 */ stl_p (p++,0x00000000 );/* nop */ -stl_p (p++,0x08000205 );/* j 814 */ +stl_p (p++,0x1000fff9 );/* b 814 */ stl_p (p++,0x00000000 );/* nop */ stl_p (p++,0x01a00009 );/* jalr t5 */ stl_p (p++,0x01602021 );/* move a0,t3 */
This looks fine. The switch from jump to branch is questionable given there are other jumps around in the code, but that's just nitpicking.
Signature · 2 lines
Aurelien Jarno GPG: 4096R/1DDD8C9B [email protected] http://www.aurel32.net
Leon Alrae
AppliedQuoted 11 lines · Paul Burton
The print routine provided as part of the in-built bootloader had a bug in that it attempted to use a jump instruction as part of a loop, but the target has its upper bits zeroed leading to control flow transferring to
0xb0000814rather than the intended0xbfc00814. Fix this by using a branch instruction instead, which seems more fit for purpose.A simple way to test this is to build a Linux kernel with EVA enabled & attempt to boot it in QEMU. It will attempt to print a message indicating the configuration mismatch but QEMU would previously incorrectly jump & wind up printing a continuous stream of the letter E.
Quoted 6 lines
Signed-off-by Paul Burton <[email protected]>Cc Aurelien Jarno <[email protected]>Cc Leon Alrae <[email protected]>--- hw/mips/mips_malta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to target-mips queue.
Thanks,
Leon