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.
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; }
Created attachment 144902 [details] Patch to fix FPSCR handling on ppc64 kernels
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.
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.