565
* __math_state_restore assumes that cr0.TS is already clear and the
566
* fpu state is all ready for use. Used during context switch.
565
* This gets called with the process already owning the
566
* FPU state, and with CR0.TS cleared. It just needs to
567
* restore the FPU register state.
568
void __math_state_restore(void)
569
void __math_state_restore(struct task_struct *tsk)
570
struct thread_info *thread = current_thread_info();
571
struct task_struct *tsk = thread->task;
571
/* We need a safe address that is cheap to find and that is already
572
in L1. We've just brought in "tsk->thread.has_fpu", so use that */
573
#define safe_address (tsk->thread.has_fpu)
575
/* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
576
is pending. Clear the x87 state here by setting it to fixed
577
values. safe_address is a random variable that should be in L1 */
580
"emms\n\t" /* clear stack tags */
581
"fildl %P[addr]", /* set F?P to defined value */
582
X86_FEATURE_FXSAVE_LEAK,
583
[addr] "m" (safe_address));
574
586
* Paranoid restore. send a SIGSEGV if we fail to restore the state.
576
588
if (unlikely(restore_fpu_checking(tsk))) {
589
__thread_fpu_end(tsk);
578
590
force_sig(SIGSEGV, tsk);
582
thread->status |= TS_USEDFPU; /* So we fnsave on switch_to() */
590
599
* Careful.. There are problems with IBM-designed IRQ13 behaviour.
591
600
* Don't touch unless you *really* know how it works.
593
* Must be called with kernel preemption disabled (in this case,
594
* local interrupts are disabled at the call-site in entry.S).
602
* Must be called with kernel preemption disabled (eg with local
603
* local interrupts as in the case of do_device_not_available).
596
asmlinkage void math_state_restore(void)
605
void math_state_restore(void)
598
struct thread_info *thread = current_thread_info();
599
struct task_struct *tsk = thread->task;
607
struct task_struct *tsk = current;
601
609
if (!tsk_used_math(tsk)) {
602
610
local_irq_enable();