From: Paolo Bonzini <pbonzini@redhat.com>
To: "Torbjörn Granlund" <tg@gmplib.org>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Bug in s390 instruction emulation
Date: Sun, 14 Dec 2014 22:45:14 +0100 [thread overview]
Message-ID: <548E04EA.1030804@redhat.com> (raw)
In-Reply-To: <86egs32obj.fsf@shell.gmplib.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 <stdio.h>
> 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?
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));
Paolo
next prev parent reply other threads:[~2014-12-14 21:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-03 21:16 [Qemu-devel] Bug in s390 instruction emulation Torbjörn Granlund
2014-12-13 22:10 ` Torbjörn Granlund
2014-12-14 21:45 ` Paolo Bonzini [this message]
2014-12-15 23:44 ` Torbjörn Granlund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=548E04EA.1030804@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=tg@gmplib.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.