* the 64bit user space sees a FXSAVE frame directly.
*/
-#include <linux/config.h>
#include <linux/sched.h>
#include <linux/init.h>
#include <asm/processor.h>
#include <asm/ptrace.h>
#include <asm/uaccess.h>
-unsigned int mxcsr_feature_mask = 0xffffffff;
+unsigned int mxcsr_feature_mask __read_mostly = 0xffffffff;
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);
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;
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 {
* 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)))
{
struct task_struct *tsk = current;
- if (!tsk->used_math)
+ if (!used_math())
return 0;
unlazy_fpu(tsk);
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)