Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
34bf22f4
Commit
34bf22f4
authored
Apr 08, 2003
by
Linus Torvalds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Annotate x87 user space access functions with proper type attributes.
parent
1eaa7f24
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
37 deletions
+37
-37
arch/i386/kernel/i387.c
arch/i386/kernel/i387.c
+35
-35
include/asm-i386/math_emu.h
include/asm-i386/math_emu.h
+2
-2
No files found.
arch/i386/kernel/i387.c
View file @
34bf22f4
...
...
@@ -40,10 +40,10 @@ void init_fpu(struct task_struct *tsk)
tsk
->
thread
.
i387
.
fxsave
.
mxcsr
=
0x1f80
;
}
else
{
memset
(
&
tsk
->
thread
.
i387
.
fsave
,
0
,
sizeof
(
struct
i387_fsave_struct
));
tsk
->
thread
.
i387
.
fsave
.
cwd
=
0xffff037f
;
tsk
->
thread
.
i387
.
fsave
.
swd
=
0xffff0000
;
tsk
->
thread
.
i387
.
fsave
.
twd
=
0xffffffff
;
tsk
->
thread
.
i387
.
fsave
.
fos
=
0xffff0000
;
tsk
->
thread
.
i387
.
fsave
.
cwd
=
0xffff037f
u
;
tsk
->
thread
.
i387
.
fsave
.
swd
=
0xffff0000
u
;
tsk
->
thread
.
i387
.
fsave
.
twd
=
0xffffffff
u
;
tsk
->
thread
.
i387
.
fsave
.
fos
=
0xffff0000
u
;
}
tsk
->
used_math
=
1
;
}
...
...
@@ -98,7 +98,7 @@ static inline unsigned long twd_fxsr_to_i387( struct i387_fxsave_struct *fxsave
struct
_fpxreg
*
st
=
NULL
;
unsigned
long
twd
=
(
unsigned
long
)
fxsave
->
twd
;
unsigned
long
tag
;
unsigned
long
ret
=
0xffff0000
;
unsigned
long
ret
=
0xffff0000
u
;
int
i
;
#define FPREG_ADDR(f, n) ((char *)&(f)->st_space + (n) * 16);
...
...
@@ -183,7 +183,7 @@ void set_fpu_cwd( struct task_struct *tsk, unsigned short cwd )
if
(
cpu_has_fxsr
)
{
tsk
->
thread
.
i387
.
fxsave
.
cwd
=
cwd
;
}
else
{
tsk
->
thread
.
i387
.
fsave
.
cwd
=
((
long
)
cwd
|
0xffff0000
);
tsk
->
thread
.
i387
.
fsave
.
cwd
=
((
long
)
cwd
|
0xffff0000
u
);
}
}
...
...
@@ -192,7 +192,7 @@ void set_fpu_swd( struct task_struct *tsk, unsigned short swd )
if
(
cpu_has_fxsr
)
{
tsk
->
thread
.
i387
.
fxsave
.
swd
=
swd
;
}
else
{
tsk
->
thread
.
i387
.
fsave
.
swd
=
((
long
)
swd
|
0xffff0000
);
tsk
->
thread
.
i387
.
fsave
.
swd
=
((
long
)
swd
|
0xffff0000
u
);
}
}
...
...
@@ -201,7 +201,7 @@ void set_fpu_twd( struct task_struct *tsk, unsigned short twd )
if
(
cpu_has_fxsr
)
{
tsk
->
thread
.
i387
.
fxsave
.
twd
=
twd_i387_to_fxsr
(
twd
);
}
else
{
tsk
->
thread
.
i387
.
fsave
.
twd
=
((
long
)
twd
|
0xffff0000
);
tsk
->
thread
.
i387
.
fsave
.
twd
=
((
long
)
twd
|
0xffff0000
u
);
}
}
...
...
@@ -216,16 +216,16 @@ void set_fpu_mxcsr( struct task_struct *tsk, unsigned short mxcsr )
* FXSR floating point environment conversions.
*/
static
int
convert_fxsr_to_user
(
struct
_fpstate
*
buf
,
static
int
convert_fxsr_to_user
(
struct
_fpstate
__user
*
buf
,
struct
i387_fxsave_struct
*
fxsave
)
{
unsigned
long
env
[
7
];
struct
_fpreg
*
to
;
struct
_fpreg
__user
*
to
;
struct
_fpxreg
*
from
;
int
i
;
env
[
0
]
=
(
unsigned
long
)
fxsave
->
cwd
|
0xffff0000
;
env
[
1
]
=
(
unsigned
long
)
fxsave
->
swd
|
0xffff0000
;
env
[
0
]
=
(
unsigned
long
)
fxsave
->
cwd
|
0xffff0000
ul
;
env
[
1
]
=
(
unsigned
long
)
fxsave
->
swd
|
0xffff0000
ul
;
env
[
2
]
=
twd_fxsr_to_i387
(
fxsave
);
env
[
3
]
=
fxsave
->
fip
;
env
[
4
]
=
fxsave
->
fcs
|
((
unsigned
long
)
fxsave
->
fop
<<
16
);
...
...
@@ -250,11 +250,11 @@ static int convert_fxsr_to_user( struct _fpstate *buf,
}
static
int
convert_fxsr_from_user
(
struct
i387_fxsave_struct
*
fxsave
,
struct
_fpstate
*
buf
)
struct
_fpstate
__user
*
buf
)
{
unsigned
long
env
[
7
];
struct
_fpxreg
*
to
;
struct
_fpreg
*
from
;
struct
_fpreg
__user
*
from
;
int
i
;
if
(
__copy_from_user
(
env
,
buf
,
7
*
sizeof
(
long
)
)
)
...
...
@@ -264,7 +264,7 @@ static int convert_fxsr_from_user( struct i387_fxsave_struct *fxsave,
fxsave
->
swd
=
(
unsigned
short
)(
env
[
1
]
&
0xffff
);
fxsave
->
twd
=
twd_i387_to_fxsr
((
unsigned
short
)(
env
[
2
]
&
0xffff
));
fxsave
->
fip
=
env
[
3
];
fxsave
->
fop
=
(
unsigned
short
)((
env
[
4
]
&
0xffff0000
)
>>
16
);
fxsave
->
fop
=
(
unsigned
short
)((
env
[
4
]
&
0xffff0000
ul
)
>>
16
);
fxsave
->
fcs
=
(
env
[
4
]
&
0xffff
);
fxsave
->
foo
=
env
[
5
];
fxsave
->
fos
=
env
[
6
];
...
...
@@ -287,7 +287,7 @@ static int convert_fxsr_from_user( struct i387_fxsave_struct *fxsave,
* Signal frame handlers.
*/
static
inline
int
save_i387_fsave
(
struct
_fpstate
*
buf
)
static
inline
int
save_i387_fsave
(
struct
_fpstate
__user
*
buf
)
{
struct
task_struct
*
tsk
=
current
;
...
...
@@ -299,7 +299,7 @@ static inline int save_i387_fsave( struct _fpstate *buf )
return
1
;
}
static
int
save_i387_fxsave
(
struct
_fpstate
*
buf
)
static
int
save_i387_fxsave
(
struct
_fpstate
__user
*
buf
)
{
struct
task_struct
*
tsk
=
current
;
int
err
=
0
;
...
...
@@ -320,7 +320,7 @@ static int save_i387_fxsave( struct _fpstate *buf )
return
1
;
}
int
save_i387
(
struct
_fpstate
*
buf
)
int
save_i387
(
struct
_fpstate
__user
*
buf
)
{
if
(
!
current
->
used_math
)
return
0
;
...
...
@@ -341,7 +341,7 @@ int save_i387( struct _fpstate *buf )
}
}
static
inline
int
restore_i387_fsave
(
struct
_fpstate
*
buf
)
static
inline
int
restore_i387_fsave
(
struct
_fpstate
__user
*
buf
)
{
struct
task_struct
*
tsk
=
current
;
clear_fpu
(
tsk
);
...
...
@@ -349,7 +349,7 @@ static inline int restore_i387_fsave( struct _fpstate *buf )
sizeof
(
struct
i387_fsave_struct
)
);
}
static
int
restore_i387_fxsave
(
struct
_fpstate
*
buf
)
static
int
restore_i387_fxsave
(
struct
_fpstate
__user
*
buf
)
{
int
err
;
struct
task_struct
*
tsk
=
current
;
...
...
@@ -361,7 +361,7 @@ static int restore_i387_fxsave( struct _fpstate *buf )
return
err
?
1
:
convert_fxsr_from_user
(
&
tsk
->
thread
.
i387
.
fxsave
,
buf
);
}
int
restore_i387
(
struct
_fpstate
*
buf
)
int
restore_i387
(
struct
_fpstate
__user
*
buf
)
{
int
err
;
...
...
@@ -382,21 +382,21 @@ int restore_i387( struct _fpstate *buf )
* ptrace request handlers.
*/
static
inline
int
get_fpregs_fsave
(
struct
user_i387_struct
*
buf
,
static
inline
int
get_fpregs_fsave
(
struct
user_i387_struct
__user
*
buf
,
struct
task_struct
*
tsk
)
{
return
__copy_to_user
(
buf
,
&
tsk
->
thread
.
i387
.
fsave
,
sizeof
(
struct
user_i387_struct
)
);
}
static
inline
int
get_fpregs_fxsave
(
struct
user_i387_struct
*
buf
,
static
inline
int
get_fpregs_fxsave
(
struct
user_i387_struct
__user
*
buf
,
struct
task_struct
*
tsk
)
{
return
convert_fxsr_to_user
(
(
struct
_fpstate
*
)
buf
,
return
convert_fxsr_to_user
(
(
struct
_fpstate
__user
*
)
buf
,
&
tsk
->
thread
.
i387
.
fxsave
);
}
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
)
{
if
(
HAVE_HWFP
)
{
if
(
cpu_has_fxsr
)
{
...
...
@@ -406,25 +406,25 @@ int get_fpregs( struct user_i387_struct *buf, struct task_struct *tsk )
}
}
else
{
return
save_i387_soft
(
&
tsk
->
thread
.
i387
.
soft
,
(
struct
_fpstate
*
)
buf
);
(
struct
_fpstate
__user
*
)
buf
);
}
}
static
inline
int
set_fpregs_fsave
(
struct
task_struct
*
tsk
,
struct
user_i387_struct
*
buf
)
struct
user_i387_struct
__user
*
buf
)
{
return
__copy_from_user
(
&
tsk
->
thread
.
i387
.
fsave
,
buf
,
sizeof
(
struct
user_i387_struct
)
);
}
static
inline
int
set_fpregs_fxsave
(
struct
task_struct
*
tsk
,
struct
user_i387_struct
*
buf
)
struct
user_i387_struct
__user
*
buf
)
{
return
convert_fxsr_from_user
(
&
tsk
->
thread
.
i387
.
fxsave
,
(
struct
_fpstate
*
)
buf
);
(
struct
_fpstate
__user
*
)
buf
);
}
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
(
HAVE_HWFP
)
{
if
(
cpu_has_fxsr
)
{
...
...
@@ -434,14 +434,14 @@ int set_fpregs( struct task_struct *tsk, struct user_i387_struct *buf )
}
}
else
{
return
restore_i387_soft
(
&
tsk
->
thread
.
i387
.
soft
,
(
struct
_fpstate
*
)
buf
);
(
struct
_fpstate
__user
*
)
buf
);
}
}
int
get_fpxregs
(
struct
user_fxsr_struct
*
buf
,
struct
task_struct
*
tsk
)
int
get_fpxregs
(
struct
user_fxsr_struct
__user
*
buf
,
struct
task_struct
*
tsk
)
{
if
(
cpu_has_fxsr
)
{
if
(
__copy_to_user
(
(
void
*
)
buf
,
&
tsk
->
thread
.
i387
.
fxsave
,
if
(
__copy_to_user
(
buf
,
&
tsk
->
thread
.
i387
.
fxsave
,
sizeof
(
struct
user_fxsr_struct
)
))
return
-
EFAULT
;
return
0
;
...
...
@@ -450,10 +450,10 @@ int get_fpxregs( struct user_fxsr_struct *buf, struct task_struct *tsk )
}
}
int
set_fpxregs
(
struct
task_struct
*
tsk
,
struct
user_fxsr_struct
*
buf
)
int
set_fpxregs
(
struct
task_struct
*
tsk
,
struct
user_fxsr_struct
__user
*
buf
)
{
if
(
cpu_has_fxsr
)
{
__copy_from_user
(
&
tsk
->
thread
.
i387
.
fxsave
,
(
void
*
)
buf
,
__copy_from_user
(
&
tsk
->
thread
.
i387
.
fxsave
,
buf
,
sizeof
(
struct
user_fxsr_struct
)
);
/* mxcsr bit 6 and 31-16 must be zero for security reasons */
tsk
->
thread
.
i387
.
fxsave
.
mxcsr
&=
0xffbf
;
...
...
include/asm-i386/math_emu.h
View file @
34bf22f4
...
...
@@ -3,8 +3,8 @@
#include <asm/sigcontext.h>
int
restore_i387_soft
(
void
*
s387
,
struct
_fpstate
*
buf
);
int
save_i387_soft
(
void
*
s387
,
struct
_fpstate
*
buf
);
int
restore_i387_soft
(
void
*
s387
,
struct
_fpstate
__user
*
buf
);
int
save_i387_soft
(
void
*
s387
,
struct
_fpstate
__user
*
buf
);
/* This structure matches the layout of the data saved to the stack
following a device-not-present interrupt, part of it saved
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment