Bug 207850 - ppc{32,64} signals corrupt $fpscr register
ppc{32,64} signals corrupt $fpscr register
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
ppc64 Linux
medium Severity medium
: ---
: ---
Assigned To: David Howells
Brian Brock
Depends On:
  Show dependency treegraph
Reported: 2006-09-24 14:43 EDT by Jakub Jelinek
Modified: 2012-06-20 12:08 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-06-20 12:08:30 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to fix FPSCR handling on ppc64 kernels (1.71 KB, patch)
2007-01-05 08:20 EST, David Howells
no flags Details | Diff

  None (edit)
Description Jakub Jelinek 2006-09-24 14:43:56 EDT
Found this while debugging while test-fenv and a couple of other tests when using
power6 emulation break in beehive, while they work just fine on my FC5 G5.

The problem is that RHEL4 kernel clears $fpscr whenever the process is interrupted by a signal (the intended behavior was that the signal handler
starts with cleared $fpscr, but when it returns, saved $fpscr is restored).

This sounds quite nasty, programs which rely on FP exception reporting just
have to hope in RHEL4 that nothing interrupts them, otherwise they lose.

http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=cc657f53928997c65bf2409c45166c6ceee8d306 fixes this and should be rather
trivial to backport, all that is needed is to clear fpscr in current->thread
only when we have already copied the fp_regs and fpscr to the signal frame.
Comment 1 Jakub Jelinek 2006-09-24 14:55:15 EDT
Testcase to make QE happy:

#include <fenv.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

                 | FE_UNDERFLOW | FE_OVERFLOW)

alrm (int sig)

main (void)
  int r, ret = 0;
  struct sigaction sa;
  sa.sa_handler = alrm;
  sigemptyset (&sa.sa_mask);
  sa.sa_flags = 0;
  sigaction (SIGALRM, &sa, NULL);
  if ((r = fetestexcept (EXCEPTS)) != 0)
      printf ("fetestexcept 0x%x != 0\n", r);
      ret = 1;
  feraiseexcept (EXCEPTS);
  if ((r = fetestexcept (EXCEPTS)) != EXCEPTS)
      printf ("fetestexcept 0x%x != all\n", r);
      ret = 1;
  alarm (1);
  pause ();
  if ((r = fetestexcept (EXCEPTS)) != EXCEPTS)
      printf ("fetestexcept 0x%x != all\n", r);
      ret = 1;
  return ret;
Comment 3 David Howells 2007-01-05 08:20:39 EST
Created attachment 144902 [details]
Patch to fix FPSCR handling on ppc64 kernels
Comment 6 RHEL Product and Program Management 2007-09-07 15:43:22 EDT
This request was previously evaluated by Red Hat Product Management
for inclusion in the current Red Hat Enterprise Linux release, but
Red Hat was unable to resolve it in time.  This request will be
reviewed for a future Red Hat Enterprise Linux release.
Comment 7 Jiri Pallich 2012-06-20 12:08:30 EDT
Thank you for submitting this issue for consideration in Red Hat Enterprise Linux. The release for which you requested us to review is now End of Life. 
Please See https://access.redhat.com/support/policy/updates/errata/

If you would like Red Hat to re-consider your feature request for an active release, please re-open the request via appropriate support channels and provide additional supporting details about the importance of this issue.

Note You need to log in before you can comment on or make changes to this bug.