[patch 16/30] x86_64: Fix FPU corruption

From: Chris Wright
Date: Wed Nov 15 2006 - 21:47:24 EST


-stable review patch. If anyone has any objections, please let us know.
------------------

From: Andi Kleen <ak@xxxxxxx>

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@xxxxxxxxxx
Signed-off-by: Andi Kleen <ak@xxxxxxx>
Signed-off-by: Chris Wright <chrisw@xxxxxxxxxxxx>
---
arch/x86_64/kernel/process.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

--- linux-2.6.18.2.orig/arch/x86_64/kernel/process.c
+++ linux-2.6.18.2/arch/x86_64/kernel/process.c
@@ -571,6 +571,9 @@ __switch_to(struct task_struct *prev_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,
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);


--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/