2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
10 #include <asm/unistd.h>
11 #include <sysdep/ptrace_user.h>
12 #include "as-layout.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 PT_INDEX(RAX)
21 #define STUB_MMAP_NR __NR_mmap
22 #define MMAP_OFFSET(o) (o)
24 #define __syscall_clobber "r11","rcx","memory"
25 #define __syscall "syscall"
27 static inline long stub_syscall0(long syscall
)
31 __asm__
volatile (__syscall
33 : "0" (syscall
) : __syscall_clobber
);
38 static inline long stub_syscall2(long syscall
, long arg1
, long arg2
)
42 __asm__
volatile (__syscall
44 : "0" (syscall
), "D" (arg1
), "S" (arg2
) : __syscall_clobber
);
49 static inline long stub_syscall3(long syscall
, long arg1
, long arg2
, long arg3
)
53 __asm__
volatile (__syscall
55 : "0" (syscall
), "D" (arg1
), "S" (arg2
), "d" (arg3
)
56 : __syscall_clobber
);
61 static inline long stub_syscall4(long syscall
, long arg1
, long arg2
, long arg3
,
66 __asm__
volatile ("movq %5,%%r10 ; " __syscall
68 : "0" (syscall
), "D" (arg1
), "S" (arg2
), "d" (arg3
),
70 : __syscall_clobber
, "r10" );
75 static inline long stub_syscall5(long syscall
, long arg1
, long arg2
, long arg3
,
80 __asm__
volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
82 : "0" (syscall
), "D" (arg1
), "S" (arg2
), "d" (arg3
),
83 "g" (arg4
), "g" (arg5
)
84 : __syscall_clobber
, "r10", "r8" );
89 static inline void trap_myself(void)
94 static inline void remap_stack(long fd
, unsigned long offset
)
96 __asm__
volatile ("movq %4,%%r10 ; movq %5,%%r8 ; "
97 "movq %6, %%r9; " __syscall
"; movq %7, %%rbx ; "
98 "movq %%rax, (%%rbx)":
99 : "a" (STUB_MMAP_NR
), "D" (STUB_DATA
),
100 "S" (UM_KERN_PAGE_SIZE
),
101 "d" (PROT_READ
| PROT_WRITE
),
102 "g" (MAP_FIXED
| MAP_SHARED
), "g" (fd
),
104 "i" (&((struct stub_data
*) STUB_DATA
)->err
)
105 : __syscall_clobber
, "r10", "r8", "r9" );