Skip to content

Commit e962591

Browse files
Suresh SiddhaH. Peter Anvin
authored andcommitted
x86, fpu: drop_fpu() before restoring new state from sigframe
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> Link: http://lkml.kernel.org/r/1345842782-24175-2-git-send-email-suresh.b.siddha@intel.com Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
1 parent 72a671c commit e962591

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

arch/x86/include/asm/fpu-internal.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,12 @@ static inline void save_init_fpu(struct task_struct *tsk)
448448
preempt_enable();
449449
}
450450

451-
static inline void stop_fpu_preload(struct task_struct *tsk)
452-
{
453-
tsk->fpu_counter = 0;
454-
}
455-
456451
static inline void drop_fpu(struct task_struct *tsk)
457452
{
458453
/*
459454
* Forget coprocessor state..
460455
*/
461-
stop_fpu_preload(tsk);
456+
tsk->fpu_counter = 0;
462457
preempt_disable();
463458
__drop_fpu(tsk);
464459
preempt_enable();

arch/x86/kernel/xsave.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,16 +382,14 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
382382
struct xsave_struct *xsave = &tsk->thread.fpu.state->xsave;
383383
struct user_i387_ia32_struct env;
384384

385-
stop_fpu_preload(tsk);
386-
unlazy_fpu(tsk);
385+
drop_fpu(tsk);
387386

388387
if (__copy_from_user(xsave, buf_fx, state_size) ||
389-
__copy_from_user(&env, buf, sizeof(env))) {
390-
drop_fpu(tsk);
388+
__copy_from_user(&env, buf, sizeof(env)))
391389
return -1;
392-
}
393390

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

0 commit comments

Comments
 (0)