|
|
bca718 |
From aea6303d6c5fa276ea10887dab968ee0f3c79328 Mon Sep 17 00:00:00 2001
|
|
|
bca718 |
From: Stefan Liebler <stli@linux.vnet.ibm.com>
|
|
|
bca718 |
Date: Thu, 8 Oct 2015 10:30:00 +0200
|
|
|
bca718 |
Subject: [PATCH 04/30] S390: Fix handling of DXC-byte in FPC-register.
|
|
|
bca718 |
MIME-Version: 1.0
|
|
|
bca718 |
Content-Type: text/plain; charset=UTF-8
|
|
|
bca718 |
Content-Transfer-Encoding: 8bit
|
|
|
bca718 |
|
|
|
bca718 |
upstream-commit-id: 5d96fe8c0dc3450bafe6c2aae2dabc76819df3e0
|
|
|
bca718 |
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00074.html
|
|
|
bca718 |
|
|
|
bca718 |
On s390, the DXC(data-exception-code)-byte in FPC(floating-point-control)-
|
|
|
bca718 |
register contains a code of the last occured exception.
|
|
|
bca718 |
If bits 6 and 7 of DXC-byte are zero, the bits 0-5 correspond to the
|
|
|
bca718 |
ieee-exception flag bits.
|
|
|
bca718 |
The current implementation always uses these bits as ieee-exception flag bits.
|
|
|
bca718 |
fetestexcept() reports any exception after the first usage of a
|
|
|
bca718 |
vector-instruction in a process, because it raises an "vector instruction
|
|
|
bca718 |
exception" with DXC-code 0xFE.
|
|
|
bca718 |
This patch fixes the handling of the DXC-byte. The DXC-Byte is only handled
|
|
|
bca718 |
if bits 6 and 7 are zero.
|
|
|
bca718 |
|
|
|
bca718 |
The #define _FPU_RESERVED is extended by the DXC-Byte.
|
|
|
bca718 |
Otherwise the tests math/test-fpucw-static and math/test-fpucw-ieee-static
|
|
|
bca718 |
fails, because DXC-Byte contains the vector instruction exception when reaching
|
|
|
bca718 |
main(). This exception was triggered by strrchr() call in __init_misc().
|
|
|
bca718 |
__init_misc() is called after __setfpucw () in __libc_init_first().
|
|
|
bca718 |
|
|
|
bca718 |
The field __ieee_instruction_pointer in struct fenv_t is renamed to __unused
|
|
|
bca718 |
because it is a relict from commit "Remove PTRACE_PEEKUSER"
|
|
|
bca718 |
(87b9b50f0d4b92248905e95a06a13c513dc45e59) and isn´t used anymore.
|
|
|
bca718 |
|
|
|
bca718 |
ChangeLog:
|
|
|
bca718 |
|
|
|
bca718 |
[BZ #18610]
|
|
|
bca718 |
* sysdeps/s390/fpu/bits/fenv.h (fenv_t): Rename
|
|
|
bca718 |
__ieee_instruction_pointer to __unused.
|
|
|
bca718 |
* sysdeps/s390/fpu/fesetenv.c (__fesetenv): Remove usage of
|
|
|
bca718 |
__ieee_instruction_pointer.
|
|
|
bca718 |
* sysdeps/s390/fpu/fclrexcpt.c (feclearexcept): Fix dxc-field handling.
|
|
|
bca718 |
* sysdeps/s390/fpu/fgetexcptflg.c (fegetexceptflag): Likewise.
|
|
|
bca718 |
* sysdeps/s390/fpu/fsetexcptflg.c (fesetexceptflag): Likewise.
|
|
|
bca718 |
* sysdeps/s390/fpu/ftestexcept.c (fetestexcept): Likewise.
|
|
|
bca718 |
* sysdeps/s390/fpu/fpu_control.h (_FPU_RESERVED):
|
|
|
bca718 |
Mark dxc-field as reserved.
|
|
|
bca718 |
---
|
|
|
bca718 |
sysdeps/s390/fpu/bits/fenv.h | 6 ++++--
|
|
|
bca718 |
sysdeps/s390/fpu/fclrexcpt.c | 7 ++++++-
|
|
|
bca718 |
sysdeps/s390/fpu/fesetenv.c | 2 --
|
|
|
bca718 |
sysdeps/s390/fpu/fgetexcptflg.c | 8 +++++++-
|
|
|
bca718 |
sysdeps/s390/fpu/fpu_control.h | 6 +++---
|
|
|
bca718 |
sysdeps/s390/fpu/fsetexcptflg.c | 15 ++++++++++++---
|
|
|
bca718 |
sysdeps/s390/fpu/ftestexcept.c | 12 +++++++++---
|
|
|
bca718 |
7 files changed, 41 insertions(+), 15 deletions(-)
|
|
|
bca718 |
|
|
|
bca718 |
diff --git a/sysdeps/s390/fpu/bits/fenv.h b/sysdeps/s390/fpu/bits/fenv.h
|
|
|
bca718 |
index 88c6f7a..93177dc 100644
|
|
|
bca718 |
--- a/sysdeps/s390/fpu/bits/fenv.h
|
|
|
bca718 |
+++ b/sysdeps/s390/fpu/bits/fenv.h
|
|
|
bca718 |
@@ -77,8 +77,10 @@ typedef unsigned int fexcept_t; /* size of fpc */
|
|
|
bca718 |
typedef struct
|
|
|
bca718 |
{
|
|
|
bca718 |
fexcept_t __fpc;
|
|
|
bca718 |
- void *__ieee_instruction_pointer;
|
|
|
bca718 |
- /* failing instruction for ieee exceptions */
|
|
|
bca718 |
+ void *__unused;
|
|
|
bca718 |
+ /* The field __unused (formerly __ieee_instruction_pointer) is a relict from
|
|
|
bca718 |
+ commit "Remove PTRACE_PEEKUSER" (87b9b50f0d4b92248905e95a06a13c513dc45e59)
|
|
|
bca718 |
+ and isn´t used anymore. */
|
|
|
bca718 |
} fenv_t;
|
|
|
bca718 |
|
|
|
bca718 |
/* If the default argument is used we use this value. */
|
|
|
bca718 |
diff --git a/sysdeps/s390/fpu/fclrexcpt.c b/sysdeps/s390/fpu/fclrexcpt.c
|
|
|
bca718 |
index 3e8d9bb..c2647ba 100644
|
|
|
bca718 |
--- a/sysdeps/s390/fpu/fclrexcpt.c
|
|
|
bca718 |
+++ b/sysdeps/s390/fpu/fclrexcpt.c
|
|
|
bca718 |
@@ -29,7 +29,12 @@ feclearexcept (int excepts)
|
|
|
bca718 |
|
|
|
bca718 |
_FPU_GETCW (temp);
|
|
|
bca718 |
/* Clear the relevant bits. */
|
|
|
bca718 |
- temp &= ~((excepts << FPC_DXC_SHIFT)|(excepts << FPC_FLAGS_SHIFT));
|
|
|
bca718 |
+ temp &= ~(excepts << FPC_FLAGS_SHIFT);
|
|
|
bca718 |
+ if ((temp & FPC_NOT_FPU_EXCEPTION) == 0)
|
|
|
bca718 |
+ /* Bits 6, 7 of dxc-byte are zero,
|
|
|
bca718 |
+ thus bits 0-5 of dxc-byte correspond to the flag-bits.
|
|
|
bca718 |
+ Clear the relevant bits in flags and dxc-field. */
|
|
|
bca718 |
+ temp &= ~(excepts << FPC_DXC_SHIFT);
|
|
|
bca718 |
|
|
|
bca718 |
/* Put the new data in effect. */
|
|
|
bca718 |
_FPU_SETCW (temp);
|
|
|
bca718 |
diff --git a/sysdeps/s390/fpu/fesetenv.c b/sysdeps/s390/fpu/fesetenv.c
|
|
|
bca718 |
index b534205..a4a0bb5 100644
|
|
|
bca718 |
--- a/sysdeps/s390/fpu/fesetenv.c
|
|
|
bca718 |
+++ b/sysdeps/s390/fpu/fesetenv.c
|
|
|
bca718 |
@@ -32,12 +32,10 @@ fesetenv (const fenv_t *envp)
|
|
|
bca718 |
if (envp == FE_DFL_ENV)
|
|
|
bca718 |
{
|
|
|
bca718 |
env.__fpc = _FPU_DEFAULT;
|
|
|
bca718 |
- env.__ieee_instruction_pointer = 0;
|
|
|
bca718 |
}
|
|
|
bca718 |
else if (envp == FE_NOMASK_ENV)
|
|
|
bca718 |
{
|
|
|
bca718 |
env.__fpc = FPC_EXCEPTION_MASK;
|
|
|
bca718 |
- env.__ieee_instruction_pointer = 0;
|
|
|
bca718 |
}
|
|
|
bca718 |
else
|
|
|
bca718 |
env = (*envp);
|
|
|
bca718 |
diff --git a/sysdeps/s390/fpu/fgetexcptflg.c b/sysdeps/s390/fpu/fgetexcptflg.c
|
|
|
bca718 |
index 7457678..7941904 100644
|
|
|
bca718 |
--- a/sysdeps/s390/fpu/fgetexcptflg.c
|
|
|
bca718 |
+++ b/sysdeps/s390/fpu/fgetexcptflg.c
|
|
|
bca718 |
@@ -27,7 +27,13 @@ fegetexceptflag (fexcept_t *flagp, int excepts)
|
|
|
bca718 |
|
|
|
bca718 |
/* Get the current exceptions. */
|
|
|
bca718 |
_FPU_GETCW (temp);
|
|
|
bca718 |
- newexcepts = (excepts << FPC_DXC_SHIFT) | (excepts << FPC_FLAGS_SHIFT);
|
|
|
bca718 |
+ newexcepts = excepts << FPC_FLAGS_SHIFT;
|
|
|
bca718 |
+ if ((temp & FPC_NOT_FPU_EXCEPTION) == 0)
|
|
|
bca718 |
+ /* Bits 6, 7 of dxc-byte are zero,
|
|
|
bca718 |
+ thus bits 0-5 of dxc-byte correspond to the flag-bits.
|
|
|
bca718 |
+ Evaluate flags and last dxc-exception-code. */
|
|
|
bca718 |
+ newexcepts |= excepts << FPC_DXC_SHIFT;
|
|
|
bca718 |
+
|
|
|
bca718 |
*flagp = temp & newexcepts;
|
|
|
bca718 |
|
|
|
bca718 |
/* Success. */
|
|
|
bca718 |
diff --git a/sysdeps/s390/fpu/fpu_control.h b/sysdeps/s390/fpu/fpu_control.h
|
|
|
bca718 |
index af81bc2..dba904d 100644
|
|
|
bca718 |
--- a/sysdeps/s390/fpu/fpu_control.h
|
|
|
bca718 |
+++ b/sysdeps/s390/fpu/fpu_control.h
|
|
|
bca718 |
@@ -19,12 +19,12 @@
|
|
|
bca718 |
<http://www.gnu.org/licenses/>. */
|
|
|
bca718 |
|
|
|
bca718 |
#ifndef _FPU_CONTROL_H
|
|
|
bca718 |
-# define _FPU_CONTROL_H
|
|
|
bca718 |
+#define _FPU_CONTROL_H
|
|
|
bca718 |
|
|
|
bca718 |
-# include <features.h>
|
|
|
bca718 |
+#include <features.h>
|
|
|
bca718 |
|
|
|
bca718 |
/* These bits are reserved are not changed. */
|
|
|
bca718 |
-# define _FPU_RESERVED 0x070700FC
|
|
|
bca718 |
+#define _FPU_RESERVED 0x0707FFFC
|
|
|
bca718 |
|
|
|
bca718 |
/* The fdlibm code requires no interrupts for exceptions. Don't
|
|
|
bca718 |
change the rounding mode, it would break long double I/O! */
|
|
|
bca718 |
diff --git a/sysdeps/s390/fpu/fsetexcptflg.c b/sysdeps/s390/fpu/fsetexcptflg.c
|
|
|
bca718 |
index aada675..85c68e8 100644
|
|
|
bca718 |
--- a/sysdeps/s390/fpu/fsetexcptflg.c
|
|
|
bca718 |
+++ b/sysdeps/s390/fpu/fsetexcptflg.c
|
|
|
bca718 |
@@ -24,16 +24,25 @@
|
|
|
bca718 |
int
|
|
|
bca718 |
fesetexceptflag (const fexcept_t *flagp, int excepts)
|
|
|
bca718 |
{
|
|
|
bca718 |
- fexcept_t temp,newexcepts;
|
|
|
bca718 |
+ fexcept_t temp, newexcepts;
|
|
|
bca718 |
|
|
|
bca718 |
/* Get the current environment. We have to do this since we cannot
|
|
|
bca718 |
separately set the status word. */
|
|
|
bca718 |
_FPU_GETCW (temp);
|
|
|
bca718 |
/* Install the new exception bits in the Accrued Exception Byte. */
|
|
|
bca718 |
excepts = excepts & FE_ALL_EXCEPT;
|
|
|
bca718 |
- newexcepts = (excepts << FPC_DXC_SHIFT) | (excepts << FPC_FLAGS_SHIFT);
|
|
|
bca718 |
+ newexcepts = excepts << FPC_FLAGS_SHIFT;
|
|
|
bca718 |
temp &= ~newexcepts;
|
|
|
bca718 |
- temp |= *flagp & newexcepts;
|
|
|
bca718 |
+ if ((temp & FPC_NOT_FPU_EXCEPTION) == 0)
|
|
|
bca718 |
+ /* Bits 6, 7 of dxc-byte are zero,
|
|
|
bca718 |
+ thus bits 0-5 of dxc-byte correspond to the flag-bits.
|
|
|
bca718 |
+ Clear given exceptions in dxc-field. */
|
|
|
bca718 |
+ temp &= ~(excepts << FPC_DXC_SHIFT);
|
|
|
bca718 |
+
|
|
|
bca718 |
+ /* Integrate dxc-byte of flagp into flags. The dxc-byte of flagp contains
|
|
|
bca718 |
+ either an ieee-exception or 0 (see fegetexceptflag). */
|
|
|
bca718 |
+ temp |= (*flagp | ((*flagp >> FPC_DXC_SHIFT) << FPC_FLAGS_SHIFT))
|
|
|
bca718 |
+ & newexcepts;
|
|
|
bca718 |
|
|
|
bca718 |
/* Store the new status word (along with the rest of the environment.
|
|
|
bca718 |
Possibly new exceptions are set but they won't get executed unless
|
|
|
bca718 |
diff --git a/sysdeps/s390/fpu/ftestexcept.c b/sysdeps/s390/fpu/ftestexcept.c
|
|
|
bca718 |
index 5594994..c36aefd 100644
|
|
|
bca718 |
--- a/sysdeps/s390/fpu/ftestexcept.c
|
|
|
bca718 |
+++ b/sysdeps/s390/fpu/ftestexcept.c
|
|
|
bca718 |
@@ -23,11 +23,17 @@
|
|
|
bca718 |
int
|
|
|
bca718 |
fetestexcept (int excepts)
|
|
|
bca718 |
{
|
|
|
bca718 |
- fexcept_t temp;
|
|
|
bca718 |
+ fexcept_t temp, res;
|
|
|
bca718 |
|
|
|
bca718 |
/* Get current exceptions. */
|
|
|
bca718 |
_FPU_GETCW (temp);
|
|
|
bca718 |
- temp = (temp >> FPC_DXC_SHIFT) | (temp >> FPC_FLAGS_SHIFT);
|
|
|
bca718 |
- return temp & excepts & FE_ALL_EXCEPT;
|
|
|
bca718 |
+ res = temp >> FPC_FLAGS_SHIFT;
|
|
|
bca718 |
+ if ((temp & FPC_NOT_FPU_EXCEPTION) == 0)
|
|
|
bca718 |
+ /* Bits 6, 7 of dxc-byte are zero,
|
|
|
bca718 |
+ thus bits 0-5 of dxc-byte correspond to the flag-bits.
|
|
|
bca718 |
+ Evaluate flags and last dxc-exception-code. */
|
|
|
bca718 |
+ res |= temp >> FPC_DXC_SHIFT;
|
|
|
bca718 |
+
|
|
|
bca718 |
+ return res & excepts & FE_ALL_EXCEPT;
|
|
|
bca718 |
}
|
|
|
bca718 |
libm_hidden_def (fetestexcept)
|
|
|
bca718 |
--
|
|
|
bca718 |
2.3.0
|
|
|
bca718 |
|