From patchwork Mon Mar 25 13:19:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 230718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4A8E62C0095 for ; Tue, 26 Mar 2013 00:20:10 +1100 (EST) Received: from localhost ([::1]:35693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK7Jo-0007Af-Fr for incoming@patchwork.ozlabs.org; Mon, 25 Mar 2013 09:20:08 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK7JX-000792-JJ for qemu-devel@nongnu.org; Mon, 25 Mar 2013 09:19:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UK7JS-0006Ur-1r for qemu-devel@nongnu.org; Mon, 25 Mar 2013 09:19:51 -0400 Received: from cantor2.suse.de ([195.135.220.15]:51266 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UK7JR-0006M0-SL for qemu-devel@nongnu.org; Mon, 25 Mar 2013 09:19:45 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EE32EA5356; Mon, 25 Mar 2013 14:19:03 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1278) From: Alexander Graf Date: Mon, 25 Mar 2013 14:19:00 +0100 Message-Id: <1E58A03D-3CD1-495E-840E-9DB7574F3638@suse.de> To: Richard Henderson X-Mailer: Apple Mail (2.1278) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: " qemu-devel" Subject: [Qemu-devel] s390 tcg breakage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Hi Richard, I've finally gotten around to debug why TCG on s390 hosts breaks for me. The reason turned out to be quite simple. The broken TB ends with a goto_tb instruction: exit_tb $0x3fffb258010 which gets translated into: 0x90000040: lgfi %r2,-81428464 0x90000046: iihl %r2,1023 0x9000004a: jg 0x91fffc10 which again leaves r2 as: 0xffff03fffb258010 This is because lgfi leaves the register negative, but iihl doesn't replace the upper 16 bits, only [48..32]. The patch below fixes it for me, but I'm sure you can come up with something cleaner, better and working on non-ext-imm machines :). Alex diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index e12a152..6b72ff4 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -775,13 +775,7 @@ static void tcg_out_movi(TCGContext *s, TCGType type, /* Insert data into the high 32-bits. */ uval = uval >> 31 >> 1; if (facilities & FACILITY_EXT_IMM) { - if (uval < 0x10000) { - tcg_out_insn(s, RI, IIHL, ret, uval); - } else if ((uval & 0xffff) == 0) { - tcg_out_insn(s, RI, IIHH, ret, uval >> 16); - } else { - tcg_out_insn(s, RIL, IIHF, ret, uval); - } + tcg_out_insn(s, RIL, IIHF, ret, uval); } else { if (uval & 0xffff) { tcg_out_insn(s, RI, IIHL, ret, uval);