Re: floating point problem

From: Richard B. Johnson (
Date: Thu Jul 05 2001 - 12:41:48 EST

On Thu, 5 Jul 2001 wrote:

> In Linux PPC, the MSR[FP] bit (that is floating point available bit) is off
> (atleast for non-SMP).

Yes, so the first FP instruction per process lets "lazy FPU" save/restore

> Due to this, whenever some floating point instruction is executed in 'user
> mode', it leads to a exception 'FPUnavailable'. The exception handler for
> this exception apart from setting the MSR[FP] bit, also sets the MSR[FE0]
> and MSR[FE1] bits. These bits basically enables the floating point
> exceptions so that if there are some floating point exception conditions
> encountered while exeuting a floating point instruction, an appropriate
> exception is raised.
> But whenever some floating point instruction is executed in 'kernel mode',
> 'FPUnavailabe' exception handler code does not set the 'MSR[FE0] and
> MSR[FE1]' bits.

The kernel is not supposed to use floating-point.


I think all you need is this:

 * Note FPU control only exists per process. Therefore, you have
 * to set up the FPU before you use it in any program.
#include <i386/fpu_control.h>

#define FPU_MASK (_FPU_MASK_IM |\
                  _FPU_MASK_DM |\
                  _FPU_MASK_ZM |\
                  _FPU_MASK_OM |\
                  _FPU_MASK_UM |\

void fpu()
    __setfpucw(_FPU_DEFAULT & ~FPU_MASK);

main() {
   double zero=0.0;
   double one=1.0;

   one /=zero;

Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

    I was going to compile a list of innovations that could be
    attributed to Microsoft. Once I realized that Ctrl-Alt-Del
    was handled in the BIOS, I found that there aren't any.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sat Jul 07 2001 - 21:00:16 EST