From patchwork Sun Dec 14 21:45:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 420909 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 74D301400E2 for ; Mon, 15 Dec 2014 08:45:57 +1100 (AEDT) Received: from localhost ([::1]:37256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0GzD-0006Ui-En for incoming@patchwork.ozlabs.org; Sun, 14 Dec 2014 16:45:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Gym-0006E9-Hg for qemu-devel@nongnu.org; Sun, 14 Dec 2014 16:45:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0Gyd-0004nw-8Q for qemu-devel@nongnu.org; Sun, 14 Dec 2014 16:45:28 -0500 Received: from mail-wi0-x22c.google.com ([2a00:1450:400c:c05::22c]:47635) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0Gyd-0004nl-22 for qemu-devel@nongnu.org; Sun, 14 Dec 2014 16:45:19 -0500 Received: by mail-wi0-f172.google.com with SMTP id n3so7130356wiv.11 for ; Sun, 14 Dec 2014 13:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=6yVNBq9cJofe+fhOeNi0usV2y9Jg0TL5vAFvcKUKc08=; b=wZbQi3DvetRk7GE/SADS1/s7/Lo9RfXyYKmEgjtpaqC+NE2hG4weCc6ozo8vWICkcQ hYoAi7kehSERzsaPgBdGpD61UWXnu+/TGhf3oiQfC6x/RPBCVDChKmQPkewMk8L+ezbf uQIbtIHcZySyGLKAyiy5lpi296eqNnIS4evi+i4QKBmcOzK0teeKzKoSAPjkriOPw+n0 HW1yjanedsSh9zWMLBfufL0W2A+urH93rzSm30sJ52YgBSnY/6gCpk42k/QsnY1/15Vf mU32E/jk4CJWlVYsndo0RuJIiVcdsTmrk5q9YPojaSNoSsRCtOupRzdhwgVcw49OYN7F jsuw== X-Received: by 10.194.19.4 with SMTP id a4mr45820838wje.3.1418593517436; Sun, 14 Dec 2014 13:45:17 -0800 (PST) Received: from [192.168.10.150] (net-2-35-193-40.cust.vodafonedsl.it. [2.35.193.40]) by mx.google.com with ESMTPSA id j2sm10629125wjs.28.2014.12.14.13.45.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Dec 2014 13:45:16 -0800 (PST) Message-ID: <548E04EA.1030804@redhat.com> Date: Sun, 14 Dec 2014 22:45:14 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: =?UTF-8?B?VG9yYmrDtnJuIEdyYW5sdW5k?= , qemu-devel References: <86lhmo303u.fsf@shell.gmplib.org> <86egs32obj.fsf@shell.gmplib.org> In-Reply-To: <86egs32obj.fsf@shell.gmplib.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22c Subject: Re: [Qemu-devel] Bug in s390 instruction emulation 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 On 13/12/2014 23:10, Torbjörn Granlund wrote: > I wrote: > > The s390 instruction emulation makes GMP fail most of its tests. > I have isolated one of the problems: > > How to reproduce: > > gcc m.c x.s > ./a.out > > Correct output on actual hardware: > ffffffff > > Incorrect output using QEMU 2.2.0 rc4: > 0 > > File m.c: > #include > int foo(); > int main() { printf("%x\n", foo()); return 0; } > > File x.s: > .text > .align 8 > .globl foo > .type foo,@function > foo: lghi %r2, 0 > lghi %r3, 1 > slgr %r2, %r3 > slbgr %r3, %r3 > slbgr %r2, %r2 > br %r14 > > Turns out that all failures except 3 are due to subb borrow handling > code which (almost) never works when there is borrow-in. A minimal fix > is quite simple: > > *** /home/tege/qemu/qemu-2.2.0/target-s390x/.~/cc_helper.c.~1~ Tue Dec 9 15:45:44 2014 > --- /home/tege/qemu/qemu-2.2.0/target-s390x/cc_helper.c Sat Dec 13 22:47:11 2014 > *************** > *** 182,184 **** > /* We had borrow-in if normal subtraction isn't equal. */ > ! int borrow_in = ar - (a1 - a2); > int borrow_out; > --- 182,184 ---- > /* We had borrow-in if normal subtraction isn't equal. */ > ! int borrow_in = (a1 - a2) - ar; > int borrow_out; > > There is at least one more instruction emulation error which I have not > yet isolated [two test failures]. And then EX is not implemented for > logical operations [one test failure]. > > This latter problem is adequately reported by qemu: > qemu: fatal: EXECUTE on instruction prefix 0xd400 not implemented > qemu: fatal: EXECUTE on instruction prefix 0xd600 not implemented Something like this? Paolo diff --git a/target-s390x/mem_helper.c b/target-s390x/mem_helper.c index 5a55de8..4de3fc2 100644 --- a/target-s390x/mem_helper.c +++ b/target-s390x/mem_helper.c @@ -490,10 +490,18 @@ uint32_t HELPER(ex)(CPUS390XState *env, uint32_t cc, uint64_t v1, helper_mvc(env, l, get_address(env, 0, b1, d1), get_address(env, 0, b2, d2)); break; + case 0x400: + cc = helper_nc(env, l, get_address(env, 0, b1, d1), + get_address(env, 0, b2, d2)); + break; case 0x500: cc = helper_clc(env, l, get_address(env, 0, b1, d1), get_address(env, 0, b2, d2)); break; + case 0x600: + cc = helper_oc(env, l, get_address(env, 0, b1, d1), + get_address(env, 0, b2, d2)); + break; case 0x700: cc = helper_xc(env, l, get_address(env, 0, b1, d1), get_address(env, 0, b2, d2));