X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fx86_64%2Fia32%2Ffpu32.c;h=2c8209a3605ad4864b1c3d8af3653493236efa9a;hb=567f20a20be06ad546b5962340c4be268462055b;hp=c6d0b02a1013b2940684701afd63e5bb998c798f;hpb=daddc0d38b3571bed170afa273a49a0eba090c1e;p=linux-2.6.git diff --git a/arch/x86_64/ia32/fpu32.c b/arch/x86_64/ia32/fpu32.c index c6d0b02a1..2c8209a36 100644 --- a/arch/x86_64/ia32/fpu32.c +++ b/arch/x86_64/ia32/fpu32.c @@ -2,7 +2,6 @@ * Copyright 2002 Andi Kleen, SuSE Labs. * FXSAVE<->i387 conversion support. Based on code by Gareth Hughes. * This is used for ptrace, signals and coredumps in 32bit emulation. - * $Id: fpu32.c,v 1.1 2002/03/21 14:16:32 ak Exp $ */ #include @@ -28,16 +27,17 @@ static inline unsigned short twd_i387_to_fxsr(unsigned short twd) static inline unsigned long twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave) { struct _fpxreg *st = NULL; + unsigned long tos = (fxsave->swd >> 11) & 7; unsigned long twd = (unsigned long) fxsave->twd; unsigned long tag; unsigned long ret = 0xffff0000; int i; -#define FPREG_ADDR(f, n) ((char *)&(f)->st_space + (n) * 16); +#define FPREG_ADDR(f, n) ((void *)&(f)->st_space + (n) * 16); for (i = 0 ; i < 8 ; i++) { if (twd & 0x1) { - st = (struct _fpxreg *) FPREG_ADDR( fxsave, i ); + st = FPREG_ADDR( fxsave, (i - tos) & 7 ); switch (st->exponent & 0x7fff) { case 0x7fff: @@ -72,15 +72,15 @@ static inline unsigned long twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave) static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave, - struct _fpstate_ia32 *buf) + struct _fpstate_ia32 __user *buf) { struct _fpxreg *to; - struct _fpreg *from; + struct _fpreg __user *from; int i; u32 v; int err = 0; -#define G(num,val) err |= __get_user(val, num + (u32 *)buf) +#define G(num,val) err |= __get_user(val, num + (u32 __user *)buf) G(0, fxsave->cwd); G(1, fxsave->swd); G(2, fxsave->twd); @@ -104,12 +104,12 @@ static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave, } -static inline int convert_fxsr_to_user(struct _fpstate_ia32 *buf, +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 *to; + struct _fpreg __user *to; struct _fpxreg *from; int i; u16 cs,ds; @@ -125,7 +125,7 @@ static inline int convert_fxsr_to_user(struct _fpstate_ia32 *buf, cs = regs->cs; } -#define P(num,val) err |= __put_user(val, num + (u32 *)buf) +#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)); @@ -147,7 +147,7 @@ static inline int convert_fxsr_to_user(struct _fpstate_ia32 *buf, return 0; } -int restore_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 *buf, int fsave) +int restore_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf, int fsave) { clear_fpu(tsk); if (!fsave) { @@ -156,13 +156,13 @@ int restore_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 *buf, int fs sizeof(struct i387_fxsave_struct))) return -1; tsk->thread.i387.fxsave.mxcsr &= mxcsr_feature_mask; - tsk->used_math = 1; + set_stopped_child_used_math(tsk); } return convert_fxsr_from_user(&tsk->thread.i387.fxsave, buf); } int save_i387_ia32(struct task_struct *tsk, - struct _fpstate_ia32 *buf, + struct _fpstate_ia32 __user *buf, struct pt_regs *regs, int fsave) {