uml: kernel_thread shouldn't panic
[pv_ops_mirror.git] / arch / um / include / sysdep-i386 / stub.h
blob4fffae75ba531d1083f2f0c41b4a27ec3b40bd38
1 /*
2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
9 #include <sys/mman.h>
10 #include <asm/ptrace.h>
11 #include <asm/unistd.h>
12 #include <asm/page.h>
13 #include "stub-data.h"
14 #include "kern_constants.h"
15 #include "uml-config.h"
17 extern void stub_segv_handler(int sig);
18 extern void stub_clone_handler(void);
20 #define STUB_SYSCALL_RET EAX
21 #define STUB_MMAP_NR __NR_mmap2
22 #define MMAP_OFFSET(o) ((o) >> PAGE_SHIFT)
24 static inline long stub_syscall0(long syscall)
26 long ret;
28 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall));
30 return ret;
33 static inline long stub_syscall1(long syscall, long arg1)
35 long ret;
37 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1));
39 return ret;
42 static inline long stub_syscall2(long syscall, long arg1, long arg2)
44 long ret;
46 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
47 "c" (arg2));
49 return ret;
52 static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
54 long ret;
56 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
57 "c" (arg2), "d" (arg3));
59 return ret;
62 static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
63 long arg4)
65 long ret;
67 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
68 "c" (arg2), "d" (arg3), "S" (arg4));
70 return ret;
73 static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
74 long arg4, long arg5)
76 long ret;
78 __asm__ volatile ("int $0x80" : "=a" (ret) : "0" (syscall), "b" (arg1),
79 "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5));
81 return ret;
84 static inline void trap_myself(void)
86 __asm("int3");
89 static inline void remap_stack(int fd, unsigned long offset)
91 __asm__ volatile ("movl %%eax,%%ebp ; movl %0,%%eax ; int $0x80 ;"
92 "movl %7, %%ebx ; movl %%eax, (%%ebx)"
93 : : "g" (STUB_MMAP_NR), "b" (UML_CONFIG_STUB_DATA),
94 "c" (UM_KERN_PAGE_SIZE),
95 "d" (PROT_READ | PROT_WRITE),
96 "S" (MAP_FIXED | MAP_SHARED), "D" (fd),
97 "a" (offset),
98 "i" (&((struct stub_data *) UML_CONFIG_STUB_DATA)->err)
99 : "memory");
102 #endif