Bug 207850 - ppc{32,64} signals corrupt $fpscr register
Summary: ppc{32,64} signals corrupt $fpscr register
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel
Version: 4.4
Hardware: ppc64
OS: Linux
medium
medium
Target Milestone: ---
: ---
Assignee: David Howells
QA Contact: Brian Brock
URL: http://www.kernel.org/git/?p=linux/ke...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-09-24 18:43 UTC by Jakub Jelinek
Modified: 2012-06-20 16:08 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-20 16:08:30 UTC
Target Upstream Version:
Embargoed:


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

Description Jakub Jelinek 2006-09-24 18:43:56 UTC
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 18:55:15 UTC
Testcase to make QE happy:

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

#define EXCEPTS (FE_DIVBYZERO | FE_INVALID | FE_INEXACT \
                 | FE_UNDERFLOW | FE_OVERFLOW)

void
alrm (int sig)
{
}

int
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 13:20:39 UTC
Created attachment 144902 [details]
Patch to fix FPSCR handling on ppc64 kernels

Comment 6 RHEL Program Management 2007-09-07 19:43:22 UTC
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 16:08:30 UTC
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.