olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1268008-4.patch

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