Commit e9625917 authored by Suresh Siddha's avatar Suresh Siddha Committed by H. Peter Anvin
Browse files

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: default avatarSuresh 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: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 72a671ce
Loading
Loading
Loading
Loading
+1 −6
Original line number Original line Diff line number Diff line
@@ -448,17 +448,12 @@ static inline void save_init_fpu(struct task_struct *tsk)
	preempt_enable();
	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)
static inline void drop_fpu(struct task_struct *tsk)
{
{
	/*
	/*
	 * Forget coprocessor state..
	 * Forget coprocessor state..
	 */
	 */
	stop_fpu_preload(tsk);
	tsk->fpu_counter = 0;
	preempt_disable();
	preempt_disable();
	__drop_fpu(tsk);
	__drop_fpu(tsk);
	preempt_enable();
	preempt_enable();
+3 −5
Original line number Original line Diff line number Diff line
@@ -382,16 +382,14 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
		struct xsave_struct *xsave = &tsk->thread.fpu.state->xsave;
		struct xsave_struct *xsave = &tsk->thread.fpu.state->xsave;
		struct user_i387_ia32_struct env;
		struct user_i387_ia32_struct env;


		stop_fpu_preload(tsk);
		drop_fpu(tsk);
		unlazy_fpu(tsk);


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


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