1 2 /*--------------------------------------------------------------------*/ 3 /*--- Linux-specific syscalls stuff. priv_syswrap-linux.h ---*/ 4 /*--------------------------------------------------------------------*/ 5 6 /* 7 This file is part of Valgrind, a dynamic binary instrumentation 8 framework. 9 10 Copyright (C) 2000-2012 Nicholas Nethercote 11 njn@valgrind.org 12 13 This program is free software; you can redistribute it and/or 14 modify it under the terms of the GNU General Public License as 15 published by the Free Software Foundation; either version 2 of the 16 License, or (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, but 19 WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 26 02111-1307, USA. 27 28 The GNU General Public License is contained in the file COPYING. 29 */ 30 31 #ifndef __PRIV_SYSWRAP_LINUX_H 32 #define __PRIV_SYSWRAP_LINUX_H 33 34 /* requires #include "priv_types_n_macros.h" */ 35 36 // Clone-related functions 37 extern Word ML_(start_thread_NORETURN) ( void* arg ); 38 extern Addr ML_(allocstack) ( ThreadId tid ); 39 extern void ML_(call_on_new_stack_0_1) ( Addr stack, Addr retaddr, 40 void (*f)(Word), Word arg1 ); 41 extern SysRes ML_(do_fork_clone) ( ThreadId tid, UInt flags, 42 Int* parent_tidptr, Int* child_tidptr ); 43 44 45 // Linux-specific (but non-arch-specific) syscalls 46 47 DECL_TEMPLATE(linux, sys_mount); 48 DECL_TEMPLATE(linux, sys_oldumount); 49 DECL_TEMPLATE(linux, sys_umount); 50 DECL_TEMPLATE(linux, sys_perf_event_open); 51 DECL_TEMPLATE(linux, sys_preadv); 52 DECL_TEMPLATE(linux, sys_pwritev); 53 DECL_TEMPLATE(linux, sys_sendmmsg); 54 DECL_TEMPLATE(linux, sys_recvmmsg); 55 DECL_TEMPLATE(linux, sys_dup3); 56 DECL_TEMPLATE(linux, sys_getcpu); 57 DECL_TEMPLATE(linux, sys_splice); 58 DECL_TEMPLATE(linux, sys_tee); 59 DECL_TEMPLATE(linux, sys_vmsplice); 60 DECL_TEMPLATE(linux, sys_readahead); 61 DECL_TEMPLATE(linux, sys_move_pages); 62 63 // POSIX, but various sub-cases differ between Linux and Darwin. 64 DECL_TEMPLATE(linux, sys_fcntl); 65 DECL_TEMPLATE(linux, sys_fcntl64); 66 DECL_TEMPLATE(linux, sys_ioctl); 67 68 DECL_TEMPLATE(linux, sys_setfsuid16); 69 DECL_TEMPLATE(linux, sys_setfsuid); 70 DECL_TEMPLATE(linux, sys_setfsgid16); 71 DECL_TEMPLATE(linux, sys_setfsgid); 72 DECL_TEMPLATE(linux, sys_setresuid16); // man page says "non-standard"; 73 DECL_TEMPLATE(linux, sys_setresuid); // man page says "non-standard" 74 DECL_TEMPLATE(linux, sys_getresuid16); 75 DECL_TEMPLATE(linux, sys_getresuid); 76 DECL_TEMPLATE(linux, sys_setresgid16); // man page says "non-standard" 77 DECL_TEMPLATE(linux, sys_setresgid); // man page says "non-standard" 78 DECL_TEMPLATE(linux, sys_getresgid16); 79 DECL_TEMPLATE(linux, sys_getresgid); 80 81 DECL_TEMPLATE(linux, sys_exit_group); 82 DECL_TEMPLATE(linux, sys_llseek); 83 DECL_TEMPLATE(linux, sys_adjtimex); 84 DECL_TEMPLATE(linux, sys_ioperm); 85 DECL_TEMPLATE(linux, sys_syslog); 86 DECL_TEMPLATE(linux, sys_vhangup); 87 DECL_TEMPLATE(linux, sys_sysinfo); 88 DECL_TEMPLATE(linux, sys_personality); 89 DECL_TEMPLATE(linux, sys_sysctl); 90 DECL_TEMPLATE(linux, sys_prctl); 91 DECL_TEMPLATE(linux, sys_sendfile); 92 DECL_TEMPLATE(linux, sys_sendfile64); 93 DECL_TEMPLATE(linux, sys_futex); 94 DECL_TEMPLATE(linux, sys_set_robust_list); 95 DECL_TEMPLATE(linux, sys_get_robust_list); 96 DECL_TEMPLATE(linux, sys_pselect6); 97 DECL_TEMPLATE(linux, sys_ppoll); 98 99 DECL_TEMPLATE(linux, sys_epoll_create); 100 DECL_TEMPLATE(linux, sys_epoll_create1); 101 DECL_TEMPLATE(linux, sys_epoll_ctl); 102 DECL_TEMPLATE(linux, sys_epoll_wait); 103 DECL_TEMPLATE(linux, sys_epoll_pwait); 104 DECL_TEMPLATE(linux, sys_eventfd); 105 DECL_TEMPLATE(linux, sys_eventfd2); 106 107 DECL_TEMPLATE(linux, sys_fallocate); 108 109 DECL_TEMPLATE(linux, sys_prlimit64); 110 111 DECL_TEMPLATE(linux, sys_gettid); 112 DECL_TEMPLATE(linux, sys_set_tid_address); 113 DECL_TEMPLATE(linux, sys_tkill); 114 DECL_TEMPLATE(linux, sys_tgkill); 115 116 DECL_TEMPLATE(linux, sys_fadvise64); 117 DECL_TEMPLATE(linux, sys_fadvise64_64); 118 119 DECL_TEMPLATE(linux, sys_io_setup); 120 DECL_TEMPLATE(linux, sys_io_destroy); 121 DECL_TEMPLATE(linux, sys_io_getevents); 122 DECL_TEMPLATE(linux, sys_io_submit); 123 DECL_TEMPLATE(linux, sys_io_cancel); 124 125 DECL_TEMPLATE(linux, sys_ioprio_set); 126 DECL_TEMPLATE(linux, sys_ioprio_get); 127 128 DECL_TEMPLATE(linux, sys_mbind); 129 DECL_TEMPLATE(linux, sys_set_mempolicy); 130 DECL_TEMPLATE(linux, sys_get_mempolicy); 131 132 DECL_TEMPLATE(linux, sys_inotify_init); 133 DECL_TEMPLATE(linux, sys_inotify_init1); 134 DECL_TEMPLATE(linux, sys_inotify_add_watch); 135 DECL_TEMPLATE(linux, sys_inotify_rm_watch); 136 137 DECL_TEMPLATE(linux, sys_mq_open); 138 DECL_TEMPLATE(linux, sys_mq_unlink); 139 DECL_TEMPLATE(linux, sys_mq_timedsend); 140 DECL_TEMPLATE(linux, sys_mq_timedreceive); 141 DECL_TEMPLATE(linux, sys_mq_notify); 142 DECL_TEMPLATE(linux, sys_mq_getsetattr); 143 144 DECL_TEMPLATE(linux, sys_clock_settime); 145 DECL_TEMPLATE(linux, sys_clock_gettime); 146 DECL_TEMPLATE(linux, sys_clock_getres); 147 DECL_TEMPLATE(linux, sys_clock_nanosleep); 148 149 DECL_TEMPLATE(linux, sys_timer_create); // Linux: varies across archs? 150 DECL_TEMPLATE(linux, sys_timer_settime); 151 DECL_TEMPLATE(linux, sys_timer_gettime); 152 DECL_TEMPLATE(linux, sys_timer_getoverrun); 153 DECL_TEMPLATE(linux, sys_timer_delete); 154 DECL_TEMPLATE(linux, sys_timerfd_create); 155 DECL_TEMPLATE(linux, sys_timerfd_gettime); 156 DECL_TEMPLATE(linux, sys_timerfd_settime); 157 158 DECL_TEMPLATE(linux, sys_signalfd); 159 DECL_TEMPLATE(linux, sys_signalfd4); 160 161 DECL_TEMPLATE(linux, sys_capget); 162 DECL_TEMPLATE(linux, sys_capset); 163 164 DECL_TEMPLATE(linux, sys_openat); 165 DECL_TEMPLATE(linux, sys_mkdirat); 166 DECL_TEMPLATE(linux, sys_mknodat); 167 DECL_TEMPLATE(linux, sys_fchownat); 168 DECL_TEMPLATE(linux, sys_futimesat); 169 DECL_TEMPLATE(linux, sys_newfstatat); 170 DECL_TEMPLATE(linux, sys_unlinkat); 171 DECL_TEMPLATE(linux, sys_renameat); 172 DECL_TEMPLATE(linux, sys_linkat); 173 DECL_TEMPLATE(linux, sys_symlinkat); 174 DECL_TEMPLATE(linux, sys_readlinkat); 175 DECL_TEMPLATE(linux, sys_fchmodat); 176 DECL_TEMPLATE(linux, sys_faccessat); 177 DECL_TEMPLATE(linux, sys_utimensat); 178 179 DECL_TEMPLATE(linux, sys_add_key); 180 DECL_TEMPLATE(linux, sys_request_key); 181 DECL_TEMPLATE(linux, sys_keyctl); 182 183 // These ones have 32-bit generic equivalents, but the 16-bit versions (they 184 // use 16-bit gid_t and uid_t types) seem to be Linux-specific. 185 DECL_TEMPLATE(linux, sys_getuid16); 186 DECL_TEMPLATE(linux, sys_setuid16); 187 DECL_TEMPLATE(linux, sys_getgid16); 188 DECL_TEMPLATE(linux, sys_setgid16); 189 DECL_TEMPLATE(linux, sys_geteuid16); 190 DECL_TEMPLATE(linux, sys_getegid16); 191 DECL_TEMPLATE(linux, sys_setreuid16); 192 DECL_TEMPLATE(linux, sys_setregid16); 193 DECL_TEMPLATE(linux, sys_getgroups16); 194 DECL_TEMPLATE(linux, sys_setgroups16); 195 196 // Again, these 16-bit versions are Linux-specific, the 32-bit versions are 197 // generic. 198 DECL_TEMPLATE(linux, sys_chown16); 199 DECL_TEMPLATE(linux, sys_fchown16); 200 //DECL_TEMPLATE(linux, sys_lchown16); // not yet encountered 201 202 // Are these POSIX? In Darwin they have an extra parameter 'position', 203 // so put them here. 204 DECL_TEMPLATE(linux, sys_setxattr); 205 DECL_TEMPLATE(linux, sys_lsetxattr); 206 DECL_TEMPLATE(linux, sys_fsetxattr); 207 DECL_TEMPLATE(linux, sys_getxattr); 208 DECL_TEMPLATE(linux, sys_lgetxattr); 209 DECL_TEMPLATE(linux, sys_fgetxattr); 210 DECL_TEMPLATE(linux, sys_listxattr); 211 DECL_TEMPLATE(linux, sys_llistxattr); 212 DECL_TEMPLATE(linux, sys_flistxattr); 213 DECL_TEMPLATE(linux, sys_removexattr); 214 DECL_TEMPLATE(linux, sys_lremovexattr); 215 DECL_TEMPLATE(linux, sys_fremovexattr); 216 217 // These are Posix, but not necessarily syscalls. Darwin only supports 218 // sched_get_priority_{min,max} and sched_yield, but as libc functions, not 219 // syscalls. 220 DECL_TEMPLATE(linux, sys_sched_setparam); 221 DECL_TEMPLATE(linux, sys_sched_getparam); 222 DECL_TEMPLATE(linux, sys_sched_setscheduler); 223 DECL_TEMPLATE(linux, sys_sched_getscheduler); 224 DECL_TEMPLATE(linux, sys_sched_yield); 225 DECL_TEMPLATE(linux, sys_sched_get_priority_max); 226 DECL_TEMPLATE(linux, sys_sched_get_priority_min); 227 DECL_TEMPLATE(linux, sys_sched_rr_get_interval); 228 DECL_TEMPLATE(linux, sys_sched_setaffinity); 229 DECL_TEMPLATE(linux, sys_sched_getaffinity); 230 231 // These ones have different parameters and/or return values on Darwin. 232 // Also, some archs on Linux do not match the generic wrapper for sys_pipe. 233 DECL_TEMPLATE(linux, sys_munlockall); 234 DECL_TEMPLATE(linux, sys_pipe); 235 DECL_TEMPLATE(linux, sys_pipe2); 236 DECL_TEMPLATE(linux, sys_quotactl); 237 DECL_TEMPLATE(linux, sys_waitid); 238 239 // Posix, but in Darwin utime is a libc function that calls syscall utimes. 240 DECL_TEMPLATE(linux, sys_utime); 241 242 // On Darwin, off_t is 64-bits even on 32-bit platforms. 243 DECL_TEMPLATE(linux, sys_lseek); 244 245 // Darwin (and probably other OSes) don't have the old_sigset_t type. 246 DECL_TEMPLATE(linux, sys_sigpending); 247 DECL_TEMPLATE(linux, sys_sigprocmask); 248 DECL_TEMPLATE(linux, sys_sigaction); 249 250 // I think these are Linux-specific? 251 DECL_TEMPLATE(linux, sys_rt_sigaction); 252 DECL_TEMPLATE(linux, sys_rt_sigprocmask); 253 DECL_TEMPLATE(linux, sys_rt_sigpending); 254 DECL_TEMPLATE(linux, sys_rt_sigtimedwait); 255 DECL_TEMPLATE(linux, sys_rt_sigqueueinfo); 256 DECL_TEMPLATE(linux, sys_rt_tgsigqueueinfo); 257 DECL_TEMPLATE(linux, sys_rt_sigsuspend); 258 259 // Linux-specific? 260 DECL_TEMPLATE(linux, sys_sync_file_range); 261 DECL_TEMPLATE(linux, sys_sync_file_range2); 262 DECL_TEMPLATE(linux, sys_stime); /* maybe generic? I'm not sure */ 263 264 // Linux specific (kernel modules) 265 DECL_TEMPLATE(linux, sys_init_module); 266 DECL_TEMPLATE(linux, sys_delete_module); 267 268 // Linux-specific (oprofile-related) 269 DECL_TEMPLATE(linux, sys_lookup_dcookie); // (*/32/64) L 270 271 // Linux-specific (new in Linux 3.2) 272 DECL_TEMPLATE(linux, sys_process_vm_readv); 273 DECL_TEMPLATE(linux, sys_process_vm_writev); 274 275 /* --------------------------------------------------------------------- 276 Wrappers for sockets and ipc-ery. These are split into standalone 277 procedures because x86-linux hides them inside multiplexors 278 (sys_socketcall and sys_ipc). 279 ------------------------------------------------------------------ */ 280 281 #define TId ThreadId 282 #define UW UWord 283 #define SR SysRes 284 285 extern void ML_(linux_PRE_sys_msgsnd) ( TId, UW, UW, UW, UW ); 286 extern void ML_(linux_PRE_sys_msgrcv) ( TId, UW, UW, UW, UW, UW ); 287 extern void ML_(linux_POST_sys_msgrcv) ( TId, UW, UW, UW, UW, UW, UW ); 288 extern void ML_(linux_PRE_sys_msgctl) ( TId, UW, UW, UW ); 289 extern void ML_(linux_POST_sys_msgctl) ( TId, UW, UW, UW, UW ); 290 extern void ML_(linux_PRE_sys_getsockopt) ( TId, UW, UW, UW, UW, UW ); 291 extern void ML_(linux_POST_sys_getsockopt) ( TId, SR, UW, UW, UW, UW, UW ); 292 293 #undef TId 294 #undef UW 295 #undef SR 296 297 #endif // __PRIV_SYSWRAP_LINUX_H 298 299 /*--------------------------------------------------------------------*/ 300 /*--- end ---*/ 301 /*--------------------------------------------------------------------*/ 302