vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / os / arch / x86_64 / syscalls.inc
blob9a4881cddc765a0771ddcf32c1ecc8e4fe086e11
1 /*
2  * Copyright 2012, Alex Smith, alex@alex-smith.me.uk.
3  * Distributed under the terms of the MIT License.
4  */
7 #include <asm_defs.h>
10 // The kernel follows the AMD64 ABI for parameter passing (first 6 arguments in
11 // registers and the remaining ones in on the stack), except that RCX (argument
12 // 4) is overwritten by the SYSCALL instruction, so it is moved to R10. Syscall
13 // number goes in RAX.
16 #define _SYSCALL_NO_RCX(name, n)        \
17         .align 8;                                               \
18         FUNCTION(name):                                 \
19                 movq    $n, %rax;                       \
20                 syscall;                                        \
21                 ret;                                            \
22         FUNCTION_END(name)
24 #define _SYSCALL_RCX(name, n)           \
25         .align 8;                                               \
26         FUNCTION(name):                                 \
27                 movq    %rcx, %r10;                     \
28                 movq    $n, %rax;                       \
29                 syscall;                                        \
30                 ret;                                            \
31         FUNCTION_END(name)
34 #define SYSCALL0(name, n)       _SYSCALL_NO_RCX(name, n)
35 #define SYSCALL1(name, n)       _SYSCALL_NO_RCX(name, n)
36 #define SYSCALL2(name, n)       _SYSCALL_NO_RCX(name, n)
37 #define SYSCALL3(name, n)       _SYSCALL_NO_RCX(name, n)
38 #define SYSCALL4(name, n)       _SYSCALL_RCX(name, n)
39 #define SYSCALL5(name, n)       _SYSCALL_RCX(name, n)
40 #define SYSCALL6(name, n)       _SYSCALL_RCX(name, n)
41 #define SYSCALL7(name, n)       _SYSCALL_RCX(name, n)
42 #define SYSCALL8(name, n)       _SYSCALL_RCX(name, n)
43 #define SYSCALL9(name, n)       _SYSCALL_RCX(name, n)
44 #define SYSCALL10(name, n)      _SYSCALL_RCX(name, n)
45 #define SYSCALL11(name, n)      _SYSCALL_RCX(name, n)
46 #define SYSCALL12(name, n)      _SYSCALL_RCX(name, n)
47 #define SYSCALL13(name, n)      _SYSCALL_RCX(name, n)
48 #define SYSCALL14(name, n)      _SYSCALL_RCX(name, n)
49 #define SYSCALL15(name, n)      _SYSCALL_RCX(name, n)
50 #define SYSCALL16(name, n)      _SYSCALL_RCX(name, n)
51 #define SYSCALL17(name, n)      _SYSCALL_RCX(name, n)
52 #define SYSCALL18(name, n)      _SYSCALL_RCX(name, n)
53 #define SYSCALL19(name, n)      _SYSCALL_RCX(name, n)
54 #define SYSCALL20(name, n)      _SYSCALL_RCX(name, n)