tsk->thread.i387.fsave.twd = 0xffffffffu;
tsk->thread.i387.fsave.fos = 0xffff0000u;
}
- tsk->used_math = 1;
+ /* only the device not available exception or ptrace can call init_fpu */
+ set_stopped_child_used_math(tsk);
}
/*
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 = 0xffff0000u;
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:
int save_i387( struct _fpstate __user *buf )
{
- if ( !current->used_math )
+ if ( !used_math() )
return 0;
/* This will cause a "finit" to be triggered by the next
* attempted FPU operation by the 'current' process.
*/
- current->used_math = 0;
+ clear_used_math();
if ( HAVE_HWFP ) {
if ( cpu_has_fxsr ) {
} else {
err = restore_i387_soft( ¤t->thread.i387.soft, buf );
}
- current->used_math = 1;
+ set_used_math();
return err;
}
int fpvalid;
struct task_struct *tsk = current;
- fpvalid = tsk->used_math;
+ fpvalid = !!used_math();
if ( fpvalid ) {
unlazy_fpu( tsk );
if ( cpu_has_fxsr ) {
return fpvalid;
}
-int dump_extended_fpu( struct pt_regs *regs, struct user_fxsr_struct *fpu )
-{
- int fpvalid;
- struct task_struct *tsk = current;
-
- fpvalid = tsk->used_math && cpu_has_fxsr;
- if ( fpvalid ) {
- unlazy_fpu( tsk );
- memcpy( fpu, &tsk->thread.i387.fxsave,
- sizeof(struct user_fxsr_struct) );
- }
-
- return fpvalid;
-}
-
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)
int dump_task_extended_fpu(struct task_struct *tsk, struct user_fxsr_struct *fpu)
{
- int fpvalid = tsk->used_math && cpu_has_fxsr;
+ int fpvalid = tsk_used_math(tsk) && cpu_has_fxsr;
if (fpvalid) {
if (tsk == current)