[RFC PATCH 10/11] x86,fpu: fix fpu_copy to deal with not-loaded fpu
From: riel
Date: Sun Jan 11 2015 - 17:08:05 EST
From: Rik van Riel <riel@xxxxxxxxxx>
It is possible to hit fpu_copy in eager fpu mode, but without
the current task's FPU context actually loaded into the CPU.
In that case, we should copy the FPU context from memory, not
save it from registers.
Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>
---
arch/x86/include/asm/fpu-internal.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
index 8546c0a..095dacc 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -594,7 +594,8 @@ static inline void fpu_free(struct fpu *fpu)
static inline void fpu_copy(struct task_struct *dst, struct task_struct *src)
{
- if (use_eager_fpu()) {
+ preempt_disable();
+ if (use_eager_fpu() && __thread_has_fpu(src)) {
memset(&dst->thread.fpu.state->xsave, 0, xstate_size);
__save_fpu(dst);
} else {
@@ -604,6 +605,7 @@ static inline void fpu_copy(struct task_struct *dst, struct task_struct *src)
unlazy_fpu(src);
memcpy(dfpu->state, sfpu->state, xstate_size);
}
+ preempt_enable();
}
static inline unsigned long
--
1.9.3
--
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/