From patchwork Sun Jun 24 23:12:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 934016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Cbuf65Wc"; dkim-atps=neutral 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 41DSlv4wrCz9ry1 for ; Mon, 25 Jun 2018 09:13:31 +1000 (AEST) Received: from localhost ([::1]:43454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXECG-0005ll-1U for incoming@patchwork.ozlabs.org; Sun, 24 Jun 2018 19:13:29 -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) 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) 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) 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The FPSCR[FI] bit indicates if the last floating point instruction had a result that was rounded. Each consecutive floating point instruction is suppose 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 behavior of a real PowerPC 950. This patch fixes that problem by deciding to set this bit after each floating point instruction. https://www.pdfdrive.net/powerpc-microprocessor-family-the-programming-environments-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 = CPU(ppc_env_get_cpu(env)); + env->fpscr |= 1 << FPSCR_FI; env->fpscr |= 1 << FPSCR_XX; /* Update the floating-point exception summary */ env->fpscr |= FP_FX; @@ -505,6 +506,7 @@ static void do_float_check_status(CPUPPCState *env, uintptr_t raddr) { CPUState *cs = CPU(ppc_env_get_cpu(env)); int status = get_float_exception_flags(&env->fp_status); + bool inexact_happened = false; if (status & float_flag_divbyzero) { float_zero_divide_excp(env, raddr); @@ -514,6 +516,12 @@ static void do_float_check_status(CPUPPCState *env, uintptr_t raddr) float_underflow_excp(env); } else if (status & float_flag_inexact) { float_inexact_excp(env); + inexact_happened = true; + } + + /* if the inexact flag was not set */ + if (inexact_happened == false) { + env->fpscr &= ~(1 << FPSCR_FI); /* clear the FPSCR[FI] bit */ } if (cs->exception_index == POWERPC_EXCP_PROGRAM &&