diff -urN xmm-ref/arch/x86_64/kernel/i387.c xmm/arch/x86_64/kernel/i387.c --- xmm-ref/arch/x86_64/kernel/i387.c Fri Apr 26 08:13:53 2002 +++ xmm/arch/x86_64/kernel/i387.c Fri Apr 26 08:14:42 2002 @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -23,6 +24,21 @@ #include #include +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 @@ -31,10 +47,8 @@ */ void init_fpu(void) { - struct task_struct *me = current; - __asm__("fninit"); - load_mxcsr(0x1f80); - me->used_math = 1; + restore_fpu_checking(&empty_fpu_state.fxsave); + current->used_math = 1; } /* diff -urN xmm-ref/include/asm-x86_64/bugs.h xmm/include/asm-x86_64/bugs.h --- xmm-ref/include/asm-x86_64/bugs.h Fri Apr 26 08:13:54 2002 +++ xmm/include/asm-x86_64/bugs.h Fri Apr 26 08:14:42 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 xmm-ref/include/asm-x86_64/i387.h xmm/include/asm-x86_64/i387.h --- xmm-ref/include/asm-x86_64/i387.h Fri Apr 26 08:13:54 2002 +++ xmm/include/asm-x86_64/i387.h Fri Apr 26 08:14:18 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; }