diff options
Diffstat (limited to 'arch/x86/kernel/i387.c')
| -rw-r--r-- | arch/x86/kernel/i387.c | 17 | 
1 files changed, 13 insertions, 4 deletions
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c index 5d576ab3440..d5dd8081441 100644 --- a/arch/x86/kernel/i387.c +++ b/arch/x86/kernel/i387.c @@ -86,10 +86,19 @@ EXPORT_SYMBOL(__kernel_fpu_begin);  void __kernel_fpu_end(void)  { -	if (use_eager_fpu()) -		math_state_restore(); -	else +	if (use_eager_fpu()) { +		/* +		 * For eager fpu, most the time, tsk_used_math() is true. +		 * Restore the user math as we are done with the kernel usage. +		 * At few instances during thread exit, signal handling etc, +		 * tsk_used_math() is false. Those few places will take proper +		 * actions, so we don't need to restore the math here. +		 */ +		if (likely(tsk_used_math(current))) +			math_state_restore(); +	} else {  		stts(); +	}  }  EXPORT_SYMBOL(__kernel_fpu_end); @@ -100,7 +109,7 @@ void unlazy_fpu(struct task_struct *tsk)  		__save_init_fpu(tsk);  		__thread_fpu_end(tsk);  	} else -		tsk->fpu_counter = 0; +		tsk->thread.fpu_counter = 0;  	preempt_enable();  }  EXPORT_SYMBOL(unlazy_fpu);  | 
