lkml.org 
[lkml]   [1998]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: Intel floating-point initialization
    In 2.1.102, floating-point initialization in arch/i386/kernel/process.c,
    function copy_thread, has been changed to the following:

    /*
    * This tried to copy the FPU state, but I wonder whether we really
    * want this at all. It is probably nicer to just have a newly started
    * process start with a clean slate wrt the fpu. - Linus
    */
    #if 1
    current->used_math = 0;
    current->flags &= ~PF_USEDFPU;
    #else
    if (last_task_used_math == current)
    __asm__("clts ; fnsave %0 ; frstor %0":"=m" (p->tss.i387));
    #endif

    I beg to disagree with Linus. The parent process/thread may have set
    the FPU control word to a non-default value (i.e. change rounding
    modes, etc). The programmer legitimely expects the child process to
    inherit those settings (just like it inherits pretty much everything
    else from its parent).

    So, it is not correct to reinitialize the FPU in the new process.
    At least the FPU control word should be copied from the parent process.
    Let's just copy the whole FPU state as the original code meant to do,
    and fix it so that it works correctly on an SMP machine as well:

    #ifdef __SMP__
    if (current->flags & PF_USEDFPU)
    #else
    if (last_task_used_math == current)
    #endif
    __asm__("clts ; fnsave %0 ; frstor %0":"=m" (p->tss.i387));

    - Xavier Leroy

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu

    \
     
     \ /
      Last update: 2005-03-22 13:42    [W:0.020 / U:124.252 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site