660
* __math_state_restore assumes that cr0.TS is already clear and the
661
* fpu state is all ready for use. Used during context switch.
660
* This gets called with the process already owning the
661
* FPU state, and with CR0.TS cleared. It just needs to
662
* restore the FPU register state.
663
void __math_state_restore(void)
664
void __math_state_restore(struct task_struct *tsk)
665
struct thread_info *thread = current_thread_info();
666
struct task_struct *tsk = thread->task;
666
/* We need a safe address that is cheap to find and that is already
667
in L1. We've just brought in "tsk->thread.has_fpu", so use that */
668
#define safe_address (tsk->thread.has_fpu)
670
/* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
671
is pending. Clear the x87 state here by setting it to fixed
672
values. safe_address is a random variable that should be in L1 */
675
"emms\n\t" /* clear stack tags */
676
"fildl %P[addr]", /* set F?P to defined value */
677
X86_FEATURE_FXSAVE_LEAK,
678
[addr] "m" (safe_address));
669
681
* Paranoid restore. send a SIGSEGV if we fail to restore the state.
671
683
if (unlikely(restore_fpu_checking(tsk))) {
684
__thread_fpu_end(tsk);
673
685
force_sig(SIGSEGV, tsk);
677
thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
685
694
* Careful.. There are problems with IBM-designed IRQ13 behaviour.
686
695
* Don't touch unless you *really* know how it works.
688
* Must be called with kernel preemption disabled (in this case,
689
* local interrupts are disabled at the call-site in entry.S).
697
* Must be called with kernel preemption disabled (eg with local
698
* local interrupts as in the case of do_device_not_available).
691
asmlinkage void math_state_restore(void)
700
void math_state_restore(void)
693
struct thread_info *thread = current_thread_info();
694
struct task_struct *tsk = thread->task;
702
struct task_struct *tsk = current;
696
704
if (!tsk_used_math(tsk)) {
697
705
local_irq_enable();