3 * Licensed under the GPL
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
10 #include <sysdep/ptrace_user.h>
11 #include <generated/asm-offsets.h>
12 #include <linux/stddef.h>
14 #define STUB_MMAP_NR __NR_mmap
15 #define MMAP_OFFSET(o) (o)
17 #define __syscall_clobber "r11","rcx","memory"
18 #define __syscall "syscall"
20 static __always_inline long stub_syscall0(long syscall)
24 __asm__ volatile (__syscall
26 : "0" (syscall) : __syscall_clobber );
31 static __always_inline long stub_syscall1(long syscall, long arg1)
35 __asm__ volatile (__syscall
37 : "0" (syscall), "D" (arg1) : __syscall_clobber );
42 static __always_inline long stub_syscall2(long syscall, long arg1, long arg2)
46 __asm__ volatile (__syscall
48 : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
53 static __always_inline long stub_syscall3(long syscall, long arg1, long arg2,
58 __asm__ volatile (__syscall
60 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
61 : __syscall_clobber );
66 static __always_inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
71 __asm__ volatile ("movq %5,%%r10 ; " __syscall
73 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
75 : __syscall_clobber, "r10" );
80 static __always_inline long stub_syscall5(long syscall, long arg1, long arg2,
81 long arg3, long arg4, long arg5)
85 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
87 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
88 "g" (arg4), "g" (arg5)
89 : __syscall_clobber, "r10", "r8" );
94 static __always_inline long stub_syscall6(long syscall, long arg1, long arg2,
95 long arg3, long arg4, long arg5,
100 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; movq %7,%%r9 ; "
103 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
104 "g" (arg4), "g" (arg5), "g" (arg6)
105 : __syscall_clobber, "r10", "r8", "r9");
110 static __always_inline void trap_myself(void)
115 static __always_inline void *get_stub_data(void)
124 : "g" (~(UM_KERN_PAGE_SIZE - 1)),
125 "g" (UM_KERN_PAGE_SIZE));
130 #define stub_start(fn) \
135 :: "i" ((1 + STUB_DATA_PAGES) * UM_KERN_PAGE_SIZE), \