From nobody Tue Nov 4 05:26:01 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529882050593952.0377550048793; Sun, 24 Jun 2018 16:14:10 -0700 (PDT) Received: from localhost ([::1]:43455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXECr-00068J-Rp for importer@patchew.org; Sun, 24 Jun 2018 19:14:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXEBv-0005kS-SI for qemu-devel@nongnu.org; Sun, 24 Jun 2018 19:13:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXEBu-0002Fp-R7 for qemu-devel@nongnu.org; Sun, 24 Jun 2018 19:13:07 -0400 Received: from mail-io0-x244.google.com ([2607:f8b0:4001:c06::244]:42509) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXEBq-0002D2-8y; Sun, 24 Jun 2018 19:13:02 -0400 Received: by mail-io0-x244.google.com with SMTP id r24-v6so10764166ioh.9; Sun, 24 Jun 2018 16:13:02 -0700 (PDT) Received: from localhost.localdomain ([69.14.184.20]) by smtp.gmail.com with ESMTPSA id d14-v6sm255087itc.34.2018.06.24.16.12.59 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 24 Jun 2018 16:13:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=lQAst/HDC0uAes5Yx6Z59W4zSfPdZwB4ZAAAcN563BU=; b=Cbuf65WcUk25t7TJxN2oEq6o/83xA7jJ8Q2C/rBZj3bgxX8B9yjRXc2Uq7FtE6MXY7 AnTdo8DE5CoRvbTlYsjGtfbOcApAD5o4su+SIyBHnVHCxpzo0KGBqAbdBE8rcuhtPiXy o7NQ6BhupKKUH0zqM/2tfSZI8DKlZwduDJzrAb9I5Z7GjUSTjzWQWmjm6j7/IG51H6db nhM0l/k0e2Gv6OzcFqY/0fRGtmbKhvD9AdJtfB+J6+j5qpVhNlQkxZrIj9ytPhtKKJrt GzVfpyRMe8dckxbhXq6o8HF/gdWlN9JMw8WNtYXmbKiM3WxPXUk5dhuv4o/4J2s7tQGJ aHdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lQAst/HDC0uAes5Yx6Z59W4zSfPdZwB4ZAAAcN563BU=; b=Fq4AIRTBcaNOkpxVARj2iNSWFUR9mVnUrAnhNAWgXgWC2jpabjfBmnGZxpD/x2Gg2f SLBhukD+/m6caMSxF6HpTEXFrFhYzUHEtGe+XItsgea+WcQTVmqpxC92nv4aFgy8qg2K hkYUQJyWqB9/Wzkx3Vjc/jj1Hb41yXWMDhuTyf6zJ1ntXhYY2SX7J2aHz/25d/Aq7aql yK1mdUSxsp6gMlKwdwc8z1wL7X03TJL/uWGSaBQs2W7xHIiLIp7sDPA7h2vM9mH4A5U1 smxUV13Ls7Ya0uVx6BCyWe08pMirV4di2vtKLV4Qr9U11k4cLtfW5ckPGWKC7qagJqtZ KOyQ== X-Gm-Message-State: APt69E0a1Ou2tfPJ/BV7sp/s14SNZfJiISBHLzpU08df/fRb9slPDNsz QKzdPXUBqg1BSD7NnJq6f10= X-Google-Smtp-Source: ADUXVKLkCw4KsR7uuzvjKLL3MqtgRDEdmhPHsyScW85i59ozu0X1AQJTFRPNNL9/rFyi+mkIB/p8Qg== X-Received: by 2002:a6b:c855:: with SMTP id y82-v6mr8325422iof.187.1529881981628; Sun, 24 Jun 2018 16:13:01 -0700 (PDT) From: John Arbuckle To: david@gibson.dropbear.id.au, agraf@suse.de, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Sun, 24 Jun 2018 19:12:48 -0400 Message-Id: <20180624231248.6827-1-programmingkidx@gmail.com> X-Mailer: git-send-email 2.14.3 (Apple Git-98) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::244 Subject: [Qemu-devel] [PATCH] fpu_helper.c: fix setting FPSCR[FI] bit 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: John Arbuckle Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The FPSCR[FI] bit indicates if the last floating point instruction had a re= sult that was rounded. Each consecutive floating point instruction is suppo= se to set this bit to the correct value. What currently happens is this bit= is not set as often as it should be. I have verified that this is the beha= vior of a real PowerPC 950. This patch fixes that problem by deciding to se= t this bit after each floating point instruction. https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-envi= ronments-for-32-e3087633.html Page 63 in table 2-4 is where the description of this bit can be found. Signed-off-by: John Arbuckle --- target/ppc/fpu_helper.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index d31a933cbb..9c841864c8 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -274,6 +274,7 @@ static inline void float_inexact_excp(CPUPPCState *env) { CPUState *cs =3D CPU(ppc_env_get_cpu(env)); =20 + env->fpscr |=3D 1 << FPSCR_FI; env->fpscr |=3D 1 << FPSCR_XX; /* Update the floating-point exception summary */ env->fpscr |=3D FP_FX; @@ -505,6 +506,7 @@ static void do_float_check_status(CPUPPCState *env, uin= tptr_t raddr) { CPUState *cs =3D CPU(ppc_env_get_cpu(env)); int status =3D get_float_exception_flags(&env->fp_status); + bool inexact_happened =3D false; =20 if (status & float_flag_divbyzero) { float_zero_divide_excp(env, raddr); @@ -514,6 +516,12 @@ static void do_float_check_status(CPUPPCState *env, ui= ntptr_t raddr) float_underflow_excp(env); } else if (status & float_flag_inexact) { float_inexact_excp(env); + inexact_happened =3D true; + } + + /* if the inexact flag was not set */ + if (inexact_happened =3D=3D false) { + env->fpscr &=3D ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */ } =20 if (cs->exception_index =3D=3D POWERPC_EXCP_PROGRAM && --=20 2.14.3 (Apple Git-98)