tcg/mips: Bugfix for crash when running program with qemu-i386.
PATCH 1/1 tcg/mips: Bugfix for crash when running program with qemu-i386.
When running a helloworld program with qemu-i386 in linux-user mode on Loongson 3A3000, it will crash. This patch fix the bug.
--- tcg/mips/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tcg/mips/tcg-target.inc.c +1 -1
@@ -1540,7 +1540,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64)#else if (TCG_TARGET_REG_BITS >TARGET_LONG_BITS ) {tcg_out_ext32u (s, base, addr_regl); - addr_regl = base; +tcg_out_mov (s,TCG_TYPE_PTR , addr_regl, base); }if (guest_base ==0 && data_regl != addr_regl) { base = addr_regl;
Signature · 1 line
2.7.4
Quoted 13 lines · Jiang Biao
When running a helloworld program with qemu-i386 in linux-user mode on Loongson 3A3000, it will crash. This patch fix the bug.
Signed-off-by Jiang Biao<[email protected]>--- tcg/mips/tcg-target.inc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tcg/mips/tcg-target.inc.c +0
-0
tcg/mips/tcg-target.inc.c static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) · line 1546
Quoted 8 lines
tcg/mips/tcg-target.inc.c +1
-1@@ -1540,7 +1540,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64)#else if (TCG_TARGET_REG_BITS >TARGET_LONG_BITS ) {tcg_out_ext32u (s, base, addr_regl); - addr_regl = base; +tcg_out_mov (s,TCG_TYPE_PTR , addr_regl, base); }if (guest_base ==0 && data_regl != addr_regl) { base = addr_regl;
This is wrong, because you're not allowed to modify the input operands.
Try this, just a few lines lower in the function:
- tcg_out_movi(s, TCG_TYPE_PTR, base, guest_base); - tcg_out_opc_reg(s, ALIAS_PADD, base, base, addr_regl); + tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, guest_base); + tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_TMP0, addr_regl);
and you'll need the same change within tcg_out_qemu_st.
Better would be to reserve a register for the guest_base, like we do for ppc. See all of the uses of TCG_GUEST_BASE_REG in tcg/ppc/tcg-target.inc.c.
r~
[Qemu-devel] 答复: Re: [PATCH] tcg/mips: Bugfix for crash when runningprogram with qemu-i386.
Quoted 13 lines
This is wrong, because you're not allowed to modify the input operands.
Try this, just a few lines lower in the function:
(quoted diff) +2
-2- tcg_out_movi(s, TCG_TYPE_PTR, base, guest_base) - tcg_out_opc_reg(s, ALIAS_PADD, base, base, addr_regl) + tcg_out_movi(s, TCG_TYPE_PTR, TCG_TMP0, guest_base) + tcg_out_opc_reg(s, ALIAS_PADD, base, TCG_TMP0, addr_regl)
Quoted 4 lines
and you'll need the same change within
tcg_out_qemu_st.Better would be to reserve a register for the
guest_base, like we do for ppc. See all of the uses ofTCG_GUEST_BASE_REGintcg/ppc/tcg-target.inc.c.
Thanks a lot for the reviewing, I'll check on these.