From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMB3z-0008TL-NZ for qemu-devel@nongnu.org; Mon, 03 Aug 2015 04:25:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZMB3y-0004Yb-Rb for qemu-devel@nongnu.org; Mon, 03 Aug 2015 04:25:39 -0400 Received: from hall.aurel32.net ([2001:bc8:30d7:100::1]:32806) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZMAz8-0003Gy-VM for qemu-devel@nongnu.org; Mon, 03 Aug 2015 04:20:39 -0400 From: Aurelien Jarno Date: Mon, 3 Aug 2015 10:20:19 +0200 Message-Id: <1438590019-16932-5-git-send-email-aurelien@aurel32.net> In-Reply-To: <1438590019-16932-1-git-send-email-aurelien@aurel32.net> References: <1438590019-16932-1-git-send-email-aurelien@aurel32.net> Subject: [Qemu-devel] [PULL 4/4] tcg/mips: fix add2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Aurelien Jarno , Richard Henderson The add2 code in the tcg_out_addsub2 function doesn't take into account the case where rl == al == bl. In that case we can't compute the carry after the addition. As it corresponds to a multiplication by 2, the carry bit is the bit 31. While this is a corner case, this prevents x86-64 guests to boot on a MIPS host. Cc: qemu-stable@nongnu.org Reviewed-by: Richard Henderson Signed-off-by: Aurelien Jarno --- tcg/mips/tcg-target.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 064db46..e97980d 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -1271,6 +1271,9 @@ static void tcg_out_addsub2(TCGContext *s, TCGReg rl, TCGReg rh, TCGReg al, if (cbl) { tcg_out_opc_imm(s, OPC_ADDIU, rl, al, bl); tcg_out_opc_imm(s, OPC_SLTIU, TCG_TMP0, rl, bl); + } else if (rl == al && rl == bl) { + tcg_out_opc_sa(s, OPC_SRL, TCG_TMP0, al, 31); + tcg_out_opc_reg(s, OPC_ADDU, rl, al, bl); } else { tcg_out_opc_reg(s, OPC_ADDU, rl, al, bl); tcg_out_opc_reg(s, OPC_SLTU, TCG_TMP0, rl, (rl == bl ? al : bl)); -- 2.1.4