diff -urN x86-64-new/arch/x86_64/kernel/i387.c fpu/arch/x86_64/kernel/i387.c --- x86-64-new/arch/x86_64/kernel/i387.c Tue Apr 30 04:08:52 2002 +++ fpu/arch/x86_64/kernel/i387.c Tue Apr 30 04:14:07 2002 @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -25,6 +26,21 @@ extern int exception_trace; +static union i387_union empty_fpu_state; + +void __init boot_init_fpu(void) +{ + memset(&empty_fpu_state, 0, sizeof(union i387_union)); + + empty_fpu_state.fxsave.cwd = 0x37f; + empty_fpu_state.fxsave.mxcsr = 0x1f80; +} + +void load_empty_fpu(struct task_struct * tsk) +{ + memcpy(&tsk->thread.i387, &empty_fpu_state, sizeof(union i387_union)); +} + /* * The _current_ task is using the FPU for the first time * so initialize it and set the mxcsr to its default @@ -33,11 +49,8 @@ */ void init_fpu(void) { - struct task_struct *me = current; - memset(&me->thread.i387.fxsave, 0, sizeof(struct i387_fxsave_struct)); - me->thread.i387.fxsave.cwd = 0x37f; - me->thread.i387.fxsave.mxcsr = 0x1f80; - me->used_math = 1; + restore_fpu_checking(&empty_fpu_state.fxsave); + current->used_math = 1; } /* diff -urN x86-64-new/arch/x86_64/kernel/traps.c fpu/arch/x86_64/kernel/traps.c --- x86-64-new/arch/x86_64/kernel/traps.c Tue Apr 30 04:08:52 2002 +++ fpu/arch/x86_64/kernel/traps.c Tue Apr 30 04:14:53 2002 @@ -745,8 +745,9 @@ clts(); /* Allow maths ops (or we recurse) */ if (!me->used_math) - init_fpu(); - restore_fpu_checking(&me->thread.i387.fxsave); + init_fpu(); + else + restore_fpu_checking(&me->thread.i387.fxsave); me->flags |= PF_USEDFPU; /* So we fxsave on switch_to() */ } diff -urN x86-64-new/include/asm-x86_64/bugs.h fpu/include/asm-x86_64/bugs.h --- x86-64-new/include/asm-x86_64/bugs.h Tue Apr 30 04:08:24 2002 +++ fpu/include/asm-x86_64/bugs.h Tue Apr 30 04:13:36 2002 @@ -35,7 +35,10 @@ static void __init check_bugs(void) { + extern void __init __boot_init_fpu(void); + identify_cpu(&boot_cpu_data); + boot_init_fpu(); check_fpu(); #if !defined(CONFIG_SMP) printk("CPU: "); diff -urN x86-64-new/include/asm-x86_64/i387.h fpu/include/asm-x86_64/i387.h --- x86-64-new/include/asm-x86_64/i387.h Tue Apr 30 04:08:24 2002 +++ fpu/include/asm-x86_64/i387.h Tue Apr 30 04:13:36 2002 @@ -51,6 +51,7 @@ struct task_struct *tsk ); extern int set_fpregs( struct task_struct *tsk, struct user_i387_struct *buf ); +extern void load_empty_fpu(struct task_struct *); /* * FPU state for core dumps... @@ -137,13 +138,8 @@ static inline void empty_fpu(struct task_struct *child) { - if (!child->used_math) { - /* Simulate an empty FPU. */ - child->thread.i387.fxsave.cwd = 0x037f; - child->thread.i387.fxsave.swd = 0; - child->thread.i387.fxsave.twd = 0; - child->thread.i387.fxsave.mxcsr = 0x1f80; - } + if (!child->used_math) + load_empty_fpu(child); child->used_math = 1; }