1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SANDBOX_LINUX_BPF_DSL_LINUX_SYSCALL_RANGES_H_
6 #define SANDBOX_LINUX_BPF_DSL_LINUX_SYSCALL_RANGES_H_
8 #include <asm/unistd.h> // For __NR_SYSCALL_BASE
10 #if defined(__x86_64__)
12 #define MIN_SYSCALL 0u
13 #define MAX_PUBLIC_SYSCALL 1024u
14 #define MAX_SYSCALL MAX_PUBLIC_SYSCALL
16 #elif defined(__i386__)
18 #define MIN_SYSCALL 0u
19 #define MAX_PUBLIC_SYSCALL 1024u
20 #define MAX_SYSCALL MAX_PUBLIC_SYSCALL
22 #elif defined(__arm__) && (defined(__thumb__) || defined(__ARM_EABI__))
24 // ARM EABI includes "ARM private" system calls starting at |__ARM_NR_BASE|,
25 // and a "ghost syscall private to the kernel", cmpxchg,
26 // at |__ARM_NR_BASE+0x00fff0|.
27 // See </arch/arm/include/asm/unistd.h> in the Linux kernel.
28 #define MIN_SYSCALL ((unsigned int)__NR_SYSCALL_BASE)
29 #define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + 1024u)
30 #define MIN_PRIVATE_SYSCALL ((unsigned int)__ARM_NR_BASE)
31 #define MAX_PRIVATE_SYSCALL (MIN_PRIVATE_SYSCALL + 16u)
32 #define MIN_GHOST_SYSCALL ((unsigned int)__ARM_NR_BASE + 0xfff0u)
33 #define MAX_SYSCALL (MIN_GHOST_SYSCALL + 4u)
35 #elif defined(__mips__) && (_MIPS_SIM == _ABIO32)
37 #define MIN_SYSCALL __NR_O32_Linux
38 #define MAX_PUBLIC_SYSCALL (MIN_SYSCALL + __NR_Linux_syscalls)
39 #define MAX_SYSCALL MAX_PUBLIC_SYSCALL
41 #elif defined(__mips__) && (_MIPS_SIM == _ABI64)
43 #error "Add support to header file"
45 #elif defined(__aarch64__)
47 #define MIN_SYSCALL 0u
48 #define MAX_PUBLIC_SYSCALL 279u
49 #define MAX_SYSCALL MAX_PUBLIC_SYSCALL
52 #error "Unsupported architecture"
55 #endif // SANDBOX_LINUX_BPF_DSL_LINUX_SYSCALL_RANGES_H_