Commit 90cbed4656108fec86d157ced39192e0774a6615

Authored by blueswir1
1 parent bffe1431

Fix 32 bit address overflow

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5019 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 19 additions and 0 deletions
tcg/sparc/tcg-target.c
@@ -625,8 +625,18 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, @@ -625,8 +625,18 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
625 /* ld [arg1 + x], arg1 */ 625 /* ld [arg1 + x], arg1 */
626 tcg_out_ldst(s, arg1, arg1, offsetof(CPUTLBEntry, addend) - 626 tcg_out_ldst(s, arg1, arg1, offsetof(CPUTLBEntry, addend) -
627 offsetof(CPUTLBEntry, addr_read), HOST_LD_OP); 627 offsetof(CPUTLBEntry, addr_read), HOST_LD_OP);
  628 +
  629 +#if TARGET_LONG_BITS == 32
  630 + /* and addr_reg, x, arg0 */
  631 + tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_I5, 0xffffffff);
  632 + tcg_out_arith(s, arg0, addr_reg, TCG_REG_I5, ARITH_AND);
  633 + /* add arg0, arg1, arg0 */
  634 + tcg_out_arith(s, arg0, arg0, arg1, ARITH_ADD);
  635 +#else
628 /* add addr_reg, arg1, arg0 */ 636 /* add addr_reg, arg1, arg0 */
629 tcg_out_arith(s, arg0, addr_reg, arg1, ARITH_ADD); 637 tcg_out_arith(s, arg0, addr_reg, arg1, ARITH_ADD);
  638 +#endif
  639 +
630 #else 640 #else
631 arg0 = addr_reg; 641 arg0 = addr_reg;
632 #endif 642 #endif
@@ -785,8 +795,17 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, @@ -785,8 +795,17 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
785 tcg_out_ldst(s, arg1, arg1, offsetof(CPUTLBEntry, addend) - 795 tcg_out_ldst(s, arg1, arg1, offsetof(CPUTLBEntry, addend) -
786 offsetof(CPUTLBEntry, addr_write), HOST_LD_OP); 796 offsetof(CPUTLBEntry, addr_write), HOST_LD_OP);
787 797
  798 +#if TARGET_LONG_BITS == 32
  799 + /* and addr_reg, x, arg0 */
  800 + tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_I5, 0xffffffff);
  801 + tcg_out_arith(s, arg0, addr_reg, TCG_REG_I5, ARITH_AND);
  802 + /* add arg0, arg1, arg0 */
  803 + tcg_out_arith(s, arg0, arg0, arg1, ARITH_ADD);
  804 +#else
788 /* add addr_reg, arg1, arg0 */ 805 /* add addr_reg, arg1, arg0 */
789 tcg_out_arith(s, arg0, addr_reg, arg1, ARITH_ADD); 806 tcg_out_arith(s, arg0, addr_reg, arg1, ARITH_ADD);
  807 +#endif
  808 +
790 #else 809 #else
791 arg0 = addr_reg; 810 arg0 = addr_reg;
792 #endif 811 #endif