]> git.hungrycats.org Git - linux/commitdiff
[PATCH] x86_64: Fix FPU corruption
authorAndi Kleen <ak@suse.de>
Sat, 11 Nov 2006 03:16:36 +0000 (04:16 +0100)
committerChris Wright <chrisw@sous-sol.org>
Sun, 19 Nov 2006 03:28:03 +0000 (19:28 -0800)
This reverts an earlier patch that was found to cause FPU
state corruption. I think the corruption happens because
unlazy_fpu() can cause FPU exceptions and when it happens
after the current switch some processing would affect
the state in the wrong process.

Thanks to  Douglas Crosher and Tom Hughes for testing.

Cc: jbeulich@novell.com
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
arch/x86_64/kernel/process.c

index bb6745d13b8ff5f3bb1b59d32e50716d910c7c39..f127e23174fcd60fbb7ca020719724e8bbd14311 100644 (file)
@@ -571,6 +571,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
                prev->gsindex = gsindex;
        }
 
+       /* Must be after DS reload */
+       unlazy_fpu(prev_p);
+
        /* 
         * Switch the PDA and FPU contexts.
         */
@@ -578,10 +581,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
        write_pda(oldrsp, next->userrsp); 
        write_pda(pcurrent, next_p); 
 
-       /* This must be here to ensure both math_state_restore() and
-          kernel_fpu_begin() work consistently. 
-          And the AMD workaround requires it to be after DS reload. */
-       unlazy_fpu(prev_p);
        write_pda(kernelstack,
                  task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET);