Commit 45948d77 authored by Jan Beulich's avatar Jan Beulich Committed by Linus Torvalds

[PATCH] x86_64: save FPU context slightly later

Touching of the floating point state in a kernel debugger must be
NMI-safe, specifically math_state_restore() must be able to deal with
being called out of an NMI context. In order to do that reliably, the
context switch code must take care to not leave a window open where
the current task's TS_USEDFPU flag and CR0.TS could get out of sync.
Signed-off-by: default avatarJan Beulich <jbeulich@novell.com>
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2b514e74
...@@ -527,8 +527,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) ...@@ -527,8 +527,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
int cpu = smp_processor_id(); int cpu = smp_processor_id();
struct tss_struct *tss = &per_cpu(init_tss, cpu); struct tss_struct *tss = &per_cpu(init_tss, cpu);
unlazy_fpu(prev_p);
/* /*
* Reload esp0, LDT and the page table pointer: * Reload esp0, LDT and the page table pointer:
*/ */
...@@ -586,11 +584,14 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) ...@@ -586,11 +584,14 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
} }
/* /*
* Switch the PDA context. * Switch the PDA and FPU contexts.
*/ */
prev->userrsp = read_pda(oldrsp); prev->userrsp = read_pda(oldrsp);
write_pda(oldrsp, next->userrsp); write_pda(oldrsp, next->userrsp);
write_pda(pcurrent, next_p); write_pda(pcurrent, next_p);
/* This must be here to ensure both math_state_restore() and
kernel_fpu_begin() work consistently. */
unlazy_fpu(prev_p);
write_pda(kernelstack, write_pda(kernelstack,
task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET); task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment