lkml.org 
[lkml]   [2012]   [Aug]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 1/6] x86, fpu: drop_fpu() before restoring new state from sigframe
    Date
    No need to save the state with unlazy_fpu(), that is about to get overwritten
    by the state from the signal frame. Instead use drop_fpu() and continue
    to restore the new state.

    Also fold the stop_fpu_preload() into drop_fpu().

    Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
    ---
    arch/x86/include/asm/fpu-internal.h | 7 +------
    arch/x86/kernel/xsave.c | 8 +++-----
    2 files changed, 4 insertions(+), 11 deletions(-)

    diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
    index ba83a08..fe95ad0 100644
    --- a/arch/x86/include/asm/fpu-internal.h
    +++ b/arch/x86/include/asm/fpu-internal.h
    @@ -448,17 +448,12 @@ static inline void save_init_fpu(struct task_struct *tsk)
    preempt_enable();
    }

    -static inline void stop_fpu_preload(struct task_struct *tsk)
    -{
    - tsk->fpu_counter = 0;
    -}
    -
    static inline void drop_fpu(struct task_struct *tsk)
    {
    /*
    * Forget coprocessor state..
    */
    - stop_fpu_preload(tsk);
    + tsk->fpu_counter = 0;
    preempt_disable();
    __drop_fpu(tsk);
    preempt_enable();
    diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
    index a23d100..6cfc7d9 100644
    --- a/arch/x86/kernel/xsave.c
    +++ b/arch/x86/kernel/xsave.c
    @@ -381,16 +381,14 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
    struct xsave_struct *xsave = &tsk->thread.fpu.state->xsave;
    struct user_i387_ia32_struct env;

    - stop_fpu_preload(tsk);
    - unlazy_fpu(tsk);
    + drop_fpu(tsk);

    if (__copy_from_user(xsave, buf_fx, state_size) ||
    - __copy_from_user(&env, buf, sizeof(env))) {
    - drop_fpu(tsk);
    + __copy_from_user(&env, buf, sizeof(env)))
    return -1;
    - }

    sanitize_restored_xstate(tsk, &env, xstate_bv, fx_only);
    + set_used_math();
    } else {
    /*
    * For 64-bit frames and 32-bit fsave frames, restore the user
    --
    1.7.6.5


    \
     
     \ /
      Last update: 2012-08-25 00:01    [W:5.752 / U:0.328 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site