From patchwork Mon Jul 10 05:49:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Biao X-Patchwork-Id: 786046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x5Yyl3ddWz9ryk for ; Mon, 10 Jul 2017 15:42:54 +1000 (AEST) Received: from localhost ([::1]:38578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dURT7-00068p-ID for incoming@patchwork.ozlabs.org; Mon, 10 Jul 2017 01:42:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dURSk-00068e-8m for qemu-devel@nongnu.org; Mon, 10 Jul 2017 01:42:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dURSf-0003jK-Jj for qemu-devel@nongnu.org; Mon, 10 Jul 2017 01:42:26 -0400 Received: from mx7.zte.com.cn ([202.103.147.169]:46466) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dURSf-0003hm-0Q for qemu-devel@nongnu.org; Mon, 10 Jul 2017 01:42:21 -0400 X-scanvirus: By SEG_CYREN AntiVirus Engine X-scanresult: CLEAN X-MAILFROM: X-RCPTTO: X-FROMIP: 10.30.3.20 X-SEG-Scaned: 1 X-Received: unknown,10.30.3.20,20170710132947 Received: from unknown (HELO mse01.zte.com.cn) (10.30.3.20) by localhost with (AES256-SHA encrypted) SMTP; 10 Jul 2017 05:29:47 -0000 Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id v6A5g2Me051992; Mon, 10 Jul 2017 13:42:02 +0800 (GMT-8) (envelope-from jiang.biao2@zte.com.cn) Received: from localhost.localdomain ([10.75.9.60]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2017071013420414-3512504 ; Mon, 10 Jul 2017 13:42:04 +0800 From: Jiang Biao To: qemu-devel@nongnu.org Date: Mon, 10 Jul 2017 13:49:49 +0800 Message-Id: <1499665789-20058-1-git-send-email-jiang.biao2@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-10 13:42:04, Serialize by Router on notes_smtp/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2017-07-10 13:42:02, Serialize complete at 2017-07-10 13:42:02 X-MAIL: mse01.zte.com.cn v6A5g2Me051992 X-HQIP: 127.0.0.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 202.103.147.169 Subject: [Qemu-devel] [PATCH v2] tcg/mips: Bugfix for crash when running program with qemu-i386. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: james.hogan@imgtec.com, zhong.weidong@zte.com.cn, wang.liang82@zte.com.cn, shi.zhongbing@zte.com.cn, jinguojie@loongson.cn, jiang.yong5@zte.com.cn, jiang.biao2@zte.com.cn, rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When running a helloworld program with qemu-i386 in linux-user mode on Loongson 3A3000, it will crash. The reasion is wrong assigning from base to addr_regl directly. This patch fix the bug. Signed-off-by: Jiang Biao Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.inc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tcg/mips/tcg-target.inc.c b/tcg/mips/tcg-target.inc.c index 8cff9a6..cebca8e 100644 --- a/tcg/mips/tcg-target.inc.c +++ b/tcg/mips/tcg-target.inc.c @@ -1539,16 +1539,18 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) s->code_ptr, label_ptr); #else if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { - tcg_out_ext32u(s, base, addr_regl); - addr_regl = base; + tcg_out_ext32u(s, TCG_TMP0, addr_regl); + } else { + tcg_out_mov(s, TCG_TYPE_PTR, TCG_TMP0, addr_regl); } + if (guest_base == 0 && data_regl != addr_regl) { base = addr_regl; } else if (guest_base == (int16_t)guest_base) { - tcg_out_opc_imm(s, ALIAS_PADDI, base, addr_regl, guest_base); + tcg_out_opc_imm(s, ALIAS_PADDI, base, TCG_TMP0, guest_base); } else { tcg_out_movi(s, TCG_TYPE_PTR, base, guest_base); - tcg_out_opc_reg(s, ALIAS_PADD, base, base, addr_regl); + tcg_out_opc_reg(s, ALIAS_PADD, base, base, TCG_TMP0); } tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); #endif