X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fx86_64%2Fkernel%2Fi387.c;h=1d58c13bc6bc0d16d0b859846e3549c7131c5d61;hb=97bf2856c6014879bd04983a3e9dfcdac1e7fe85;hp=1aa4deb43de17f2fe75951bcd6f8263fb9e7f0f9;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/arch/x86_64/kernel/i387.c b/arch/x86_64/kernel/i387.c index 1aa4deb43..1d58c13bc 100644 --- a/arch/x86_64/kernel/i387.c +++ b/arch/x86_64/kernel/i387.c @@ -14,7 +14,6 @@ * the 64bit user space sees a FXSAVE frame directly. */ -#include #include #include #include @@ -24,7 +23,7 @@ #include #include -unsigned int mxcsr_feature_mask = 0xffffffff; +unsigned int mxcsr_feature_mask __read_mostly = 0xffffffff; void mxcsr_feature_mask_init(void) { @@ -42,7 +41,7 @@ void mxcsr_feature_mask_init(void) * Called at bootup to set up the initial FPU state that is later cloned * into all processes. */ -void __init fpu_init(void) +void __cpuinit fpu_init(void) { unsigned long oldcr0 = read_cr0(); extern void __bad_fxsave_alignment(void); @@ -57,12 +56,12 @@ void __init fpu_init(void) mxcsr_feature_mask_init(); /* clean state in init */ current_thread_info()->status = 0; - current->used_math = 0; + clear_used_math(); } void init_fpu(struct task_struct *child) { - if (child->used_math) { + if (tsk_used_math(child)) { if (child == current) unlazy_fpu(child); return; @@ -70,32 +69,30 @@ void init_fpu(struct task_struct *child) memset(&child->thread.i387.fxsave, 0, sizeof(struct i387_fxsave_struct)); child->thread.i387.fxsave.cwd = 0x37f; child->thread.i387.fxsave.mxcsr = 0x1f80; - child->used_math = 1; + /* only the device not available exception or ptrace can call init_fpu */ + set_stopped_child_used_math(child); } /* * Signal frame handlers. */ -int save_i387(struct _fpstate *buf) +int save_i387(struct _fpstate __user *buf) { struct task_struct *tsk = current; int err = 0; - { - extern void bad_user_i387_struct(void); - if (sizeof(struct user_i387_struct) != sizeof(tsk->thread.i387.fxsave)) - bad_user_i387_struct(); - } + BUILD_BUG_ON(sizeof(struct user_i387_struct) != + sizeof(tsk->thread.i387.fxsave)); if ((unsigned long)buf % 16) printk("save_i387: bad fpstate %p\n",buf); - if (!tsk->used_math) + if (!used_math()) return 0; - tsk->used_math = 0; /* trigger finit */ - if (tsk->thread_info->status & TS_USEDFPU) { - err = save_i387_checking((struct i387_fxsave_struct *)buf); + clear_used_math(); /* trigger finit */ + if (task_thread_info(tsk)->status & TS_USEDFPU) { + err = save_i387_checking((struct i387_fxsave_struct __user *)buf); if (err) return err; stts(); } else { @@ -110,14 +107,14 @@ int save_i387(struct _fpstate *buf) * ptrace request handlers. */ -int get_fpregs(struct user_i387_struct *buf, struct task_struct *tsk) +int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *tsk) { init_fpu(tsk); - return __copy_to_user((void *)buf, &tsk->thread.i387.fxsave, + return __copy_to_user(buf, &tsk->thread.i387.fxsave, sizeof(struct user_i387_struct)) ? -EFAULT : 0; } -int set_fpregs(struct task_struct *tsk, struct user_i387_struct *buf) +int set_fpregs(struct task_struct *tsk, struct user_i387_struct __user *buf) { if (__copy_from_user(&tsk->thread.i387.fxsave, buf, sizeof(struct user_i387_struct))) @@ -133,7 +130,7 @@ int dump_fpu( struct pt_regs *regs, struct user_i387_struct *fpu ) { struct task_struct *tsk = current; - if (!tsk->used_math) + if (!used_math()) return 0; unlazy_fpu(tsk); @@ -143,7 +140,7 @@ int dump_fpu( struct pt_regs *regs, struct user_i387_struct *fpu ) int dump_task_fpu(struct task_struct *tsk, struct user_i387_struct *fpu) { - int fpvalid = tsk->used_math; + int fpvalid = !!tsk_used_math(tsk); if (fpvalid) { if (tsk == current)