aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/include/sysdep-i386/stub.h
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2005-12-18 11:50:39 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-12-18 14:19:44 -0500
commit5b7b15afee89d6940482259b54d0864b7b2302b0 (patch)
treea3294a2c1f14ff4ebc9d645189ad12070529a639 /arch/um/include/sysdep-i386/stub.h
parent76c842d8f8096e2c98ff9ebe1db861363ff254e5 (diff)
[PATCH] uml skas0: stop gcc's insanity
With Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> UML skas0 stub has been miscompiling for many people (incidentally not the authors), depending on the used GCC versions. I think (and testing on some GCC versions shows) this patch avoids the fundamental issue which is behind this, namely gcc using the stack when we have just replaced it, behind gcc's back. The remapping and storage of the return value is hidden in a blob of asm, hopefully giving gcc no room for creativity. Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/include/sysdep-i386/stub.h')
-rw-r--r--arch/um/include/sysdep-i386/stub.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/arch/um/include/sysdep-i386/stub.h b/arch/um/include/sysdep-i386/stub.h
index 6ba8cbbe0d36..b492b12b4a10 100644
--- a/arch/um/include/sysdep-i386/stub.h
+++ b/arch/um/include/sysdep-i386/stub.h
@@ -6,8 +6,12 @@
6#ifndef __SYSDEP_STUB_H 6#ifndef __SYSDEP_STUB_H
7#define __SYSDEP_STUB_H 7#define __SYSDEP_STUB_H
8 8
9#include <sys/mman.h>
9#include <asm/ptrace.h> 10#include <asm/ptrace.h>
10#include <asm/unistd.h> 11#include <asm/unistd.h>
12#include "stub-data.h"
13#include "kern_constants.h"
14#include "uml-config.h"
11 15
12extern void stub_segv_handler(int sig); 16extern void stub_segv_handler(int sig);
13extern void stub_clone_handler(void); 17extern void stub_clone_handler(void);
@@ -76,23 +80,22 @@ static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
76 return ret; 80 return ret;
77} 81}
78 82
79static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3, 83static inline void trap_myself(void)
80 long arg4, long arg5, long arg6)
81{ 84{
82 long ret; 85 __asm("int3");
83
84 __asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; "
85 "int $0x80 ; pop %%ebp"
86 : "=a" (ret)
87 : "g" (syscall), "b" (arg1), "c" (arg2), "d" (arg3),
88 "S" (arg4), "D" (arg5), "0" (arg6));
89
90 return ret;
91} 86}
92 87
93static inline void trap_myself(void) 88static inline void remap_stack(int fd, unsigned long offset)
94{ 89{
95 __asm("int3"); 90 __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
91 "movl %7, %%ebx ; movl %%eax, (%%ebx)"
92 : : "g" (STUB_MMAP_NR), "b" (UML_CONFIG_STUB_DATA),
93 "c" (UM_KERN_PAGE_SIZE),
94 "d" (PROT_READ | PROT_WRITE),
95 "S" (MAP_FIXED | MAP_SHARED), "D" (fd),
96 "a" (offset),
97 "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
98 : "memory");
96} 99}
97 100
98#endif 101#endif