From nobody Sat Nov 8 10:13:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550068809952979.4042951080932; Wed, 13 Feb 2019 06:40:09 -0800 (PST) Received: from localhost ([127.0.0.1]:57789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtvhm-0004Z8-Tf for importer@patchew.org; Wed, 13 Feb 2019 09:40:07 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtvbZ-0008J1-PN for qemu-devel@nongnu.org; Wed, 13 Feb 2019 09:33:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtvbY-00029F-SL for qemu-devel@nongnu.org; Wed, 13 Feb 2019 09:33:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57404) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gtvbY-00026J-JM; Wed, 13 Feb 2019 09:33:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A05A48BD23; Wed, 13 Feb 2019 14:33:35 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-173.ams2.redhat.com [10.36.116.173]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE2125D6AA; Wed, 13 Feb 2019 14:33:33 +0000 (UTC) From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 13 Feb 2019 15:33:11 +0100 Message-Id: <20190213143322.31371-5-david@redhat.com> In-Reply-To: <20190213143322.31371-1-david@redhat.com> References: <20190213143322.31371-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 13 Feb 2019 14:33:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 04/15] s390x/tcg: Fix parts of IEEE exception handling 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: Thomas Huth , Janosch Frank , David Hildenbrand , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Many things are wrong and some parts cannot be fixed yet. Fix what we can fix easily and add two FIXMEs: The fpc flags are not updated in case an exception is actually injected. Inexact exceptions have to be handled separately, as they are the only exceptions that can coexist with underflows and overflows. I reread the horribly complicated chapters in the PoP at least 5 times and hope I got it right. For references: - z14 PoP, 9-18, "IEEE Exceptions" - z14 PoP, 19-9, Figure 19-8 Reviewed-by: Richard Henderson Signed-off-by: David Hildenbrand --- target/s390x/fpu_helper.c | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/target/s390x/fpu_helper.c b/target/s390x/fpu_helper.c index de02cf792d..dcad9c367a 100644 --- a/target/s390x/fpu_helper.c +++ b/target/s390x/fpu_helper.c @@ -63,13 +63,39 @@ static void handle_exceptions(CPUS390XState *env, uintp= tr_t retaddr) env->fpu_status.float_exception_flags =3D 0; s390_exc =3D s390_softfloat_exc_to_ieee(qemu_exc); =20 - /* Install the exceptions that we raised. */ - env->fpc |=3D s390_exc << 16; + /* + * FIXME: + * 1. Right now, all inexact conditions are inidicated as + * "truncated" (0) and never as "incremented" (1) in the DXC. + * 2. Only traps due to invalid/divbyzero are suppressing. Other traps + * are completing, meaning the target register has to be written! + * This, however will mean that we have to write the register before + * triggering the trap - impossible right now. + */ + + /* + * invalid/divbyzero cannot coexist with other conditions. + * overflow/underflow however can coexist with inexact, we have to + * handle it separatly. + */ + if (s390_exc & ~S390_IEEE_MASK_INEXACT) { + if (s390_exc & ~S390_IEEE_MASK_INEXACT & env->fpc >> 24) { + /* trap condition - inexact reported along */ + tcg_s390_data_exception(env, s390_exc, retaddr); + } + /* nontrap condition - inexact handled differently */ + env->fpc |=3D (s390_exc & ~S390_IEEE_MASK_INEXACT) << 16; + } =20 - /* Send signals for enabled exceptions. */ - s390_exc &=3D env->fpc >> 24; - if (s390_exc) { - tcg_s390_data_exception(env, s390_exc, retaddr); + /* inexact handling */ + if (s390_exc & S390_IEEE_MASK_INEXACT) { + /* trap condition - overflow/underflow _not_ reported along */ + if (s390_exc & S390_IEEE_MASK_INEXACT & env->fpc >> 24) { + tcg_s390_data_exception(env, s390_exc & S390_IEEE_MASK_INEXACT, + retaddr); + } + /* nontrap condition */ + env->fpc |=3D (s390_exc & S390_IEEE_MASK_INEXACT) << 16; } } =20 --=20 2.17.2