|
@@ -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);
|
|
|
|