scalar.c revision e739ac0589b4fb43561f801c4faba8c1b89f8680
1#include "../../memcheck.h"
2#include "scalar.h"
3#include <unistd.h>
4#include <sched.h>
5#include <signal.h>
6#include <sys/shm.h>
7
8// See memcheck/tests/x86-linux/scalar.c for an explanation of what this test
9// is doing.
10
11int main(void)
12{
13   // uninitialised, but we know px[0] is 0x0
14   long* px  = malloc(sizeof(long));
15   long  x0  = px[0];
16   long  res;
17
18   VALGRIND_MAKE_MEM_NOACCESS(0, 0x1000);
19
20   // __NR_syscall 0
21   // XXX
22
23   GO(__NR_exit, 1, "below");
24   // (see below)
25
26   GO(__NR_fork, 2, "other");
27   // (sse scalar_fork.c)
28
29   // Nb: here we are also getting an error from the syscall arg itself.
30   GO(__NR_read, 3, "1+3s 1m");
31   SY(__NR_read+(int)x0, x0, x0, x0+1); FAILx(EFAULT);
32
33   GO(__NR_write, 4, "3s 1m");
34   SY(__NR_write, x0, x0, x0+1); FAIL;
35   //res = write(x0, x0, x0+1); FAIL;
36
37   GO(__NR_open, 5, "(2-args) 2s 1m");
38   SY(__NR_open, x0, x0); FAIL;
39   // Only 1s 0m errors -- the other 2s 1m have been checked in the previous
40   // open test, and if we test them they may be commoned up but they also
41   // may not.
42   GO(__NR_open, 5, "(3-args) 1s 0m");
43   SY(__NR_open, "scalar.c", O_CREAT|O_EXCL, x0); FAIL;
44
45   GO(__NR_close, 6, "1s 0m");
46   SY(__NR_close, x0-1); FAIL;
47
48   GO(__NR_wait4, 7, "4s 2m");
49   SY(__NR_wait4, x0, x0+1, x0, x0+1); FAIL;
50
51   GO_UNIMP(8, "old creat");
52
53   GO(__NR_link, 9, "2s 2m");
54   SY(__NR_link, x0, x0); FAIL;
55
56   GO(__NR_unlink, 10, "1s 1m");
57   SY(__NR_unlink, x0); FAIL;
58
59   GO_UNIMP(11, "old execv");
60
61   GO(__NR_chdir, 12, "1s 1m");
62   SY(__NR_chdir, x0); FAIL;
63
64   GO(__NR_fchdir, 13, "1s 0m");
65   SY(__NR_fchdir, x0-1); FAIL;
66
67   GO(__NR_mknod, 14, "3s 1m");
68   SY(__NR_mknod, x0, x0, x0); FAIL;
69
70   GO(__NR_chmod, 15, "2s 1m");
71   SY(__NR_chmod, x0, x0); FAIL;
72
73   GO(__NR_chown, 16, "3s 1m");
74   SY(__NR_chown, x0, x0, x0); FAIL;
75
76   GO_UNIMP(17, "old break");
77
78   GO(__NR_getfsstat, 18, "3s 1m");
79   SY(__NR_getfsstat, x0+1, x0+1, x0); SUCC; // This should fail...
80
81   GO_UNIMP(19, "old lseek");
82
83   // __NR_getpid 20
84
85   GO_UNIMP(21, "old mount");
86
87   GO_UNIMP(22, "old umount");
88
89   // __NR_setuid 23
90   // __NR_getuid 24
91   // __NR_geteuid 25
92   // __NR_ptrace 26
93   // __NR_recvmsg 27
94   // __NR_sendmsg 28
95   // __NR_recvfrom 29
96   // __NR_accept 30
97   // __NR_getpeername 31
98   // __NR_getsockname 32
99   // __NR_access 33
100   // __NR_chflags 34
101   // __NR_fchflags 35
102   // __NR_sync 36
103   // __NR_kill 37
104
105   GO_UNIMP(38, "old stat");
106
107   // __NR_getppid 39
108
109   GO_UNIMP(40, "old lstat");
110
111   // __NR_dup 41
112   // __NR_pipe           VG_DARWIN_SYSCALL_CONSTRUCT_UX64(42
113   // __NR_getegid 43
114   // __NR_profil 44
115
116   GO_UNIMP(45, "old ktrace");
117
118   // __NR_sigaction 46
119   // __NR_getgid 47
120   // __NR_sigprocmask 48
121   // __NR_getlogin 49
122   // __NR_setlogin 50
123   // __NR_acct 51
124   // __NR_sigpending 52
125   // __NR_sigaltstack 53
126   // __NR_ioctl 54
127   // __NR_reboot 55
128   // __NR_revoke 56
129   // __NR_symlink 57
130   // __NR_readlink 58
131   // __NR_execve 59
132   // __NR_umask 60
133   // __NR_chroot 61
134
135   GO_UNIMP(62, "old fstat");
136
137   GO_UNIMP(63, "used internally, reserved");
138
139   GO_UNIMP(64, "old getpagesize");
140
141   // __NR_msync 65
142   // __NR_vfork 66
143
144   GO_UNIMP(67, "old vread");
145
146   GO_UNIMP(68, "old vwrite");
147
148   GO_UNIMP(69, "old sbrk");
149
150   GO_UNIMP(70, "old sstk");
151
152   GO_UNIMP(71, "old mmap");
153
154   GO_UNIMP(72, "old vadvise");
155
156   // __NR_munmap 73
157   // __NR_mprotect 74
158   // __NR_madvise 75
159
160   GO_UNIMP(76, "old vhangup");
161
162   GO_UNIMP(77, "old vlimit");
163
164   GO(__NR_mincore, 78, "3s 1m");
165   SY(__NR_mincore, x0, x0+40960, x0); FAIL;
166
167   // __NR_getgroups 79
168   // __NR_setgroups 80
169   // __NR_getpgrp 81
170
171   GO(__NR_setpgid, 82, "2s 0m");
172   SY(__NR_setpgid, x0-1, x0-1); FAIL;
173
174   // __NR_setitimer 83
175
176   GO_UNIMP(78, "old wait");
177
178   // __NR_swapon 85
179   // __NR_getitimer 86
180
181   GO_UNIMP(87, "old gethostname");
182
183   GO_UNIMP(88, "old sethostname");
184
185   // __NR_getdtablesize 89
186   // __NR_dup2 90
187
188   GO_UNIMP(91, "old getdopt");
189
190   // __NR_fcntl 92
191   // __NR_select 93
192
193   GO_UNIMP(94, "old setdopt");
194
195   // __NR_fsync 95
196   // __NR_setpriority 96
197   // __NR_socket 97
198   // __NR_connect 98
199
200   GO_UNIMP(99, "old accept");
201
202   // __NR_getpriority 100
203
204   GO_UNIMP(101, "old send");
205
206   GO_UNIMP(102, "old recv");
207
208   GO_UNIMP(103, "old sigreturn");
209
210   // __NR_bind 104
211
212   GO(__NR_setsockopt, 105, "5s 1m");
213   SY(__NR_setsockopt, x0, x0, x0, x0+1, x0+1); FAIL;
214
215   // __NR_listen 106
216
217   GO_UNIMP(107, "old vtimes");
218
219   GO_UNIMP(108, "old sigvec");
220
221   GO_UNIMP(109, "old sigblock");
222
223   GO_UNIMP(110, "old sigsetmask");
224
225   // __NR_sigsuspend 111
226
227   GO_UNIMP(112, "old sigstack");
228
229   GO_UNIMP(113, "old recvmsg");
230
231   GO_UNIMP(114, "old sendmsg");
232
233   GO_UNIMP(115, "old vtrace");
234
235   // __NR_gettimeofday 116
236   // __NR_getrusage 117
237
238   // Nb: there's no "getsockopt(optlen) points to unaddressable byte(s)";
239   // difficult to get with arg4 being checked with buf_and_len_pre_check.
240   GO(__NR_getsockopt, 118, "5s 1m");
241   SY(__NR_getsockopt, x0, x0, x0, x0+1, x0+&px[1]); FAIL;
242
243   GO_UNIMP(119, "old resuba");
244
245   // __NR_readv 120
246   // __NR_writev 121
247   // __NR_settimeofday 122
248   // __NR_fchown 123
249   // __NR_fchmod 124
250
251   GO_UNIMP(125, "old recvfrom");
252
253   // __NR_setreuid 126
254   // __NR_setregid 127
255   // __NR_rename 128
256
257   GO_UNIMP(129, "old truncate");
258
259   GO_UNIMP(130, "old ftruncate");
260
261   // __NR_flock 131
262   // __NR_mkfifo 132
263   // __NR_sendto 133
264   // __NR_shutdown 134
265   // __NR_socketpair 135
266   // __NR_mkdir 136
267   // __NR_rmdir 137
268   // __NR_utimes 138
269   // __NR_futimes 139
270   // __NR_adjtime 140
271
272   GO_UNIMP(141, "old getpeername");
273
274   // __NR_gethostuuid 142
275
276   GO_UNIMP(143, "old sethostid");
277
278   GO_UNIMP(144, "old getrlimit");
279
280   GO_UNIMP(145, "old setrlimit");
281
282   GO_UNIMP(146, "old killpg");
283
284   // __NR_setsid 147
285
286   GO_UNIMP(148, "old setquota");
287
288   GO_UNIMP(149, "old qquota");
289
290   GO_UNIMP(150, "old getsockname");
291
292   // __NR_getpgid 151
293   // __NR_setprivexec 152
294   // __NR_pread 153
295   // __NR_pwrite 154
296   // __NR_nfssvc 155
297
298   GO_UNIMP(156, "old getdirentries");
299
300   // __NR_statfs 157
301   // __NR_fstatfs 158
302   // __NR_unmount 159
303
304   GO_UNIMP(160, "old async_daemon");
305
306   // __NR_getfh 161
307
308   GO_UNIMP(162, "old getdomainname");
309
310   GO_UNIMP(163, "old setdomainname");
311
312   // /* 164 */
313
314   // __NR_quotactl 165
315
316   GO_UNIMP(166, "old exportfs");
317
318   GO(__NR_mount, 167, "4s 2m");
319   SY(__NR_mount, x0, x0, x0, x0); FAIL;
320
321   GO_UNIMP(168, "old ustat");
322
323   GO(__NR_csops, 169, "4s 1m");
324   SY(__NR_csops, x0, x0, x0+1, x0+1); FAILx(EFAULT);
325
326   GO_UNIMP(170, "old table");
327
328   GO_UNIMP(171, "old wait3");
329
330   GO_UNIMP(172, "old rpause");
331
332   // __NR_waitid 173
333
334   GO_UNIMP(174, "old getdents");
335
336   GO_UNIMP(175, "old gc_control");
337
338   // __NR_add_profil 176
339
340   GO_UNIMP(177-179, "unused");
341
342   // __NR_kdebug_trace 180
343   // __NR_setgid 181
344   // __NR_setegid 182
345   // __NR_seteuid 183
346   // __NR_sigreturn 184
347   // __NR_chud 185
348
349   GO_UNIMP(186-187, "unused");
350
351   // __NR_stat 188
352   // __NR_fstat 189
353   // __NR_lstat 190
354   // __NR_pathconf 191
355   // __NR_fpathconf 192
356
357   GO_UNIMP(193, "unused");
358
359   // __NR_getrlimit 194
360   // __NR_setrlimit 195
361   // __NR_getdirentries 196
362   // __NR_mmap 197
363
364   // /* 198  __syscall */
365
366   // __NR_lseek          VG_DARWIN_SYSCALL_CONSTRUCT_UX64(199
367   // __NR_truncate 200
368   // __NR_ftruncate 201
369   // __NR___sysctl 202
370   // __NR_mlock 203
371   // __NR_munlock 204
372   // __NR_undelete 205
373   // __NR_ATsocket 206
374   // __NR_ATgetmsg 207
375   // __NR_ATputmsg 208
376   // __NR_ATPsndreq 209
377   // __NR_ATPsndrsp 210
378   // __NR_ATPgetreq 211
379   // __NR_ATPgetrsp 212
380
381   GO_UNIMP(213, "reserved for AppleTalk");
382
383   // __NR_kqueue_from_portset_np 214
384   // __NR_kqueue_portset_np 215
385   // __NR_mkcomplex 216
386   // __NR_statv 217
387   // __NR_lstatv 218
388   // __NR_fstatv 219
389   // __NR_getattrlist 220
390   // __NR_setattrlist 221
391   // __NR_getdirentriesattr 222
392
393   GO(__NR_exchangedata, 223, "3s 2m");
394   SY(__NR_exchangedata, x0, x0, x0); FAIL;
395
396   // /* 224  checkuseraccess */
397
398   // __NR_searchfs 225
399   // __NR_delete 226
400   // __NR_copyfile 227
401
402   GO_UNIMP(228-229, "unused");
403
404   // __NR_poll 230
405   // __NR_watchevent 231
406   // __NR_waitevent 232
407   // __NR_modwatch 233
408   // __NR_getxattr 234
409   // __NR_fgetxattr 235
410   // __NR_setxattr 236
411   // __NR_fsetxattr 237
412   // __NR_removexattr 238
413   // __NR_fremovexattr 239
414   // __NR_listxattr 240
415   // __NR_flistxattr 241
416   // __NR_fsctl 242
417   // __NR_initgroups 243
418   // __NR_posix_spawn 244
419
420   GO_UNIMP(245-246, "unused");
421
422   // __NR_nfsclnt 247
423   // __NR_fhopen 248
424
425   GO_UNIMP(249, "unused");
426
427   // __NR_minherit 250
428   // __NR_semsys 251
429   // __NR_msgsys 252
430   // __NR_shmsys 253
431   // __NR_semctl 254
432   // __NR_semget 255
433   // __NR_semop 256
434
435   GO_UNIMP(257, "unused");
436
437   // __NR_msgctl 258
438   // __NR_msgget 259
439   // __NR_msgsnd 260
440   // __NR_msgrcv 261
441
442   GO(__NR_shmat, 262, "3s 0m");
443   SY(__NR_shmat, x0, x0, x0); FAIL;
444
445   GO(__NR_shmctl, 263, "3s 1m");
446   SY(__NR_shmctl, x0, x0+IPC_STAT, x0+1); FAIL;
447
448   GO(__NR_shmdt, 264, "1s 0m");
449   SY(__NR_shmdt, x0); FAIL;
450
451   GO(__NR_shmget, 265, "3s 0m");
452   SY(__NR_shmget, x0, x0, x0); FAIL;
453
454   // __NR_shm_open 266
455   // __NR_shm_unlink 267
456
457   GO(__NR_sem_open, 268, "2s 1m");
458   SY(__NR_sem_open, x0, x0); FAIL;
459
460   GO(__NR_sem_open, 268, "(4-args) 2s 0m");
461   SY(__NR_sem_open, "my_sem", O_CREAT|O_EXCL, x0, x0); SUCC_OR_FAIL;
462
463   // Nb: we add 0x12345 to make sure it's not a valid semaphore descriptor.
464   GO(__NR_sem_close, 269, "1s 0m");
465   SY(__NR_sem_close, x0+0x12345); FAIL;
466
467   GO(__NR_sem_unlink, 270, "1s 1m");
468   SY(__NR_sem_unlink, x0); FAIL;
469
470   GO(__NR_sem_wait, 271, "1s 0m");
471   SY(__NR_sem_wait, x0); FAIL;
472
473   GO(__NR_sem_trywait, 272, "1s 0m");
474   SY(__NR_sem_trywait, x0); FAIL;
475
476   GO(__NR_sem_post, 273, "1s 0m");
477   SY(__NR_sem_post, x0); FAIL;
478
479   // __NR_sem_getvalue 274
480
481   GO(__NR_sem_init, 275, "3s 1m");
482   SY(__NR_sem_init, x0+1, x0, x0); FAILx(ENOSYS);
483
484   GO(__NR_sem_destroy, 276, "1s 1m");
485   SY(__NR_sem_destroy, x0+1); FAILx(ENOSYS);
486
487   // __NR_open_extended 277
488   // __NR_umask_extended 278
489
490   {
491      size_t one = 1;
492      GO(__NR_stat_extended, 279, "4s 4m");
493      SY(__NR_stat_extended, x0, x0, x0, x0); FAIL;
494      // Go again to get a complaint about where the 3rd arg points;  it
495      // requires the 4th arg to point to a valid value.
496      SY(__NR_stat_extended, 0, 0, 0, &one); FAIL;
497
498      GO(__NR_lstat_extended, 280, "4s 4m");
499      SY(__NR_lstat_extended, x0, x0, x0, x0); FAIL;
500      // Go again to get a complaint about where the 3rd arg points;  it
501      // requires the 4th arg to point to a valid value.
502      SY(__NR_lstat_extended, 0, 0, 0, &one); FAIL;
503
504      GO(__NR_fstat_extended, 280, "4s 3m");
505      SY(__NR_fstat_extended, x0, x0, x0, x0); FAIL;
506      // Go again to get a complaint about where the 3rd arg points;  it
507      // requires the 4th arg to point to a valid value.
508      SY(__NR_fstat_extended, 0, 0, 0, &one); FAIL;
509   }
510
511   // __NR_chmod_extended 282
512   // __NR_fchmod_extended 283
513
514   // XXX: we don't check the 'results' (too hard, see the wrapper code).  If
515   // we did, it would be 2m.
516   GO(__NR_access_extended, 284, "4s 1m");
517   SY(__NR_access_extended, x0, x0+1, x0, x0); FAIL;
518
519   // __NR_settid 285
520   // __NR_gettid 286
521   // __NR_setsgroups 287
522   // __NR_getsgroups 288
523   // __NR_setwgroups 289
524   // __NR_getwgroups 290
525   // __NR_mkfifo_extended 291
526   // __NR_mkdir_extended 292
527   // __NR_identitysvc 293
528   // __NR_shared_region_check_np 294
529   // __NR_shared_region_map_np 295
530
531   GO_UNIMP(296, "old load_shared_file");
532
533   GO_UNIMP(297, "old reset_shared_file");
534
535   GO_UNIMP(298, "old new_system_shared_regions");
536
537   GO_UNIMP(299, "old shared_region_map_file_np");
538
539   GO_UNIMP(300, "old shared_region_make_private_np");
540
541   // __NR___pthread_mutex_destroy 301
542   // __NR___pthread_mutex_init 302
543   // __NR___pthread_mutex_lock 303
544   // __NR___pthread_mutex_trylock 304
545   // __NR___pthread_mutex_unlock 305
546   // __NR___pthread_cond_init 306
547   // __NR___pthread_cond_destroy 307
548   // __NR___pthread_cond_broadcast 308
549   // __NR___pthread_cond_signal 309
550   // __NR_getsid 310
551   // __NR_settid_with_pid 311
552   // __NR___pthread_cond_timedwait 312
553   // __NR_aio_fsync 313
554
555   GO(__NR_aio_return, 314, "1s 0m");
556   SY(__NR_aio_return, x0); FAIL;
557
558   GO(__NR_aio_suspend, 315, "1s 0m");
559   SY(__NR_aio_suspend, x0, x0+1, x0); FAIL;
560
561   // __NR_aio_cancel 316
562
563   GO(__NR_aio_error, 317, "1s 0m");
564   SY(__NR_aio_error, x0); FAIL;
565
566   GO(__NR_aio_read, 318, "1s 1m");
567   SY(__NR_aio_read, x0); FAIL;
568
569   GO(__NR_aio_write, 319, "1s 1m");
570   SY(__NR_aio_write, x0); FAIL;
571
572   // __NR_lio_listio 320
573   // __NR___pthread_cond_wait 321
574   // __NR_iopolicysys 322
575
576   GO_UNIMP(323, "unused");
577
578   // __NR_mlockall 324
579   // __NR_munlockall 325
580
581   GO_UNIMP(326, "unused");
582
583   // __NR_issetugid 327
584
585   GO(__NR___pthread_kill, 328, "2s 0m");
586   SY(__NR___pthread_kill, x0, x0); FAIL;
587
588   // __NR___pthread_sigmask 329
589   // __NR___sigwait 330
590   // __NR_sigwait 330) // GrP fixme hack
591   // __NR___disable_threadsignal 331
592   // __NR___pthread_markcancel 332
593   // __NR___pthread_canceled 333
594   // __NR___semwait_signal 334
595
596   GO_UNIMP(335, "old utrace");
597
598   // __NR_proc_info 336
599   // __NR_sendfile 337
600   // __NR_stat64 338
601   // __NR_fstat64 339
602   // __NR_lstat64 340
603
604   {
605      size_t one = 1;
606      GO(__NR_stat64_extended, 341, "4s 4m");
607      SY(__NR_stat64_extended, x0, x0, x0, x0); FAIL;
608      // Go again to get a complaint about where the 3rd arg points;  it
609      // requires the 4th arg to point to a valid value.
610      SY(__NR_stat64_extended, 0, 0, 0, &one); FAIL;
611
612      GO(__NR_lstat64_extended, 342, "4s 4m");
613      SY(__NR_lstat64_extended, x0, x0, x0, x0); FAIL;
614      // Go again to get a complaint about where the 3rd arg points;  it
615      // requires the 4th arg to point to a valid value.
616      SY(__NR_lstat64_extended, 0, 0, 0, &one); FAIL;
617
618      GO(__NR_fstat64_extended, 342, "4s 3m");
619      SY(__NR_fstat64_extended, x0, x0, x0, x0); FAIL;
620      // Go again to get a complaint about where the 3rd arg points;  it
621      // requires the 4th arg to point to a valid value.
622      SY(__NR_fstat64_extended, 0, 0, 0, &one); FAIL;
623   }
624
625   // __NR_fstat64_extended 343
626   // __NR_getdirentries64 344
627   // __NR_statfs64 345
628   // __NR_fstatfs64 346
629
630   GO(__NR_getfsstat64, 347, "3s 1m");
631   SY(__NR_getfsstat64, x0+1, x0+1, x0); SUCC; // This should fail...
632
633   // __NR___pthread_chdir 348
634   // __NR___pthread_fchdir 349
635   // __NR_audit 350
636   // __NR_auditon 351
637
638   // /* 352 */
639
640   // __NR_getauid 353
641   // __NR_setauid 354
642   // __NR_getaudit 355
643   // __NR_setaudit 356
644   // __NR_getaudit_addr 357
645   // __NR_setaudit_addr 358
646   // __NR_auditctl 359
647   // __NR_bsdthread_create 360
648   // __NR_bsdthread_terminate 361
649   // __NR_kqueue 362
650   // __NR_kevent 363
651   // __NR_lchown 364
652   // __NR_stack_snapshot 365
653   // __NR_bsdthread_register 366
654   // __NR_workq_open 367
655   // __NR_workq_ops 368
656
657   GO_UNIMP(369-379, "unused");
658
659   // __NR___mac_execve 380
660   // __NR___mac_syscall 381
661   // __NR___mac_get_file 382
662   // __NR___mac_set_file 383
663   // __NR___mac_get_link 384
664   // __NR___mac_set_link 385
665   // __NR___mac_get_proc 386
666   // __NR___mac_set_proc 387
667   // __NR___mac_get_fd 388
668   // __NR___mac_set_fd 389
669   // __NR___mac_get_pid 390
670   // __NR___mac_get_lcid 391
671   // __NR___mac_get_lctx 392
672   // __NR___mac_set_lctx 393
673   // __NR_setlcid 394
674   // __NR_getlcid 395
675
676   // The nocancel syscalls (396--423) are tested in scalar_nocancel.c.
677
678   // __NR___mac_mount 424
679   // __NR___mac_get_mount 425
680   // __NR___mac_getfsstat 426
681   // __NR_MAXSYSCALL 427
682
683#if 0
684   // XXX: all these are copied from x86-linux/scalar.c.
685
686   // __NR_creat 8
687   GO(__NR_creat, "2s 1m");
688   SY(__NR_creat, x0, x0); FAIL;
689
690   // __NR_execve 11
691   // Nb: could have 3 memory errors if we pass x0+1 as the 2nd and 3rd
692   // args, except for bug #93174.
693   GO(__NR_execve, "3s 1m");
694   SY(__NR_execve, x0, x0, x0); FAIL;
695
696   // __NR_time 13
697   GO(__NR_time, "1s 1m");
698   SY(__NR_time, x0+1); FAIL;
699
700   // __NR_lchown 16
701   GO(__NR_lchown, "n/a");
702 //SY(__NR_lchown); // (Not yet handled by Valgrind) FAIL;
703
704   // __NR_break 17
705   GO(__NR_break, "ni");
706   SY(__NR_break); FAIL;
707
708   // __NR_oldstat 18
709   GO(__NR_oldstat, "n/a");
710   // (obsolete, not handled by Valgrind)
711
712   // __NR_lseek 19
713   GO(__NR_lseek, "3s 0m");
714   SY(__NR_lseek, x0-1, x0, x0); FAILx(EBADF);
715
716   // __NR_getpid 20
717   GO(__NR_getpid, "0s 0m");
718   SY(__NR_getpid); SUCC;
719
720   // __NR_mount 21
721   GO(__NR_mount, "5s 3m");
722   SY(__NR_mount, x0, x0, x0, x0, x0); FAIL;
723
724   // __NR_umount 22
725   GO(__NR_umount, "1s 1m");
726   SY(__NR_umount, x0); FAIL;
727
728   // __NR_setuid 23
729   GO(__NR_setuid, "1s 0m");
730   SY(__NR_setuid, x0); FAIL;
731
732   // __NR_getuid 24
733   GO(__NR_getuid, "0s 0m");
734   SY(__NR_getuid); SUCC;
735
736   // __NR_stime 25
737   GO(__NR_stime, "n/a");
738 //SY(__NR_stime); // (Not yet handled by Valgrind) FAIL;
739
740   // __NR_ptrace 26
741   // XXX: memory pointed to by arg3 goes unchecked... otherwise would be 2m
742   GO(__NR_ptrace, "4s 1m");
743   SY(__NR_ptrace, x0+PTRACE_GETREGS, x0, x0, x0); FAIL;
744
745   // __NR_alarm 27
746   GO(__NR_alarm, "1s 0m");
747   SY(__NR_alarm, x0); SUCC;
748
749   // __NR_oldfstat 28
750   GO(__NR_oldfstat, "n/a");
751   // (obsolete, not handled by Valgrind)
752
753   // __NR_pause 29
754   GO(__NR_pause, "ignore");
755   // (hard to test, and no args so not much to be gained -- don't bother)
756
757   // __NR_utime 30
758   GO(__NR_utime, "2s 2m");
759   SY(__NR_utime, x0, x0+1); FAIL;
760
761   // __NR_stty 31
762   GO(__NR_stty, "ni");
763   SY(__NR_stty); FAIL;
764
765   // __NR_gtty 32
766   GO(__NR_gtty, "ni");
767   SY(__NR_gtty); FAIL;
768
769   // __NR_access 33
770   GO(__NR_access, "2s 1m");
771   SY(__NR_access, x0, x0); FAIL;
772
773   // __NR_nice 34
774   GO(__NR_nice, "1s 0m");
775   SY(__NR_nice, x0); SUCC;
776
777   // __NR_ftime 35
778   GO(__NR_ftime, "ni");
779   SY(__NR_ftime); FAIL;
780
781   // __NR_sync 36
782   GO(__NR_sync, "0s 0m");
783   SY(__NR_sync); SUCC;
784
785   // __NR_kill 37
786   GO(__NR_kill, "2s 0m");
787   SY(__NR_kill, x0, x0); SUCC;
788
789   // __NR_rename 38
790   GO(__NR_rename, "2s 2m");
791   SY(__NR_rename, x0, x0); FAIL;
792
793   // __NR_mkdir 39
794   GO(__NR_mkdir, "2s 1m");
795   SY(__NR_mkdir, x0, x0); FAIL;
796
797   // __NR_rmdir 40
798   GO(__NR_rmdir, "1s 1m");
799   SY(__NR_rmdir, x0); FAIL;
800
801   // __NR_dup 41
802   GO(__NR_dup, "1s 0m");
803   SY(__NR_dup, x0-1); FAIL;
804
805   // __NR_pipe 42
806   GO(__NR_pipe, "1s 1m");
807   SY(__NR_pipe, x0); FAIL;
808
809   // __NR_times 43
810   GO(__NR_times, "1s 1m");
811   SY(__NR_times, x0+1); FAIL;
812
813   // __NR_prof 44
814   GO(__NR_prof, "ni");
815   SY(__NR_prof); FAIL;
816
817   // __NR_brk 45
818   GO(__NR_brk, "1s 0m");
819   SY(__NR_brk, x0); SUCC;
820
821   // __NR_setgid 46
822   GO(__NR_setgid, "1s 0m");
823   SY(__NR_setgid, x0); FAIL;
824
825   // __NR_getgid 47
826   GO(__NR_getgid, "0s 0m");
827   SY(__NR_getgid); SUCC;
828
829   // __NR_signal 48
830   GO(__NR_signal, "n/a");
831 //SY(__NR_signal); // (Not yet handled by Valgrind) FAIL;
832
833   // __NR_geteuid 49
834   GO(__NR_geteuid, "0s 0m");
835   SY(__NR_geteuid); SUCC;
836
837   // __NR_getegid 50
838   GO(__NR_getegid, "0s 0m");
839   SY(__NR_getegid); SUCC;
840
841   // __NR_acct 51
842   GO(__NR_acct, "1s 1m");
843   SY(__NR_acct, x0); FAIL;
844
845   // __NR_umount2 52
846   GO(__NR_umount2, "2s 1m");
847   SY(__NR_umount2, x0, x0); FAIL;
848
849   // __NR_lock 53
850   GO(__NR_lock, "ni");
851   SY(__NR_lock); FAIL;
852
853   // __NR_ioctl 54
854   #include <asm/ioctls.h>
855   GO(__NR_ioctl, "3s 1m");
856   SY(__NR_ioctl, x0, x0+TCSETS, x0); FAIL;
857
858   // __NR_fcntl 55
859   // As with sys_open(), the 'fd' error is suppressed for the later ones.
860   // For F_GETFD the 3rd arg is ignored
861   GO(__NR_fcntl, "(GETFD) 2s 0m");
862   SY(__NR_fcntl, x0-1, x0+F_GETFD, x0); FAILx(EBADF);
863
864   // For F_DUPFD the 3rd arg is 'arg'.  We don't check the 1st two args
865   // because any errors may or may not be commoned up with the ones from
866   // the previous fcntl call.
867   GO(__NR_fcntl, "(DUPFD) 1s 0m");
868   SY(__NR_fcntl, -1, F_DUPFD, x0); FAILx(EBADF);
869
870   // For F_GETLK the 3rd arg is 'lock'.  On x86, this fails w/EBADF.  But
871   // on amd64 in 32-bit mode it fails w/EFAULT.  We don't check the 1st two
872   // args for the reason given above.
873   GO(__NR_fcntl, "(GETLK) 1s 0m");
874   SY(__NR_fcntl, -1, F_GETLK, x0); FAIL; //FAILx(EBADF);
875
876   // __NR_mpx 56
877   GO(__NR_mpx, "ni");
878   SY(__NR_mpx); FAIL;
879
880   // __NR_setpgid 57
881   GO(__NR_setpgid, "2s 0m");
882   SY(__NR_setpgid, x0, x0-1); FAIL;
883
884   // __NR_ulimit 58
885   GO(__NR_ulimit, "ni");
886   SY(__NR_ulimit); FAIL;
887
888   // __NR_oldolduname 59
889   GO(__NR_oldolduname, "n/a");
890   // (obsolete, not handled by Valgrind)
891
892   // __NR_umask 60
893   GO(__NR_umask, "1s 0m");
894   SY(__NR_umask, x0+022); SUCC;
895
896   // __NR_chroot 61
897   GO(__NR_chroot, "1s 1m");
898   SY(__NR_chroot, x0); FAIL;
899
900   // __NR_ustat 62
901   GO(__NR_ustat, "n/a");
902   // (deprecated, not handled by Valgrind)
903
904   // __NR_dup2 63
905   GO(__NR_dup2, "2s 0m");
906   SY(__NR_dup2, x0-1, x0); FAIL;
907
908   // __NR_getppid 64
909   GO(__NR_getppid, "0s 0m");
910   SY(__NR_getppid); SUCC;
911
912   // __NR_getpgrp 65
913   GO(__NR_getpgrp, "0s 0m");
914   SY(__NR_getpgrp); SUCC;
915
916   // __NR_setsid 66
917   GO(__NR_setsid, "0s 0m");
918   SY(__NR_setsid); SUCC_OR_FAIL;
919
920   // __NR_sigaction 67
921   GO(__NR_sigaction, "3s 4m");
922   SY(__NR_sigaction, x0, x0+&px[1], x0+&px[1]); FAIL;
923
924   // __NR_sgetmask 68 sys_sgetmask()
925   GO(__NR_sgetmask, "n/a");
926 //SY(__NR_sgetmask); // (Not yet handled by Valgrind) FAIL;
927
928   // __NR_ssetmask 69
929   GO(__NR_ssetmask, "n/a");
930 //SY(__NR_ssetmask); // (Not yet handled by Valgrind) FAIL;
931
932   // __NR_setreuid 70
933   GO(__NR_setreuid, "2s 0m");
934   SY(__NR_setreuid, x0, x0); FAIL;
935
936   // __NR_setregid 71
937   GO(__NR_setregid, "2s 0m");
938   SY(__NR_setregid, x0, x0); FAIL;
939
940   // __NR_sigsuspend 72
941   // XXX: how do you use this function?
942   GO(__NR_sigsuspend, "ignore");
943   // (I don't know how to test this...)
944
945   // __NR_sigpending 73
946   GO(__NR_sigpending, "1s 1m");
947   SY(__NR_sigpending, x0); FAIL;
948
949   // __NR_sethostname 74
950   GO(__NR_sethostname, "n/a");
951 //SY(__NR_sethostname); // (Not yet handled by Valgrind) FAIL;
952
953   // __NR_setrlimit 75
954   GO(__NR_setrlimit, "2s 1m");
955   SY(__NR_setrlimit, x0, x0); FAIL;
956
957   // __NR_getrlimit 76
958   GO(__NR_getrlimit, "2s 1m");
959   SY(__NR_getrlimit, x0, x0); FAIL;
960
961   // __NR_getrusage 77
962   GO(__NR_getrusage, "2s 1m");
963   SY(__NR_getrusage, x0, x0); FAIL;
964
965   // __NR_gettimeofday 78
966   GO(__NR_gettimeofday, "2s 2m");
967   SY(__NR_gettimeofday, x0, x0+1); FAIL;
968
969   // __NR_settimeofday 79
970   GO(__NR_settimeofday, "2s 2m");
971   SY(__NR_settimeofday, x0, x0+1); FAIL;
972
973   // __NR_getgroups 80
974   GO(__NR_getgroups, "2s 1m");
975   SY(__NR_getgroups, x0+1, x0+1); FAIL;
976
977   // __NR_setgroups 81
978   GO(__NR_setgroups, "2s 1m");
979   SY(__NR_setgroups, x0+1, x0+1); FAIL;
980
981   // __NR_select 82
982   {
983      long args[5] = { x0+8, x0+0xffffffee, x0+1, x0+1, x0+1 };
984      GO(__NR_select, "1s 5m");
985      SY(__NR_select, args+x0); FAIL;
986   }
987
988   // __NR_symlink 83
989   GO(__NR_symlink, "2s 2m");
990   SY(__NR_symlink, x0, x0); FAIL;
991
992   // __NR_oldlstat 84
993   GO(__NR_oldlstat, "n/a");
994   // (obsolete, not handled by Valgrind)
995
996   // __NR_readlink 85
997   GO(__NR_readlink, "3s 2m");
998   SY(__NR_readlink, x0+1, x0+1, x0+1); FAIL;
999
1000   // __NR_uselib 86
1001   GO(__NR_uselib, "n/a");
1002 //SY(__NR_uselib); // (Not yet handled by Valgrind) FAIL;
1003
1004   // __NR_swapon 87
1005   GO(__NR_swapon, "n/a");
1006 //SY(__NR_swapon); // (Not yet handled by Valgrind) FAIL;
1007
1008   // __NR_reboot 88
1009   GO(__NR_reboot, "n/a");
1010 //SY(__NR_reboot); // (Not yet handled by Valgrind) FAIL;
1011
1012   // __NR_readdir 89
1013   GO(__NR_readdir, "n/a");
1014   // (superseded, not handled by Valgrind)
1015
1016   // __NR_mmap 90
1017   {
1018      long args[6] = { x0, x0, x0, x0, x0-1, x0 };
1019      GO(__NR_mmap, "1s 1m");
1020      SY(__NR_mmap, args+x0); FAIL;
1021   }
1022
1023   // __NR_munmap 91
1024   GO(__NR_munmap, "2s 0m");
1025   SY(__NR_munmap, x0, x0); FAIL;
1026
1027   // __NR_truncate 92
1028   GO(__NR_truncate, "2s 1m");
1029   SY(__NR_truncate, x0, x0); FAIL;
1030
1031   // __NR_ftruncate 93
1032   GO(__NR_ftruncate, "2s 0m");
1033   SY(__NR_ftruncate, x0, x0); FAIL;
1034
1035   // __NR_fchmod 94
1036   GO(__NR_fchmod, "2s 0m");
1037   SY(__NR_fchmod, x0-1, x0); FAIL;
1038
1039   // __NR_fchown 95
1040   GO(__NR_fchown, "3s 0m");
1041   SY(__NR_fchown, x0, x0, x0); FAIL;
1042
1043   // __NR_getpriority 96
1044   GO(__NR_getpriority, "2s 0m");
1045   SY(__NR_getpriority, x0-1, x0); FAIL;
1046
1047   // __NR_setpriority 97
1048   GO(__NR_setpriority, "3s 0m");
1049   SY(__NR_setpriority, x0-1, x0, x0); FAIL;
1050
1051   // __NR_profil 98
1052   GO(__NR_profil, "ni");
1053   SY(__NR_profil); FAIL;
1054
1055   // __NR_statfs 99
1056   GO(__NR_statfs, "2s 2m");
1057   SY(__NR_statfs, x0, x0); FAIL;
1058
1059   // __NR_fstatfs 100
1060   GO(__NR_fstatfs, "2s 1m");
1061   SY(__NR_fstatfs, x0, x0); FAIL;
1062
1063   // __NR_ioperm 101
1064   GO(__NR_ioperm, "3s 0m");
1065   SY(__NR_ioperm, x0, x0, x0); FAIL;
1066
1067   // __NR_socketcall 102
1068   GO(__NR_socketcall, "XXX");
1069   // (XXX: need to do all sub-cases properly)
1070
1071   // __NR_syslog 103
1072   GO(__NR_syslog, "3s 1m");
1073   SY(__NR_syslog, x0+2, x0, x0+1); FAIL;
1074
1075   // __NR_setitimer 104
1076   GO(__NR_setitimer, "3s 2m");
1077   SY(__NR_setitimer, x0, x0+1, x0+1); FAIL;
1078
1079   // __NR_getitimer 105
1080   GO(__NR_getitimer, "2s 1m");
1081   SY(__NR_getitimer, x0, x0, x0); FAIL;
1082
1083   // __NR_stat 106
1084   GO(__NR_stat, "2s 2m");
1085   SY(__NR_stat, x0, x0); FAIL;
1086
1087   // __NR_lstat 107
1088   GO(__NR_lstat, "2s 2m");
1089   SY(__NR_lstat, x0, x0); FAIL;
1090
1091   // __NR_fstat 108
1092   GO(__NR_fstat, "2s 1m");
1093   SY(__NR_fstat, x0, x0); FAIL;
1094
1095   // __NR_olduname 109
1096   GO(__NR_olduname, "n/a");
1097   // (obsolete, not handled by Valgrind)
1098
1099   // __NR_iopl 110
1100   GO(__NR_iopl, "1s 0m");
1101   SY(__NR_iopl, x0+100); FAIL;
1102
1103   // __NR_vhangup 111
1104   GO(__NR_vhangup, "0s 0m");
1105   SY(__NR_vhangup); SUCC_OR_FAIL;  // Will succeed for superuser
1106
1107   // __NR_idle 112
1108   GO(__NR_idle, "ni");
1109   SY(__NR_idle); FAIL;
1110
1111   // __NR_vm86old 113
1112   GO(__NR_vm86old, "n/a");
1113   // (will probably never be handled by Valgrind)
1114
1115   // __NR_swapoff 115
1116   GO(__NR_swapoff, "n/a");
1117 //SY(__NR_swapoff); // (Not yet handled by Valgrind) FAIL;
1118
1119   // __NR_sysinfo 116
1120   GO(__NR_sysinfo, "1s 1m");
1121   SY(__NR_sysinfo, x0); FAIL;
1122
1123   // __NR_ipc 117
1124   // XXX: This is simplistic -- need to do all the sub-cases properly.
1125   // XXX: Also, should be 6 scalar errors, except glibc's syscall() doesn't
1126   //      use the 6th one!
1127   GO(__NR_ipc, "5s 0m");
1128   SY(__NR_ipc, x0+4, x0, x0, x0, x0, x0); FAIL;
1129
1130   // __NR_fsync 118
1131   GO(__NR_fsync, "1s 0m");
1132   SY(__NR_fsync, x0-1); FAIL;
1133
1134   // __NR_sigreturn 119
1135   GO(__NR_sigreturn, "n/a");
1136 //SY(__NR_sigreturn); // (Not yet handled by Valgrind) FAIL;
1137
1138   // __NR_clone 120
1139#ifndef CLONE_PARENT_SETTID
1140#define CLONE_PARENT_SETTID   0x00100000
1141#endif
1142   // XXX: should really be "4s 2m"?  Not sure... (see PRE(sys_clone))
1143   GO(__NR_clone, "4s 0m");
1144   SY(__NR_clone, x0|CLONE_PARENT_SETTID|SIGCHLD, x0, x0, x0); FAIL;
1145   if (0 == res) {
1146      SY(__NR_exit, 0); FAIL;
1147   }
1148
1149   // __NR_setdomainname 121
1150   GO(__NR_setdomainname, "n/a");
1151 //SY(__NR_setdomainname); // (Not yet handled by Valgrind) FAIL;
1152
1153   // __NR_uname 122
1154   GO(__NR_uname, "1s 1m");
1155   SY(__NR_uname, x0); FAIL;
1156
1157   // __NR_modify_ldt 123
1158   GO(__NR_modify_ldt, "3s 1m");
1159   SY(__NR_modify_ldt, x0+1, x0, x0+1); FAILx(EINVAL);
1160
1161   // __NR_adjtimex 124
1162   // XXX: need to do properly, but deref'ing NULL causing Valgrind to crash...
1163     GO(__NR_adjtimex, "XXX");
1164//   SY(__NR_adjtimex, x0); FAIL;
1165
1166   // __NR_mprotect 125
1167   GO(__NR_mprotect, "3s 0m");
1168   SY(__NR_mprotect, x0+1, x0, x0); FAILx(EINVAL);
1169
1170   // __NR_sigprocmask 126
1171   GO(__NR_sigprocmask, "3s 2m");
1172   SY(__NR_sigprocmask, x0, x0+&px[1], x0+&px[1]); SUCC;
1173
1174   // __NR_create_module 127
1175   GO(__NR_create_module, "ni");
1176   SY(__NR_create_module); FAIL;
1177
1178   // __NR_init_module 128
1179   GO(__NR_init_module, "3s 2m");
1180   SY(__NR_init_module, x0, x0+1, x0); FAIL;
1181
1182   // __NR_delete_module 129
1183   GO(__NR_delete_module, "n/a");
1184 //SY(__NR_delete_module); // (Not yet handled by Valgrind) FAIL;
1185
1186   // __NR_get_kernel_syms 130
1187   GO(__NR_get_kernel_syms, "ni");
1188   SY(__NR_get_kernel_syms); FAIL;
1189
1190   // __NR_quotactl 131
1191   GO(__NR_quotactl, "4s 1m");
1192   SY(__NR_quotactl, x0, x0, x0, x0); FAIL;
1193
1194   // __NR_getpgid 132
1195   GO(__NR_getpgid, "1s 0m");
1196   SY(__NR_getpgid, x0-1); FAIL;
1197
1198   // __NR_bdflush 134
1199   GO(__NR_bdflush, "n/a");
1200 //SY(__NR_bdflush); // (Not yet handled by Valgrind) FAIL;
1201
1202   // __NR_sysfs 135
1203   GO(__NR_sysfs, "n/a");
1204 //SY(__NR_sysfs); // (Not yet handled by Valgrind) FAIL;
1205
1206   // __NR_personality 136
1207   GO(__NR_personality, "1s 0m");
1208   SY(__NR_personality, x0+0xffffffff); SUCC;
1209
1210   // __NR_afs_syscall 137
1211   GO(__NR_afs_syscall, "ni");
1212   SY(__NR_afs_syscall); FAIL;
1213
1214   // __NR_setfsuid 138
1215   GO(__NR_setfsuid, "1s 0m");
1216   SY(__NR_setfsuid, x0); SUCC;  // This syscall has a stupid return value
1217
1218   // __NR_setfsgid 139
1219   GO(__NR_setfsgid, "1s 0m");
1220   SY(__NR_setfsgid, x0); SUCC;  // This syscall has a stupid return value
1221
1222   // __NR__llseek 140
1223   GO(__NR__llseek, "5s 1m");
1224   SY(__NR__llseek, x0, x0, x0, x0, x0); FAIL;
1225
1226   // __NR_getdents 141
1227   GO(__NR_getdents, "3s 1m");
1228   SY(__NR_getdents, x0, x0, x0+1); FAIL;
1229
1230   // __NR__newselect 142
1231   GO(__NR__newselect, "5s 4m");
1232   SY(__NR__newselect, x0+8, x0+0xffffffff, x0+1, x0+1, x0+1); FAIL;
1233
1234   // __NR_flock 143
1235   GO(__NR_flock, "2s 0m");
1236   SY(__NR_flock, x0, x0); FAIL;
1237
1238   // __NR_msync 144
1239   GO(__NR_msync, "3s 1m");
1240   SY(__NR_msync, x0, x0+1, x0); FAIL;
1241
1242   // __NR_readv 145
1243   GO(__NR_readv, "3s 1m");
1244   SY(__NR_readv, x0, x0, x0+1); FAIL;
1245
1246   // __NR_writev 146
1247   GO(__NR_writev, "3s 1m");
1248   SY(__NR_writev, x0, x0, x0+1); FAIL;
1249
1250   // __NR_getsid 147
1251   GO(__NR_getsid, "1s 0m");
1252   SY(__NR_getsid, x0-1); FAIL;
1253
1254   // __NR_fdatasync 148
1255   GO(__NR_fdatasync, "1s 0m");
1256   SY(__NR_fdatasync, x0-1); FAIL;
1257
1258   // __NR__sysctl 149
1259   GO(__NR__sysctl, "1s 1m");
1260   SY(__NR__sysctl, x0); FAIL;
1261
1262   // __NR_mlock 150
1263   GO(__NR_mlock, "2s 0m");
1264   SY(__NR_mlock, x0, x0+1); FAIL;
1265
1266   // __NR_munlock 151
1267   GO(__NR_munlock, "2s 0m");
1268   SY(__NR_munlock, x0, x0+1); FAIL;
1269
1270   // __NR_mlockall 152
1271   GO(__NR_mlockall, "1s 0m");
1272   SY(__NR_mlockall, x0-1); FAIL;
1273
1274   // __NR_munlockall 153
1275   GO(__NR_munlockall, "0s 0m");
1276   SY(__NR_munlockall); SUCC_OR_FAILx(EPERM);
1277
1278   // __NR_sched_setparam 154
1279   GO(__NR_sched_setparam, "2s 1m");
1280   SY(__NR_sched_setparam, x0, x0); FAIL;
1281
1282   // __NR_sched_getparam 155
1283   GO(__NR_sched_getparam, "2s 1m");
1284   SY(__NR_sched_getparam, x0, x0); FAIL;
1285
1286   // __NR_sched_setscheduler 156
1287   GO(__NR_sched_setscheduler, "3s 1m");
1288   SY(__NR_sched_setscheduler, x0-1, x0, x0+1); FAIL;
1289
1290   // __NR_sched_getscheduler 157
1291   GO(__NR_sched_getscheduler, "1s 0m");
1292   SY(__NR_sched_getscheduler, x0-1); FAIL;
1293
1294   // __NR_sched_yield 158
1295   GO(__NR_sched_yield, "0s 0m");
1296   SY(__NR_sched_yield); SUCC;
1297
1298   // __NR_sched_get_priority_max 159
1299   GO(__NR_sched_get_priority_max, "1s 0m");
1300   SY(__NR_sched_get_priority_max, x0-1); FAIL;
1301
1302   // __NR_sched_get_priority_min 160
1303   GO(__NR_sched_get_priority_min, "1s 0m");
1304   SY(__NR_sched_get_priority_min, x0-1); FAIL;
1305
1306   // __NR_sched_rr_get_interval 161
1307   GO(__NR_sched_rr_get_interval, "n/a");
1308 //SY(__NR_sched_rr_get_interval); // (Not yet handled by Valgrind) FAIL;
1309
1310   // __NR_nanosleep 162
1311   GO(__NR_nanosleep, "2s 2m");
1312   SY(__NR_nanosleep, x0, x0+1); FAIL;
1313
1314   // __NR_mremap 163
1315   GO(__NR_mremap, "5s 0m");
1316   SY(__NR_mremap, x0+1, x0, x0, x0+MREMAP_FIXED, x0); FAILx(EINVAL);
1317
1318   // __NR_setresuid 164
1319   GO(__NR_setresuid, "3s 0m");
1320   SY(__NR_setresuid, x0, x0, x0); FAIL;
1321
1322   // __NR_getresuid 165
1323   GO(__NR_getresuid, "3s 3m");
1324   SY(__NR_getresuid, x0, x0, x0); FAIL;
1325
1326   // __NR_vm86 166
1327   GO(__NR_vm86, "n/a");
1328   // (will probably never be handled by Valgrind)
1329
1330   // __NR_query_module 167
1331   GO(__NR_query_module, "ni");
1332   SY(__NR_query_module); FAIL;
1333
1334   // __NR_poll 168
1335   GO(__NR_poll, "3s 1m");
1336   SY(__NR_poll, x0, x0+1, x0); FAIL;
1337
1338   // __NR_nfsservctl 169
1339   GO(__NR_nfsservctl, "n/a");
1340 //SY(__NR_nfsservctl); // (Not yet handled by Valgrind) FAIL;
1341
1342   // __NR_setresgid 170
1343   GO(__NR_setresgid, "3s 0m");
1344   SY(__NR_setresgid, x0, x0, x0); FAIL;
1345
1346   // __NR_getresgid 171
1347   GO(__NR_getresgid, "3s 3m");
1348   SY(__NR_getresgid, x0, x0, x0); FAIL;
1349
1350   // __NR_prctl 172
1351   GO(__NR_prctl, "5s 0m");
1352   SY(__NR_prctl, x0, x0, x0, x0, x0); FAIL;
1353
1354   // __NR_rt_sigreturn 173
1355   GO(__NR_rt_sigreturn, "n/a");
1356 //SY(__NR_rt_sigreturn); // (Not yet handled by Valgrind) FAIL;
1357
1358   // __NR_rt_sigaction 174
1359   GO(__NR_rt_sigaction, "4s 4m");
1360   SY(__NR_rt_sigaction, x0, x0+&px[2], x0+&px[2], x0); FAIL;
1361
1362   // __NR_rt_sigprocmask 175
1363   GO(__NR_rt_sigprocmask, "4s 2m");
1364   SY(__NR_rt_sigprocmask, x0, x0+1, x0+1, x0); FAIL;
1365
1366   // __NR_rt_sigpending 176
1367   GO(__NR_rt_sigpending, "2s 1m");
1368   SY(__NR_rt_sigpending, x0, x0+1); FAIL;
1369
1370   // __NR_rt_sigtimedwait 177
1371   GO(__NR_rt_sigtimedwait, "4s 3m");
1372   SY(__NR_rt_sigtimedwait, x0+1, x0+1, x0+1, x0); FAIL;
1373
1374   // __NR_rt_sigqueueinfo 178
1375   GO(__NR_rt_sigqueueinfo, "3s 1m");
1376   SY(__NR_rt_sigqueueinfo, x0, x0+1, x0); FAIL;
1377
1378   // __NR_rt_sigsuspend 179
1379   GO(__NR_rt_sigsuspend, "ignore");
1380   // (I don't know how to test this...)
1381
1382   // __NR_pread64 180
1383   GO(__NR_pread64, "5s 1m");
1384   SY(__NR_pread64, x0, x0, x0+1, x0, x0); FAIL;
1385
1386   // __NR_pwrite64 181
1387   GO(__NR_pwrite64, "5s 1m");
1388   SY(__NR_pwrite64, x0, x0, x0+1, x0, x0); FAIL;
1389
1390   // __NR_getcwd 183
1391   GO(__NR_getcwd, "2s 1m");
1392   SY(__NR_getcwd, x0, x0+1); FAIL;
1393
1394   // __NR_capget 184
1395   GO(__NR_capget, "2s 2m");
1396   SY(__NR_capget, x0, x0); FAIL;
1397
1398   // __NR_capset 185
1399   GO(__NR_capset, "2s 2m");
1400   SY(__NR_capset, x0, x0); FAIL;
1401
1402   // __NR_sigaltstack 186
1403   {
1404      struct our_sigaltstack {
1405              void *ss_sp;
1406              int ss_flags;
1407              size_t ss_size;
1408      } ss;
1409      ss.ss_sp     = NULL;
1410      ss.ss_flags  = 0;
1411      ss.ss_size   = 0;
1412      VALGRIND_MAKE_MEM_NOACCESS(& ss, sizeof(struct our_sigaltstack));
1413      GO(__NR_sigaltstack, "2s 2m");
1414      SY(__NR_sigaltstack, x0+&ss, x0+&ss); SUCC;
1415   }
1416
1417   // __NR_sendfile 187
1418   GO(__NR_sendfile, "4s 1m");
1419   SY(__NR_sendfile, x0, x0, x0+1, x0); FAIL;
1420
1421   // __NR_getpmsg 188
1422   // Could do 5s 4m with more effort, but I can't be bothered for this
1423   // crappy non-standard syscall.
1424   GO(__NR_getpmsg, "5s 0m");
1425   SY(__NR_getpmsg, x0, x0, x0, x0); FAIL;
1426
1427   // __NR_putpmsg 189
1428   // Could do 5s 2m with more effort, but I can't be bothered for this
1429   // crappy non-standard syscall.
1430   GO(__NR_putpmsg, "5s 0m");
1431   SY(__NR_putpmsg, x0, x0, x0, x0, x0); FAIL;
1432
1433   // __NR_vfork 190
1434   GO(__NR_vfork, "other");
1435   // (sse scalar_vfork.c)
1436
1437   // __NR_ugetrlimit 191
1438   GO(__NR_ugetrlimit, "2s 1m");
1439   SY(__NR_ugetrlimit, x0, x0); FAIL;
1440
1441   // __NR_mmap2 192
1442   GO(__NR_mmap2, "6s 0m");
1443   SY(__NR_mmap2, x0, x0, x0, x0, x0-1, x0); FAIL;
1444
1445   // __NR_truncate64 193
1446   GO(__NR_truncate64, "3s 1m");
1447   SY(__NR_truncate64, x0, x0, x0); FAIL;
1448
1449   // __NR_ftruncate64 194
1450   GO(__NR_ftruncate64, "3s 0m");
1451   SY(__NR_ftruncate64, x0, x0, x0); FAIL;
1452
1453   // __NR_stat64 195
1454   GO(__NR_stat64, "2s 2m");
1455   SY(__NR_stat64, x0, x0); FAIL;
1456
1457   // __NR_lstat64 196
1458   GO(__NR_lstat64, "2s 2m");
1459   SY(__NR_lstat64, x0, x0); FAIL;
1460
1461   // __NR_fstat64 197
1462   GO(__NR_fstat64, "2s 1m");
1463   SY(__NR_fstat64, x0, x0); FAIL;
1464
1465   // __NR_lchown32 198
1466   GO(__NR_lchown32, "3s 1m");
1467   SY(__NR_lchown32, x0, x0, x0); FAIL;
1468
1469   // __NR_getuid32 199
1470   GO(__NR_getuid32, "0s 0m");
1471   SY(__NR_getuid32); SUCC;
1472
1473   // __NR_getgid32 200
1474   GO(__NR_getgid32, "0s 0m");
1475   SY(__NR_getgid32); SUCC;
1476
1477   // __NR_geteuid32 201
1478   GO(__NR_geteuid32, "0s 0m");
1479   SY(__NR_geteuid32); SUCC;
1480
1481   // __NR_getegid32 202
1482   GO(__NR_getegid32, "0s 0m");
1483   SY(__NR_getegid32); SUCC;
1484
1485   // __NR_setreuid32 203
1486   GO(__NR_setreuid32, "2s 0m");
1487   SY(__NR_setreuid32, x0, x0); FAIL;
1488
1489   // __NR_setregid32 204
1490   GO(__NR_setregid32, "2s 0m");
1491   SY(__NR_setregid32, x0, x0); FAIL;
1492
1493   // __NR_getgroups32 205
1494   GO(__NR_getgroups32, "2s 1m");
1495   SY(__NR_getgroups32, x0+1, x0+1); FAIL;
1496
1497   // __NR_setgroups32 206
1498   GO(__NR_setgroups32, "2s 1m");
1499   SY(__NR_setgroups32, x0+1, x0+1); FAIL;
1500
1501   // __NR_fchown32 207
1502   GO(__NR_fchown32, "3s 0m");
1503   SY(__NR_fchown32, x0, x0, x0); FAIL;
1504
1505   // __NR_setresuid32 208
1506   GO(__NR_setresuid32, "3s 0m");
1507   SY(__NR_setresuid32, x0, x0, x0); FAIL;
1508
1509   // __NR_getresuid32 209
1510   GO(__NR_getresuid32, "3s 3m");
1511   SY(__NR_getresuid32, x0, x0, x0); FAIL;
1512
1513   // __NR_setresgid32 210
1514   GO(__NR_setresgid32, "3s 0m");
1515   SY(__NR_setresgid32, x0, x0, x0); FAIL;
1516
1517   // __NR_getresgid32 211
1518   GO(__NR_getresgid32, "3s 3m");
1519   SY(__NR_getresgid32, x0, x0, x0); FAIL;
1520
1521   // __NR_chown32 212
1522   GO(__NR_chown32, "3s 1m");
1523   SY(__NR_chown32, x0, x0, x0); FAIL;
1524
1525   // __NR_setuid32 213
1526   GO(__NR_setuid32, "1s 0m");
1527   SY(__NR_setuid32, x0); FAIL;
1528
1529   // __NR_setgid32 214
1530   GO(__NR_setgid32, "1s 0m");
1531   SY(__NR_setgid32, x0); FAIL;
1532
1533   // __NR_setfsuid32 215
1534   GO(__NR_setfsuid32, "1s 0m");
1535   SY(__NR_setfsuid32, x0); SUCC;  // This syscall has a stupid return value
1536
1537   // __NR_setfsgid32 216
1538   GO(__NR_setfsgid32, "1s 0m");
1539   SY(__NR_setfsgid32, x0); SUCC;  // This syscall has a stupid return value
1540
1541   // __NR_pivot_root 217
1542   GO(__NR_pivot_root, "n/a");
1543 //SY(__NR_pivot_root); // (Not yet handled by Valgrind) FAIL;
1544
1545   // __NR_mincore 218
1546   GO(__NR_mincore, "3s 1m");
1547   SY(__NR_mincore, x0, x0+40960, x0); FAIL;
1548
1549   // __NR_madvise 219
1550   GO(__NR_madvise, "3s 0m");
1551   SY(__NR_madvise, x0, x0+1, x0); FAILx(ENOMEM);
1552
1553   // __NR_getdents64 220
1554   GO(__NR_getdents64, "3s 1m");
1555   SY(__NR_getdents64, x0, x0, x0+1); FAIL;
1556
1557   // __NR_fcntl64 221
1558   // As with sys_open(), we don't trigger errors for the 1st two args for
1559   // the later ones.
1560   // For F_GETFD the 3rd arg is ignored.
1561   GO(__NR_fcntl64, "(GETFD) 2s 0m");
1562   SY(__NR_fcntl64, x0-1, x0+F_GETFD, x0); FAILx(EBADF);
1563
1564   // For F_DUPFD the 3rd arg is 'arg'
1565   GO(__NR_fcntl64, "(DUPFD) 1s 0m");
1566   SY(__NR_fcntl64, -1, F_DUPFD, x0); FAILx(EBADF);
1567
1568   // For F_GETLK the 3rd arg is 'lock'.
1569   // On x86, this fails w/EBADF.  But on amd64 in 32-bit mode it fails
1570   // w/EFAULT.
1571   GO(__NR_fcntl64, "(GETLK) 1s 0m");
1572   SY(__NR_fcntl64, -1, +F_GETLK, x0); FAIL; //FAILx(EBADF);
1573
1574   // 222
1575   GO(222, "ni");
1576   SY(222); FAIL;
1577
1578   // 223
1579   GO(223, "ni");
1580   SY(223); FAIL;
1581
1582   // __NR_gettid 224
1583   GO(__NR_gettid, "n/a");
1584 //SY(__NR_gettid); // (Not yet handled by Valgrind) FAIL;
1585
1586   // __NR_readahead 225
1587   GO(__NR_readahead, "n/a");
1588 //SY(__NR_readahead); // (Not yet handled by Valgrind) FAIL;
1589
1590   // __NR_setxattr 226
1591   GO(__NR_setxattr, "5s 3m");
1592   SY(__NR_setxattr, x0, x0, x0, x0+1, x0); FAIL;
1593
1594   // __NR_lsetxattr 227
1595   GO(__NR_lsetxattr, "5s 3m");
1596   SY(__NR_lsetxattr, x0, x0, x0, x0+1, x0); FAIL;
1597
1598   // __NR_fsetxattr 228
1599   GO(__NR_fsetxattr, "5s 2m");
1600   SY(__NR_fsetxattr, x0, x0, x0, x0+1, x0); FAIL;
1601
1602   // __NR_getxattr 229
1603   GO(__NR_getxattr, "4s 3m");
1604   SY(__NR_getxattr, x0, x0, x0, x0+1); FAIL;
1605
1606   // __NR_lgetxattr 230
1607   GO(__NR_lgetxattr, "4s 3m");
1608   SY(__NR_lgetxattr, x0, x0, x0, x0+1); FAIL;
1609
1610   // __NR_fgetxattr 231
1611   GO(__NR_fgetxattr, "4s 2m");
1612   SY(__NR_fgetxattr, x0, x0, x0, x0+1); FAIL;
1613
1614   // __NR_listxattr 232
1615   GO(__NR_listxattr, "3s 2m");
1616   SY(__NR_listxattr, x0, x0, x0+1); FAIL;
1617
1618   // __NR_llistxattr 233
1619   GO(__NR_llistxattr, "3s 2m");
1620   SY(__NR_llistxattr, x0, x0, x0+1); FAIL;
1621
1622   // __NR_flistxattr 234
1623   GO(__NR_flistxattr, "3s 1m");
1624   SY(__NR_flistxattr, x0-1, x0, x0+1); FAIL; /* kernel returns EBADF, but both seem correct */
1625
1626   // __NR_removexattr 235
1627   GO(__NR_removexattr, "2s 2m");
1628   SY(__NR_removexattr, x0, x0); FAIL;
1629
1630   // __NR_lremovexattr 236
1631   GO(__NR_lremovexattr, "2s 2m");
1632   SY(__NR_lremovexattr, x0, x0); FAIL;
1633
1634   // __NR_fremovexattr 237
1635   GO(__NR_fremovexattr, "2s 1m");
1636   SY(__NR_fremovexattr, x0, x0); FAIL;
1637
1638   // __NR_tkill 238
1639   GO(__NR_tkill, "n/a");
1640 //SY(__NR_tkill); // (Not yet handled by Valgrind) FAIL;
1641
1642   // __NR_sendfile64 239
1643   GO(__NR_sendfile64, "4s 1m");
1644   SY(__NR_sendfile64, x0, x0, x0+1, x0); FAIL;
1645
1646   // __NR_futex 240
1647   #ifndef FUTEX_WAIT
1648   #define FUTEX_WAIT   0
1649   #endif
1650   // XXX: again, glibc not doing 6th arg means we have only 5s errors
1651   GO(__NR_futex, "5s 2m");
1652   SY(__NR_futex, x0+FUTEX_WAIT, x0, x0, x0+1, x0, x0); FAIL;
1653
1654   // __NR_sched_setaffinity 241
1655   GO(__NR_sched_setaffinity, "3s 1m");
1656   SY(__NR_sched_setaffinity, x0, x0+1, x0); FAIL;
1657
1658   // __NR_sched_getaffinity 242
1659   GO(__NR_sched_getaffinity, "3s 1m");
1660   SY(__NR_sched_getaffinity, x0, x0+1, x0); FAIL;
1661
1662   // __NR_set_thread_area 243
1663   GO(__NR_set_thread_area, "1s 1m");
1664   SY(__NR_set_thread_area, x0); FAILx(EFAULT);
1665
1666   // __NR_get_thread_area 244
1667   GO(__NR_get_thread_area, "1s 1m");
1668   SY(__NR_get_thread_area, x0); FAILx(EFAULT);
1669
1670   // __NR_io_setup 245
1671   GO(__NR_io_setup, "2s 1m");
1672   SY(__NR_io_setup, x0, x0); FAIL;
1673
1674   // __NR_io_destroy 246
1675   {
1676      // jump through hoops to prevent the PRE(io_destroy) wrapper crashing.
1677      struct fake_aio_ring {
1678        unsigned        id;     /* kernel internal index number */
1679        unsigned        nr;     /* number of io_events */
1680        // There are more fields in the real aio_ring, but the 'nr' field is
1681        // the only one used by the PRE() wrapper.
1682      } ring = { 0, 0 };
1683      struct fake_aio_ring* ringptr = &ring;
1684      GO(__NR_io_destroy, "1s 0m");
1685      SY(__NR_io_destroy, x0+&ringptr); FAIL;
1686   }
1687
1688   // __NR_io_getevents 247
1689   GO(__NR_io_getevents, "5s 2m");
1690   SY(__NR_io_getevents, x0, x0, x0+1, x0, x0+1); FAIL;
1691
1692   // __NR_io_submit 248
1693   GO(__NR_io_submit, "3s 1m");
1694   SY(__NR_io_submit, x0, x0+1, x0); FAIL;
1695
1696   // __NR_io_cancel 249
1697   GO(__NR_io_cancel, "3s 2m");
1698   SY(__NR_io_cancel, x0, x0, x0); FAIL;
1699
1700   // __NR_fadvise64 250
1701   GO(__NR_fadvise64, "n/a");
1702 //SY(__NR_fadvise64); // (Not yet handled by Valgrind) FAIL;
1703
1704   // 251
1705   GO(251, "ni");
1706   SY(251); FAIL;
1707
1708   // __NR_exit_group 252
1709   GO(__NR_exit_group, "other");
1710   // (see scalar_exit_group.c)
1711
1712   // __NR_lookup_dcookie 253
1713   GO(__NR_lookup_dcookie, "4s 1m");
1714   SY(__NR_lookup_dcookie, x0, x0, x0, x0+1); FAIL;
1715
1716   // __NR_epoll_create 254
1717   GO(__NR_epoll_create, "1s 0m");
1718   SY(__NR_epoll_create, x0); SUCC_OR_FAIL;
1719
1720   // __NR_epoll_ctl 255
1721   GO(__NR_epoll_ctl, "4s 1m");
1722   SY(__NR_epoll_ctl, x0, x0, x0, x0); FAIL;
1723
1724   // __NR_epoll_wait 256
1725   GO(__NR_epoll_wait, "4s 1m");
1726   SY(__NR_epoll_wait, x0, x0, x0+1, x0); FAIL;
1727
1728   // __NR_remap_file_pages 257
1729   GO(__NR_remap_file_pages, "n/a");
1730 //SY(__NR_remap_file_pages); // (Not yet handled by Valgrind) FAIL;
1731
1732   // __NR_set_tid_address 258
1733   GO(__NR_set_tid_address, "1s 0m");
1734   SY(__NR_set_tid_address, x0); SUCC_OR_FAILx(ENOSYS);
1735
1736   // __NR_timer_create 259
1737   GO(__NR_timer_create, "3s 2m");
1738   SY(__NR_timer_create, x0, x0+1, x0); FAIL;
1739
1740   // __NR_timer_settime (__NR_timer_create+1)
1741   GO(__NR_timer_settime, "4s 2m");
1742   SY(__NR_timer_settime, x0, x0, x0, x0+1); FAIL;
1743
1744   // __NR_timer_gettime (__NR_timer_create+2)
1745   GO(__NR_timer_gettime, "2s 1m");
1746   SY(__NR_timer_gettime, x0, x0); FAIL;
1747
1748   // __NR_timer_getoverrun (__NR_timer_create+3)
1749   GO(__NR_timer_getoverrun, "1s 0m");
1750   SY(__NR_timer_getoverrun, x0); FAIL;
1751
1752   // __NR_timer_delete (__NR_timer_create+4)
1753   GO(__NR_timer_delete, "1s 0m");
1754   SY(__NR_timer_delete, x0); FAIL;
1755
1756   // __NR_clock_settime (__NR_timer_create+5)
1757   GO(__NR_clock_settime, "2s 1m");
1758   SY(__NR_clock_settime, x0, x0);  FAIL; FAIL;
1759
1760   // __NR_clock_gettime (__NR_timer_create+6)
1761   GO(__NR_clock_gettime, "2s 1m");
1762   SY(__NR_clock_gettime, x0, x0); FAIL;
1763
1764   // __NR_clock_getres (__NR_timer_create+7)
1765   GO(__NR_clock_getres, "2s 1m");
1766   SY(__NR_clock_getres, x0+1, x0+1); FAIL; FAIL;
1767
1768   // __NR_clock_nanosleep (__NR_timer_create+8)
1769   GO(__NR_clock_nanosleep, "n/a");
1770 //SY(__NR_clock_nanosleep); // (Not yet handled by Valgrind) FAIL;
1771
1772   // __NR_statfs64 268
1773   GO(__NR_statfs64, "3s 2m");
1774   SY(__NR_statfs64, x0, x0+1, x0); FAIL;
1775
1776   // __NR_fstatfs64 269
1777   GO(__NR_fstatfs64, "3s 1m");
1778   SY(__NR_fstatfs64, x0, x0+1, x0); FAIL;
1779
1780   // __NR_tgkill 270
1781   GO(__NR_tgkill, "n/a");
1782 //SY(__NR_tgkill); // (Not yet handled by Valgrind) FAIL;
1783
1784   // __NR_utimes 271
1785   GO(__NR_utimes, "2s 2m");
1786   SY(__NR_utimes, x0, x0+1); FAIL;
1787
1788   // __NR_fadvise64_64 272
1789   GO(__NR_fadvise64_64, "n/a");
1790 //SY(__NR_fadvise64_64); // (Not yet handled by Valgrind) FAIL;
1791
1792   // __NR_vserver 273
1793   GO(__NR_vserver, "ni");
1794   SY(__NR_vserver); FAIL;
1795
1796   // __NR_mbind 274
1797   GO(__NR_mbind, "n/a");
1798 //SY(__NR_mbind); // (Not yet handled by Valgrind) FAIL;
1799
1800   // __NR_get_mempolicy 275
1801   GO(__NR_get_mempolicy, "n/a");
1802 //SY(__NR_get_mempolicy); // (Not yet handled by Valgrind) FAIL;
1803
1804   // __NR_set_mempolicy 276
1805   GO(__NR_set_mempolicy, "n/a");
1806 //SY(__NR_set_mempolicy); // (Not yet handled by Valgrind) FAIL;
1807
1808   // __NR_mq_open 277
1809   GO(__NR_mq_open, "4s 3m");
1810   SY(__NR_mq_open, x0, x0+O_CREAT, x0, x0+1); FAIL;
1811
1812   // __NR_mq_unlink (__NR_mq_open+1)
1813   GO(__NR_mq_unlink, "1s 1m");
1814   SY(__NR_mq_unlink, x0); FAIL;
1815
1816   // __NR_mq_timedsend (__NR_mq_open+2)
1817   GO(__NR_mq_timedsend, "5s 2m");
1818   SY(__NR_mq_timedsend, x0, x0, x0+1, x0, x0+1); FAIL;
1819
1820   // __NR_mq_timedreceive (__NR_mq_open+3)
1821   GO(__NR_mq_timedreceive, "5s 3m");
1822   SY(__NR_mq_timedreceive, x0, x0, x0+1, x0+1, x0+1); FAIL;
1823
1824   // __NR_mq_notify (__NR_mq_open+4)
1825   GO(__NR_mq_notify, "2s 1m");
1826   SY(__NR_mq_notify, x0, x0+1); FAIL;
1827
1828   // __NR_mq_getsetattr (__NR_mq_open+5)
1829   GO(__NR_mq_getsetattr, "3s 2m");
1830   SY(__NR_mq_getsetattr, x0, x0+1, x0+1); FAIL;
1831
1832   // __NR_sys_kexec_load 283
1833   GO(__NR_sys_kexec_load, "ni");
1834   SY(__NR_sys_kexec_load); FAIL;
1835#endif
1836
1837   // no such syscall...
1838   GO(9999, 9999, "1e");
1839   SY(9999); FAIL;
1840
1841   // __NR_exit 1
1842   GO(__NR_exit, 1, "1s 0m");
1843   SY(__NR_exit, x0); FAIL;
1844
1845   assert(0);
1846}
1847
1848