lkml.org 
[lkml]   [2015]   [Jan]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 3/3] x86, fpu: kill save_init_fpu(), change math_error() to use unlazy_fpu()
    math_error() calls save_init_fpu() after conditional_sti(), this means
    that the caller can be preempted. If !use_eager_fpu() we can hit the
    WARN_ON_ONCE(!__thread_has_fpu(tsk)) and/or save the wrong FPU state.

    Change math_error() to use unlazy_fpu() and kill save_init_fpu().

    Signed-off-by: Oleg Nesterov <oleg@redhat.com>
    ---
    arch/x86/include/asm/fpu-internal.h | 18 ------------------
    arch/x86/kernel/traps.c | 2 +-
    2 files changed, 1 insertions(+), 19 deletions(-)

    diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
    index e97622f..02f2e08 100644
    --- a/arch/x86/include/asm/fpu-internal.h
    +++ b/arch/x86/include/asm/fpu-internal.h
    @@ -518,24 +518,6 @@ static inline void __save_fpu(struct task_struct *tsk)
    }

    /*
    - * These disable preemption on their own and are safe
    - */
    -static inline void save_init_fpu(struct task_struct *tsk)
    -{
    - WARN_ON_ONCE(!__thread_has_fpu(tsk));
    -
    - if (use_eager_fpu()) {
    - __save_fpu(tsk);
    - return;
    - }
    -
    - preempt_disable();
    - __save_init_fpu(tsk);
    - __thread_fpu_end(tsk);
    - preempt_enable();
    -}
    -
    -/*
    * i387 state interaction
    */
    static inline unsigned short get_fpu_cwd(struct task_struct *tsk)
    diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
    index fb4cb6a..51c4658 100644
    --- a/arch/x86/kernel/traps.c
    +++ b/arch/x86/kernel/traps.c
    @@ -663,7 +663,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)
    /*
    * Save the info for the exception handler and clear the error.
    */
    - save_init_fpu(task);
    + unlazy_fpu(task);
    task->thread.trap_nr = trapnr;
    task->thread.error_code = error_code;
    info.si_signo = SIGFPE;
    --
    1.5.5.1



    \
     
     \ /
      Last update: 2015-01-29 22:21    [W:4.061 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site