cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1 | |
| 2 | /*--------------------------------------------------------------------*/ |
| 3 | /*--- Platform-specific syscalls stuff. syswrap-ppc32-linux.c ---*/ |
| 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
| 9 | |
njn | bd77403 | 2005-08-04 19:26:54 +0000 | [diff] [blame] | 10 | Copyright (C) 2005 Nicholas Nethercote <njn@valgrind.org> |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 11 | Copyright (C) 2005 Cerion Armour-Brown <cerion@open-works.co.uk> |
| 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 | #include "pub_core_basics.h" |
| 32 | #include "pub_core_threadstate.h" |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 33 | #include "pub_core_aspacemgr.h" |
njn | 899ce73 | 2005-06-21 00:28:11 +0000 | [diff] [blame] | 34 | #include "pub_core_debuglog.h" |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 35 | #include "pub_core_libcbase.h" |
| 36 | #include "pub_core_libcassert.h" |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 37 | #include "pub_core_libcprint.h" |
| 38 | #include "pub_core_libcproc.h" |
sewardj | e00659d | 2005-11-10 13:15:31 +0000 | [diff] [blame] | 39 | #include "pub_core_libcsignal.h" |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 40 | #include "pub_core_options.h" |
| 41 | #include "pub_core_scheduler.h" |
| 42 | #include "pub_core_sigframe.h" // For VG_(sigframe_destroy)() |
| 43 | #include "pub_core_signals.h" |
| 44 | #include "pub_core_syscall.h" |
| 45 | #include "pub_core_syswrap.h" |
| 46 | #include "pub_core_tooliface.h" |
| 47 | |
| 48 | #include "priv_types_n_macros.h" |
| 49 | #include "priv_syswrap-generic.h" /* for decls of generic wrappers */ |
| 50 | #include "priv_syswrap-linux.h" /* for decls of linux-ish wrappers */ |
| 51 | #include "priv_syswrap-main.h" |
| 52 | |
| 53 | #include "vki_unistd.h" /* for the __NR_* constants */ |
| 54 | |
| 55 | |
| 56 | /* --------------------------------------------------------------------- |
njn | e148666 | 2005-11-10 02:48:04 +0000 | [diff] [blame] | 57 | clone() handling |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 58 | ------------------------------------------------------------------ */ |
| 59 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 60 | /* Call f(arg1), but first switch stacks, using 'stack' as the new |
njn | a3afdfb | 2005-11-09 04:49:28 +0000 | [diff] [blame] | 61 | stack, and use 'retaddr' as f's return-to address. Also, clear all |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 62 | the integer registers before entering f.*/ |
| 63 | __attribute__((noreturn)) |
njn | a3afdfb | 2005-11-09 04:49:28 +0000 | [diff] [blame] | 64 | void ML_(call_on_new_stack_0_1) ( Addr stack, |
| 65 | Addr retaddr, |
| 66 | void (*f)(Word), |
| 67 | Word arg1 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 68 | // r3 = stack |
| 69 | // r4 = retaddr |
| 70 | // r5 = f |
| 71 | // r6 = arg1 |
| 72 | asm( |
sewardj | d9fc382 | 2005-11-18 23:50:43 +0000 | [diff] [blame] | 73 | ".text\n" |
njn | a3afdfb | 2005-11-09 04:49:28 +0000 | [diff] [blame] | 74 | ".globl vgModuleLocal_call_on_new_stack_0_1\n" |
| 75 | "vgModuleLocal_call_on_new_stack_0_1:\n" |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 76 | " mr %r1,%r3\n\t" // stack to %sp |
| 77 | " mtlr %r4\n\t" // retaddr to %lr |
| 78 | " mtctr %r5\n\t" // f to count reg |
| 79 | " mr %r3,%r6\n\t" // arg1 to %r3 |
| 80 | " li 0,0\n\t" // zero all GP regs |
| 81 | " li 4,0\n\t" |
| 82 | " li 5,0\n\t" |
| 83 | " li 6,0\n\t" |
| 84 | " li 7,0\n\t" |
| 85 | " li 8,0\n\t" |
| 86 | " li 9,0\n\t" |
| 87 | " li 10,0\n\t" |
| 88 | " li 11,0\n\t" |
| 89 | " li 12,0\n\t" |
| 90 | " li 13,0\n\t" |
| 91 | " li 14,0\n\t" |
| 92 | " li 15,0\n\t" |
| 93 | " li 16,0\n\t" |
| 94 | " li 17,0\n\t" |
| 95 | " li 18,0\n\t" |
| 96 | " li 19,0\n\t" |
| 97 | " li 20,0\n\t" |
| 98 | " li 21,0\n\t" |
| 99 | " li 22,0\n\t" |
| 100 | " li 23,0\n\t" |
| 101 | " li 24,0\n\t" |
| 102 | " li 25,0\n\t" |
| 103 | " li 26,0\n\t" |
| 104 | " li 27,0\n\t" |
| 105 | " li 28,0\n\t" |
| 106 | " li 29,0\n\t" |
| 107 | " li 30,0\n\t" |
| 108 | " li 31,0\n\t" |
| 109 | " mtxer 0\n\t" // CAB: Need this? |
| 110 | " mtcr 0\n\t" // CAB: Need this? |
| 111 | " bctr\n\t" // jump to dst |
| 112 | " trap\n" // should never get here |
sewardj | 2fedc64 | 2005-11-19 02:02:57 +0000 | [diff] [blame] | 113 | ".previous\n" |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 114 | ); |
| 115 | |
| 116 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 117 | /* |
| 118 | Perform a clone system call. clone is strange because it has |
| 119 | fork()-like return-twice semantics, so it needs special |
| 120 | handling here. |
| 121 | |
| 122 | Upon entry, we have: |
| 123 | |
| 124 | int (fn)(void*) in r3 |
| 125 | void* child_stack in r4 |
| 126 | int flags in r5 |
| 127 | void* arg in r6 |
| 128 | pid_t* child_tid in r7 |
| 129 | pid_t* parent_tid in r8 |
sewardj | e21058c | 2005-08-05 02:15:18 +0000 | [diff] [blame] | 130 | void* ??? in r9 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 131 | |
| 132 | System call requires: |
| 133 | |
| 134 | int $__NR_clone in r0 (sc number) |
| 135 | int flags in r3 (sc arg1) |
| 136 | void* child_stack in r4 (sc arg2) |
| 137 | pid_t* parent_tid in r5 (sc arg3) |
sewardj | e21058c | 2005-08-05 02:15:18 +0000 | [diff] [blame] | 138 | ?? child_tls in r6 (sc arg4) |
| 139 | pid_t* child_tid in r7 (sc arg5) |
| 140 | void* ??? in r8 (sc arg6) |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 141 | |
| 142 | Returns an Int encoded in the linux-ppc32 way, not a SysRes. |
| 143 | */ |
sewardj | 7d15e51 | 2005-09-30 01:20:47 +0000 | [diff] [blame] | 144 | #define __NR_CLONE VG_STRINGIFY(__NR_clone) |
| 145 | #define __NR_EXIT VG_STRINGIFY(__NR_exit) |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 146 | |
| 147 | extern |
njn | ffd9c1d | 2005-11-10 04:02:19 +0000 | [diff] [blame] | 148 | ULong do_syscall_clone_ppc32_linux ( Word (*fn)(void *), |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 149 | void* stack, |
| 150 | Int flags, |
| 151 | void* arg, |
| 152 | Int* child_tid, |
| 153 | Int* parent_tid, |
| 154 | vki_modify_ldt_t * ); |
| 155 | asm( |
sewardj | d9fc382 | 2005-11-18 23:50:43 +0000 | [diff] [blame] | 156 | ".text\n" |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 157 | "do_syscall_clone_ppc32_linux:\n" |
| 158 | " stwu 1,-32(1)\n" |
| 159 | " stw 29,20(1)\n" |
| 160 | " stw 30,24(1)\n" |
| 161 | " stw 31,28(1)\n" |
| 162 | " mr 30,3\n" // preserve fn |
| 163 | " mr 31,6\n" // preserve arg |
| 164 | |
| 165 | // setup child stack |
| 166 | " rlwinm 4,4,0,~0xf\n" // trim sp to multiple of 16 bytes |
| 167 | " li 0,0\n" |
| 168 | " stwu 0,-16(4)\n" // make initial stack frame |
| 169 | " mr 29,4\n" // preserve sp |
| 170 | |
| 171 | // setup syscall |
| 172 | " li 0,"__NR_CLONE"\n" // syscall number |
| 173 | " mr 3,5\n" // syscall arg1: flags |
| 174 | // r4 already setup // syscall arg2: child_stack |
| 175 | " mr 5,8\n" // syscall arg3: parent_tid |
sewardj | e21058c | 2005-08-05 02:15:18 +0000 | [diff] [blame] | 176 | " mr 6,2\n" // syscall arg4: REAL THREAD tls |
| 177 | " mr 7,7\n" // syscall arg5: child_tid |
| 178 | " mr 8,8\n" // syscall arg6: ???? |
| 179 | " mr 9,9\n" // syscall arg7: ???? |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 180 | |
| 181 | " sc\n" // clone() |
| 182 | |
| 183 | " mfcr 4\n" // return CR in r4 (low word of ULong) |
| 184 | " cmpwi 3,0\n" // child if retval == 0 |
| 185 | " bne 1f\n" // jump if !child |
| 186 | |
| 187 | /* CHILD - call thread function */ |
| 188 | /* Note: 2.4 kernel doesn't set the child stack pointer, |
| 189 | so we do it here. |
| 190 | That does leave a small window for a signal to be delivered |
| 191 | on the wrong stack, unfortunately. */ |
| 192 | " mr 1,29\n" |
| 193 | " mtctr 30\n" // ctr reg = fn |
| 194 | " mr 3,31\n" // r3 = arg |
| 195 | " bctrl\n" // call fn() |
| 196 | |
| 197 | // exit with result |
| 198 | " li 0,"__NR_EXIT"\n" |
| 199 | " sc\n" |
| 200 | |
| 201 | // Exit returned?! |
| 202 | " .long 0\n" |
| 203 | |
| 204 | // PARENT or ERROR - return |
| 205 | "1: lwz 29,20(1)\n" |
| 206 | " lwz 30,24(1)\n" |
| 207 | " lwz 31,28(1)\n" |
| 208 | " addi 1,1,32\n" |
| 209 | " blr\n" |
sewardj | 2fedc64 | 2005-11-19 02:02:57 +0000 | [diff] [blame] | 210 | ".previous\n" |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 211 | ); |
| 212 | |
| 213 | #undef __NR_CLONE |
| 214 | #undef __NR_EXIT |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 215 | |
| 216 | // forward declarations |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 217 | static void setup_child ( ThreadArchState*, ThreadArchState* ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 218 | |
| 219 | /* |
| 220 | When a client clones, we need to keep track of the new thread. This means: |
| 221 | 1. allocate a ThreadId+ThreadState+stack for the the thread |
| 222 | |
| 223 | 2. initialize the thread's new VCPU state |
| 224 | |
| 225 | 3. create the thread using the same args as the client requested, |
| 226 | but using the scheduler entrypoint for IP, and a separate stack |
| 227 | for SP. |
| 228 | */ |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 229 | static SysRes do_clone ( ThreadId ptid, |
| 230 | UInt flags, Addr sp, |
| 231 | Int *parent_tidptr, |
| 232 | Int *child_tidptr, |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 233 | Addr child_tls) |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 234 | { |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 235 | const Bool debug = False; |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 236 | |
| 237 | ThreadId ctid = VG_(alloc_ThreadState)(); |
| 238 | ThreadState* ptst = VG_(get_ThreadState)(ptid); |
| 239 | ThreadState* ctst = VG_(get_ThreadState)(ctid); |
| 240 | ULong word64; |
| 241 | UWord* stack; |
sewardj | a48a493 | 2005-09-29 11:09:56 +0000 | [diff] [blame] | 242 | NSegment* seg; |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 243 | SysRes res; |
| 244 | vki_sigset_t blockall, savedmask; |
| 245 | |
| 246 | VG_(sigfillset)(&blockall); |
| 247 | |
| 248 | vg_assert(VG_(is_running_thread)(ptid)); |
| 249 | vg_assert(VG_(is_valid_tid)(ctid)); |
| 250 | |
njn | a3afdfb | 2005-11-09 04:49:28 +0000 | [diff] [blame] | 251 | stack = (UWord*)ML_(allocstack)(ctid); |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 252 | if (stack == NULL) { |
| 253 | res = VG_(mk_SysRes_Error)( VKI_ENOMEM ); |
| 254 | goto out; |
| 255 | } |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 256 | |
| 257 | //? /* make a stack frame */ |
| 258 | //? stack -= 16; |
| 259 | //? *(UWord *)stack = 0; |
| 260 | |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 261 | |
| 262 | /* Copy register state |
| 263 | |
| 264 | Both parent and child return to the same place, and the code |
| 265 | following the clone syscall works out which is which, so we |
| 266 | don't need to worry about it. |
| 267 | |
| 268 | The parent gets the child's new tid returned from clone, but the |
| 269 | child gets 0. |
| 270 | |
| 271 | If the clone call specifies a NULL SP for the new thread, then |
| 272 | it actually gets a copy of the parent's SP. |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 273 | |
| 274 | The child's TLS register (r2) gets set to the tlsaddr argument |
| 275 | if the CLONE_SETTLS flag is set. |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 276 | */ |
| 277 | setup_child( &ctst->arch, &ptst->arch ); |
| 278 | |
| 279 | /* Make sys_clone appear to have returned Success(0) in the |
| 280 | child. */ |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 281 | { UInt old_cr = LibVEX_GuestPPC32_get_CR( &ctst->arch.vex ); |
| 282 | /* %r3 = 0 */ |
| 283 | ctst->arch.vex.guest_GPR3 = 0; |
| 284 | /* %cr0.so = 0 */ |
| 285 | LibVEX_GuestPPC32_put_CR( old_cr & ~(1<<28), &ctst->arch.vex ); |
| 286 | } |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 287 | |
| 288 | if (sp != 0) |
| 289 | ctst->arch.vex.guest_GPR1 = sp; |
| 290 | |
| 291 | ctst->os_state.parent = ptid; |
| 292 | |
| 293 | /* inherit signal mask */ |
| 294 | ctst->sig_mask = ptst->sig_mask; |
| 295 | ctst->tmp_sig_mask = ptst->sig_mask; |
| 296 | |
| 297 | /* We don't really know where the client stack is, because its |
| 298 | allocated by the client. The best we can do is look at the |
| 299 | memory mappings and try to derive some useful information. We |
| 300 | assume that esp starts near its highest possible value, and can |
| 301 | only go down to the start of the mmaped segment. */ |
sewardj | a48a493 | 2005-09-29 11:09:56 +0000 | [diff] [blame] | 302 | seg = VG_(am_find_nsegment)(sp); |
| 303 | if (seg && seg->kind != SkResvn) { |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 304 | ctst->client_stack_highest_word = (Addr)VG_PGROUNDUP(sp); |
sewardj | a48a493 | 2005-09-29 11:09:56 +0000 | [diff] [blame] | 305 | ctst->client_stack_szB = ctst->client_stack_highest_word - seg->start; |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 306 | |
| 307 | if (debug) |
sewardj | e21058c | 2005-08-05 02:15:18 +0000 | [diff] [blame] | 308 | VG_(printf)("\ntid %d: guessed client stack range %p-%p\n", |
sewardj | a48a493 | 2005-09-29 11:09:56 +0000 | [diff] [blame] | 309 | ctid, seg->start, VG_PGROUNDUP(sp)); |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 310 | } else { |
| 311 | VG_(message)(Vg_UserMsg, "!? New thread %d starts with R1(%p) unmapped\n", |
| 312 | ctid, sp); |
| 313 | ctst->client_stack_szB = 0; |
| 314 | } |
| 315 | |
| 316 | if (flags & VKI_CLONE_SETTLS) { |
| 317 | if (debug) |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 318 | VG_(printf)("clone child has SETTLS: tls at %p\n", child_tls); |
| 319 | ctst->arch.vex.guest_GPR2 = child_tls; |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | flags &= ~VKI_CLONE_SETTLS; |
| 323 | |
| 324 | /* start the thread with everything blocked */ |
| 325 | VG_(sigprocmask)(VKI_SIG_SETMASK, &blockall, &savedmask); |
| 326 | |
| 327 | /* Create the new thread */ |
| 328 | word64 = do_syscall_clone_ppc32_linux( |
njn | a3afdfb | 2005-11-09 04:49:28 +0000 | [diff] [blame] | 329 | ML_(start_thread_NORETURN), stack, flags, &VG_(threads)[ctid], |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 330 | child_tidptr, parent_tidptr, NULL |
| 331 | ); |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 332 | /* High half word64 is syscall return value. Low half is |
| 333 | the entire CR, from which we need to extract CR0.SO. */ |
| 334 | /* VG_(printf)("word64 = 0x%llx\n", word64); */ |
| 335 | res = VG_(mk_SysRes_ppc32_linux)( |
| 336 | /*val*/(UInt)(word64 >> 32), |
| 337 | /*errflag*/ (((UInt)word64) >> 28) & 1 |
| 338 | ); |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 339 | |
| 340 | VG_(sigprocmask)(VKI_SIG_SETMASK, &savedmask, NULL); |
| 341 | |
sewardj | a48a493 | 2005-09-29 11:09:56 +0000 | [diff] [blame] | 342 | out: |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 343 | if (res.isError) { |
| 344 | /* clone failed */ |
| 345 | VG_(cleanup_thread)(&ctst->arch); |
| 346 | ctst->status = VgTs_Empty; |
| 347 | } |
| 348 | |
| 349 | return res; |
| 350 | } |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 351 | |
| 352 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 353 | |
| 354 | /* --------------------------------------------------------------------- |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 355 | More thread stuff |
| 356 | ------------------------------------------------------------------ */ |
| 357 | |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 358 | void VG_(cleanup_thread) ( ThreadArchState* arch ) |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 359 | { |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 360 | } |
| 361 | |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 362 | void setup_child ( /*OUT*/ ThreadArchState *child, |
| 363 | /*IN*/ ThreadArchState *parent ) |
| 364 | { |
| 365 | /* We inherit our parent's guest state. */ |
| 366 | child->vex = parent->vex; |
| 367 | child->vex_shadow = parent->vex_shadow; |
| 368 | } |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 369 | |
| 370 | |
| 371 | /* --------------------------------------------------------------------- |
| 372 | PRE/POST wrappers for ppc32/Linux-specific syscalls |
| 373 | ------------------------------------------------------------------ */ |
| 374 | |
| 375 | #define PRE(name) DEFN_PRE_TEMPLATE(ppc32_linux, name) |
| 376 | #define POST(name) DEFN_POST_TEMPLATE(ppc32_linux, name) |
| 377 | |
| 378 | /* Add prototypes for the wrappers declared here, so that gcc doesn't |
| 379 | harass us for not having prototypes. Really this is a kludge -- |
| 380 | the right thing to do is to make these wrappers 'static' since they |
| 381 | aren't visible outside this file, but that requires even more macro |
| 382 | magic. */ |
| 383 | |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 384 | DECL_TEMPLATE(ppc32_linux, sys_socketcall); |
tom | 9548a16 | 2005-09-30 08:07:53 +0000 | [diff] [blame] | 385 | DECL_TEMPLATE(ppc32_linux, sys_mmap); |
| 386 | DECL_TEMPLATE(ppc32_linux, sys_mmap2); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 387 | DECL_TEMPLATE(ppc32_linux, sys_stat64); |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 388 | DECL_TEMPLATE(ppc32_linux, sys_lstat64); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 389 | DECL_TEMPLATE(ppc32_linux, sys_fstat64); |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 390 | DECL_TEMPLATE(ppc32_linux, sys_ipc); |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 391 | DECL_TEMPLATE(ppc32_linux, sys_clone); |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 392 | DECL_TEMPLATE(ppc32_linux, sys_sigreturn); |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 393 | DECL_TEMPLATE(ppc32_linux, sys_rt_sigreturn); |
sewardj | 3849cc5 | 2005-11-07 15:48:31 +0000 | [diff] [blame] | 394 | DECL_TEMPLATE(ppc32_linux, sys_sigaction); |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 395 | |
| 396 | PRE(sys_socketcall) |
| 397 | { |
| 398 | # define ARG2_0 (((UWord*)ARG2)[0]) |
| 399 | # define ARG2_1 (((UWord*)ARG2)[1]) |
| 400 | # define ARG2_2 (((UWord*)ARG2)[2]) |
| 401 | # define ARG2_3 (((UWord*)ARG2)[3]) |
| 402 | # define ARG2_4 (((UWord*)ARG2)[4]) |
| 403 | # define ARG2_5 (((UWord*)ARG2)[5]) |
| 404 | |
| 405 | *flags |= SfMayBlock; |
| 406 | PRINT("sys_socketcall ( %d, %p )",ARG1,ARG2); |
| 407 | PRE_REG_READ2(long, "socketcall", int, call, unsigned long *, args); |
| 408 | |
| 409 | switch (ARG1 /* request */) { |
| 410 | |
| 411 | case VKI_SYS_SOCKETPAIR: |
| 412 | /* int socketpair(int d, int type, int protocol, int sv[2]); */ |
| 413 | PRE_MEM_READ( "socketcall.socketpair(args)", ARG2, 4*sizeof(Addr) ); |
| 414 | ML_(generic_PRE_sys_socketpair)( tid, ARG2_0, ARG2_1, ARG2_2, ARG2_3 ); |
| 415 | break; |
| 416 | |
| 417 | case VKI_SYS_SOCKET: |
| 418 | /* int socket(int domain, int type, int protocol); */ |
| 419 | PRE_MEM_READ( "socketcall.socket(args)", ARG2, 3*sizeof(Addr) ); |
| 420 | break; |
| 421 | |
| 422 | case VKI_SYS_BIND: |
| 423 | /* int bind(int sockfd, struct sockaddr *my_addr, |
| 424 | int addrlen); */ |
| 425 | PRE_MEM_READ( "socketcall.bind(args)", ARG2, 3*sizeof(Addr) ); |
| 426 | ML_(generic_PRE_sys_bind)( tid, ARG2_0, ARG2_1, ARG2_2 ); |
| 427 | break; |
| 428 | |
| 429 | case VKI_SYS_LISTEN: |
| 430 | /* int listen(int s, int backlog); */ |
| 431 | PRE_MEM_READ( "socketcall.listen(args)", ARG2, 2*sizeof(Addr) ); |
| 432 | break; |
| 433 | |
| 434 | case VKI_SYS_ACCEPT: { |
| 435 | /* int accept(int s, struct sockaddr *addr, int *addrlen); */ |
| 436 | PRE_MEM_READ( "socketcall.accept(args)", ARG2, 3*sizeof(Addr) ); |
| 437 | ML_(generic_PRE_sys_accept)( tid, ARG2_0, ARG2_1, ARG2_2 ); |
| 438 | break; |
| 439 | } |
| 440 | |
| 441 | case VKI_SYS_SENDTO: |
| 442 | /* int sendto(int s, const void *msg, int len, |
| 443 | unsigned int flags, |
| 444 | const struct sockaddr *to, int tolen); */ |
| 445 | PRE_MEM_READ( "socketcall.sendto(args)", ARG2, 6*sizeof(Addr) ); |
| 446 | ML_(generic_PRE_sys_sendto)( tid, ARG2_0, ARG2_1, ARG2_2, |
| 447 | ARG2_3, ARG2_4, ARG2_5 ); |
| 448 | break; |
| 449 | |
| 450 | case VKI_SYS_SEND: |
| 451 | /* int send(int s, const void *msg, size_t len, int flags); */ |
| 452 | PRE_MEM_READ( "socketcall.send(args)", ARG2, 4*sizeof(Addr) ); |
| 453 | ML_(generic_PRE_sys_send)( tid, ARG2_0, ARG2_1, ARG2_2 ); |
| 454 | break; |
| 455 | |
| 456 | case VKI_SYS_RECVFROM: |
| 457 | /* int recvfrom(int s, void *buf, int len, unsigned int flags, |
| 458 | struct sockaddr *from, int *fromlen); */ |
| 459 | PRE_MEM_READ( "socketcall.recvfrom(args)", ARG2, 6*sizeof(Addr) ); |
| 460 | ML_(generic_PRE_sys_recvfrom)( tid, ARG2_0, ARG2_1, ARG2_2, |
| 461 | ARG2_3, ARG2_4, ARG2_5 ); |
| 462 | break; |
| 463 | |
| 464 | case VKI_SYS_RECV: |
| 465 | /* int recv(int s, void *buf, int len, unsigned int flags); */ |
| 466 | /* man 2 recv says: |
| 467 | The recv call is normally used only on a connected socket |
| 468 | (see connect(2)) and is identical to recvfrom with a NULL |
| 469 | from parameter. |
| 470 | */ |
| 471 | PRE_MEM_READ( "socketcall.recv(args)", ARG2, 4*sizeof(Addr) ); |
| 472 | ML_(generic_PRE_sys_recv)( tid, ARG2_0, ARG2_1, ARG2_2 ); |
| 473 | break; |
| 474 | |
| 475 | case VKI_SYS_CONNECT: |
| 476 | /* int connect(int sockfd, |
| 477 | struct sockaddr *serv_addr, int addrlen ); */ |
| 478 | PRE_MEM_READ( "socketcall.connect(args)", ARG2, 3*sizeof(Addr) ); |
| 479 | ML_(generic_PRE_sys_connect)( tid, ARG2_0, ARG2_1, ARG2_2 ); |
| 480 | break; |
| 481 | |
| 482 | case VKI_SYS_SETSOCKOPT: |
| 483 | /* int setsockopt(int s, int level, int optname, |
| 484 | const void *optval, int optlen); */ |
| 485 | PRE_MEM_READ( "socketcall.setsockopt(args)", ARG2, 5*sizeof(Addr) ); |
| 486 | ML_(generic_PRE_sys_setsockopt)( tid, ARG2_0, ARG2_1, ARG2_2, |
| 487 | ARG2_3, ARG2_4 ); |
| 488 | break; |
| 489 | |
| 490 | case VKI_SYS_GETSOCKOPT: |
| 491 | /* int getsockopt(int s, int level, int optname, |
| 492 | void *optval, socklen_t *optlen); */ |
| 493 | PRE_MEM_READ( "socketcall.getsockopt(args)", ARG2, 5*sizeof(Addr) ); |
| 494 | ML_(generic_PRE_sys_getsockopt)( tid, ARG2_0, ARG2_1, ARG2_2, |
| 495 | ARG2_3, ARG2_4 ); |
| 496 | break; |
| 497 | |
| 498 | case VKI_SYS_GETSOCKNAME: |
| 499 | /* int getsockname(int s, struct sockaddr* name, int* namelen) */ |
| 500 | PRE_MEM_READ( "socketcall.getsockname(args)", ARG2, 3*sizeof(Addr) ); |
| 501 | ML_(generic_PRE_sys_getsockname)( tid, ARG2_0, ARG2_1, ARG2_2 ); |
| 502 | break; |
| 503 | |
| 504 | case VKI_SYS_GETPEERNAME: |
| 505 | /* int getpeername(int s, struct sockaddr* name, int* namelen) */ |
| 506 | PRE_MEM_READ( "socketcall.getpeername(args)", ARG2, 3*sizeof(Addr) ); |
| 507 | ML_(generic_PRE_sys_getpeername)( tid, ARG2_0, ARG2_1, ARG2_2 ); |
| 508 | break; |
| 509 | |
| 510 | case VKI_SYS_SHUTDOWN: |
| 511 | /* int shutdown(int s, int how); */ |
| 512 | PRE_MEM_READ( "socketcall.shutdown(args)", ARG2, 2*sizeof(Addr) ); |
| 513 | break; |
| 514 | |
| 515 | case VKI_SYS_SENDMSG: { |
| 516 | /* int sendmsg(int s, const struct msghdr *msg, int flags); */ |
| 517 | |
| 518 | /* this causes warnings, and I don't get why. glibc bug? |
| 519 | * (after all it's glibc providing the arguments array) |
| 520 | PRE_MEM_READ( "socketcall.sendmsg(args)", ARG2, 3*sizeof(Addr) ); |
| 521 | */ |
| 522 | ML_(generic_PRE_sys_sendmsg)( tid, ARG2_0, ARG2_1 ); |
| 523 | break; |
| 524 | } |
| 525 | |
| 526 | case VKI_SYS_RECVMSG: { |
| 527 | /* int recvmsg(int s, struct msghdr *msg, int flags); */ |
| 528 | |
| 529 | /* this causes warnings, and I don't get why. glibc bug? |
| 530 | * (after all it's glibc providing the arguments array) |
| 531 | PRE_MEM_READ("socketcall.recvmsg(args)", ARG2, 3*sizeof(Addr) ); |
| 532 | */ |
| 533 | ML_(generic_PRE_sys_recvmsg)( tid, ARG2_0, ARG2_1 ); |
| 534 | break; |
| 535 | } |
| 536 | |
| 537 | default: |
| 538 | VG_(message)(Vg_DebugMsg,"Warning: unhandled socketcall 0x%x",ARG1); |
| 539 | SET_STATUS_Failure( VKI_EINVAL ); |
| 540 | break; |
| 541 | } |
| 542 | # undef ARG2_0 |
| 543 | # undef ARG2_1 |
| 544 | # undef ARG2_2 |
| 545 | # undef ARG2_3 |
| 546 | # undef ARG2_4 |
| 547 | # undef ARG2_5 |
| 548 | } |
| 549 | |
| 550 | POST(sys_socketcall) |
| 551 | { |
| 552 | # define ARG2_0 (((UWord*)ARG2)[0]) |
| 553 | # define ARG2_1 (((UWord*)ARG2)[1]) |
| 554 | # define ARG2_2 (((UWord*)ARG2)[2]) |
| 555 | # define ARG2_3 (((UWord*)ARG2)[3]) |
| 556 | # define ARG2_4 (((UWord*)ARG2)[4]) |
| 557 | # define ARG2_5 (((UWord*)ARG2)[5]) |
| 558 | |
| 559 | SysRes r; |
| 560 | vg_assert(SUCCESS); |
| 561 | switch (ARG1 /* request */) { |
| 562 | |
| 563 | case VKI_SYS_SOCKETPAIR: |
| 564 | r = ML_(generic_POST_sys_socketpair)( |
| 565 | tid, VG_(mk_SysRes_Success)(RES), |
| 566 | ARG2_0, ARG2_1, ARG2_2, ARG2_3 |
| 567 | ); |
| 568 | SET_STATUS_from_SysRes(r); |
| 569 | break; |
| 570 | |
| 571 | case VKI_SYS_SOCKET: |
| 572 | r = ML_(generic_POST_sys_socket)( tid, VG_(mk_SysRes_Success)(RES) ); |
| 573 | SET_STATUS_from_SysRes(r); |
| 574 | break; |
| 575 | |
| 576 | case VKI_SYS_BIND: |
| 577 | /* int bind(int sockfd, struct sockaddr *my_addr, |
| 578 | int addrlen); */ |
| 579 | break; |
| 580 | |
| 581 | case VKI_SYS_LISTEN: |
| 582 | /* int listen(int s, int backlog); */ |
| 583 | break; |
| 584 | |
| 585 | case VKI_SYS_ACCEPT: |
| 586 | /* int accept(int s, struct sockaddr *addr, int *addrlen); */ |
| 587 | r = ML_(generic_POST_sys_accept)( tid, VG_(mk_SysRes_Success)(RES), |
| 588 | ARG2_0, ARG2_1, ARG2_2 ); |
| 589 | SET_STATUS_from_SysRes(r); |
| 590 | break; |
| 591 | |
| 592 | case VKI_SYS_SENDTO: |
| 593 | break; |
| 594 | |
| 595 | case VKI_SYS_SEND: |
| 596 | break; |
| 597 | |
| 598 | case VKI_SYS_RECVFROM: |
| 599 | ML_(generic_POST_sys_recvfrom)( tid, VG_(mk_SysRes_Success)(RES), |
| 600 | ARG2_0, ARG2_1, ARG2_2, |
| 601 | ARG2_3, ARG2_4, ARG2_5 ); |
| 602 | break; |
| 603 | |
| 604 | case VKI_SYS_RECV: |
| 605 | ML_(generic_POST_sys_recv)( tid, RES, ARG2_0, ARG2_1, ARG2_2 ); |
| 606 | break; |
| 607 | |
| 608 | case VKI_SYS_CONNECT: |
| 609 | break; |
| 610 | |
| 611 | case VKI_SYS_SETSOCKOPT: |
| 612 | break; |
| 613 | |
| 614 | case VKI_SYS_GETSOCKOPT: |
| 615 | ML_(generic_POST_sys_getsockopt)( tid, VG_(mk_SysRes_Success)(RES), |
| 616 | ARG2_0, ARG2_1, |
| 617 | ARG2_2, ARG2_3, ARG2_4 ); |
| 618 | break; |
| 619 | |
| 620 | case VKI_SYS_GETSOCKNAME: |
| 621 | ML_(generic_POST_sys_getsockname)( tid, VG_(mk_SysRes_Success)(RES), |
| 622 | ARG2_0, ARG2_1, ARG2_2 ); |
| 623 | break; |
| 624 | |
| 625 | case VKI_SYS_GETPEERNAME: |
| 626 | ML_(generic_POST_sys_getpeername)( tid, VG_(mk_SysRes_Success)(RES), |
| 627 | ARG2_0, ARG2_1, ARG2_2 ); |
| 628 | break; |
| 629 | |
| 630 | case VKI_SYS_SHUTDOWN: |
| 631 | break; |
| 632 | |
| 633 | case VKI_SYS_SENDMSG: |
| 634 | break; |
| 635 | |
| 636 | case VKI_SYS_RECVMSG: |
| 637 | ML_(generic_POST_sys_recvmsg)( tid, ARG2_0, ARG2_1 ); |
| 638 | break; |
| 639 | |
| 640 | default: |
| 641 | VG_(message)(Vg_DebugMsg,"FATAL: unhandled socketcall 0x%x",ARG1); |
| 642 | VG_(core_panic)("... bye!\n"); |
| 643 | break; /*NOTREACHED*/ |
| 644 | } |
| 645 | # undef ARG2_0 |
| 646 | # undef ARG2_1 |
| 647 | # undef ARG2_2 |
| 648 | # undef ARG2_3 |
| 649 | # undef ARG2_4 |
| 650 | # undef ARG2_5 |
| 651 | } |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 652 | |
tom | 9548a16 | 2005-09-30 08:07:53 +0000 | [diff] [blame] | 653 | PRE(sys_mmap) |
| 654 | { |
| 655 | SysRes r; |
| 656 | |
| 657 | PRINT("sys_mmap ( %p, %llu, %d, %d, %d, %d )", |
| 658 | ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, ARG6 ); |
| 659 | PRE_REG_READ6(long, "mmap", |
| 660 | unsigned long, start, unsigned long, length, |
| 661 | unsigned long, prot, unsigned long, flags, |
| 662 | unsigned long, fd, unsigned long, offset); |
| 663 | |
sewardj | 274461d | 2005-10-02 17:01:41 +0000 | [diff] [blame] | 664 | r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, |
| 665 | (Off64T)ARG6 ); |
tom | 9548a16 | 2005-09-30 08:07:53 +0000 | [diff] [blame] | 666 | SET_STATUS_from_SysRes(r); |
| 667 | } |
| 668 | |
| 669 | PRE(sys_mmap2) |
| 670 | { |
| 671 | SysRes r; |
| 672 | |
| 673 | // Exactly like old_mmap() except: |
| 674 | // - the file offset is specified in pagesize units rather than bytes, |
| 675 | // so that it can be used for files bigger than 2^32 bytes. |
| 676 | PRINT("sys_mmap2 ( %p, %llu, %d, %d, %d, %d )", |
| 677 | ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, ARG6 ); |
| 678 | PRE_REG_READ6(long, "mmap2", |
| 679 | unsigned long, start, unsigned long, length, |
| 680 | unsigned long, prot, unsigned long, flags, |
| 681 | unsigned long, fd, unsigned long, offset); |
| 682 | |
sewardj | 274461d | 2005-10-02 17:01:41 +0000 | [diff] [blame] | 683 | r = ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5, |
sewardj | 1ba8031 | 2005-10-02 17:33:07 +0000 | [diff] [blame] | 684 | VKI_PAGE_SIZE * (Off64T)ARG6 ); |
tom | 9548a16 | 2005-09-30 08:07:53 +0000 | [diff] [blame] | 685 | SET_STATUS_from_SysRes(r); |
| 686 | } |
| 687 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 688 | // XXX: lstat64/fstat64/stat64 are generic, but not necessarily |
| 689 | // applicable to every architecture -- I think only to 32-bit archs. |
| 690 | // We're going to need something like linux/core_os32.h for such |
| 691 | // things, eventually, I think. --njn |
| 692 | PRE(sys_stat64) |
| 693 | { |
| 694 | PRINT("sys_stat64 ( %p, %p )",ARG1,ARG2); |
| 695 | PRE_REG_READ2(long, "stat64", char *, file_name, struct stat64 *, buf); |
| 696 | PRE_MEM_RASCIIZ( "stat64(file_name)", ARG1 ); |
| 697 | PRE_MEM_WRITE( "stat64(buf)", ARG2, sizeof(struct vki_stat64) ); |
| 698 | } |
| 699 | |
| 700 | POST(sys_stat64) |
| 701 | { |
| 702 | POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) ); |
| 703 | } |
| 704 | |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 705 | PRE(sys_lstat64) |
| 706 | { |
| 707 | PRINT("sys_lstat64 ( %p(%s), %p )",ARG1,ARG1,ARG2); |
| 708 | PRE_REG_READ2(long, "lstat64", char *, file_name, struct stat64 *, buf); |
| 709 | PRE_MEM_RASCIIZ( "lstat64(file_name)", ARG1 ); |
| 710 | PRE_MEM_WRITE( "lstat64(buf)", ARG2, sizeof(struct vki_stat64) ); |
| 711 | } |
| 712 | |
| 713 | POST(sys_lstat64) |
| 714 | { |
| 715 | vg_assert(SUCCESS); |
| 716 | if (RES == 0) { |
| 717 | POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) ); |
| 718 | } |
| 719 | } |
| 720 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 721 | PRE(sys_fstat64) |
| 722 | { |
| 723 | PRINT("sys_fstat64 ( %d, %p )",ARG1,ARG2); |
| 724 | PRE_REG_READ2(long, "fstat64", unsigned long, fd, struct stat64 *, buf); |
| 725 | PRE_MEM_WRITE( "fstat64(buf)", ARG2, sizeof(struct vki_stat64) ); |
| 726 | } |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 727 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 728 | POST(sys_fstat64) |
| 729 | { |
| 730 | POST_MEM_WRITE( ARG2, sizeof(struct vki_stat64) ); |
| 731 | } |
| 732 | |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 733 | static Addr deref_Addr ( ThreadId tid, Addr a, Char* s ) |
| 734 | { |
| 735 | Addr* a_p = (Addr*)a; |
| 736 | PRE_MEM_READ( s, (Addr)a_p, sizeof(Addr) ); |
| 737 | return *a_p; |
| 738 | } |
| 739 | |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 740 | PRE(sys_ipc) |
| 741 | { |
| 742 | PRINT("sys_ipc ( %d, %d, %d, %d, %p, %d )", ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); |
| 743 | // XXX: this is simplistic -- some args are not used in all circumstances. |
| 744 | PRE_REG_READ6(int, "ipc", |
| 745 | vki_uint, call, int, first, int, second, int, third, |
| 746 | void *, ptr, long, fifth) |
| 747 | |
| 748 | switch (ARG1 /* call */) { |
| 749 | case VKI_SEMOP: |
| 750 | ML_(generic_PRE_sys_semop)( tid, ARG2, ARG5, ARG3 ); |
| 751 | *flags |= SfMayBlock; |
| 752 | break; |
| 753 | case VKI_SEMGET: |
| 754 | break; |
| 755 | case VKI_SEMCTL: |
| 756 | { |
| 757 | UWord arg = deref_Addr( tid, ARG5, "semctl(arg)" ); |
| 758 | ML_(generic_PRE_sys_semctl)( tid, ARG2, ARG3, ARG4, arg ); |
| 759 | break; |
| 760 | } |
| 761 | case VKI_SEMTIMEDOP: |
| 762 | ML_(generic_PRE_sys_semtimedop)( tid, ARG2, ARG5, ARG3, ARG6 ); |
| 763 | *flags |= SfMayBlock; |
| 764 | break; |
| 765 | case VKI_MSGSND: |
njn | de5c5f5 | 2005-09-01 03:35:40 +0000 | [diff] [blame] | 766 | ML_(linux_PRE_sys_msgsnd)( tid, ARG2, ARG5, ARG3, ARG4 ); |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 767 | if ((ARG4 & VKI_IPC_NOWAIT) == 0) |
| 768 | *flags |= SfMayBlock; |
| 769 | break; |
| 770 | case VKI_MSGRCV: |
| 771 | { |
| 772 | Addr msgp; |
| 773 | Word msgtyp; |
| 774 | |
| 775 | msgp = deref_Addr( tid, |
| 776 | (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgp), |
| 777 | "msgrcv(msgp)" ); |
| 778 | msgtyp = deref_Addr( tid, |
| 779 | (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgtyp), |
| 780 | "msgrcv(msgp)" ); |
| 781 | |
njn | de5c5f5 | 2005-09-01 03:35:40 +0000 | [diff] [blame] | 782 | ML_(linux_PRE_sys_msgrcv)( tid, ARG2, msgp, ARG3, msgtyp, ARG4 ); |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 783 | |
| 784 | if ((ARG4 & VKI_IPC_NOWAIT) == 0) |
| 785 | *flags |= SfMayBlock; |
| 786 | break; |
| 787 | } |
| 788 | case VKI_MSGGET: |
| 789 | break; |
| 790 | case VKI_MSGCTL: |
njn | de5c5f5 | 2005-09-01 03:35:40 +0000 | [diff] [blame] | 791 | ML_(linux_PRE_sys_msgctl)( tid, ARG2, ARG3, ARG5 ); |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 792 | break; |
| 793 | case VKI_SHMAT: |
| 794 | { |
| 795 | UWord w; |
| 796 | PRE_MEM_WRITE( "shmat(raddr)", ARG4, sizeof(Addr) ); |
| 797 | w = ML_(generic_PRE_sys_shmat)( tid, ARG2, ARG5, ARG3 ); |
| 798 | if (w == 0) |
| 799 | SET_STATUS_Failure( VKI_EINVAL ); |
| 800 | else |
| 801 | ARG5 = w; |
| 802 | break; |
| 803 | } |
| 804 | case VKI_SHMDT: |
| 805 | if (!ML_(generic_PRE_sys_shmdt)(tid, ARG5)) |
| 806 | SET_STATUS_Failure( VKI_EINVAL ); |
| 807 | break; |
| 808 | case VKI_SHMGET: |
| 809 | break; |
| 810 | case VKI_SHMCTL: /* IPCOP_shmctl */ |
| 811 | ML_(generic_PRE_sys_shmctl)( tid, ARG2, ARG3, ARG5 ); |
| 812 | break; |
| 813 | default: |
| 814 | VG_(message)(Vg_DebugMsg, "FATAL: unhandled syscall(ipc) %d", ARG1 ); |
| 815 | VG_(core_panic)("... bye!\n"); |
| 816 | break; /*NOTREACHED*/ |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | POST(sys_ipc) |
| 821 | { |
| 822 | vg_assert(SUCCESS); |
| 823 | switch (ARG1 /* call */) { |
| 824 | case VKI_SEMOP: |
| 825 | case VKI_SEMGET: |
| 826 | break; |
| 827 | case VKI_SEMCTL: |
| 828 | { |
| 829 | UWord arg = deref_Addr( tid, ARG5, "semctl(arg)" ); |
| 830 | ML_(generic_PRE_sys_semctl)( tid, ARG2, ARG3, ARG4, arg ); |
| 831 | break; |
| 832 | } |
| 833 | case VKI_SEMTIMEDOP: |
| 834 | case VKI_MSGSND: |
| 835 | break; |
| 836 | case VKI_MSGRCV: |
| 837 | { |
| 838 | Addr msgp; |
| 839 | Word msgtyp; |
| 840 | |
| 841 | msgp = deref_Addr( tid, |
| 842 | (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgp), |
| 843 | "msgrcv(msgp)" ); |
| 844 | msgtyp = deref_Addr( tid, |
| 845 | (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgtyp), |
| 846 | "msgrcv(msgp)" ); |
| 847 | |
njn | a560c5c | 2005-09-01 16:27:28 +0000 | [diff] [blame] | 848 | ML_(linux_POST_sys_msgrcv)( tid, RES, ARG2, msgp, ARG3, msgtyp, ARG4 ); |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 849 | break; |
| 850 | } |
| 851 | case VKI_MSGGET: |
| 852 | break; |
| 853 | case VKI_MSGCTL: |
njn | a560c5c | 2005-09-01 16:27:28 +0000 | [diff] [blame] | 854 | ML_(linux_POST_sys_msgctl)( tid, RES, ARG2, ARG3, ARG5 ); |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 855 | break; |
| 856 | case VKI_SHMAT: |
| 857 | { |
| 858 | Addr addr; |
| 859 | |
| 860 | /* force readability. before the syscall it is |
| 861 | * indeed uninitialized, as can be seen in |
| 862 | * glibc/sysdeps/unix/sysv/linux/shmat.c */ |
| 863 | POST_MEM_WRITE( ARG4, sizeof( Addr ) ); |
| 864 | |
| 865 | addr = deref_Addr ( tid, ARG4, "shmat(addr)" ); |
| 866 | if ( addr > 0 ) { |
| 867 | ML_(generic_POST_sys_shmat)( tid, addr, ARG2, ARG5, ARG3 ); |
| 868 | } |
| 869 | break; |
| 870 | } |
| 871 | case VKI_SHMDT: |
| 872 | ML_(generic_POST_sys_shmdt)( tid, RES, ARG5 ); |
| 873 | break; |
| 874 | case VKI_SHMGET: |
| 875 | break; |
| 876 | case VKI_SHMCTL: |
| 877 | ML_(generic_POST_sys_shmctl)( tid, RES, ARG2, ARG3, ARG5 ); |
| 878 | break; |
| 879 | default: |
| 880 | VG_(message)(Vg_DebugMsg, |
| 881 | "FATAL: unhandled syscall(ipc) %d", |
| 882 | ARG1 ); |
| 883 | VG_(core_panic)("... bye!\n"); |
| 884 | break; /*NOTREACHED*/ |
| 885 | } |
| 886 | } |
| 887 | |
| 888 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 889 | |
| 890 | |
| 891 | //.. PRE(old_select, MayBlock) |
| 892 | //.. { |
| 893 | //.. /* struct sel_arg_struct { |
| 894 | //.. unsigned long n; |
| 895 | //.. fd_set *inp, *outp, *exp; |
| 896 | //.. struct timeval *tvp; |
| 897 | //.. }; |
| 898 | //.. */ |
| 899 | //.. PRE_REG_READ1(long, "old_select", struct sel_arg_struct *, args); |
| 900 | //.. PRE_MEM_READ( "old_select(args)", ARG1, 5*sizeof(UWord) ); |
| 901 | //.. |
| 902 | //.. { |
| 903 | //.. UInt* arg_struct = (UInt*)ARG1; |
| 904 | //.. UInt a1, a2, a3, a4, a5; |
| 905 | //.. |
| 906 | //.. a1 = arg_struct[0]; |
| 907 | //.. a2 = arg_struct[1]; |
| 908 | //.. a3 = arg_struct[2]; |
| 909 | //.. a4 = arg_struct[3]; |
| 910 | //.. a5 = arg_struct[4]; |
| 911 | //.. |
| 912 | //.. PRINT("old_select ( %d, %p, %p, %p, %p )", a1,a2,a3,a4,a5); |
| 913 | //.. if (a2 != (Addr)NULL) |
| 914 | //.. PRE_MEM_READ( "old_select(readfds)", a2, a1/8 /* __FD_SETSIZE/8 */ ); |
| 915 | //.. if (a3 != (Addr)NULL) |
| 916 | //.. PRE_MEM_READ( "old_select(writefds)", a3, a1/8 /* __FD_SETSIZE/8 */ ); |
| 917 | //.. if (a4 != (Addr)NULL) |
| 918 | //.. PRE_MEM_READ( "old_select(exceptfds)", a4, a1/8 /* __FD_SETSIZE/8 */ ); |
| 919 | //.. if (a5 != (Addr)NULL) |
| 920 | //.. PRE_MEM_READ( "old_select(timeout)", a5, sizeof(struct vki_timeval) ); |
| 921 | //.. } |
| 922 | //.. } |
| 923 | |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 924 | PRE(sys_clone) |
| 925 | { |
| 926 | UInt cloneflags; |
| 927 | |
| 928 | PRINT("sys_clone ( %x, %p, %p, %p, %p )",ARG1,ARG2,ARG3,ARG4,ARG5); |
| 929 | PRE_REG_READ5(int, "clone", |
| 930 | unsigned long, flags, |
sewardj | e21058c | 2005-08-05 02:15:18 +0000 | [diff] [blame] | 931 | void *, child_stack, |
| 932 | int *, parent_tidptr, |
| 933 | void *, child_tls, |
| 934 | int *, child_tidptr); |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 935 | |
| 936 | if (ARG1 & VKI_CLONE_PARENT_SETTID) { |
| 937 | PRE_MEM_WRITE("clone(parent_tidptr)", ARG3, sizeof(Int)); |
sewardj | a48a493 | 2005-09-29 11:09:56 +0000 | [diff] [blame] | 938 | if (!VG_(am_is_valid_for_client)(ARG3, sizeof(Int), |
| 939 | VKI_PROT_WRITE)) { |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 940 | SET_STATUS_Failure( VKI_EFAULT ); |
| 941 | return; |
| 942 | } |
| 943 | } |
| 944 | if (ARG1 & (VKI_CLONE_CHILD_SETTID | VKI_CLONE_CHILD_CLEARTID)) { |
| 945 | PRE_MEM_WRITE("clone(child_tidptr)", ARG5, sizeof(Int)); |
sewardj | a48a493 | 2005-09-29 11:09:56 +0000 | [diff] [blame] | 946 | if (!VG_(am_is_valid_for_client)(ARG5, sizeof(Int), |
| 947 | VKI_PROT_WRITE)) { |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 948 | SET_STATUS_Failure( VKI_EFAULT ); |
| 949 | return; |
| 950 | } |
| 951 | } |
| 952 | |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 953 | cloneflags = ARG1; |
| 954 | |
| 955 | if (!ML_(client_signal_OK)(ARG1 & VKI_CSIGNAL)) { |
| 956 | SET_STATUS_Failure( VKI_EINVAL ); |
| 957 | return; |
| 958 | } |
| 959 | |
| 960 | /* Only look at the flags we really care about */ |
| 961 | switch (cloneflags & (VKI_CLONE_VM | VKI_CLONE_FS |
| 962 | | VKI_CLONE_FILES | VKI_CLONE_VFORK)) { |
| 963 | case VKI_CLONE_VM | VKI_CLONE_FS | VKI_CLONE_FILES: |
| 964 | /* thread creation */ |
| 965 | SET_STATUS_from_SysRes( |
| 966 | do_clone(tid, |
| 967 | ARG1, /* flags */ |
| 968 | (Addr)ARG2, /* child SP */ |
| 969 | (Int *)ARG3, /* parent_tidptr */ |
| 970 | (Int *)ARG5, /* child_tidptr */ |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 971 | (Addr)ARG4)); /* child_tls */ |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 972 | break; |
| 973 | |
| 974 | case VKI_CLONE_VFORK | VKI_CLONE_VM: /* vfork */ |
| 975 | /* FALLTHROUGH - assume vfork == fork */ |
| 976 | cloneflags &= ~(VKI_CLONE_VFORK | VKI_CLONE_VM); |
| 977 | |
| 978 | case 0: /* plain fork */ |
| 979 | SET_STATUS_from_SysRes( |
njn | e148666 | 2005-11-10 02:48:04 +0000 | [diff] [blame] | 980 | ML_(do_fork_clone)(tid, |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 981 | cloneflags, /* flags */ |
sewardj | e23772f | 2005-07-02 11:27:02 +0000 | [diff] [blame] | 982 | (Int *)ARG3, /* parent_tidptr */ |
| 983 | (Int *)ARG5)); /* child_tidptr */ |
| 984 | break; |
| 985 | |
| 986 | default: |
| 987 | /* should we just ENOSYS? */ |
| 988 | VG_(message)(Vg_UserMsg, "Unsupported clone() flags: 0x%x", ARG1); |
| 989 | VG_(message)(Vg_UserMsg, ""); |
| 990 | VG_(message)(Vg_UserMsg, "The only supported clone() uses are:"); |
| 991 | VG_(message)(Vg_UserMsg, " - via a threads library (LinuxThreads or NPTL)"); |
| 992 | VG_(message)(Vg_UserMsg, " - via the implementation of fork or vfork"); |
| 993 | VG_(unimplemented) |
| 994 | ("Valgrind does not support general clone()."); |
| 995 | } |
| 996 | |
| 997 | if (SUCCESS) { |
| 998 | if (ARG1 & VKI_CLONE_PARENT_SETTID) |
| 999 | POST_MEM_WRITE(ARG3, sizeof(Int)); |
| 1000 | if (ARG1 & (VKI_CLONE_CHILD_SETTID | VKI_CLONE_CHILD_CLEARTID)) |
| 1001 | POST_MEM_WRITE(ARG5, sizeof(Int)); |
| 1002 | |
| 1003 | /* Thread creation was successful; let the child have the chance |
| 1004 | to run */ |
| 1005 | *flags |= SfYieldAfter; |
| 1006 | } |
| 1007 | } |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1008 | |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1009 | PRE(sys_sigreturn) |
| 1010 | { |
| 1011 | ThreadState* tst; |
| 1012 | PRINT("sigreturn ( )"); |
| 1013 | |
| 1014 | vg_assert(VG_(is_valid_tid)(tid)); |
| 1015 | vg_assert(tid >= 1 && tid < VG_N_THREADS); |
| 1016 | vg_assert(VG_(is_running_thread)(tid)); |
| 1017 | |
| 1018 | ///* Adjust esp to point to start of frame; skip back up over |
| 1019 | // sigreturn sequence's "popl %eax" and handler ret addr */ |
| 1020 | tst = VG_(get_ThreadState)(tid); |
| 1021 | //tst->arch.vex.guest_ESP -= sizeof(Addr)+sizeof(Word); |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 1022 | // Should we do something equivalent on ppc32? Who knows. |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1023 | |
| 1024 | ///* This is only so that the EIP is (might be) useful to report if |
| 1025 | // something goes wrong in the sigreturn */ |
| 1026 | //ML_(fixup_guest_state_to_restart_syscall)(&tst->arch); |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 1027 | // Should we do something equivalent on ppc32? Who knows. |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1028 | |
| 1029 | VG_(sigframe_destroy)(tid, False); |
| 1030 | |
| 1031 | /* For unclear reasons, it appears we need the syscall to return |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 1032 | without changing R3. Since R3 is the return value, and can |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1033 | denote either success or failure, we must set up so that the |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 1034 | driver logic copies it back unchanged. Also, note R3 is of |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1035 | the guest registers written by VG_(sigframe_destroy). */ |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 1036 | /* jrs 16 Nov 05: for some reason this occasionally causes the |
| 1037 | is-this-a-sane-error-value sanity check to fail: |
| 1038 | m_syswrap/syswrap-ppc32-linux.c:1037 |
| 1039 | (vgSysWrap_ppc32_linux_sys_sigreturn_before): |
| 1040 | Assertion 'wzz >= 0 && wzz < 10000' failed. |
| 1041 | Hence use a sanity-check-free version. |
| 1042 | Perhaps we should ignore CR0.S0 here? |
| 1043 | In general I have no idea what this is for or if it is necessary. |
| 1044 | It's a conceptual copy-n-paste from the x86 equivalent, but I'm |
| 1045 | equally unclear as to whether it is needed there either. |
| 1046 | */ |
| 1047 | SET_STATUS_from_SysRes_NO_SANITY_CHECK( |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1048 | VG_(mk_SysRes_ppc32_linux)( |
| 1049 | tst->arch.vex.guest_GPR3, |
sewardj | 463b3d9 | 2005-07-18 11:41:15 +0000 | [diff] [blame] | 1050 | /* get CR0.SO */ |
| 1051 | (LibVEX_GuestPPC32_get_CR( &tst->arch.vex ) >> 28) & 1 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1052 | ) |
| 1053 | ); |
| 1054 | |
| 1055 | /* Check to see if some any signals arose as a result of this. */ |
| 1056 | *flags |= SfPollAfter; |
| 1057 | } |
| 1058 | |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 1059 | PRE(sys_rt_sigreturn) |
| 1060 | { |
| 1061 | ThreadState* tst; |
| 1062 | PRINT("rt_sigreturn ( )"); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1063 | |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 1064 | vg_assert(VG_(is_valid_tid)(tid)); |
| 1065 | vg_assert(tid >= 1 && tid < VG_N_THREADS); |
| 1066 | vg_assert(VG_(is_running_thread)(tid)); |
| 1067 | |
| 1068 | ///* Adjust esp to point to start of frame; skip back up over handler |
| 1069 | // ret addr */ |
| 1070 | tst = VG_(get_ThreadState)(tid); |
| 1071 | //tst->arch.vex.guest_ESP -= sizeof(Addr); |
| 1072 | // Should we do something equivalent on ppc32? Who knows. |
| 1073 | |
| 1074 | ///* This is only so that the EIP is (might be) useful to report if |
| 1075 | // something goes wrong in the sigreturn */ |
| 1076 | //ML_(fixup_guest_state_to_restart_syscall)(&tst->arch); |
| 1077 | // Should we do something equivalent on ppc32? Who knows. |
| 1078 | |
| 1079 | VG_(sigframe_destroy)(tid, True); |
| 1080 | |
| 1081 | /* See comments above in PRE(sys_sigreturn) about this. */ |
| 1082 | SET_STATUS_from_SysRes_NO_SANITY_CHECK( |
| 1083 | VG_(mk_SysRes_ppc32_linux)( |
| 1084 | tst->arch.vex.guest_GPR3, |
| 1085 | /* get CR0.SO */ |
| 1086 | (LibVEX_GuestPPC32_get_CR( &tst->arch.vex ) >> 28) & 1 |
| 1087 | ) |
| 1088 | ); |
| 1089 | |
| 1090 | /* Check to see if some any signals arose as a result of this. */ |
| 1091 | *flags |= SfPollAfter; |
| 1092 | } |
| 1093 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1094 | |
| 1095 | //.. PRE(sys_modify_ldt, Special) |
| 1096 | //.. { |
| 1097 | //.. PRINT("sys_modify_ldt ( %d, %p, %d )", ARG1,ARG2,ARG3); |
| 1098 | //.. PRE_REG_READ3(int, "modify_ldt", int, func, void *, ptr, |
| 1099 | //.. unsigned long, bytecount); |
| 1100 | //.. |
| 1101 | //.. if (ARG1 == 0) { |
| 1102 | //.. /* read the LDT into ptr */ |
| 1103 | //.. PRE_MEM_WRITE( "modify_ldt(ptr)", ARG2, ARG3 ); |
| 1104 | //.. } |
| 1105 | //.. if (ARG1 == 1 || ARG1 == 0x11) { |
| 1106 | //.. /* write the LDT with the entry pointed at by ptr */ |
| 1107 | //.. PRE_MEM_READ( "modify_ldt(ptr)", ARG2, sizeof(vki_modify_ldt_t) ); |
| 1108 | //.. } |
| 1109 | //.. /* "do" the syscall ourselves; the kernel never sees it */ |
| 1110 | //.. SET_RESULT( VG_(sys_modify_ldt)( tid, ARG1, (void*)ARG2, ARG3 ) ); |
| 1111 | //.. |
| 1112 | //.. if (ARG1 == 0 && !VG_(is_kerror)(RES) && RES > 0) { |
| 1113 | //.. POST_MEM_WRITE( ARG2, RES ); |
| 1114 | //.. } |
| 1115 | //.. } |
| 1116 | |
| 1117 | //.. PRE(sys_set_thread_area, Special) |
| 1118 | //.. { |
| 1119 | //.. PRINT("sys_set_thread_area ( %p )", ARG1); |
| 1120 | //.. PRE_REG_READ1(int, "set_thread_area", struct user_desc *, u_info) |
| 1121 | //.. PRE_MEM_READ( "set_thread_area(u_info)", ARG1, sizeof(vki_modify_ldt_t) ); |
| 1122 | //.. |
| 1123 | //.. /* "do" the syscall ourselves; the kernel never sees it */ |
| 1124 | //.. SET_RESULT( VG_(sys_set_thread_area)( tid, (void *)ARG1 ) ); |
| 1125 | //.. } |
| 1126 | |
| 1127 | //.. PRE(sys_get_thread_area, Special) |
| 1128 | //.. { |
| 1129 | //.. PRINT("sys_get_thread_area ( %p )", ARG1); |
| 1130 | //.. PRE_REG_READ1(int, "get_thread_area", struct user_desc *, u_info) |
| 1131 | //.. PRE_MEM_WRITE( "get_thread_area(u_info)", ARG1, sizeof(vki_modify_ldt_t) ); |
| 1132 | //.. |
| 1133 | //.. /* "do" the syscall ourselves; the kernel never sees it */ |
| 1134 | //.. SET_RESULT( VG_(sys_get_thread_area)( tid, (void *)ARG1 ) ); |
| 1135 | //.. |
| 1136 | //.. if (!VG_(is_kerror)(RES)) { |
| 1137 | //.. POST_MEM_WRITE( ARG1, sizeof(vki_modify_ldt_t) ); |
| 1138 | //.. } |
| 1139 | //.. } |
| 1140 | |
| 1141 | //.. // Parts of this are ppc32-specific, but the *PEEK* cases are generic. |
| 1142 | //.. // XXX: Why is the memory pointed to by ARG3 never checked? |
| 1143 | //.. PRE(sys_ptrace, 0) |
| 1144 | //.. { |
| 1145 | //.. PRINT("sys_ptrace ( %d, %d, %p, %p )", ARG1,ARG2,ARG3,ARG4); |
| 1146 | //.. PRE_REG_READ4(int, "ptrace", |
| 1147 | //.. long, request, long, pid, long, addr, long, data); |
| 1148 | //.. switch (ARG1) { |
| 1149 | //.. case VKI_PTRACE_PEEKTEXT: |
| 1150 | //.. case VKI_PTRACE_PEEKDATA: |
| 1151 | //.. case VKI_PTRACE_PEEKUSR: |
| 1152 | //.. PRE_MEM_WRITE( "ptrace(peek)", ARG4, |
| 1153 | //.. sizeof (long)); |
| 1154 | //.. break; |
| 1155 | //.. case VKI_PTRACE_GETREGS: |
| 1156 | //.. PRE_MEM_WRITE( "ptrace(getregs)", ARG4, |
| 1157 | //.. sizeof (struct vki_user_regs_struct)); |
| 1158 | //.. break; |
| 1159 | //.. case VKI_PTRACE_GETFPREGS: |
| 1160 | //.. PRE_MEM_WRITE( "ptrace(getfpregs)", ARG4, |
| 1161 | //.. sizeof (struct vki_user_i387_struct)); |
| 1162 | //.. break; |
| 1163 | //.. case VKI_PTRACE_GETFPXREGS: |
| 1164 | //.. PRE_MEM_WRITE( "ptrace(getfpxregs)", ARG4, |
| 1165 | //.. sizeof(struct vki_user_fxsr_struct) ); |
| 1166 | //.. break; |
| 1167 | //.. case VKI_PTRACE_SETREGS: |
| 1168 | //.. PRE_MEM_READ( "ptrace(setregs)", ARG4, |
| 1169 | //.. sizeof (struct vki_user_regs_struct)); |
| 1170 | //.. break; |
| 1171 | //.. case VKI_PTRACE_SETFPREGS: |
| 1172 | //.. PRE_MEM_READ( "ptrace(setfpregs)", ARG4, |
| 1173 | //.. sizeof (struct vki_user_i387_struct)); |
| 1174 | //.. break; |
| 1175 | //.. case VKI_PTRACE_SETFPXREGS: |
| 1176 | //.. PRE_MEM_READ( "ptrace(setfpxregs)", ARG4, |
| 1177 | //.. sizeof(struct vki_user_fxsr_struct) ); |
| 1178 | //.. break; |
| 1179 | //.. default: |
| 1180 | //.. break; |
| 1181 | //.. } |
| 1182 | //.. } |
| 1183 | |
| 1184 | //.. POST(sys_ptrace) |
| 1185 | //.. { |
| 1186 | //.. switch (ARG1) { |
| 1187 | //.. case VKI_PTRACE_PEEKTEXT: |
| 1188 | //.. case VKI_PTRACE_PEEKDATA: |
| 1189 | //.. case VKI_PTRACE_PEEKUSR: |
| 1190 | //.. POST_MEM_WRITE( ARG4, sizeof (long)); |
| 1191 | //.. break; |
| 1192 | //.. case VKI_PTRACE_GETREGS: |
| 1193 | //.. POST_MEM_WRITE( ARG4, sizeof (struct vki_user_regs_struct)); |
| 1194 | //.. break; |
| 1195 | //.. case VKI_PTRACE_GETFPREGS: |
| 1196 | //.. POST_MEM_WRITE( ARG4, sizeof (struct vki_user_i387_struct)); |
| 1197 | //.. break; |
| 1198 | //.. case VKI_PTRACE_GETFPXREGS: |
| 1199 | //.. POST_MEM_WRITE( ARG4, sizeof(struct vki_user_fxsr_struct) ); |
| 1200 | //.. break; |
| 1201 | //.. default: |
| 1202 | //.. break; |
| 1203 | //.. } |
| 1204 | //.. } |
| 1205 | |
| 1206 | //.. // XXX: this duplicates a function in coregrind/vg_syscalls.c, yuk |
| 1207 | //.. static Addr deref_Addr ( ThreadId tid, Addr a, Char* s ) |
| 1208 | //.. { |
| 1209 | //.. Addr* a_p = (Addr*)a; |
| 1210 | //.. PRE_MEM_READ( s, (Addr)a_p, sizeof(Addr) ); |
| 1211 | //.. return *a_p; |
| 1212 | //.. } |
| 1213 | |
| 1214 | //.. // XXX: should use the constants here (eg. SHMAT), not the numbers directly! |
| 1215 | //.. PRE(sys_ipc, 0) |
| 1216 | //.. { |
| 1217 | //.. PRINT("sys_ipc ( %d, %d, %d, %d, %p, %d )", ARG1,ARG2,ARG3,ARG4,ARG5,ARG6); |
| 1218 | //.. // XXX: this is simplistic -- some args are not used in all circumstances. |
| 1219 | //.. PRE_REG_READ6(int, "ipc", |
| 1220 | //.. vki_uint, call, int, first, int, second, int, third, |
| 1221 | //.. void *, ptr, long, fifth) |
| 1222 | //.. |
| 1223 | //.. switch (ARG1 /* call */) { |
| 1224 | //.. case VKI_SEMOP: |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1225 | //.. ML_(generic_PRE_sys_semop)( tid, ARG2, ARG5, ARG3 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1226 | //.. /* tst->sys_flags |= MayBlock; */ |
| 1227 | //.. break; |
| 1228 | //.. case VKI_SEMGET: |
| 1229 | //.. break; |
| 1230 | //.. case VKI_SEMCTL: |
| 1231 | //.. { |
| 1232 | //.. UWord arg = deref_Addr( tid, ARG5, "semctl(arg)" ); |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1233 | //.. ML_(generic_PRE_sys_semctl)( tid, ARG2, ARG3, ARG4, arg ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1234 | //.. break; |
| 1235 | //.. } |
| 1236 | //.. case VKI_SEMTIMEDOP: |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1237 | //.. ML_(generic_PRE_sys_semtimedop)( tid, ARG2, ARG5, ARG3, ARG6 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1238 | //.. /* tst->sys_flags |= MayBlock; */ |
| 1239 | //.. break; |
| 1240 | //.. case VKI_MSGSND: |
njn | de5c5f5 | 2005-09-01 03:35:40 +0000 | [diff] [blame] | 1241 | //.. ML_(linux_PRE_sys_msgsnd)( tid, ARG2, ARG5, ARG3, ARG4 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1242 | //.. /* if ((ARG4 & VKI_IPC_NOWAIT) == 0) |
| 1243 | //.. tst->sys_flags |= MayBlock; |
| 1244 | //.. */ |
| 1245 | //.. break; |
| 1246 | //.. case VKI_MSGRCV: |
| 1247 | //.. { |
| 1248 | //.. Addr msgp; |
| 1249 | //.. Word msgtyp; |
| 1250 | //.. |
| 1251 | //.. msgp = deref_Addr( tid, |
| 1252 | //.. (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgp), |
| 1253 | //.. "msgrcv(msgp)" ); |
| 1254 | //.. msgtyp = deref_Addr( tid, |
| 1255 | //.. (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgtyp), |
| 1256 | //.. "msgrcv(msgp)" ); |
| 1257 | //.. |
njn | de5c5f5 | 2005-09-01 03:35:40 +0000 | [diff] [blame] | 1258 | //.. ML_(linux_PRE_sys_msgrcv)( tid, ARG2, msgp, ARG3, msgtyp, ARG4 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1259 | //.. |
| 1260 | //.. /* if ((ARG4 & VKI_IPC_NOWAIT) == 0) |
| 1261 | //.. tst->sys_flags |= MayBlock; |
| 1262 | //.. */ |
| 1263 | //.. break; |
| 1264 | //.. } |
| 1265 | //.. case VKI_MSGGET: |
| 1266 | //.. break; |
| 1267 | //.. case VKI_MSGCTL: |
njn | de5c5f5 | 2005-09-01 03:35:40 +0000 | [diff] [blame] | 1268 | //.. ML_(linux_PRE_sys_msgctl)( tid, ARG2, ARG3, ARG5 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1269 | //.. break; |
| 1270 | //.. case VKI_SHMAT: |
| 1271 | //.. PRE_MEM_WRITE( "shmat(raddr)", ARG4, sizeof(Addr) ); |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1272 | //.. ARG5 = ML_(generic_PRE_sys_shmat)( tid, ARG2, ARG5, ARG3 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1273 | //.. if (ARG5 == 0) |
| 1274 | //.. SET_RESULT( -VKI_EINVAL ); |
| 1275 | //.. break; |
| 1276 | //.. case VKI_SHMDT: |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1277 | //.. if (!ML_(generic_PRE_sys_shmdt)(tid, ARG5)) |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1278 | //.. SET_RESULT( -VKI_EINVAL ); |
| 1279 | //.. break; |
| 1280 | //.. case VKI_SHMGET: |
| 1281 | //.. break; |
| 1282 | //.. case VKI_SHMCTL: /* IPCOP_shmctl */ |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1283 | //.. ML_(generic_PRE_sys_shmctl)( tid, ARG2, ARG3, ARG5 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1284 | //.. break; |
| 1285 | //.. default: |
| 1286 | //.. VG_(message)(Vg_DebugMsg, "FATAL: unhandled syscall(ipc) %d", ARG1 ); |
| 1287 | //.. VG_(core_panic)("... bye!\n"); |
| 1288 | //.. break; /*NOTREACHED*/ |
| 1289 | //.. } |
| 1290 | //.. } |
| 1291 | |
| 1292 | //.. POST(sys_ipc) |
| 1293 | //.. { |
| 1294 | //.. switch (ARG1 /* call */) { |
| 1295 | //.. case VKI_SEMOP: |
| 1296 | //.. case VKI_SEMGET: |
| 1297 | //.. break; |
| 1298 | //.. case VKI_SEMCTL: |
| 1299 | //.. { |
| 1300 | //.. UWord arg = deref_Addr( tid, ARG5, "semctl(arg)" ); |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1301 | //.. ML_(generic_PRE_sys_semctl)( tid, ARG2, ARG3, ARG4, arg ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1302 | //.. break; |
| 1303 | //.. } |
| 1304 | //.. case VKI_SEMTIMEDOP: |
| 1305 | //.. case VKI_MSGSND: |
| 1306 | //.. break; |
| 1307 | //.. case VKI_MSGRCV: |
| 1308 | //.. { |
| 1309 | //.. Addr msgp; |
| 1310 | //.. Word msgtyp; |
| 1311 | //.. |
| 1312 | //.. msgp = deref_Addr( tid, |
| 1313 | //.. (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgp), |
| 1314 | //.. "msgrcv(msgp)" ); |
| 1315 | //.. msgtyp = deref_Addr( tid, |
| 1316 | //.. (Addr) (&((struct vki_ipc_kludge *)ARG5)->msgtyp), |
| 1317 | //.. "msgrcv(msgp)" ); |
| 1318 | //.. |
njn | a560c5c | 2005-09-01 16:27:28 +0000 | [diff] [blame] | 1319 | //.. ML_(linux_POST_sys_msgrcv)( tid, RES, ARG2, msgp, ARG3, msgtyp, ARG4 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1320 | //.. break; |
| 1321 | //.. } |
| 1322 | //.. case VKI_MSGGET: |
| 1323 | //.. break; |
| 1324 | //.. case VKI_MSGCTL: |
njn | a560c5c | 2005-09-01 16:27:28 +0000 | [diff] [blame] | 1325 | //.. ML_(linux_POST_sys_msgctl)( tid, RES, ARG2, ARG3, ARG5 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1326 | //.. break; |
| 1327 | //.. case VKI_SHMAT: |
| 1328 | //.. { |
| 1329 | //.. Addr addr; |
| 1330 | //.. |
| 1331 | //.. /* force readability. before the syscall it is |
| 1332 | //.. * indeed uninitialized, as can be seen in |
| 1333 | //.. * glibc/sysdeps/unix/sysv/linux/shmat.c */ |
| 1334 | //.. POST_MEM_WRITE( ARG4, sizeof( Addr ) ); |
| 1335 | //.. |
| 1336 | //.. addr = deref_Addr ( tid, ARG4, "shmat(addr)" ); |
| 1337 | //.. if ( addr > 0 ) { |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1338 | //.. ML_(generic_POST_sys_shmat)( tid, addr, ARG2, ARG5, ARG3 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1339 | //.. } |
| 1340 | //.. break; |
| 1341 | //.. } |
| 1342 | //.. case VKI_SHMDT: |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1343 | //.. ML_(generic_POST_sys_shmdt)( tid, RES, ARG5 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1344 | //.. break; |
| 1345 | //.. case VKI_SHMGET: |
| 1346 | //.. break; |
| 1347 | //.. case VKI_SHMCTL: |
cerion | 7b2c38c | 2005-06-23 07:52:54 +0000 | [diff] [blame] | 1348 | //.. ML_(generic_POST_sys_shmctl)( tid, RES, ARG2, ARG3, ARG5 ); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1349 | //.. break; |
| 1350 | //.. default: |
| 1351 | //.. VG_(message)(Vg_DebugMsg, |
| 1352 | //.. "FATAL: unhandled syscall(ipc) %d", |
| 1353 | //.. ARG1 ); |
| 1354 | //.. VG_(core_panic)("... bye!\n"); |
| 1355 | //.. break; /*NOTREACHED*/ |
| 1356 | //.. } |
| 1357 | //.. } |
| 1358 | |
| 1359 | |
sewardj | 3849cc5 | 2005-11-07 15:48:31 +0000 | [diff] [blame] | 1360 | /* Convert from non-RT to RT sigset_t's */ |
| 1361 | static |
| 1362 | void convert_sigset_to_rt(const vki_old_sigset_t *oldset, vki_sigset_t *set) |
| 1363 | { |
| 1364 | VG_(sigemptyset)(set); |
| 1365 | set->sig[0] = *oldset; |
| 1366 | } |
| 1367 | PRE(sys_sigaction) |
| 1368 | { |
| 1369 | struct vki_sigaction new, old; |
| 1370 | struct vki_sigaction *newp, *oldp; |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1371 | |
sewardj | 3849cc5 | 2005-11-07 15:48:31 +0000 | [diff] [blame] | 1372 | PRINT("sys_sigaction ( %d, %p, %p )", ARG1,ARG2,ARG3); |
| 1373 | PRE_REG_READ3(int, "sigaction", |
| 1374 | int, signum, const struct old_sigaction *, act, |
| 1375 | struct old_sigaction *, oldact); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1376 | |
sewardj | 3849cc5 | 2005-11-07 15:48:31 +0000 | [diff] [blame] | 1377 | newp = oldp = NULL; |
| 1378 | |
| 1379 | if (ARG2 != 0) { |
| 1380 | struct vki_old_sigaction *sa = (struct vki_old_sigaction *)ARG2; |
| 1381 | PRE_MEM_READ( "sigaction(act->sa_handler)", (Addr)&sa->ksa_handler, sizeof(sa->ksa_handler)); |
| 1382 | PRE_MEM_READ( "sigaction(act->sa_mask)", (Addr)&sa->sa_mask, sizeof(sa->sa_mask)); |
| 1383 | PRE_MEM_READ( "sigaction(act->sa_flags)", (Addr)&sa->sa_flags, sizeof(sa->sa_flags)); |
| 1384 | if (ML_(safe_to_deref)(sa,sizeof(sa)) |
| 1385 | && (sa->sa_flags & VKI_SA_RESTORER)) |
| 1386 | PRE_MEM_READ( "sigaction(act->sa_restorer)", (Addr)&sa->sa_restorer, sizeof(sa->sa_restorer)); |
| 1387 | } |
| 1388 | |
| 1389 | if (ARG3 != 0) { |
| 1390 | PRE_MEM_WRITE( "sigaction(oldact)", ARG3, sizeof(struct vki_old_sigaction)); |
| 1391 | oldp = &old; |
| 1392 | } |
| 1393 | |
| 1394 | //jrs 20050207: what?! how can this make any sense? |
| 1395 | //if (VG_(is_kerror)(SYSRES)) |
| 1396 | // return; |
| 1397 | |
| 1398 | if (ARG2 != 0) { |
| 1399 | struct vki_old_sigaction *oldnew = (struct vki_old_sigaction *)ARG2; |
| 1400 | |
| 1401 | new.ksa_handler = oldnew->ksa_handler; |
| 1402 | new.sa_flags = oldnew->sa_flags; |
| 1403 | new.sa_restorer = oldnew->sa_restorer; |
| 1404 | convert_sigset_to_rt(&oldnew->sa_mask, &new.sa_mask); |
| 1405 | newp = &new; |
| 1406 | } |
| 1407 | |
| 1408 | SET_STATUS_from_SysRes( VG_(do_sys_sigaction)(ARG1, newp, oldp) ); |
| 1409 | |
| 1410 | if (ARG3 != 0 && SUCCESS && RES == 0) { |
| 1411 | struct vki_old_sigaction *oldold = (struct vki_old_sigaction *)ARG3; |
| 1412 | |
| 1413 | oldold->ksa_handler = oldp->ksa_handler; |
| 1414 | oldold->sa_flags = oldp->sa_flags; |
| 1415 | oldold->sa_restorer = oldp->sa_restorer; |
| 1416 | oldold->sa_mask = oldp->sa_mask.sig[0]; |
| 1417 | } |
| 1418 | } |
| 1419 | |
| 1420 | POST(sys_sigaction) |
| 1421 | { |
| 1422 | vg_assert(SUCCESS); |
| 1423 | if (RES == 0 && ARG3 != 0) |
| 1424 | POST_MEM_WRITE( ARG3, sizeof(struct vki_old_sigaction)); |
| 1425 | } |
| 1426 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1427 | |
| 1428 | #undef PRE |
| 1429 | #undef POST |
| 1430 | |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1431 | /* --------------------------------------------------------------------- |
| 1432 | The ppc32/Linux syscall table |
| 1433 | ------------------------------------------------------------------ */ |
| 1434 | |
| 1435 | /* Add an ppc32-linux specific wrapper to a syscall table. */ |
| 1436 | #define PLAX_(sysno, name) WRAPPER_ENTRY_X_(ppc32_linux, sysno, name) |
| 1437 | #define PLAXY(sysno, name) WRAPPER_ENTRY_XY(ppc32_linux, sysno, name) |
| 1438 | |
| 1439 | // This table maps from __NR_xxx syscall numbers (from |
| 1440 | // linux/include/asm-ppc/unistd.h) to the appropriate PRE/POST sys_foo() |
| 1441 | // wrappers on ppc32 (as per sys_call_table in linux/arch/ppc/kernel/entry.S). |
| 1442 | // |
| 1443 | // For those syscalls not handled by Valgrind, the annotation indicate its |
| 1444 | // arch/OS combination, eg. */* (generic), */Linux (Linux only), ?/? |
| 1445 | // (unknown). |
| 1446 | |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 1447 | const SyscallTableEntry ML_(syscall_table)[] = { |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1448 | //.. (restart_syscall) // 0 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1449 | GENX_(__NR_exit, sys_exit), // 1 |
sewardj | fbba371 | 2005-11-13 02:41:58 +0000 | [diff] [blame] | 1450 | GENX_(__NR_fork, sys_fork), // 2 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1451 | GENXY(__NR_read, sys_read), // 3 |
| 1452 | GENX_(__NR_write, sys_write), // 4 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1453 | |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1454 | GENXY(__NR_open, sys_open), // 5 |
| 1455 | GENXY(__NR_close, sys_close), // 6 |
| 1456 | GENXY(__NR_waitpid, sys_waitpid), // 7 |
| 1457 | GENXY(__NR_creat, sys_creat), // 8 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1458 | GENX_(__NR_link, sys_link), // 9 |
| 1459 | |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1460 | GENX_(__NR_unlink, sys_unlink), // 10 |
| 1461 | GENX_(__NR_execve, sys_execve), // 11 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1462 | GENX_(__NR_chdir, sys_chdir), // 12 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1463 | GENXY(__NR_time, sys_time), // 13 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1464 | //.. GENX_(__NR_mknod, sys_mknod), // 14 |
| 1465 | //.. |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1466 | GENX_(__NR_chmod, sys_chmod), // 15 |
njn | efc957c | 2005-08-26 04:36:10 +0000 | [diff] [blame] | 1467 | //.. LINX_(__NR_lchown, sys_lchown16), // 16 ## P |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1468 | //.. GENX_(__NR_break, sys_ni_syscall), // 17 |
| 1469 | //.. // (__NR_oldstat, sys_stat), // 18 (obsolete) |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1470 | LINX_(__NR_lseek, sys_lseek), // 19 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1471 | //.. |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1472 | GENX_(__NR_getpid, sys_getpid), // 20 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1473 | //.. LINX_(__NR_mount, sys_mount), // 21 |
| 1474 | //.. LINX_(__NR_umount, sys_oldumount), // 22 |
njn | a3b67b7 | 2005-08-26 04:27:54 +0000 | [diff] [blame] | 1475 | LINX_(__NR_setuid, sys_setuid16), // 23 ## P |
| 1476 | LINX_(__NR_getuid, sys_getuid16), // 24 ## P |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1477 | //.. |
| 1478 | //.. // (__NR_stime, sys_stime), // 25 * (SVr4,SVID,X/OPEN) |
| 1479 | //.. PLAXY(__NR_ptrace, sys_ptrace), // 26 |
sewardj | a9fff9b | 2005-08-19 10:07:29 +0000 | [diff] [blame] | 1480 | GENX_(__NR_alarm, sys_alarm), // 27 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1481 | //.. // (__NR_oldfstat, sys_fstat), // 28 * L -- obsolete |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1482 | GENX_(__NR_pause, sys_pause), // 29 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1483 | //.. |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1484 | LINX_(__NR_utime, sys_utime), // 30 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1485 | //.. GENX_(__NR_stty, sys_ni_syscall), // 31 |
| 1486 | //.. GENX_(__NR_gtty, sys_ni_syscall), // 32 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1487 | GENX_(__NR_access, sys_access), // 33 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1488 | //.. GENX_(__NR_nice, sys_nice), // 34 |
| 1489 | //.. |
| 1490 | //.. GENX_(__NR_ftime, sys_ni_syscall), // 35 |
| 1491 | //.. GENX_(__NR_sync, sys_sync), // 36 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1492 | GENX_(__NR_kill, sys_kill), // 37 |
| 1493 | GENX_(__NR_rename, sys_rename), // 38 |
| 1494 | GENX_(__NR_mkdir, sys_mkdir), // 39 |
| 1495 | |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 1496 | GENX_(__NR_rmdir, sys_rmdir), // 40 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1497 | GENXY(__NR_dup, sys_dup), // 41 |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1498 | LINXY(__NR_pipe, sys_pipe), // 42 |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 1499 | GENXY(__NR_times, sys_times), // 43 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1500 | //.. GENX_(__NR_prof, sys_ni_syscall), // 44 |
| 1501 | //.. |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1502 | GENX_(__NR_brk, sys_brk), // 45 |
njn | a3b67b7 | 2005-08-26 04:27:54 +0000 | [diff] [blame] | 1503 | LINX_(__NR_setgid, sys_setgid16), // 46 |
| 1504 | LINX_(__NR_getgid, sys_getgid16), // 47 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1505 | //.. // (__NR_signal, sys_signal), // 48 */* (ANSI C) |
njn | a3b67b7 | 2005-08-26 04:27:54 +0000 | [diff] [blame] | 1506 | LINX_(__NR_geteuid, sys_geteuid16), // 49 |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 1507 | |
njn | a3b67b7 | 2005-08-26 04:27:54 +0000 | [diff] [blame] | 1508 | LINX_(__NR_getegid, sys_getegid16), // 50 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1509 | //.. GENX_(__NR_acct, sys_acct), // 51 |
| 1510 | //.. LINX_(__NR_umount2, sys_umount), // 52 |
| 1511 | //.. GENX_(__NR_lock, sys_ni_syscall), // 53 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1512 | GENXY(__NR_ioctl, sys_ioctl), // 54 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1513 | //.. |
sewardj | fe0ffd4 | 2005-10-19 01:14:22 +0000 | [diff] [blame] | 1514 | GENXY(__NR_fcntl, sys_fcntl), // 55 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1515 | //.. GENX_(__NR_mpx, sys_ni_syscall), // 56 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1516 | GENX_(__NR_setpgid, sys_setpgid), // 57 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1517 | //.. GENX_(__NR_ulimit, sys_ni_syscall), // 58 |
| 1518 | //.. // (__NR_oldolduname, sys_olduname), // 59 Linux -- obsolete |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1519 | |
| 1520 | GENX_(__NR_umask, sys_umask), // 60 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1521 | //.. GENX_(__NR_chroot, sys_chroot), // 61 |
| 1522 | //.. // (__NR_ustat, sys_ustat) // 62 SVr4 -- deprecated |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1523 | GENXY(__NR_dup2, sys_dup2), // 63 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1524 | GENX_(__NR_getppid, sys_getppid), // 64 |
| 1525 | |
| 1526 | GENX_(__NR_getpgrp, sys_getpgrp), // 65 |
| 1527 | GENX_(__NR_setsid, sys_setsid), // 66 |
sewardj | 3849cc5 | 2005-11-07 15:48:31 +0000 | [diff] [blame] | 1528 | PLAXY(__NR_sigaction, sys_sigaction), // 67 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1529 | //.. // (__NR_sgetmask, sys_sgetmask), // 68 */* (ANSI C) |
| 1530 | //.. // (__NR_ssetmask, sys_ssetmask), // 69 */* (ANSI C) |
| 1531 | //.. |
njn | a3b67b7 | 2005-08-26 04:27:54 +0000 | [diff] [blame] | 1532 | //.. LINX_(__NR_setreuid, sys_setreuid16), // 70 |
| 1533 | //.. LINX_(__NR_setregid, sys_setregid16), // 71 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1534 | //.. GENX_(__NR_sigsuspend, sys_sigsuspend), // 72 |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1535 | //.. LINXY(__NR_sigpending, sys_sigpending), // 73 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1536 | //.. // (__NR_sethostname, sys_sethostname), // 74 */* |
| 1537 | //.. |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 1538 | GENX_(__NR_setrlimit, sys_setrlimit), // 75 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1539 | //.. GENXY(__NR_getrlimit, sys_old_getrlimit), // 76 |
sewardj | 33d17fa | 2005-08-21 00:49:41 +0000 | [diff] [blame] | 1540 | GENXY(__NR_getrusage, sys_getrusage), // 77 |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 1541 | GENXY(__NR_gettimeofday, sys_gettimeofday), // 78 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1542 | //.. GENX_(__NR_settimeofday, sys_settimeofday), // 79 |
| 1543 | //.. |
njn | a3b67b7 | 2005-08-26 04:27:54 +0000 | [diff] [blame] | 1544 | LINXY(__NR_getgroups, sys_getgroups16), // 80 |
| 1545 | //.. LINX_(__NR_setgroups, sys_setgroups16), // 81 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1546 | //.. PLAX_(__NR_select, old_select), // 82 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1547 | GENX_(__NR_symlink, sys_symlink), // 83 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1548 | //.. // (__NR_oldlstat, sys_lstat), // 84 -- obsolete |
| 1549 | //.. |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1550 | GENX_(__NR_readlink, sys_readlink), // 85 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1551 | //.. // (__NR_uselib, sys_uselib), // 86 */Linux |
| 1552 | //.. // (__NR_swapon, sys_swapon), // 87 */Linux |
| 1553 | //.. // (__NR_reboot, sys_reboot), // 88 */Linux |
| 1554 | //.. // (__NR_readdir, old_readdir), // 89 -- superseded |
| 1555 | |
tom | 9548a16 | 2005-09-30 08:07:53 +0000 | [diff] [blame] | 1556 | PLAX_(__NR_mmap, sys_mmap), // 90 |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 1557 | GENXY(__NR_munmap, sys_munmap), // 91 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1558 | //.. GENX_(__NR_truncate, sys_truncate), // 92 |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 1559 | GENX_(__NR_ftruncate, sys_ftruncate), // 93 |
sewardj | 2d7c396 | 2005-07-29 22:01:19 +0000 | [diff] [blame] | 1560 | GENX_(__NR_fchmod, sys_fchmod), // 94 |
| 1561 | |
njn | efc957c | 2005-08-26 04:36:10 +0000 | [diff] [blame] | 1562 | LINX_(__NR_fchown, sys_fchown16), // 95 |
sewardj | dc1750a | 2005-12-02 16:45:28 +0000 | [diff] [blame] | 1563 | GENX_(__NR_getpriority, sys_getpriority), // 96 |
| 1564 | GENX_(__NR_setpriority, sys_setpriority), // 97 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1565 | //.. GENX_(__NR_profil, sys_ni_syscall), // 98 |
| 1566 | //.. GENXY(__NR_statfs, sys_statfs), // 99 |
| 1567 | //.. |
| 1568 | //.. GENXY(__NR_fstatfs, sys_fstatfs), // 100 |
| 1569 | //.. LINX_(__NR_ioperm, sys_ioperm), // 101 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1570 | PLAXY(__NR_socketcall, sys_socketcall), // 102 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1571 | //.. LINXY(__NR_syslog, sys_syslog), // 103 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1572 | GENXY(__NR_setitimer, sys_setitimer), // 104 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1573 | //.. |
| 1574 | //.. GENXY(__NR_getitimer, sys_getitimer), // 105 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1575 | GENXY(__NR_stat, sys_newstat), // 106 |
sewardj | 8202204 | 2005-11-17 11:01:55 +0000 | [diff] [blame] | 1576 | GENXY(__NR_lstat, sys_newlstat), // 107 |
sewardj | fe0ffd4 | 2005-10-19 01:14:22 +0000 | [diff] [blame] | 1577 | GENXY(__NR_fstat, sys_newfstat), // 108 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1578 | //.. // (__NR_olduname, sys_uname), // 109 -- obsolete |
| 1579 | //.. |
| 1580 | //.. GENX_(__NR_iopl, sys_iopl), // 110 |
| 1581 | //.. LINX_(__NR_vhangup, sys_vhangup), // 111 |
| 1582 | //.. GENX_(__NR_idle, sys_ni_syscall), // 112 |
| 1583 | //.. // (__NR_vm86old, sys_vm86old), // 113 x86/Linux-only |
sewardj | fbba371 | 2005-11-13 02:41:58 +0000 | [diff] [blame] | 1584 | GENXY(__NR_wait4, sys_wait4), // 114 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1585 | //.. |
| 1586 | //.. // (__NR_swapoff, sys_swapoff), // 115 */Linux |
| 1587 | //.. LINXY(__NR_sysinfo, sys_sysinfo), // 116 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1588 | PLAXY(__NR_ipc, sys_ipc), // 117 |
sewardj | d84f467 | 2005-10-07 23:06:13 +0000 | [diff] [blame] | 1589 | GENX_(__NR_fsync, sys_fsync), // 118 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1590 | PLAX_(__NR_sigreturn, sys_sigreturn), // 119 ?/Linux |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1591 | //.. |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1592 | PLAX_(__NR_clone, sys_clone), // 120 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1593 | //.. // (__NR_setdomainname, sys_setdomainname), // 121 */*(?) |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1594 | GENXY(__NR_uname, sys_newuname), // 122 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1595 | //.. PLAX_(__NR_modify_ldt, sys_modify_ldt), // 123 |
| 1596 | //.. LINXY(__NR_adjtimex, sys_adjtimex), // 124 |
| 1597 | //.. |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1598 | GENXY(__NR_mprotect, sys_mprotect), // 125 |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1599 | LINXY(__NR_sigprocmask, sys_sigprocmask), // 126 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1600 | //.. // Nb: create_module() was removed 2.4-->2.6 |
| 1601 | //.. GENX_(__NR_create_module, sys_ni_syscall), // 127 |
| 1602 | //.. GENX_(__NR_init_module, sys_init_module), // 128 |
| 1603 | //.. // (__NR_delete_module, sys_delete_module), // 129 (*/Linux)? |
| 1604 | //.. |
| 1605 | //.. // Nb: get_kernel_syms() was removed 2.4-->2.6 |
| 1606 | //.. GENX_(__NR_get_kernel_syms, sys_ni_syscall), // 130 |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1607 | //.. LINX_(__NR_quotactl, sys_quotactl), // 131 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1608 | GENX_(__NR_getpgid, sys_getpgid), // 132 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1609 | //.. GENX_(__NR_fchdir, sys_fchdir), // 133 |
| 1610 | //.. // (__NR_bdflush, sys_bdflush), // 134 */Linux |
| 1611 | //.. |
| 1612 | //.. // (__NR_sysfs, sys_sysfs), // 135 SVr4 |
| 1613 | //.. LINX_(__NR_personality, sys_personality), // 136 |
| 1614 | //.. GENX_(__NR_afs_syscall, sys_ni_syscall), // 137 |
sewardj | 31d8342 | 2005-10-15 02:00:41 +0000 | [diff] [blame] | 1615 | LINX_(__NR_setfsuid, sys_setfsuid16), // 138 |
| 1616 | LINX_(__NR_setfsgid, sys_setfsgid16), // 139 |
| 1617 | |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1618 | LINXY(__NR__llseek, sys_llseek), // 140 |
sewardj | 31d8342 | 2005-10-15 02:00:41 +0000 | [diff] [blame] | 1619 | GENXY(__NR_getdents, sys_getdents), // 141 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1620 | GENX_(__NR__newselect, sys_select), // 142 |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 1621 | GENX_(__NR_flock, sys_flock), // 143 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1622 | //.. GENX_(__NR_msync, sys_msync), // 144 |
| 1623 | //.. |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1624 | GENXY(__NR_readv, sys_readv), // 145 |
| 1625 | GENX_(__NR_writev, sys_writev), // 146 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1626 | //.. GENX_(__NR_getsid, sys_getsid), // 147 |
sewardj | 5addd6c | 2005-08-18 23:44:13 +0000 | [diff] [blame] | 1627 | GENX_(__NR_fdatasync, sys_fdatasync), // 148 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1628 | LINXY(__NR__sysctl, sys_sysctl), // 149 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1629 | //.. |
| 1630 | //.. GENX_(__NR_mlock, sys_mlock), // 150 |
| 1631 | //.. GENX_(__NR_munlock, sys_munlock), // 151 |
| 1632 | //.. GENX_(__NR_mlockall, sys_mlockall), // 152 |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1633 | //.. LINX_(__NR_munlockall, sys_munlockall), // 153 |
njn | b2480c9 | 2005-08-30 02:17:23 +0000 | [diff] [blame] | 1634 | //.. LINXY(__NR_sched_setparam, sys_sched_setparam), // 154 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1635 | //.. |
njn | b2480c9 | 2005-08-30 02:17:23 +0000 | [diff] [blame] | 1636 | LINXY(__NR_sched_getparam, sys_sched_getparam), // 155 |
sewardj | d84f467 | 2005-10-07 23:06:13 +0000 | [diff] [blame] | 1637 | LINX_(__NR_sched_setscheduler, sys_sched_setscheduler), // 156 |
njn | b2480c9 | 2005-08-30 02:17:23 +0000 | [diff] [blame] | 1638 | LINX_(__NR_sched_getscheduler, sys_sched_getscheduler), // 157 |
dirk | 331e576 | 2005-12-05 22:11:02 +0000 | [diff] [blame^] | 1639 | LINX_(__NR_sched_yield, sys_sched_yield), // 158 |
njn | b2480c9 | 2005-08-30 02:17:23 +0000 | [diff] [blame] | 1640 | LINX_(__NR_sched_get_priority_max, sys_sched_get_priority_max),// 159 |
sewardj | 5addd6c | 2005-08-18 23:44:13 +0000 | [diff] [blame] | 1641 | |
njn | b2480c9 | 2005-08-30 02:17:23 +0000 | [diff] [blame] | 1642 | LINX_(__NR_sched_get_priority_min, sys_sched_get_priority_min),// 160 |
| 1643 | //.. //LINX?(__NR_sched_rr_get_interval, sys_sched_rr_get_interval), // 161 */* |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1644 | GENXY(__NR_nanosleep, sys_nanosleep), // 162 |
| 1645 | GENX_(__NR_mremap, sys_mremap), // 163 |
sewardj | 33d17fa | 2005-08-21 00:49:41 +0000 | [diff] [blame] | 1646 | LINX_(__NR_setresuid, sys_setresuid16), // 164 |
| 1647 | |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 1648 | LINXY(__NR_getresuid, sys_getresuid16), // 165 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1649 | |
| 1650 | //.. GENX_(__NR_query_module, sys_ni_syscall), // 166 |
sewardj | ca33405 | 2005-07-24 06:30:37 +0000 | [diff] [blame] | 1651 | GENXY(__NR_poll, sys_poll), // 167 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1652 | //.. // (__NR_nfsservctl, sys_nfsservctl), // 168 */Linux |
| 1653 | //.. |
| 1654 | //.. LINX_(__NR_setresgid, sys_setresgid16), // 169 |
sewardj | 6a32449 | 2005-08-05 00:10:11 +0000 | [diff] [blame] | 1655 | LINXY(__NR_getresgid, sys_getresgid16), // 170 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1656 | LINX_(__NR_prctl, sys_prctl), // 171 |
sewardj | 4ce89e1 | 2005-11-16 19:15:33 +0000 | [diff] [blame] | 1657 | PLAX_(__NR_rt_sigreturn, sys_rt_sigreturn), // 172 |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1658 | LINXY(__NR_rt_sigaction, sys_rt_sigaction), // 173 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1659 | |
njn | cd405ea | 2005-08-31 02:44:31 +0000 | [diff] [blame] | 1660 | LINXY(__NR_rt_sigprocmask, sys_rt_sigprocmask), // 174 |
| 1661 | //.. LINXY(__NR_rt_sigpending, sys_rt_sigpending), // 175 |
| 1662 | LINXY(__NR_rt_sigtimedwait, sys_rt_sigtimedwait), // 176 |
| 1663 | //.. LINXY(__NR_rt_sigqueueinfo, sys_rt_sigqueueinfo), // 177 |
sewardj | 1ea00a1 | 2005-11-16 12:51:34 +0000 | [diff] [blame] | 1664 | LINX_(__NR_rt_sigsuspend, sys_rt_sigsuspend), // 178 |
| 1665 | |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1666 | GENXY(__NR_pread64, sys_pread64), // 179 |
| 1667 | GENX_(__NR_pwrite64, sys_pwrite64), // 180 |
njn | efc957c | 2005-08-26 04:36:10 +0000 | [diff] [blame] | 1668 | LINX_(__NR_chown, sys_chown16), // 181 |
sewardj | b865b16 | 2005-07-08 18:26:37 +0000 | [diff] [blame] | 1669 | GENXY(__NR_getcwd, sys_getcwd), // 182 |
njn | 9fe7b12 | 2005-08-26 04:03:04 +0000 | [diff] [blame] | 1670 | //.. LINXY(__NR_capget, sys_capget), // 183 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1671 | //.. |
njn | 9fe7b12 | 2005-08-26 04:03:04 +0000 | [diff] [blame] | 1672 | //.. LINX_(__NR_capset, sys_capset), // 184 |
sewardj | a9fff9b | 2005-08-19 10:07:29 +0000 | [diff] [blame] | 1673 | GENXY(__NR_sigaltstack, sys_sigaltstack), // 185 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1674 | //.. LINXY(__NR_sendfile, sys_sendfile), // 186 |
| 1675 | //.. GENXY(__NR_getpmsg, sys_getpmsg), // 187 |
| 1676 | //.. GENX_(__NR_putpmsg, sys_putpmsg), // 188 |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1677 | |
| 1678 | // Nb: we treat vfork as fork |
| 1679 | GENX_(__NR_vfork, sys_fork), // 189 |
| 1680 | GENXY(__NR_ugetrlimit, sys_getrlimit), // 190 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1681 | //__NR_readahead // 191 ppc/Linux only? |
tom | 9548a16 | 2005-09-30 08:07:53 +0000 | [diff] [blame] | 1682 | PLAX_(__NR_mmap2, sys_mmap2), // 192 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1683 | //.. GENX_(__NR_truncate64, sys_truncate64), // 193 |
sewardj | 48db0f0 | 2005-10-07 13:30:48 +0000 | [diff] [blame] | 1684 | GENX_(__NR_ftruncate64, sys_ftruncate64), // 194 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1685 | //.. |
| 1686 | |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1687 | PLAXY(__NR_stat64, sys_stat64), // 195 |
| 1688 | PLAXY(__NR_lstat64, sys_lstat64), // 196 |
| 1689 | PLAXY(__NR_fstat64, sys_fstat64), // 197 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1690 | |
| 1691 | // __NR_pciconfig_read // 198 |
| 1692 | // __NR_pciconfig_write // 199 |
| 1693 | // __NR_pciconfig_iobase // 200 |
| 1694 | // __NR_multiplexer // 201 |
| 1695 | |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1696 | GENXY(__NR_getdents64, sys_getdents64), // 202 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1697 | //.. // (__NR_pivot_root, sys_pivot_root), // 203 */Linux |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1698 | GENXY(__NR_fcntl64, sys_fcntl64), // 204 |
sewardj | 249ebd7 | 2005-10-07 19:12:18 +0000 | [diff] [blame] | 1699 | GENX_(__NR_madvise, sys_madvise), // 205 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1700 | //.. GENXY(__NR_mincore, sys_mincore), // 206 |
sewardj | a9fff9b | 2005-08-19 10:07:29 +0000 | [diff] [blame] | 1701 | LINX_(__NR_gettid, sys_gettid), // 207 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1702 | //.. LINX_(__NR_tkill, sys_tkill), // 208 */Linux |
njn | 65ccc50 | 2005-08-30 01:53:54 +0000 | [diff] [blame] | 1703 | //.. LINX_(__NR_setxattr, sys_setxattr), // 209 |
| 1704 | //.. LINX_(__NR_lsetxattr, sys_lsetxattr), // 210 |
| 1705 | //.. LINX_(__NR_fsetxattr, sys_fsetxattr), // 211 |
njn | ef0da67 | 2005-08-30 03:02:00 +0000 | [diff] [blame] | 1706 | LINXY(__NR_getxattr, sys_getxattr), // 212 |
njn | 65ccc50 | 2005-08-30 01:53:54 +0000 | [diff] [blame] | 1707 | //.. LINXY(__NR_lgetxattr, sys_lgetxattr), // 213 |
| 1708 | //.. LINXY(__NR_fgetxattr, sys_fgetxattr), // 214 |
| 1709 | //.. LINXY(__NR_listxattr, sys_listxattr), // 215 |
| 1710 | //.. LINXY(__NR_llistxattr, sys_llistxattr), // 216 |
| 1711 | //.. LINXY(__NR_flistxattr, sys_flistxattr), // 217 |
| 1712 | //.. LINX_(__NR_removexattr, sys_removexattr), // 218 |
| 1713 | //.. LINX_(__NR_lremovexattr, sys_lremovexattr), // 219 |
| 1714 | //.. LINX_(__NR_fremovexattr, sys_fremovexattr), // 220 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1715 | |
cerion | 508aef5 | 2005-06-24 15:26:49 +0000 | [diff] [blame] | 1716 | LINXY(__NR_futex, sys_futex), // 221 |
njn | b2480c9 | 2005-08-30 02:17:23 +0000 | [diff] [blame] | 1717 | //.. LINX_(__NR_sched_setaffinity, sys_sched_setaffinity), // 222 |
| 1718 | //.. LINXY(__NR_sched_getaffinity, sys_sched_getaffinity), // 223 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1719 | /* 224 currently unused */ |
| 1720 | |
| 1721 | // __NR_tuxcall // 225 |
| 1722 | |
| 1723 | //.. LINXY(__NR_sendfile64, sys_sendfile64), // 226 |
| 1724 | //.. |
| 1725 | //.. LINX_(__NR_io_setup, sys_io_setup), // 227 |
| 1726 | //.. LINX_(__NR_io_destroy, sys_io_destroy), // 228 |
| 1727 | //.. LINXY(__NR_io_getevents, sys_io_getevents), // 229 |
| 1728 | //.. LINX_(__NR_io_submit, sys_io_submit), // 230 |
| 1729 | //.. LINXY(__NR_io_cancel, sys_io_cancel), // 231 |
| 1730 | //.. |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1731 | LINX_(__NR_set_tid_address, sys_set_tid_address), // 232 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1732 | |
| 1733 | //.. LINX_(__NR_fadvise64, sys_fadvise64), // 233 */(Linux?) |
sewardj | a932d29 | 2005-07-08 00:18:25 +0000 | [diff] [blame] | 1734 | LINX_(__NR_exit_group, sys_exit_group), // 234 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1735 | //.. GENXY(__NR_lookup_dcookie, sys_lookup_dcookie), // 235 |
| 1736 | //.. LINXY(__NR_epoll_create, sys_epoll_create), // 236 |
| 1737 | //.. LINX_(__NR_epoll_ctl, sys_epoll_ctl), // 237 |
| 1738 | //.. LINXY(__NR_epoll_wait, sys_epoll_wait), // 238 |
| 1739 | |
| 1740 | //.. // (__NR_remap_file_pages, sys_remap_file_pages), // 239 */Linux |
njn | 424c056 | 2005-08-26 03:54:30 +0000 | [diff] [blame] | 1741 | //.. LINXY(__NR_timer_create, sys_timer_create), // 240 |
| 1742 | //.. LINXY(__NR_timer_settime, sys_timer_settime), // 241 |
| 1743 | //.. LINXY(__NR_timer_gettime, sys_timer_gettime), // 242 |
| 1744 | //.. LINX_(__NR_timer_getoverrun, sys_timer_getoverrun), // 243 |
| 1745 | //.. LINX_(__NR_timer_delete, sys_timer_delete), // 244 |
njn | 1588bc0 | 2005-08-26 03:49:43 +0000 | [diff] [blame] | 1746 | //.. LINX_(__NR_clock_settime, sys_clock_settime), // 245 |
| 1747 | LINXY(__NR_clock_gettime, sys_clock_gettime), // 246 |
dirk | 331e576 | 2005-12-05 22:11:02 +0000 | [diff] [blame^] | 1748 | LINXY(__NR_clock_getres, sys_clock_getres), // 247 |
njn | 1588bc0 | 2005-08-26 03:49:43 +0000 | [diff] [blame] | 1749 | //.. LINXY(__NR_clock_nanosleep, sys_clock_nanosleep), // 248 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1750 | |
| 1751 | // __NR_swapcontext // 249 |
| 1752 | |
sewardj | 7f4bd10 | 2005-11-17 14:22:22 +0000 | [diff] [blame] | 1753 | LINXY(__NR_tgkill, sys_tgkill), // 250 */Linux |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1754 | //.. GENX_(__NR_utimes, sys_utimes), // 251 |
| 1755 | //.. GENXY(__NR_statfs64, sys_statfs64), // 252 |
| 1756 | //.. GENXY(__NR_fstatfs64, sys_fstatfs64), // 253 |
| 1757 | //.. LINX_(__NR_fadvise64_64, sys_fadvise64_64), // 254 */(Linux?) |
| 1758 | |
| 1759 | // __NR_rtas // 255 |
| 1760 | |
| 1761 | /* Number 256 is reserved for sys_debug_setcontext */ |
| 1762 | /* Number 257 is reserved for vserver */ |
| 1763 | /* Number 258 is reserved for new sys_remap_file_pages */ |
| 1764 | /* Number 259 is reserved for new sys_mbind */ |
| 1765 | /* Number 260 is reserved for new sys_get_mempolicy */ |
| 1766 | /* Number 261 is reserved for new sys_set_mempolicy */ |
| 1767 | |
sewardj | 54e095f | 2005-11-17 19:09:02 +0000 | [diff] [blame] | 1768 | LINXY(__NR_mq_open, sys_mq_open), // 262 |
| 1769 | LINX_(__NR_mq_unlink, sys_mq_unlink), // 263 |
| 1770 | LINX_(__NR_mq_timedsend, sys_mq_timedsend), // 264 |
| 1771 | LINXY(__NR_mq_timedreceive, sys_mq_timedreceive), // 265 |
| 1772 | LINX_(__NR_mq_notify, sys_mq_notify), // 266 |
| 1773 | LINXY(__NR_mq_getsetattr, sys_mq_getsetattr), // 267 |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1774 | |
| 1775 | // __NR_kexec_load // 268 |
| 1776 | }; |
| 1777 | |
njn | af839f5 | 2005-06-23 03:27:57 +0000 | [diff] [blame] | 1778 | const UInt ML_(syscall_table_size) = |
| 1779 | sizeof(ML_(syscall_table)) / sizeof(ML_(syscall_table)[0]); |
cerion | 85665ca | 2005-06-20 15:51:07 +0000 | [diff] [blame] | 1780 | |
| 1781 | /*--------------------------------------------------------------------*/ |
| 1782 | /*--- end ---*/ |
| 1783 | /*--------------------------------------------------------------------*/ |