X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fx86_64%2Fia32%2Ffpu32.c;h=2c8209a3605ad4864b1c3d8af3653493236efa9a;hb=567f20a20be06ad546b5962340c4be268462055b;hp=c17168be018bec416b4554068e35250b117bb1b2;hpb=653a9213ae6f303790975dd836d95778aab070de;p=linux-2.6.git diff --git a/arch/x86_64/ia32/fpu32.c b/arch/x86_64/ia32/fpu32.c index c17168be0..2c8209a36 100644 --- a/arch/x86_64/ia32/fpu32.c +++ b/arch/x86_64/ia32/fpu32.c @@ -9,7 +9,6 @@ #include #include #include -#include static inline unsigned short twd_i387_to_fxsr(unsigned short twd) { @@ -25,8 +24,7 @@ static inline unsigned short twd_i387_to_fxsr(unsigned short twd) return tmp; } -static inline unsigned long -twd_fxsr_to_i387(const struct i387_fxsave_struct *fxsave) +static inline unsigned long twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave) { struct _fpxreg *st = NULL; unsigned long tos = (fxsave->swd >> 11) & 7; @@ -73,11 +71,16 @@ twd_fxsr_to_i387(const struct i387_fxsave_struct *fxsave) } -static inline void -convert_fxsr_env_from_i387(struct i387_fxsave_struct *fxsave, const u32 env[7]) +static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave, + struct _fpstate_ia32 __user *buf) { + struct _fpxreg *to; + struct _fpreg __user *from; + int i; u32 v; -#define G(num,val) val = env[num] + int err = 0; + +#define G(num,val) err |= __get_user(val, num + (u32 __user *)buf) G(0, fxsave->cwd); G(1, fxsave->swd); G(2, fxsave->twd); @@ -88,21 +91,9 @@ convert_fxsr_env_from_i387(struct i387_fxsave_struct *fxsave, const u32 env[7]) G(5, fxsave->rdp); /* 6: ds ignored */ #undef G -} - -static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave, - struct _fpstate_ia32 __user *buf) -{ - u32 env[7]; - struct _fpxreg *to; - struct _fpreg __user *from; - int i; - - if (__copy_from_user(env, buf, sizeof(env))) + if (err) return -1; - convert_fxsr_env_from_i387(fxsave, env); - to = (struct _fpxreg *)&fxsave->st_space[0]; from = &buf->_st[0]; for (i = 0 ; i < 8 ; i++, to++, from++) { @@ -113,11 +104,16 @@ static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave, } -static inline void -convert_fxsr_env_to_i387(struct task_struct *tsk, struct pt_regs *regs, - u32 env[7], const struct i387_fxsave_struct *fxsave) +static inline int convert_fxsr_to_user(struct _fpstate_ia32 __user *buf, + struct i387_fxsave_struct *fxsave, + struct pt_regs *regs, + struct task_struct *tsk) { + struct _fpreg __user *to; + struct _fpxreg *from; + int i; u16 cs,ds; + int err = 0; if (tsk == current) { /* should be actually ds/cs at fpu exception time, @@ -129,7 +125,7 @@ convert_fxsr_env_to_i387(struct task_struct *tsk, struct pt_regs *regs, cs = regs->cs; } -#define P(num,val) env[num] = val +#define P(num,val) err |= __put_user(val, num + (u32 __user *)buf) P(0, (u32)fxsave->cwd | 0xffff0000); P(1, (u32)fxsave->swd | 0xffff0000); P(2, twd_fxsr_to_i387(fxsave)); @@ -138,21 +134,8 @@ convert_fxsr_env_to_i387(struct task_struct *tsk, struct pt_regs *regs, P(5, fxsave->rdp); P(6, 0xffff0000 | ds); #undef P -} - -static inline int convert_fxsr_to_user(struct _fpstate_ia32 __user *buf, - struct i387_fxsave_struct *fxsave, - struct pt_regs *regs, - struct task_struct *tsk) -{ - struct _fpreg __user *to; - struct _fpxreg *from; - int i; - u32 env[7]; - - convert_fxsr_env_to_i387(tsk, regs, env, fxsave); - if (__copy_to_user(buf, env, sizeof(env))) + if (err) return -1; to = &buf->_st[0]; @@ -198,38 +181,3 @@ int save_i387_ia32(struct task_struct *tsk, sizeof(struct i387_fxsave_struct)); return err ? -1 : 1; } - -int get_fpregs32(struct user_i387_ia32_struct *buf, struct task_struct *tsk) -{ - struct pt_regs *regs = ((struct pt_regs *)tsk->thread.rsp0) - 1; - struct _fpreg *to; - const struct _fpxreg *from; - unsigned int i; - - convert_fxsr_env_to_i387(tsk, regs, - (u32 *) buf, &tsk->thread.i387.fxsave); - - to = (struct _fpreg *) buf->st_space; - from = (const struct _fpxreg *) &tsk->thread.i387.fxsave.st_space[0]; - for (i = 0; i < 8; i++, to++, from++) - *to = *(const struct _fpreg *) from; - - return 0; -} - -int -set_fpregs32(struct task_struct *tsk, const struct user_i387_ia32_struct *buf) -{ - struct _fpxreg *to; - const struct _fpreg *from; - unsigned int i; - - convert_fxsr_env_from_i387(&tsk->thread.i387.fxsave, (u32 *) buf); - - to = (struct _fpxreg *) &tsk->thread.i387.fxsave.st_space[0]; - from = (const struct _fpreg *) buf->st_space; - for (i = 0; i < 8; i++, to++, from++) - *(struct _fpreg *) to = *from; - - return 0; -}