diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2005-11-07 03:58:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 10:53:30 -0500 |
commit | 4f0272415ad1867cea2a7ef5659769243ae50fbe (patch) | |
tree | 5daba11ac90defc604399aa7ff41fa11b8cd088a /arch/um/include/sysdep-i386 | |
parent | 953206858070e5921b9d5931c293ec983a6790cb (diff) |
[PATCH] uml: fix syscall stubs
Jeff Dike noted that the assembly code for syscall stubs is misassembled with
GCC 3.2.3: the values copied in registers weren't preserved between one asm()
and the following one.
So I fixed the thing by rewriting the __asm__ constraints more like unistd.h
ones.
Note: in syscall6 case I had to add one more instruction (i.e. moving arg6 in
eax and shuffling things around) - it's needed for the function to be valid in
general (we can't load the value from the stack, relative to ebp, because we
change it), but could be avoided since we actually use a constant as param 6.
The only fix would be to turn stub_syscall6 to a macro and use a "i"
constraint for arg6 (i.e., specify it's a constant value).
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/include/sysdep-i386')
-rw-r--r-- | arch/um/include/sysdep-i386/stub.h | 64 |
1 files changed, 44 insertions, 20 deletions
diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h index d3699fe1c613..a49ceb199ee5 100644 --- a/arch/um/include/sysdep-i386/stub.h +++ b/arch/um/include/sysdep-i386/stub.h | |||
@@ -16,45 +16,69 @@ extern void stub_clone_handler(void); | |||
16 | #define STUB_MMAP_NR __NR_mmap2 | 16 | #define STUB_MMAP_NR __NR_mmap2 |
17 | #define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT) | 17 | #define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT) |
18 | 18 | ||
19 | static inline long stub_syscall1(long syscall, long arg1) | ||
20 | { | ||
21 | long ret; | ||
22 | |||
23 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1)); | ||
24 | |||
25 | return ret; | ||
26 | } | ||
27 | |||
19 | static inline long stub_syscall2(long syscall, long arg1, long arg2) | 28 | static inline long stub_syscall2(long syscall, long arg1, long arg2) |
20 | { | 29 | { |
21 | long ret; | 30 | long ret; |
22 | 31 | ||
23 | __asm__("movl %0, %%ecx; " : : "g" (arg2) : "%ecx"); | 32 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), |
24 | __asm__("movl %0, %%ebx; " : : "g" (arg1) : "%ebx"); | 33 | "c" (arg2)); |
25 | __asm__("movl %0, %%eax; " : : "g" (syscall) : "%eax"); | 34 | |
26 | __asm__("int $0x80;" : : : "%eax"); | 35 | return ret; |
27 | __asm__ __volatile__("movl %%eax, %0; " : "=g" (ret) :); | ||
28 | return(ret); | ||
29 | } | 36 | } |
30 | 37 | ||
31 | static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) | 38 | static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3) |
32 | { | 39 | { |
33 | __asm__("movl %0, %%edx; " : : "g" (arg3) : "%edx"); | 40 | long ret; |
34 | return(stub_syscall2(syscall, arg1, arg2)); | 41 | |
42 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
43 | "c" (arg2), "d" (arg3)); | ||
44 | |||
45 | return ret; | ||
35 | } | 46 | } |
36 | 47 | ||
37 | static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, | 48 | static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3, |
38 | long arg4) | 49 | long arg4) |
39 | { | 50 | { |
40 | __asm__("movl %0, %%esi; " : : "g" (arg4) : "%esi"); | 51 | long ret; |
41 | return(stub_syscall3(syscall, arg1, arg2, arg3)); | 52 | |
53 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
54 | "c" (arg2), "d" (arg3), "S" (arg4)); | ||
55 | |||
56 | return ret; | ||
57 | } | ||
58 | |||
59 | static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3, | ||
60 | long arg4, long arg5) | ||
61 | { | ||
62 | long ret; | ||
63 | |||
64 | __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1), | ||
65 | "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)); | ||
66 | |||
67 | return ret; | ||
42 | } | 68 | } |
43 | 69 | ||
44 | static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, | 70 | static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, |
45 | long arg4, long arg5, long arg6) | 71 | long arg4, long arg5, long arg6) |
46 | { | 72 | { |
47 | long ret; | 73 | long ret; |
48 | __asm__("movl %0, %%eax; " : : "g" (syscall) : "%eax"); | 74 | |
49 | __asm__("movl %0, %%ebx; " : : "g" (arg1) : "%ebx"); | 75 | __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; " |
50 | __asm__("movl %0, %%ecx; " : : "g" (arg2) : "%ecx"); | 76 | "int $0x80 ; pop %%ebp" |
51 | __asm__("movl %0, %%edx; " : : "g" (arg3) : "%edx"); | 77 | : "=a" (ret) |
52 | __asm__("movl %0, %%esi; " : : "g" (arg4) : "%esi"); | 78 | : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3), |
53 | __asm__("movl %0, %%edi; " : : "g" (arg5) : "%edi"); | 79 | "S" (arg4), "D" (arg5), "0" (arg6)); |
54 | __asm__ __volatile__("pushl %%ebp ; movl %1, %%ebp; " | 80 | |
55 | "int $0x80; popl %%ebp ; " | 81 | return ret; |
56 | "movl %%eax, %0; " : "=g" (ret) : "g" (arg6) : "%eax"); | ||
57 | return(ret); | ||
58 | } | 82 | } |
59 | 83 | ||
60 | static inline void trap_myself(void) | 84 | static inline void trap_myself(void) |