2 /*--------------------------------------------------------------------*/
3 /*--- Linux-specific syscalls, etc. syswrap-linux.c ---*/
4 /*--------------------------------------------------------------------*/
7 This file is part of Valgrind, a dynamic binary instrumentation
10 Copyright (C) 2000-2013 Nicholas Nethercote
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.
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.
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
28 The GNU General Public License is contained in the file COPYING.
31 #if defined(VGO_linux)
33 #include "pub_core_basics.h"
34 #include "pub_core_vki.h"
35 #include "pub_core_vkiscnums.h"
36 #include "pub_core_threadstate.h"
37 #include "pub_core_aspacemgr.h"
38 #include "pub_core_debuginfo.h" // VG_(di_notify_*)
39 #include "pub_core_transtab.h" // VG_(discard_translations)
40 #include "pub_core_xarray.h"
41 #include "pub_core_clientstate.h"
42 #include "pub_core_debuglog.h"
43 #include "pub_core_libcbase.h"
44 #include "pub_core_libcassert.h"
45 #include "pub_core_libcfile.h"
46 #include "pub_core_libcprint.h"
47 #include "pub_core_libcproc.h"
48 #include "pub_core_libcsignal.h"
49 #include "pub_core_machine.h" // VG_(get_SP)
50 #include "pub_core_mallocfree.h"
51 #include "pub_core_tooliface.h"
52 #include "pub_core_options.h"
53 #include "pub_core_scheduler.h"
54 #include "pub_core_signals.h"
55 #include "pub_core_syscall.h"
56 #include "pub_core_syswrap.h"
57 #include "pub_core_inner.h"
58 #if defined(ENABLE_INNER_CLIENT_REQUEST)
59 #include "pub_core_clreq.h"
62 #include "priv_types_n_macros.h"
63 #include "priv_syswrap-generic.h"
64 #include "priv_syswrap-linux.h"
65 #include "priv_syswrap-xen.h"
67 // Run a thread from beginning to end and return the thread's
68 // scheduler-return-code.
69 static VgSchedReturnCode
thread_wrapper(Word
/*ThreadId*/ tidW
)
71 VgSchedReturnCode ret
;
72 ThreadId tid
= (ThreadId
)tidW
;
73 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
75 VG_(debugLog
)(1, "syswrap-linux",
76 "thread_wrapper(tid=%lld): entry\n",
79 vg_assert(tst
->status
== VgTs_Init
);
81 /* make sure we get the CPU lock before doing anything significant */
82 VG_(acquire_BigLock
)(tid
, "thread_wrapper(starting new thread)");
85 VG_(printf
)("thread tid %d started: stack = %p\n",
88 /* Make sure error reporting is enabled in the new thread. */
89 tst
->err_disablement_level
= 0;
91 VG_TRACK(pre_thread_first_insn
, tid
);
93 tst
->os_state
.lwpid
= VG_(gettid
)();
94 /* Set the threadgroup for real. This overwrites the provisional
95 value set in do_clone() syswrap-*-linux.c. See comments in
96 do_clone for background, also #226116. */
97 tst
->os_state
.threadgroup
= VG_(getpid
)();
99 /* Thread created with all signals blocked; scheduler will set the
102 ret
= VG_(scheduler
)(tid
);
104 vg_assert(VG_(is_exiting
)(tid
));
106 vg_assert(tst
->status
== VgTs_Runnable
);
107 vg_assert(VG_(is_running_thread
)(tid
));
109 VG_(debugLog
)(1, "syswrap-linux",
110 "thread_wrapper(tid=%lld): exit, schedreturncode %s\n",
111 (ULong
)tidW
, VG_(name_of_VgSchedReturnCode
)(ret
));
113 /* Return to caller, still holding the lock. */
118 /* ---------------------------------------------------------------------
120 ------------------------------------------------------------------ */
122 /* Run a thread all the way to the end, then do appropriate exit actions
123 (this is the last-one-out-turn-off-the-lights bit). */
124 static void run_a_thread_NORETURN ( Word tidW
)
126 ThreadId tid
= (ThreadId
)tidW
;
127 VgSchedReturnCode src
;
130 #ifdef ENABLE_INNER_CLIENT_REQUEST
131 Int registered_vgstack_id
;
134 VG_(debugLog
)(1, "syswrap-linux",
135 "run_a_thread_NORETURN(tid=%lld): pre-thread_wrapper\n",
138 tst
= VG_(get_ThreadState
)(tid
);
141 /* An thread has two stacks:
142 * the simulated stack (used by the synthetic cpu. Guest process
143 is using this stack).
144 * the valgrind stack (used by the real cpu. Valgrind code is running
146 When Valgrind runs as an inner, it must signals that its (real) stack
147 is the stack to use by the outer to e.g. do stacktraces.
150 (registered_vgstack_id
151 = VALGRIND_STACK_REGISTER (tst
->os_state
.valgrind_stack_base
,
152 tst
->os_state
.valgrind_stack_init_SP
));
154 /* Run the thread all the way through. */
155 src
= thread_wrapper(tid
);
157 VG_(debugLog
)(1, "syswrap-linux",
158 "run_a_thread_NORETURN(tid=%lld): post-thread_wrapper\n",
161 c
= VG_(count_living_threads
)();
162 vg_assert(c
>= 1); /* stay sane */
164 // Tell the tool this thread is exiting
165 VG_TRACK( pre_thread_ll_exit
, tid
);
167 /* If the thread is exiting with errors disabled, complain loudly;
168 doing so is bad (does the user know this has happened?) Also,
169 in all cases, be paranoid and clear the flag anyway so that the
170 thread slot is safe in this respect if later reallocated. This
171 should be unnecessary since the flag should be cleared when the
172 slot is reallocated, in thread_wrapper(). */
173 if (tst
->err_disablement_level
> 0) {
175 "WARNING: exiting thread has error reporting disabled.\n"
176 "WARNING: possibly as a result of some mistake in the use\n"
177 "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n"
181 "run_a_thread_NORETURN(tid=%lld): "
182 "WARNING: exiting thread has err_disablement_level = %u\n",
183 (ULong
)tidW
, tst
->err_disablement_level
186 tst
->err_disablement_level
= 0;
190 VG_(debugLog
)(1, "syswrap-linux",
191 "run_a_thread_NORETURN(tid=%lld): "
192 "last one standing\n",
195 /* We are the last one standing. Keep hold of the lock and
196 carry on to show final tool results, then exit the entire system.
197 Use the continuation pointer set at startup in m_main. */
198 ( * VG_(address_of_m_main_shutdown_actions_NORETURN
) ) (tid
, src
);
201 VG_(debugLog
)(1, "syswrap-linux",
202 "run_a_thread_NORETURN(tid=%lld): "
203 "not last one standing\n",
206 /* OK, thread is dead, but others still exist. Just exit. */
208 /* This releases the run lock */
209 VG_(exit_thread
)(tid
);
210 vg_assert(tst
->status
== VgTs_Zombie
);
211 vg_assert(sizeof(tst
->status
) == 4);
212 vg_assert(sizeof(tst
->os_state
.exitcode
) == sizeof(Word
));
214 INNER_REQUEST (VALGRIND_STACK_DEREGISTER (registered_vgstack_id
));
216 /* We have to use this sequence to terminate the thread to
217 prevent a subtle race. If VG_(exit_thread)() had left the
218 ThreadState as Empty, then it could have been reallocated,
219 reusing the stack while we're doing these last cleanups.
220 Instead, VG_(exit_thread) leaves it as Zombie to prevent
221 reallocation. We need to make sure we don't touch the stack
222 between marking it Empty and exiting. Hence the
224 #if defined(VGP_x86_linux)
227 "movl %1, %0\n" /* set tst->status = VgTs_Empty */
228 "movl %2, %%eax\n" /* set %eax = __NR_exit */
229 "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */
230 "int $0x80\n" /* exit(tst->os_state.exitcode) */
233 : "n" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
236 #elif defined(VGP_amd64_linux)
238 "movl %1, %0\n" /* set tst->status = VgTs_Empty */
239 "movq %2, %%rax\n" /* set %rax = __NR_exit */
240 "movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */
241 "syscall\n" /* exit(tst->os_state.exitcode) */
243 : "n" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
246 #elif defined(VGP_ppc32_linux) || defined(VGP_ppc64be_linux) \
247 || defined(VGP_ppc64le_linux)
248 { UInt vgts_empty
= (UInt
)VgTs_Empty
;
250 "stw %1,%0\n\t" /* set tst->status = VgTs_Empty */
251 "li 0,%2\n\t" /* set r0 = __NR_exit */
252 "lwz 3,%3\n\t" /* set r3 = tst->os_state.exitcode */
253 "sc\n\t" /* exit(tst->os_state.exitcode) */
255 : "r" (vgts_empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
259 #elif defined(VGP_arm_linux)
261 "str %1, %0\n" /* set tst->status = VgTs_Empty */
262 "mov r7, %2\n" /* set %r7 = __NR_exit */
263 "ldr r0, %3\n" /* set %r0 = tst->os_state.exitcode */
264 "svc 0x00000000\n" /* exit(tst->os_state.exitcode) */
266 : "r" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
269 #elif defined(VGP_arm64_linux)
271 "str %w1, %0\n" /* set tst->status = VgTs_Empty (32-bit store) */
272 "mov x8, %2\n" /* set %r7 = __NR_exit */
273 "ldr x0, %3\n" /* set %r0 = tst->os_state.exitcode */
274 "svc 0x00000000\n" /* exit(tst->os_state.exitcode) */
276 : "r" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
279 #elif defined(VGP_s390x_linux)
281 "st %1, %0\n" /* set tst->status = VgTs_Empty */
282 "lg 2, %3\n" /* set r2 = tst->os_state.exitcode */
283 "svc %2\n" /* exit(tst->os_state.exitcode) */
285 : "d" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
288 #elif defined(VGP_mips32_linux) || defined(VGP_mips64_linux)
290 "sw %1, %0\n\t" /* set tst->status = VgTs_Empty */
291 "li $2, %2\n\t" /* set v0 = __NR_exit */
292 "lw $4, %3\n\t" /* set a0 = tst->os_state.exitcode */
293 "syscall\n\t" /* exit(tst->os_state.exitcode) */
296 : "r" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
297 : "cc", "memory" , "v0", "a0"
299 #elif defined(VGP_tilegx_linux)
301 "st4 %0, %1\n" /* set tst->status = VgTs_Empty */
302 "moveli r10, %2\n" /* set r10 = __NR_exit */
303 "move r0, %3\n" /* set r0 = tst->os_state.exitcode */
304 "swint1\n" /* exit(tst->os_state.exitcode) */
306 : "r" (VgTs_Empty
), "n" (__NR_exit
), "r" (tst
->os_state
.exitcode
)
307 : "r0", "r1", "r2", "r3", "r4", "r5");
309 # error Unknown platform
312 VG_(core_panic
)("Thread exit failed?\n");
319 Word
ML_(start_thread_NORETURN
) ( void* arg
)
321 ThreadState
* tst
= (ThreadState
*)arg
;
322 ThreadId tid
= tst
->tid
;
324 run_a_thread_NORETURN ( (Word
)tid
);
329 /* Allocate a stack for this thread, if it doesn't already have one.
330 They're allocated lazily, and never freed. Returns the initial stack
331 pointer value to use, or 0 if allocation failed. */
332 Addr
ML_(allocstack
)(ThreadId tid
)
334 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
338 /* Either the stack_base and stack_init_SP are both zero (in which
339 case a stack hasn't been allocated) or they are both non-zero,
340 in which case it has. */
342 if (tst
->os_state
.valgrind_stack_base
== 0)
343 vg_assert(tst
->os_state
.valgrind_stack_init_SP
== 0);
345 if (tst
->os_state
.valgrind_stack_base
!= 0)
346 vg_assert(tst
->os_state
.valgrind_stack_init_SP
!= 0);
348 /* If no stack is present, allocate one. */
350 if (tst
->os_state
.valgrind_stack_base
== 0) {
351 stack
= VG_(am_alloc_VgStack
)( &initial_SP
);
353 tst
->os_state
.valgrind_stack_base
= (Addr
)stack
;
354 tst
->os_state
.valgrind_stack_init_SP
= initial_SP
;
359 VG_(printf
)( "stack for tid %d at %p; init_SP=%p\n",
361 (void*)tst
->os_state
.valgrind_stack_base
,
362 (void*)tst
->os_state
.valgrind_stack_init_SP
);
364 return tst
->os_state
.valgrind_stack_init_SP
;
367 /* Allocate a stack for the main thread, and run it all the way to the
368 end. Although we already have a working VgStack
369 (VG_(interim_stack)) it's better to allocate a new one, so that
370 overflow detection works uniformly for all threads.
372 void VG_(main_thread_wrapper_NORETURN
)(ThreadId tid
)
375 VG_(debugLog
)(1, "syswrap-linux",
376 "entering VG_(main_thread_wrapper_NORETURN)\n");
378 sp
= ML_(allocstack
)(tid
);
379 #if defined(ENABLE_INNER_CLIENT_REQUEST)
381 // we must register the main thread stack before the call
382 // to ML_(call_on_new_stack_0_1), otherwise the outer valgrind
383 // reports 'write error' on the non registered stack.
384 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
387 VALGRIND_STACK_REGISTER (tst
->os_state
.valgrind_stack_base
,
388 tst
->os_state
.valgrind_stack_init_SP
));
392 #if defined(VGP_ppc32_linux)
393 /* make a stack frame */
397 #elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
398 /* make a stack frame */
402 #elif defined(VGP_s390x_linux)
403 /* make a stack frame */
409 /* If we can't even allocate the first thread's stack, we're hosed.
411 vg_assert2(sp
!= 0, "Cannot allocate main thread's stack.");
413 /* shouldn't be any other threads around yet */
414 vg_assert( VG_(count_living_threads
)() == 1 );
416 ML_(call_on_new_stack_0_1
)(
417 (Addr
)sp
, /* stack */
418 0, /* bogus return address */
419 run_a_thread_NORETURN
, /* fn to call */
420 (Word
)tid
/* arg to give it */
428 /* Do a clone which is really a fork() */
429 SysRes
ML_(do_fork_clone
) ( ThreadId tid
, UInt flags
,
430 Int
* parent_tidptr
, Int
* child_tidptr
)
432 vki_sigset_t fork_saved_mask
;
436 if (flags
& (VKI_CLONE_SETTLS
| VKI_CLONE_FS
| VKI_CLONE_VM
437 | VKI_CLONE_FILES
| VKI_CLONE_VFORK
))
438 return VG_(mk_SysRes_Error
)( VKI_EINVAL
);
440 /* Block all signals during fork, so that we can fix things up in
441 the child without being interrupted. */
442 VG_(sigfillset
)(&mask
);
443 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &mask
, &fork_saved_mask
);
445 VG_(do_atfork_pre
)(tid
);
447 /* Since this is the fork() form of clone, we don't need all that
449 #if defined(VGP_x86_linux) \
450 || defined(VGP_ppc32_linux) \
451 || defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) \
452 || defined(VGP_arm_linux) || defined(VGP_mips32_linux) \
453 || defined(VGP_mips64_linux) || defined(VGP_arm64_linux)
454 res
= VG_(do_syscall5
)( __NR_clone
, flags
,
455 (UWord
)NULL
, (UWord
)parent_tidptr
,
456 (UWord
)NULL
, (UWord
)child_tidptr
);
457 #elif defined(VGP_amd64_linux) || defined(VGP_tilegx_linux)
458 /* note that the last two arguments are the opposite way round to x86 and
459 ppc32 as the amd64 kernel expects the arguments in a different order */
460 res
= VG_(do_syscall5
)( __NR_clone
, flags
,
461 (UWord
)NULL
, (UWord
)parent_tidptr
,
462 (UWord
)child_tidptr
, (UWord
)NULL
);
463 #elif defined(VGP_s390x_linux)
464 /* Note that s390 has the stack first and then the flags */
465 res
= VG_(do_syscall4
)( __NR_clone
, (UWord
) NULL
, flags
,
466 (UWord
)parent_tidptr
, (UWord
)child_tidptr
);
468 # error Unknown platform
471 if (!sr_isError(res
) && sr_Res(res
) == 0) {
473 VG_(do_atfork_child
)(tid
);
475 /* restore signal mask */
476 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &fork_saved_mask
, NULL
);
478 /* If --child-silent-after-fork=yes was specified, set the
479 output file descriptors to 'impossible' values. This is
480 noticed by send_bytes_to_logging_sink in m_libcprint.c, which
481 duly stops writing any further output. */
482 if (VG_(clo_child_silent_after_fork
)) {
483 if (!VG_(log_output_sink
).is_socket
)
484 VG_(log_output_sink
).fd
= -1;
485 if (!VG_(xml_output_sink
).is_socket
)
486 VG_(xml_output_sink
).fd
= -1;
490 if (!sr_isError(res
) && sr_Res(res
) > 0) {
492 VG_(do_atfork_parent
)(tid
);
494 if (VG_(clo_trace_syscalls
))
495 VG_(printf
)(" clone(fork): process %d created child %ld\n",
496 VG_(getpid
)(), sr_Res(res
));
498 /* restore signal mask */
499 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &fork_saved_mask
, NULL
);
506 /* ---------------------------------------------------------------------
507 PRE/POST wrappers for arch-generic, Linux-specific syscalls
508 ------------------------------------------------------------------ */
510 // Nb: See the comment above the generic PRE/POST wrappers in
511 // m_syswrap/syswrap-generic.c for notes about how they work.
513 #define PRE(name) DEFN_PRE_TEMPLATE(linux, name)
514 #define POST(name) DEFN_POST_TEMPLATE(linux, name)
516 // Macros to support 64-bit syscall args split into two 32 bit values
517 #define LOHI64(lo,hi) ( ((ULong)(lo)) | (((ULong)(hi)) << 32) )
518 #if defined(VG_LITTLEENDIAN)
519 #define MERGE64(lo,hi) ( ((ULong)(lo)) | (((ULong)(hi)) << 32) )
520 #define MERGE64_FIRST(name) name##_low
521 #define MERGE64_SECOND(name) name##_high
522 #elif defined(VG_BIGENDIAN)
523 #define MERGE64(hi,lo) ( ((ULong)(lo)) | (((ULong)(hi)) << 32) )
524 #define MERGE64_FIRST(name) name##_high
525 #define MERGE64_SECOND(name) name##_low
527 #error Unknown endianness
530 /* ---------------------------------------------------------------------
532 ------------------------------------------------------------------ */
536 // Nb: depending on 'flags', the 'type' and 'data' args may be ignored.
537 // We are conservative and check everything, except the memory pointed to
539 *flags
|= SfMayBlock
;
540 PRINT("sys_mount( %#lx(%s), %#lx(%s), %#lx(%s), %#lx, %#lx )",
541 ARG1
,(HChar
*)ARG1
, ARG2
,(HChar
*)ARG2
, ARG3
,(HChar
*)ARG3
, ARG4
, ARG5
);
542 PRE_REG_READ5(long, "mount",
543 char *, source
, char *, target
, char *, type
,
544 unsigned long, flags
, void *, data
);
546 PRE_MEM_RASCIIZ( "mount(source)", ARG1
);
547 PRE_MEM_RASCIIZ( "mount(target)", ARG2
);
548 PRE_MEM_RASCIIZ( "mount(type)", ARG3
);
553 PRINT("sys_oldumount( %#lx )", ARG1
);
554 PRE_REG_READ1(long, "umount", char *, path
);
555 PRE_MEM_RASCIIZ( "umount(path)", ARG1
);
560 PRINT("sys_umount( %#lx, %ld )", ARG1
, ARG2
);
561 PRE_REG_READ2(long, "umount2", char *, path
, int, flags
);
562 PRE_MEM_RASCIIZ( "umount2(path)", ARG1
);
565 /* Not actually wrapped by GLibc but does things with the system
566 * mounts so it is put here.
570 PRINT("sys_pivot_root ( %s %s )", (HChar
*)ARG1
, (HChar
*)ARG2
);
571 PRE_REG_READ2(int, "pivot_root", char *, new_root
, char *, old_root
);
572 PRE_MEM_RASCIIZ( "pivot_root(new_root)", ARG1
);
573 PRE_MEM_RASCIIZ( "pivot_root(old_root)", ARG2
);
577 /* ---------------------------------------------------------------------
578 16- and 32-bit uid/gid wrappers
579 ------------------------------------------------------------------ */
583 PRINT("sys_setfsuid16 ( %ld )", ARG1
);
584 PRE_REG_READ1(long, "setfsuid16", vki_old_uid_t
, uid
);
589 PRINT("sys_setfsuid ( %ld )", ARG1
);
590 PRE_REG_READ1(long, "setfsuid", vki_uid_t
, uid
);
595 PRINT("sys_setfsgid16 ( %ld )", ARG1
);
596 PRE_REG_READ1(long, "setfsgid16", vki_old_gid_t
, gid
);
601 PRINT("sys_setfsgid ( %ld )", ARG1
);
602 PRE_REG_READ1(long, "setfsgid", vki_gid_t
, gid
);
607 PRINT("sys_setresuid16 ( %ld, %ld, %ld )", ARG1
, ARG2
, ARG3
);
608 PRE_REG_READ3(long, "setresuid16",
609 vki_old_uid_t
, ruid
, vki_old_uid_t
, euid
, vki_old_uid_t
, suid
);
614 PRINT("sys_setresuid ( %ld, %ld, %ld )", ARG1
, ARG2
, ARG3
);
615 PRE_REG_READ3(long, "setresuid",
616 vki_uid_t
, ruid
, vki_uid_t
, euid
, vki_uid_t
, suid
);
621 PRINT("sys_getresuid16 ( %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
622 PRE_REG_READ3(long, "getresuid16",
623 vki_old_uid_t
*, ruid
, vki_old_uid_t
*, euid
,
624 vki_old_uid_t
*, suid
);
625 PRE_MEM_WRITE( "getresuid16(ruid)", ARG1
, sizeof(vki_old_uid_t
) );
626 PRE_MEM_WRITE( "getresuid16(euid)", ARG2
, sizeof(vki_old_uid_t
) );
627 PRE_MEM_WRITE( "getresuid16(suid)", ARG3
, sizeof(vki_old_uid_t
) );
629 POST(sys_getresuid16
)
633 POST_MEM_WRITE( ARG1
, sizeof(vki_old_uid_t
) );
634 POST_MEM_WRITE( ARG2
, sizeof(vki_old_uid_t
) );
635 POST_MEM_WRITE( ARG3
, sizeof(vki_old_uid_t
) );
641 PRINT("sys_getresuid ( %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
642 PRE_REG_READ3(long, "getresuid",
643 vki_uid_t
*, ruid
, vki_uid_t
*, euid
, vki_uid_t
*, suid
);
644 PRE_MEM_WRITE( "getresuid(ruid)", ARG1
, sizeof(vki_uid_t
) );
645 PRE_MEM_WRITE( "getresuid(euid)", ARG2
, sizeof(vki_uid_t
) );
646 PRE_MEM_WRITE( "getresuid(suid)", ARG3
, sizeof(vki_uid_t
) );
652 POST_MEM_WRITE( ARG1
, sizeof(vki_uid_t
) );
653 POST_MEM_WRITE( ARG2
, sizeof(vki_uid_t
) );
654 POST_MEM_WRITE( ARG3
, sizeof(vki_uid_t
) );
660 PRINT("sys_setresgid16 ( %ld, %ld, %ld )", ARG1
, ARG2
, ARG3
);
661 PRE_REG_READ3(long, "setresgid16",
663 vki_old_gid_t
, egid
, vki_old_gid_t
, sgid
);
668 PRINT("sys_setresgid ( %ld, %ld, %ld )", ARG1
, ARG2
, ARG3
);
669 PRE_REG_READ3(long, "setresgid",
670 vki_gid_t
, rgid
, vki_gid_t
, egid
, vki_gid_t
, sgid
);
675 PRINT("sys_getresgid16 ( %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
676 PRE_REG_READ3(long, "getresgid16",
677 vki_old_gid_t
*, rgid
, vki_old_gid_t
*, egid
,
678 vki_old_gid_t
*, sgid
);
679 PRE_MEM_WRITE( "getresgid16(rgid)", ARG1
, sizeof(vki_old_gid_t
) );
680 PRE_MEM_WRITE( "getresgid16(egid)", ARG2
, sizeof(vki_old_gid_t
) );
681 PRE_MEM_WRITE( "getresgid16(sgid)", ARG3
, sizeof(vki_old_gid_t
) );
683 POST(sys_getresgid16
)
687 POST_MEM_WRITE( ARG1
, sizeof(vki_old_gid_t
) );
688 POST_MEM_WRITE( ARG2
, sizeof(vki_old_gid_t
) );
689 POST_MEM_WRITE( ARG3
, sizeof(vki_old_gid_t
) );
695 PRINT("sys_getresgid ( %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
696 PRE_REG_READ3(long, "getresgid",
697 vki_gid_t
*, rgid
, vki_gid_t
*, egid
, vki_gid_t
*, sgid
);
698 PRE_MEM_WRITE( "getresgid(rgid)", ARG1
, sizeof(vki_gid_t
) );
699 PRE_MEM_WRITE( "getresgid(egid)", ARG2
, sizeof(vki_gid_t
) );
700 PRE_MEM_WRITE( "getresgid(sgid)", ARG3
, sizeof(vki_gid_t
) );
706 POST_MEM_WRITE( ARG1
, sizeof(vki_gid_t
) );
707 POST_MEM_WRITE( ARG2
, sizeof(vki_gid_t
) );
708 POST_MEM_WRITE( ARG3
, sizeof(vki_gid_t
) );
712 /* ---------------------------------------------------------------------
713 miscellaneous wrappers
714 ------------------------------------------------------------------ */
721 PRINT("exit_group( %ld )", ARG1
);
722 PRE_REG_READ1(void, "exit_group", int, status
);
724 tst
= VG_(get_ThreadState
)(tid
);
725 /* A little complex; find all the threads with the same threadgroup
726 as this one (including this one), and mark them to exit */
727 /* It is unclear how one can get a threadgroup in this process which
728 is not the threadgroup of the calling thread:
729 The assignments to threadgroups are:
730 = 0; /// scheduler.c os_state_clear
731 = getpid(); /// scheduler.c in child after fork
732 = getpid(); /// this file, in thread_wrapper
733 = ptst->os_state.threadgroup; /// syswrap-*-linux.c,
734 copying the thread group of the thread doing clone
735 So, the only case where the threadgroup might be different to the getpid
736 value is in the child, just after fork. But then the fork syscall is
737 still going on, the forked thread has had no chance yet to make this
739 for (t
= 1; t
< VG_N_THREADS
; t
++) {
741 VG_(threads
)[t
].status
== VgTs_Empty
744 VG_(threads
)[t
].os_state
.threadgroup
!= tst
->os_state
.threadgroup
747 /* Assign the exit code, VG_(nuke_all_threads_except) will assign
749 VG_(threads
)[t
].os_state
.exitcode
= ARG1
;
752 /* Indicate in all other threads that the process is exiting.
753 Then wait using VG_(reap_threads) for these threads to disappear.
755 Can this give a deadlock if another thread is calling exit in parallel
756 and would then wait for this thread to disappear ?
758 Other threads are either blocked in a syscall or have yielded the CPU.
760 A thread that has yielded the CPU is trying to get the big lock in
761 VG_(scheduler). This thread will get the CPU thanks to the call
762 to VG_(reap_threads). The scheduler will then check for signals,
763 kill the process if this is a fatal signal, and otherwise prepare
764 the thread for handling this signal. After this preparation, if
765 the thread status is VG_(is_exiting), the scheduler exits the thread.
766 So, a thread that has yielded the CPU does not have a chance to
767 call exit => no deadlock for this thread.
769 VG_(nuke_all_threads_except) will send the VG_SIGVGKILL signal
770 to all threads blocked in a syscall.
771 The syscall will be interrupted, and the control will go to the
772 scheduler. The scheduler will then return, as the thread is in
775 VG_(nuke_all_threads_except
)( tid
, VgSrc_ExitProcess
);
776 VG_(reap_threads
)(tid
);
777 VG_(threads
)[tid
].exitreason
= VgSrc_ExitThread
;
778 /* we do assign VgSrc_ExitThread and not VgSrc_ExitProcess, as this thread
779 is the thread calling exit_group and so its registers must be considered
780 as not reachable. See pub_tool_machine.h VG_(apply_to_GP_regs). */
782 /* We have to claim the syscall already succeeded. */
783 SET_STATUS_Success(0);
788 PRINT("sys_llseek ( %ld, 0x%lx, 0x%lx, %#lx, %ld )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
789 PRE_REG_READ5(long, "llseek",
790 unsigned int, fd
, unsigned long, offset_high
,
791 unsigned long, offset_low
, vki_loff_t
*, result
,
792 unsigned int, whence
);
793 if (!ML_(fd_allowed
)(ARG1
, "llseek", tid
, False
))
794 SET_STATUS_Failure( VKI_EBADF
);
796 PRE_MEM_WRITE( "llseek(result)", ARG4
, sizeof(vki_loff_t
));
802 POST_MEM_WRITE( ARG4
, sizeof(vki_loff_t
) );
807 struct vki_timex
*tx
= (struct vki_timex
*)ARG1
;
808 PRINT("sys_adjtimex ( %#lx )", ARG1
);
809 PRE_REG_READ1(long, "adjtimex", struct timex
*, buf
);
810 PRE_MEM_READ( "adjtimex(timex->modes)", ARG1
, sizeof(tx
->modes
));
812 #define ADJX(bits,field) \
813 if (tx->modes & (bits)) \
814 PRE_MEM_READ( "adjtimex(timex->"#field")", \
815 (Addr)&tx->field, sizeof(tx->field))
817 if (tx
->modes
& VKI_ADJ_ADJTIME
) {
818 if (!(tx
->modes
& VKI_ADJ_OFFSET_READONLY
))
819 PRE_MEM_READ( "adjtimex(timex->offset)", (Addr
)&tx
->offset
, sizeof(tx
->offset
));
821 ADJX(VKI_ADJ_OFFSET
, offset
);
822 ADJX(VKI_ADJ_FREQUENCY
, freq
);
823 ADJX(VKI_ADJ_MAXERROR
, maxerror
);
824 ADJX(VKI_ADJ_ESTERROR
, esterror
);
825 ADJX(VKI_ADJ_STATUS
, status
);
826 ADJX(VKI_ADJ_TIMECONST
|VKI_ADJ_TAI
, constant
);
827 ADJX(VKI_ADJ_TICK
, tick
);
831 PRE_MEM_WRITE( "adjtimex(timex)", ARG1
, sizeof(struct vki_timex
));
836 POST_MEM_WRITE( ARG1
, sizeof(struct vki_timex
) );
839 PRE(sys_clock_adjtime
)
841 struct vki_timex
*tx
= (struct vki_timex
*)ARG2
;
842 PRINT("sys_clock_adjtime ( %ld, %#lx )", ARG1
,ARG2
);
843 PRE_REG_READ2(long, "clock_adjtime", vki_clockid_t
, id
, struct timex
*, buf
);
844 PRE_MEM_READ( "clock_adjtime(timex->modes)", ARG2
, sizeof(tx
->modes
));
846 #define ADJX(bits,field) \
847 if (tx->modes & (bits)) \
848 PRE_MEM_READ( "clock_adjtime(timex->"#field")", \
849 (Addr)&tx->field, sizeof(tx->field))
851 if (tx
->modes
& VKI_ADJ_ADJTIME
) {
852 if (!(tx
->modes
& VKI_ADJ_OFFSET_READONLY
))
853 PRE_MEM_READ( "clock_adjtime(timex->offset)", (Addr
)&tx
->offset
, sizeof(tx
->offset
));
855 ADJX(VKI_ADJ_OFFSET
, offset
);
856 ADJX(VKI_ADJ_FREQUENCY
, freq
);
857 ADJX(VKI_ADJ_MAXERROR
, maxerror
);
858 ADJX(VKI_ADJ_ESTERROR
, esterror
);
859 ADJX(VKI_ADJ_STATUS
, status
);
860 ADJX(VKI_ADJ_TIMECONST
|VKI_ADJ_TAI
, constant
);
861 ADJX(VKI_ADJ_TICK
, tick
);
865 PRE_MEM_WRITE( "adjtimex(timex)", ARG2
, sizeof(struct vki_timex
));
868 POST(sys_clock_adjtime
)
870 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timex
) );
875 PRINT("sys_ioperm ( %ld, %ld, %ld )", ARG1
, ARG2
, ARG3
);
876 PRE_REG_READ3(long, "ioperm",
877 unsigned long, from
, unsigned long, num
, int, turn_on
);
882 *flags
|= SfMayBlock
;
883 PRINT("sys_syslog (%ld, %#lx, %ld)", ARG1
,ARG2
,ARG3
);
884 PRE_REG_READ3(long, "syslog", int, type
, char *, bufp
, int, len
);
886 // The kernel uses magic numbers here, rather than named constants,
887 // therefore so do we.
888 case 2: case 3: case 4:
889 PRE_MEM_WRITE( "syslog(bufp)", ARG2
, ARG3
);
898 case 2: case 3: case 4:
899 POST_MEM_WRITE( ARG2
, ARG3
);
908 PRINT("sys_vhangup ( )");
909 PRE_REG_READ0(long, "vhangup");
914 PRINT("sys_sysinfo ( %#lx )",ARG1
);
915 PRE_REG_READ1(long, "sysinfo", struct sysinfo
*, info
);
916 PRE_MEM_WRITE( "sysinfo(info)", ARG1
, sizeof(struct vki_sysinfo
) );
920 POST_MEM_WRITE( ARG1
, sizeof(struct vki_sysinfo
) );
925 PRINT("sys_personality ( %llu )", (ULong
)ARG1
);
926 PRE_REG_READ1(long, "personality", vki_u_long
, persona
);
931 struct __vki_sysctl_args
*args
;
932 PRINT("sys_sysctl ( %#lx )", ARG1
);
933 args
= (struct __vki_sysctl_args
*)ARG1
;
934 PRE_REG_READ1(long, "sysctl", struct __sysctl_args
*, args
);
935 PRE_MEM_WRITE( "sysctl(args)", ARG1
, sizeof(struct __vki_sysctl_args
) );
936 if (!VG_(am_is_valid_for_client
)(ARG1
, sizeof(struct __vki_sysctl_args
),
938 SET_STATUS_Failure( VKI_EFAULT
);
942 PRE_MEM_READ("sysctl(name)", (Addr
)args
->name
, args
->nlen
* sizeof(*args
->name
));
943 if (args
->newval
!= NULL
)
944 PRE_MEM_READ("sysctl(newval)", (Addr
)args
->newval
, args
->newlen
);
945 if (args
->oldlenp
!= NULL
) {
946 PRE_MEM_READ("sysctl(oldlenp)", (Addr
)args
->oldlenp
, sizeof(*args
->oldlenp
));
947 PRE_MEM_WRITE("sysctl(oldval)", (Addr
)args
->oldval
, *args
->oldlenp
);
952 struct __vki_sysctl_args
*args
;
953 args
= (struct __vki_sysctl_args
*)ARG1
;
954 if (args
->oldlenp
!= NULL
) {
955 POST_MEM_WRITE((Addr
)args
->oldlenp
, sizeof(*args
->oldlenp
));
956 POST_MEM_WRITE((Addr
)args
->oldval
, 1 + *args
->oldlenp
);
962 *flags
|= SfMayBlock
;
963 PRINT( "sys_prctl ( %ld, %ld, %ld, %ld, %ld )", ARG1
, ARG2
, ARG3
, ARG4
, ARG5
);
965 case VKI_PR_SET_PDEATHSIG
:
966 PRE_REG_READ2(int, "prctl", int, option
, int, signal
);
968 case VKI_PR_GET_PDEATHSIG
:
969 PRE_REG_READ2(int, "prctl", int, option
, int *, signal
);
970 PRE_MEM_WRITE("prctl(get-death-signal)", ARG2
, sizeof(Int
));
972 case VKI_PR_GET_DUMPABLE
:
973 PRE_REG_READ1(int, "prctl", int, option
);
975 case VKI_PR_SET_DUMPABLE
:
976 PRE_REG_READ2(int, "prctl", int, option
, int, dump
);
978 case VKI_PR_GET_UNALIGN
:
979 PRE_REG_READ2(int, "prctl", int, option
, int *, value
);
980 PRE_MEM_WRITE("prctl(get-unalign)", ARG2
, sizeof(Int
));
982 case VKI_PR_SET_UNALIGN
:
983 PRE_REG_READ2(int, "prctl", int, option
, int, value
);
985 case VKI_PR_GET_KEEPCAPS
:
986 PRE_REG_READ1(int, "prctl", int, option
);
988 case VKI_PR_SET_KEEPCAPS
:
989 PRE_REG_READ2(int, "prctl", int, option
, int, keepcaps
);
991 case VKI_PR_GET_FPEMU
:
992 PRE_REG_READ2(int, "prctl", int, option
, int *, value
);
993 PRE_MEM_WRITE("prctl(get-fpemu)", ARG2
, sizeof(Int
));
995 case VKI_PR_SET_FPEMU
:
996 PRE_REG_READ2(int, "prctl", int, option
, int, value
);
998 case VKI_PR_GET_FPEXC
:
999 PRE_REG_READ2(int, "prctl", int, option
, int *, value
);
1000 PRE_MEM_WRITE("prctl(get-fpexc)", ARG2
, sizeof(Int
));
1002 case VKI_PR_SET_FPEXC
:
1003 PRE_REG_READ2(int, "prctl", int, option
, int, value
);
1005 case VKI_PR_GET_TIMING
:
1006 PRE_REG_READ1(int, "prctl", int, option
);
1008 case VKI_PR_SET_TIMING
:
1009 PRE_REG_READ2(int, "prctl", int, option
, int, timing
);
1011 case VKI_PR_SET_NAME
:
1012 PRE_REG_READ2(int, "prctl", int, option
, char *, name
);
1013 PRE_MEM_RASCIIZ("prctl(set-name)", ARG2
);
1015 case VKI_PR_GET_NAME
:
1016 PRE_REG_READ2(int, "prctl", int, option
, char *, name
);
1017 PRE_MEM_WRITE("prctl(get-name)", ARG2
, VKI_TASK_COMM_LEN
);
1019 case VKI_PR_GET_ENDIAN
:
1020 PRE_REG_READ2(int, "prctl", int, option
, int *, value
);
1021 PRE_MEM_WRITE("prctl(get-endian)", ARG2
, sizeof(Int
));
1023 case VKI_PR_SET_ENDIAN
:
1024 PRE_REG_READ2(int, "prctl", int, option
, int, value
);
1026 case VKI_PR_SET_PTRACER
:
1027 PRE_REG_READ2(int, "prctl", int, option
, int, ptracer_process_ID
);
1029 case VKI_PR_SET_SECCOMP
:
1030 /* This is a bit feeble in that it uses |option| before checking
1031 it, but at least both sides of the conditional check it. */
1032 if (ARG2
== VKI_SECCOMP_MODE_FILTER
) {
1033 PRE_REG_READ3(int, "prctl", int, option
, int, mode
, char*, filter
);
1035 /* Should check that ARG3 points at a valid struct sock_fprog.
1036 Sounds complex; hence be lame. */
1037 PRE_MEM_READ( "prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, filter)",
1041 PRE_REG_READ2(int, "prctl", int, option
, int, mode
);
1045 PRE_REG_READ5(long, "prctl",
1046 int, option
, unsigned long, arg2
, unsigned long, arg3
,
1047 unsigned long, arg4
, unsigned long, arg5
);
1054 case VKI_PR_GET_PDEATHSIG
:
1055 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1057 case VKI_PR_GET_UNALIGN
:
1058 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1060 case VKI_PR_GET_FPEMU
:
1061 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1063 case VKI_PR_GET_FPEXC
:
1064 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1066 case VKI_PR_GET_NAME
:
1067 POST_MEM_WRITE(ARG2
, VKI_TASK_COMM_LEN
);
1069 case VKI_PR_GET_ENDIAN
:
1070 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1072 case VKI_PR_SET_NAME
:
1074 const HChar
* new_name
= (const HChar
*) ARG2
;
1075 if (new_name
) { // Paranoia
1076 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
1077 SizeT new_len
= VG_(strlen
)(new_name
);
1079 /* Don't bother reusing the memory. This is a rare event. */
1081 VG_(realloc
)("syswrap.prctl", tst
->thread_name
, new_len
+ 1);
1082 VG_(strcpy
)(tst
->thread_name
, new_name
);
1091 *flags
|= SfMayBlock
;
1092 PRINT("sys_sendfile ( %ld, %ld, %#lx, %lu )", ARG1
,ARG2
,ARG3
,ARG4
);
1093 PRE_REG_READ4(ssize_t
, "sendfile",
1094 int, out_fd
, int, in_fd
, vki_off_t
*, offset
,
1097 PRE_MEM_WRITE( "sendfile(offset)", ARG3
, sizeof(vki_off_t
) );
1102 POST_MEM_WRITE( ARG3
, sizeof( vki_off_t
) );
1108 *flags
|= SfMayBlock
;
1109 PRINT("sendfile64 ( %ld, %ld, %#lx, %lu )",ARG1
,ARG2
,ARG3
,ARG4
);
1110 PRE_REG_READ4(ssize_t
, "sendfile64",
1111 int, out_fd
, int, in_fd
, vki_loff_t
*, offset
,
1114 PRE_MEM_WRITE( "sendfile64(offset)", ARG3
, sizeof(vki_loff_t
) );
1116 POST(sys_sendfile64
)
1119 POST_MEM_WRITE( ARG3
, sizeof(vki_loff_t
) );
1126 arg param used by ops
1128 ARG1 - u32 *futex all
1130 ARG3 - int val WAIT,WAKE,FD,REQUEUE,CMP_REQUEUE
1131 ARG4 - struct timespec *utime WAIT:time* REQUEUE,CMP_REQUEUE:val2
1132 ARG5 - u32 *uaddr2 REQUEUE,CMP_REQUEUE
1133 ARG6 - int val3 CMP_REQUEUE
1135 PRINT("sys_futex ( %#lx, %ld, %ld, %#lx, %#lx )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
1136 switch(ARG2
& ~(VKI_FUTEX_PRIVATE_FLAG
|VKI_FUTEX_CLOCK_REALTIME
)) {
1137 case VKI_FUTEX_CMP_REQUEUE
:
1138 case VKI_FUTEX_WAKE_OP
:
1139 case VKI_FUTEX_CMP_REQUEUE_PI
:
1140 PRE_REG_READ6(long, "futex",
1141 vki_u32
*, futex
, int, op
, int, val
,
1142 struct timespec
*, utime
, vki_u32
*, uaddr2
, int, val3
);
1144 case VKI_FUTEX_REQUEUE
:
1145 case VKI_FUTEX_WAIT_REQUEUE_PI
:
1146 PRE_REG_READ5(long, "futex",
1147 vki_u32
*, futex
, int, op
, int, val
,
1148 struct timespec
*, utime
, vki_u32
*, uaddr2
);
1150 case VKI_FUTEX_WAIT_BITSET
:
1151 /* Check that the address at least begins in client-accessible area. */
1152 if (!VG_(am_is_valid_for_client
)( ARG1
, 1, VKI_PROT_READ
)) {
1153 SET_STATUS_Failure( VKI_EFAULT
);
1156 if (*(vki_u32
*)ARG1
!= ARG3
) {
1157 PRE_REG_READ5(long, "futex",
1158 vki_u32
*, futex
, int, op
, int, val
,
1159 struct timespec
*, utime
, int, dummy
);
1161 PRE_REG_READ6(long, "futex",
1162 vki_u32
*, futex
, int, op
, int, val
,
1163 struct timespec
*, utime
, int, dummy
, int, val3
);
1166 case VKI_FUTEX_WAKE_BITSET
:
1167 PRE_REG_READ6(long, "futex",
1168 vki_u32
*, futex
, int, op
, int, val
,
1169 int, dummy
, int, dummy2
, int, val3
);
1171 case VKI_FUTEX_WAIT
:
1172 case VKI_FUTEX_LOCK_PI
:
1173 PRE_REG_READ4(long, "futex",
1174 vki_u32
*, futex
, int, op
, int, val
,
1175 struct timespec
*, utime
);
1177 case VKI_FUTEX_WAKE
:
1179 case VKI_FUTEX_TRYLOCK_PI
:
1180 PRE_REG_READ3(long, "futex",
1181 vki_u32
*, futex
, int, op
, int, val
);
1183 case VKI_FUTEX_UNLOCK_PI
:
1185 PRE_REG_READ2(long, "futex", vki_u32
*, futex
, int, op
);
1189 *flags
|= SfMayBlock
;
1191 switch(ARG2
& ~(VKI_FUTEX_PRIVATE_FLAG
|VKI_FUTEX_CLOCK_REALTIME
)) {
1192 case VKI_FUTEX_WAIT
:
1193 case VKI_FUTEX_LOCK_PI
:
1194 case VKI_FUTEX_WAIT_BITSET
:
1195 case VKI_FUTEX_WAIT_REQUEUE_PI
:
1196 PRE_MEM_READ( "futex(futex)", ARG1
, sizeof(Int
) );
1198 PRE_MEM_READ( "futex(timeout)", ARG4
, sizeof(struct vki_timespec
) );
1201 case VKI_FUTEX_REQUEUE
:
1202 case VKI_FUTEX_CMP_REQUEUE
:
1203 case VKI_FUTEX_CMP_REQUEUE_PI
:
1204 case VKI_FUTEX_WAKE_OP
:
1205 PRE_MEM_READ( "futex(futex)", ARG1
, sizeof(Int
) );
1206 PRE_MEM_READ( "futex(futex2)", ARG5
, sizeof(Int
) );
1210 case VKI_FUTEX_TRYLOCK_PI
:
1211 case VKI_FUTEX_UNLOCK_PI
:
1212 PRE_MEM_READ( "futex(futex)", ARG1
, sizeof(Int
) );
1215 case VKI_FUTEX_WAKE
:
1216 case VKI_FUTEX_WAKE_BITSET
:
1217 /* no additional pointers */
1221 SET_STATUS_Failure( VKI_ENOSYS
); // some futex function we don't understand
1228 POST_MEM_WRITE( ARG1
, sizeof(int) );
1229 if (ARG2
== VKI_FUTEX_FD
) {
1230 if (!ML_(fd_allowed
)(RES
, "futex", tid
, True
)) {
1232 SET_STATUS_Failure( VKI_EMFILE
);
1234 if (VG_(clo_track_fds
))
1235 ML_(record_fd_open_nameless
)(tid
, RES
);
1240 PRE(sys_set_robust_list
)
1242 PRINT("sys_set_robust_list ( %#lx, %ld )", ARG1
,ARG2
);
1243 PRE_REG_READ2(long, "set_robust_list",
1244 struct vki_robust_list_head
*, head
, vki_size_t
, len
);
1246 /* Just check the robust_list_head structure is readable - don't
1247 try and chase the list as the kernel will only read it when
1248 the thread exits so the current contents is irrelevant. */
1250 PRE_MEM_READ("set_robust_list(head)", ARG1
, ARG2
);
1253 PRE(sys_get_robust_list
)
1255 PRINT("sys_get_robust_list ( %ld, %#lx, %ld )", ARG1
,ARG2
,ARG3
);
1256 PRE_REG_READ3(long, "get_robust_list",
1258 struct vki_robust_list_head
**, head_ptr
,
1259 vki_size_t
*, len_ptr
);
1260 PRE_MEM_WRITE("get_robust_list(head_ptr)",
1261 ARG2
, sizeof(struct vki_robust_list_head
*));
1262 PRE_MEM_WRITE("get_robust_list(len_ptr)",
1263 ARG3
, sizeof(struct vki_size_t
*));
1265 POST(sys_get_robust_list
)
1267 POST_MEM_WRITE(ARG2
, sizeof(struct vki_robust_list_head
*));
1268 POST_MEM_WRITE(ARG3
, sizeof(struct vki_size_t
*));
1273 *flags
|= SfMayBlock
;
1274 PRINT("sys_pselect6 ( %ld, %#lx, %#lx, %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
1275 PRE_REG_READ6(long, "pselect6",
1276 int, n
, vki_fd_set
*, readfds
, vki_fd_set
*, writefds
,
1277 vki_fd_set
*, exceptfds
, struct vki_timeval
*, timeout
,
1279 // XXX: this possibly understates how much memory is read.
1281 PRE_MEM_READ( "pselect6(readfds)",
1282 ARG2
, ARG1
/8 /* __FD_SETSIZE/8 */ );
1284 PRE_MEM_READ( "pselect6(writefds)",
1285 ARG3
, ARG1
/8 /* __FD_SETSIZE/8 */ );
1287 PRE_MEM_READ( "pselect6(exceptfds)",
1288 ARG4
, ARG1
/8 /* __FD_SETSIZE/8 */ );
1290 PRE_MEM_READ( "pselect6(timeout)", ARG5
, sizeof(struct vki_timeval
) );
1292 PRE_MEM_READ( "pselect6(sig)", ARG6
, sizeof(void *)+sizeof(vki_size_t
) );
1298 struct vki_pollfd
* ufds
= (struct vki_pollfd
*)ARG1
;
1299 *flags
|= SfMayBlock
;
1300 PRINT("sys_ppoll ( %#lx, %ld, %#lx, %#lx, %llu )\n", ARG1
,ARG2
,ARG3
,ARG4
,(ULong
)ARG5
);
1301 PRE_REG_READ5(long, "ppoll",
1302 struct vki_pollfd
*, ufds
, unsigned int, nfds
,
1303 struct vki_timespec
*, tsp
, vki_sigset_t
*, sigmask
,
1304 vki_size_t
, sigsetsize
);
1306 for (i
= 0; i
< ARG2
; i
++) {
1307 PRE_MEM_READ( "ppoll(ufds.fd)",
1308 (Addr
)(&ufds
[i
].fd
), sizeof(ufds
[i
].fd
) );
1309 PRE_MEM_READ( "ppoll(ufds.events)",
1310 (Addr
)(&ufds
[i
].events
), sizeof(ufds
[i
].events
) );
1311 PRE_MEM_WRITE( "ppoll(ufds.revents)",
1312 (Addr
)(&ufds
[i
].revents
), sizeof(ufds
[i
].revents
) );
1316 PRE_MEM_READ( "ppoll(tsp)", ARG3
, sizeof(struct vki_timespec
) );
1318 PRE_MEM_READ( "ppoll(sigmask)", ARG4
, sizeof(vki_sigset_t
) );
1325 struct vki_pollfd
* ufds
= (struct vki_pollfd
*)ARG1
;
1326 for (i
= 0; i
< ARG2
; i
++)
1327 POST_MEM_WRITE( (Addr
)(&ufds
[i
].revents
), sizeof(ufds
[i
].revents
) );
1332 /* ---------------------------------------------------------------------
1334 ------------------------------------------------------------------ */
1336 PRE(sys_epoll_create
)
1338 PRINT("sys_epoll_create ( %ld )", ARG1
);
1339 PRE_REG_READ1(long, "epoll_create", int, size
);
1341 POST(sys_epoll_create
)
1344 if (!ML_(fd_allowed
)(RES
, "epoll_create", tid
, True
)) {
1346 SET_STATUS_Failure( VKI_EMFILE
);
1348 if (VG_(clo_track_fds
))
1349 ML_(record_fd_open_nameless
) (tid
, RES
);
1353 PRE(sys_epoll_create1
)
1355 PRINT("sys_epoll_create1 ( %ld )", ARG1
);
1356 PRE_REG_READ1(long, "epoll_create1", int, flags
);
1358 POST(sys_epoll_create1
)
1361 if (!ML_(fd_allowed
)(RES
, "epoll_create1", tid
, True
)) {
1363 SET_STATUS_Failure( VKI_EMFILE
);
1365 if (VG_(clo_track_fds
))
1366 ML_(record_fd_open_nameless
) (tid
, RES
);
1372 static const HChar
* epoll_ctl_s
[3] = {
1377 PRINT("sys_epoll_ctl ( %ld, %s, %ld, %#lx )",
1378 ARG1
, ( ARG2
<3 ? epoll_ctl_s
[ARG2
] : "?" ), ARG3
, ARG4
);
1379 PRE_REG_READ4(long, "epoll_ctl",
1380 int, epfd
, int, op
, int, fd
, struct vki_epoll_event
*, event
);
1381 if (ARG2
!= VKI_EPOLL_CTL_DEL
)
1382 PRE_MEM_READ( "epoll_ctl(event)", ARG4
, sizeof(struct vki_epoll_event
) );
1387 *flags
|= SfMayBlock
;
1388 PRINT("sys_epoll_wait ( %ld, %#lx, %ld, %ld )", ARG1
, ARG2
, ARG3
, ARG4
);
1389 PRE_REG_READ4(long, "epoll_wait",
1390 int, epfd
, struct vki_epoll_event
*, events
,
1391 int, maxevents
, int, timeout
);
1392 PRE_MEM_WRITE( "epoll_wait(events)", ARG2
, sizeof(struct vki_epoll_event
)*ARG3
);
1394 POST(sys_epoll_wait
)
1398 POST_MEM_WRITE( ARG2
, sizeof(struct vki_epoll_event
)*RES
) ;
1401 PRE(sys_epoll_pwait
)
1403 *flags
|= SfMayBlock
;
1404 PRINT("sys_epoll_pwait ( %ld, %#lx, %ld, %ld, %#lx, %llu )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,(ULong
)ARG6
);
1405 PRE_REG_READ6(long, "epoll_pwait",
1406 int, epfd
, struct vki_epoll_event
*, events
,
1407 int, maxevents
, int, timeout
, vki_sigset_t
*, sigmask
,
1408 vki_size_t
, sigsetsize
);
1409 PRE_MEM_WRITE( "epoll_pwait(events)", ARG2
, sizeof(struct vki_epoll_event
)*ARG3
);
1411 PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5
, sizeof(vki_sigset_t
) );
1413 POST(sys_epoll_pwait
)
1417 POST_MEM_WRITE( ARG2
, sizeof(struct vki_epoll_event
)*RES
) ;
1422 PRINT("sys_eventfd ( %lu )", ARG1
);
1423 PRE_REG_READ1(long, "sys_eventfd", unsigned int, count
);
1427 if (!ML_(fd_allowed
)(RES
, "eventfd", tid
, True
)) {
1429 SET_STATUS_Failure( VKI_EMFILE
);
1431 if (VG_(clo_track_fds
))
1432 ML_(record_fd_open_nameless
) (tid
, RES
);
1438 PRINT("sys_eventfd2 ( %lu, %ld )", ARG1
,ARG2
);
1439 PRE_REG_READ2(long, "sys_eventfd2", unsigned int, count
, int, flags
);
1443 if (!ML_(fd_allowed
)(RES
, "eventfd2", tid
, True
)) {
1445 SET_STATUS_Failure( VKI_EMFILE
);
1447 if (VG_(clo_track_fds
))
1448 ML_(record_fd_open_nameless
) (tid
, RES
);
1454 *flags
|= SfMayBlock
;
1455 #if VG_WORDSIZE == 4
1456 PRINT("sys_fallocate ( %ld, %ld, %lld, %lld )",
1457 ARG1
, ARG2
, MERGE64(ARG3
,ARG4
), MERGE64(ARG5
,ARG6
));
1458 PRE_REG_READ6(long, "fallocate",
1460 unsigned, MERGE64_FIRST(offset
), unsigned, MERGE64_SECOND(offset
),
1461 unsigned, MERGE64_FIRST(len
), unsigned, MERGE64_SECOND(len
));
1462 #elif VG_WORDSIZE == 8
1463 PRINT("sys_fallocate ( %ld, %ld, %lld, %lld )",
1464 ARG1
, ARG2
, (Long
)ARG3
, (Long
)ARG4
);
1465 PRE_REG_READ4(long, "fallocate",
1466 int, fd
, int, mode
, vki_loff_t
, offset
, vki_loff_t
, len
);
1468 # error Unexpected word size
1470 if (!ML_(fd_allowed
)(ARG1
, "fallocate", tid
, False
))
1471 SET_STATUS_Failure( VKI_EBADF
);
1476 PRINT("sys_prlimit64 ( %ld, %ld, %#lx, %#lx )", ARG1
,ARG2
,ARG3
,ARG4
);
1477 PRE_REG_READ4(long, "prlimit64",
1478 vki_pid_t
, pid
, unsigned int, resource
,
1479 const struct rlimit64
*, new_rlim
,
1480 struct rlimit64
*, old_rlim
);
1482 PRE_MEM_READ( "rlimit64(new_rlim)", ARG3
, sizeof(struct vki_rlimit64
) );
1484 PRE_MEM_WRITE( "rlimit64(old_rlim)", ARG4
, sizeof(struct vki_rlimit64
) );
1487 ((struct vki_rlimit64
*)ARG3
)->rlim_cur
> ((struct vki_rlimit64
*)ARG3
)->rlim_max
) {
1488 SET_STATUS_Failure( VKI_EINVAL
);
1490 else if (ARG1
== 0 || ARG1
== VG_(getpid
)()) {
1492 case VKI_RLIMIT_NOFILE
:
1493 SET_STATUS_Success( 0 );
1495 ((struct vki_rlimit64
*)ARG4
)->rlim_cur
= VG_(fd_soft_limit
);
1496 ((struct vki_rlimit64
*)ARG4
)->rlim_max
= VG_(fd_hard_limit
);
1499 if (((struct vki_rlimit64
*)ARG3
)->rlim_cur
> VG_(fd_hard_limit
) ||
1500 ((struct vki_rlimit64
*)ARG3
)->rlim_max
!= VG_(fd_hard_limit
)) {
1501 SET_STATUS_Failure( VKI_EPERM
);
1504 VG_(fd_soft_limit
) = ((struct vki_rlimit64
*)ARG3
)->rlim_cur
;
1509 case VKI_RLIMIT_DATA
:
1510 SET_STATUS_Success( 0 );
1512 ((struct vki_rlimit64
*)ARG4
)->rlim_cur
= VG_(client_rlimit_data
).rlim_cur
;
1513 ((struct vki_rlimit64
*)ARG4
)->rlim_max
= VG_(client_rlimit_data
).rlim_max
;
1516 if (((struct vki_rlimit64
*)ARG3
)->rlim_cur
> VG_(client_rlimit_data
).rlim_max
||
1517 ((struct vki_rlimit64
*)ARG3
)->rlim_max
> VG_(client_rlimit_data
).rlim_max
) {
1518 SET_STATUS_Failure( VKI_EPERM
);
1521 VG_(client_rlimit_data
).rlim_cur
= ((struct vki_rlimit64
*)ARG3
)->rlim_cur
;
1522 VG_(client_rlimit_data
).rlim_max
= ((struct vki_rlimit64
*)ARG3
)->rlim_max
;
1527 case VKI_RLIMIT_STACK
:
1528 SET_STATUS_Success( 0 );
1530 ((struct vki_rlimit64
*)ARG4
)->rlim_cur
= VG_(client_rlimit_stack
).rlim_cur
;
1531 ((struct vki_rlimit64
*)ARG4
)->rlim_max
= VG_(client_rlimit_stack
).rlim_max
;
1534 if (((struct vki_rlimit64
*)ARG3
)->rlim_cur
> VG_(client_rlimit_stack
).rlim_max
||
1535 ((struct vki_rlimit64
*)ARG3
)->rlim_max
> VG_(client_rlimit_stack
).rlim_max
) {
1536 SET_STATUS_Failure( VKI_EPERM
);
1539 VG_(threads
)[tid
].client_stack_szB
= ((struct vki_rlimit64
*)ARG3
)->rlim_cur
;
1540 VG_(client_rlimit_stack
).rlim_cur
= ((struct vki_rlimit64
*)ARG3
)->rlim_cur
;
1541 VG_(client_rlimit_stack
).rlim_max
= ((struct vki_rlimit64
*)ARG3
)->rlim_max
;
1552 POST_MEM_WRITE( ARG4
, sizeof(struct vki_rlimit64
) );
1555 /* ---------------------------------------------------------------------
1556 tid-related wrappers
1557 ------------------------------------------------------------------ */
1561 PRINT("sys_gettid ()");
1562 PRE_REG_READ0(long, "gettid");
1565 PRE(sys_set_tid_address
)
1567 PRINT("sys_set_tid_address ( %#lx )", ARG1
);
1568 PRE_REG_READ1(long, "set_tid_address", int *, tidptr
);
1573 PRINT("sys_tgkill ( %ld, %ld )", ARG1
,ARG2
);
1574 PRE_REG_READ2(long, "tkill", int, tid
, int, sig
);
1575 if (!ML_(client_signal_OK
)(ARG2
)) {
1576 SET_STATUS_Failure( VKI_EINVAL
);
1580 /* Check to see if this kill gave us a pending signal */
1581 *flags
|= SfPollAfter
;
1583 if (VG_(clo_trace_signals
))
1584 VG_(message
)(Vg_DebugMsg
, "tkill: sending signal %ld to pid %ld\n",
1587 /* If we're sending SIGKILL, check to see if the target is one of
1588 our threads and handle it specially. */
1589 if (ARG2
== VKI_SIGKILL
&& ML_(do_sigkill
)(ARG1
, -1)) {
1590 SET_STATUS_Success(0);
1594 /* Ask to handle this syscall via the slow route, since that's the
1595 only one that sets tst->status to VgTs_WaitSys. If the result
1596 of doing the syscall is an immediate run of
1597 async_signalhandler() in m_signals, then we need the thread to
1598 be properly tidied away. I have the impression the previous
1599 version of this wrapper worked on x86/amd64 only because the
1600 kernel did not immediately deliver the async signal to this
1601 thread (on ppc it did, which broke the assertion re tst->status
1602 at the top of async_signalhandler()). */
1603 *flags
|= SfMayBlock
;
1607 if (VG_(clo_trace_signals
))
1608 VG_(message
)(Vg_DebugMsg
, "tkill: sent signal %ld to pid %ld\n",
1614 PRINT("sys_tgkill ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
1615 PRE_REG_READ3(long, "tgkill", int, tgid
, int, tid
, int, sig
);
1616 if (!ML_(client_signal_OK
)(ARG3
)) {
1617 SET_STATUS_Failure( VKI_EINVAL
);
1621 /* Check to see if this kill gave us a pending signal */
1622 *flags
|= SfPollAfter
;
1624 if (VG_(clo_trace_signals
))
1625 VG_(message
)(Vg_DebugMsg
,
1626 "tgkill: sending signal %ld to pid %ld/%ld\n",
1629 /* If we're sending SIGKILL, check to see if the target is one of
1630 our threads and handle it specially. */
1631 if (ARG3
== VKI_SIGKILL
&& ML_(do_sigkill
)(ARG2
, ARG1
)) {
1632 SET_STATUS_Success(0);
1636 /* Ask to handle this syscall via the slow route, since that's the
1637 only one that sets tst->status to VgTs_WaitSys. If the result
1638 of doing the syscall is an immediate run of
1639 async_signalhandler() in m_signals, then we need the thread to
1640 be properly tidied away. I have the impression the previous
1641 version of this wrapper worked on x86/amd64 only because the
1642 kernel did not immediately deliver the async signal to this
1643 thread (on ppc it did, which broke the assertion re tst->status
1644 at the top of async_signalhandler()). */
1645 *flags
|= SfMayBlock
;
1649 if (VG_(clo_trace_signals
))
1650 VG_(message
)(Vg_DebugMsg
,
1651 "tgkill: sent signal %ld to pid %ld/%ld\n",
1655 /* ---------------------------------------------------------------------
1657 ------------------------------------------------------------------ */
1661 PRINT("sys_fadvise64 ( %ld, %lld, %lu, %ld )",
1662 ARG1
, MERGE64(ARG2
,ARG3
), ARG4
, ARG5
);
1663 PRE_REG_READ5(long, "fadvise64",
1664 int, fd
, vki_u32
, MERGE64_FIRST(offset
), vki_u32
, MERGE64_SECOND(offset
),
1665 vki_size_t
, len
, int, advice
);
1668 PRE(sys_fadvise64_64
)
1670 PRINT("sys_fadvise64_64 ( %ld, %lld, %lld, %ld )",
1671 ARG1
, MERGE64(ARG2
,ARG3
), MERGE64(ARG4
,ARG5
), ARG6
);
1672 PRE_REG_READ6(long, "fadvise64_64",
1673 int, fd
, vki_u32
, MERGE64_FIRST(offset
), vki_u32
, MERGE64_SECOND(offset
),
1674 vki_u32
, MERGE64_FIRST(len
), vki_u32
, MERGE64_SECOND(len
), int, advice
);
1677 /* ---------------------------------------------------------------------
1679 ------------------------------------------------------------------ */
1681 // Nb: this wrapper has to pad/unpad memory around the syscall itself,
1682 // and this allows us to control exactly the code that gets run while
1683 // the padding is in place.
1687 PRINT("sys_io_setup ( %lu, %#lx )", ARG1
,ARG2
);
1688 PRE_REG_READ2(long, "io_setup",
1689 unsigned, nr_events
, vki_aio_context_t
*, ctxp
);
1690 PRE_MEM_WRITE( "io_setup(ctxp)", ARG2
, sizeof(vki_aio_context_t
) );
1696 struct vki_aio_ring
*r
;
1698 size
= VG_PGROUNDUP(sizeof(struct vki_aio_ring
) +
1699 ARG1
*sizeof(struct vki_io_event
));
1700 r
= *(struct vki_aio_ring
**)ARG2
;
1701 vg_assert(ML_(valid_client_addr
)((Addr
)r
, size
, tid
, "io_setup"));
1703 ML_(notify_core_and_tool_of_mmap
)( (Addr
)r
, size
,
1704 VKI_PROT_READ
| VKI_PROT_WRITE
,
1705 VKI_MAP_ANONYMOUS
, -1, 0 );
1707 POST_MEM_WRITE( ARG2
, sizeof(vki_aio_context_t
) );
1710 // Nb: This wrapper is "Special" because we need 'size' to do the unmap
1711 // after the syscall. We must get 'size' from the aio_ring structure,
1712 // before the syscall, while the aio_ring structure still exists. (And we
1713 // know that we must look at the aio_ring structure because Tom inspected the
1714 // kernel and glibc sources to see what they do, yuk.)
1716 // XXX This segment can be implicitly unmapped when aio
1717 // file-descriptors are closed...
1722 PRINT("sys_io_destroy ( %llu )", (ULong
)ARG1
);
1723 PRE_REG_READ1(long, "io_destroy", vki_aio_context_t
, ctx
);
1725 // If we are going to seg fault (due to a bogus ARG1) do it as late as
1727 if (ML_(safe_to_deref
)( (void*)ARG1
, sizeof(struct vki_aio_ring
))) {
1728 struct vki_aio_ring
*r
= (struct vki_aio_ring
*)ARG1
;
1729 size
= VG_PGROUNDUP(sizeof(struct vki_aio_ring
) +
1730 r
->nr
*sizeof(struct vki_io_event
));
1733 SET_STATUS_from_SysRes( VG_(do_syscall1
)(SYSNO
, ARG1
) );
1735 if (SUCCESS
&& RES
== 0) {
1736 Bool d
= VG_(am_notify_munmap
)( ARG1
, size
);
1737 VG_TRACK( die_mem_munmap
, ARG1
, size
);
1739 VG_(discard_translations
)( (Addr
)ARG1
, (ULong
)size
,
1740 "PRE(sys_io_destroy)" );
1744 PRE(sys_io_getevents
)
1746 *flags
|= SfMayBlock
;
1747 PRINT("sys_io_getevents ( %llu, %lld, %lld, %#lx, %#lx )",
1748 (ULong
)ARG1
,(Long
)ARG2
,(Long
)ARG3
,ARG4
,ARG5
);
1749 PRE_REG_READ5(long, "io_getevents",
1750 vki_aio_context_t
, ctx_id
, long, min_nr
, long, nr
,
1751 struct io_event
*, events
,
1752 struct timespec
*, timeout
);
1754 PRE_MEM_WRITE( "io_getevents(events)",
1755 ARG4
, sizeof(struct vki_io_event
)*ARG3
);
1757 PRE_MEM_READ( "io_getevents(timeout)",
1758 ARG5
, sizeof(struct vki_timespec
));
1760 POST(sys_io_getevents
)
1765 POST_MEM_WRITE( ARG4
, sizeof(struct vki_io_event
)*RES
);
1766 for (i
= 0; i
< RES
; i
++) {
1767 const struct vki_io_event
*vev
= ((struct vki_io_event
*)ARG4
) + i
;
1768 const struct vki_iocb
*cb
= (struct vki_iocb
*)(Addr
)vev
->obj
;
1770 switch (cb
->aio_lio_opcode
) {
1771 case VKI_IOCB_CMD_PREAD
:
1772 if (vev
->result
> 0)
1773 POST_MEM_WRITE( cb
->aio_buf
, vev
->result
);
1776 case VKI_IOCB_CMD_PWRITE
:
1779 case VKI_IOCB_CMD_FSYNC
:
1782 case VKI_IOCB_CMD_FDSYNC
:
1785 case VKI_IOCB_CMD_PREADV
:
1786 if (vev
->result
> 0) {
1787 struct vki_iovec
* vec
= (struct vki_iovec
*)(Addr
)cb
->aio_buf
;
1788 Int remains
= vev
->result
;
1791 for (j
= 0; j
< cb
->aio_nbytes
; j
++) {
1792 Int nReadThisBuf
= vec
[j
].iov_len
;
1793 if (nReadThisBuf
> remains
) nReadThisBuf
= remains
;
1794 POST_MEM_WRITE( (Addr
)vec
[j
].iov_base
, nReadThisBuf
);
1795 remains
-= nReadThisBuf
;
1796 if (remains
< 0) VG_(core_panic
)("io_getevents(PREADV): remains < 0");
1801 case VKI_IOCB_CMD_PWRITEV
:
1805 VG_(message
)(Vg_DebugMsg
,
1806 "Warning: unhandled io_getevents opcode: %u\n",
1807 cb
->aio_lio_opcode
);
1818 PRINT("sys_io_submit ( %llu, %ld, %#lx )", (ULong
)ARG1
,ARG2
,ARG3
);
1819 PRE_REG_READ3(long, "io_submit",
1820 vki_aio_context_t
, ctx_id
, long, nr
,
1821 struct iocb
**, iocbpp
);
1822 PRE_MEM_READ( "io_submit(iocbpp)", ARG3
, ARG2
*sizeof(struct vki_iocb
*) );
1824 for (i
= 0; i
< ARG2
; i
++) {
1825 struct vki_iocb
*cb
= ((struct vki_iocb
**)ARG3
)[i
];
1826 struct vki_iovec
*iov
;
1828 PRE_MEM_READ( "io_submit(iocb)", (Addr
)cb
, sizeof(struct vki_iocb
) );
1829 switch (cb
->aio_lio_opcode
) {
1830 case VKI_IOCB_CMD_PREAD
:
1831 PRE_MEM_WRITE( "io_submit(PREAD)", cb
->aio_buf
, cb
->aio_nbytes
);
1834 case VKI_IOCB_CMD_PWRITE
:
1835 PRE_MEM_READ( "io_submit(PWRITE)", cb
->aio_buf
, cb
->aio_nbytes
);
1838 case VKI_IOCB_CMD_FSYNC
:
1841 case VKI_IOCB_CMD_FDSYNC
:
1844 case VKI_IOCB_CMD_PREADV
:
1845 iov
= (struct vki_iovec
*)(Addr
)cb
->aio_buf
;
1846 PRE_MEM_READ( "io_submit(PREADV)", cb
->aio_buf
, cb
->aio_nbytes
* sizeof(struct vki_iovec
) );
1847 for (j
= 0; j
< cb
->aio_nbytes
; j
++)
1848 PRE_MEM_WRITE( "io_submit(PREADV(iov[i]))", (Addr
)iov
[j
].iov_base
, iov
[j
].iov_len
);
1851 case VKI_IOCB_CMD_PWRITEV
:
1852 iov
= (struct vki_iovec
*)(Addr
)cb
->aio_buf
;
1853 PRE_MEM_READ( "io_submit(PWRITEV)", cb
->aio_buf
, cb
->aio_nbytes
* sizeof(struct vki_iovec
) );
1854 for (j
= 0; j
< cb
->aio_nbytes
; j
++)
1855 PRE_MEM_READ( "io_submit(PWRITEV(iov[i]))", (Addr
)iov
[j
].iov_base
, iov
[j
].iov_len
);
1859 VG_(message
)(Vg_DebugMsg
,"Warning: unhandled io_submit opcode: %u\n",
1860 cb
->aio_lio_opcode
);
1869 PRINT("sys_io_cancel ( %llu, %#lx, %#lx )", (ULong
)ARG1
,ARG2
,ARG3
);
1870 PRE_REG_READ3(long, "io_cancel",
1871 vki_aio_context_t
, ctx_id
, struct iocb
*, iocb
,
1872 struct io_event
*, result
);
1873 PRE_MEM_READ( "io_cancel(iocb)", ARG2
, sizeof(struct vki_iocb
) );
1874 PRE_MEM_WRITE( "io_cancel(result)", ARG3
, sizeof(struct vki_io_event
) );
1878 POST_MEM_WRITE( ARG3
, sizeof(struct vki_io_event
) );
1881 /* ---------------------------------------------------------------------
1882 *_mempolicy wrappers
1883 ------------------------------------------------------------------ */
1887 PRINT("sys_mbind ( %#lx, %lu, %ld, %#lx, %lu, %lu )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
1888 PRE_REG_READ6(long, "mbind",
1889 unsigned long, start
, unsigned long, len
,
1890 unsigned long, policy
, unsigned long *, nodemask
,
1891 unsigned long, maxnode
, unsigned, flags
);
1893 PRE_MEM_READ( "mbind(nodemask)", ARG4
,
1894 VG_ROUNDUP( ARG5
-1, sizeof(UWord
) * 8 ) / 8 );
1897 PRE(sys_set_mempolicy
)
1899 PRINT("sys_set_mempolicy ( %ld, %#lx, %ld )", ARG1
,ARG2
,ARG3
);
1900 PRE_REG_READ3(long, "set_mempolicy",
1901 int, policy
, unsigned long *, nodemask
,
1902 unsigned long, maxnode
);
1903 PRE_MEM_READ( "set_mempolicy(nodemask)", ARG2
,
1904 VG_ROUNDUP( ARG3
-1, sizeof(UWord
) * 8 ) / 8 );
1907 PRE(sys_get_mempolicy
)
1909 PRINT("sys_get_mempolicy ( %#lx, %#lx, %ld, %#lx, %lx )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
1910 PRE_REG_READ5(long, "get_mempolicy",
1911 int *, policy
, unsigned long *, nodemask
,
1912 unsigned long, maxnode
, unsigned long, addr
,
1913 unsigned long, flags
);
1915 PRE_MEM_WRITE( "get_mempolicy(policy)", ARG1
, sizeof(Int
) );
1917 PRE_MEM_WRITE( "get_mempolicy(nodemask)", ARG2
,
1918 VG_ROUNDUP( ARG3
-1, sizeof(UWord
) * 8 ) / 8 );
1920 POST(sys_get_mempolicy
)
1923 POST_MEM_WRITE( ARG1
, sizeof(Int
) );
1925 POST_MEM_WRITE( ARG2
, VG_ROUNDUP( ARG3
-1, sizeof(UWord
) * 8 ) / 8 );
1928 /* ---------------------------------------------------------------------
1930 ------------------------------------------------------------------ */
1932 PRE(sys_fanotify_init
)
1934 PRINT("sys_fanotify_init ( %lu, %lu )", ARG1
,ARG2
);
1935 PRE_REG_READ2(long, "fanotify_init",
1936 unsigned int, flags
, unsigned int, event_f_flags
);
1939 POST(sys_fanotify_init
)
1942 if (!ML_(fd_allowed
)(RES
, "fanotify_init", tid
, True
)) {
1944 SET_STATUS_Failure( VKI_EMFILE
);
1946 if (VG_(clo_track_fds
))
1947 ML_(record_fd_open_nameless
) (tid
, RES
);
1951 PRE(sys_fanotify_mark
)
1953 #if VG_WORDSIZE == 4
1954 PRINT( "sys_fanotify_mark ( %ld, %lu, %llu, %ld, %#lx(%s))",
1955 ARG1
,ARG2
,MERGE64(ARG3
,ARG4
),ARG5
,ARG6
,(char *)ARG6
);
1956 PRE_REG_READ6(long, "sys_fanotify_mark",
1957 int, fanotify_fd
, unsigned int, flags
,
1958 __vki_u32
, mask0
, __vki_u32
, mask1
,
1959 int, dfd
, const char *, pathname
);
1961 PRE_MEM_RASCIIZ( "fanotify_mark(path)", ARG6
);
1962 #elif VG_WORDSIZE == 8
1963 PRINT( "sys_fanotify_mark ( %ld, %lu, %llu, %ld, %#lx(%s))",
1964 ARG1
,ARG2
,(ULong
)ARG3
,ARG4
,ARG5
,(char *)ARG5
);
1965 PRE_REG_READ5(long, "sys_fanotify_mark",
1966 int, fanotify_fd
, unsigned int, flags
,
1968 int, dfd
, const char *, pathname
);
1970 PRE_MEM_RASCIIZ( "fanotify_mark(path)", ARG5
);
1972 # error Unexpected word size
1976 /* ---------------------------------------------------------------------
1978 ------------------------------------------------------------------ */
1980 PRE(sys_inotify_init
)
1982 PRINT("sys_inotify_init ( )");
1983 PRE_REG_READ0(long, "inotify_init");
1985 POST(sys_inotify_init
)
1988 if (!ML_(fd_allowed
)(RES
, "inotify_init", tid
, True
)) {
1990 SET_STATUS_Failure( VKI_EMFILE
);
1992 if (VG_(clo_track_fds
))
1993 ML_(record_fd_open_nameless
) (tid
, RES
);
1997 PRE(sys_inotify_init1
)
1999 PRINT("sys_inotify_init ( %ld )", ARG1
);
2000 PRE_REG_READ1(long, "inotify_init", int, flag
);
2003 POST(sys_inotify_init1
)
2006 if (!ML_(fd_allowed
)(RES
, "inotify_init", tid
, True
)) {
2008 SET_STATUS_Failure( VKI_EMFILE
);
2010 if (VG_(clo_track_fds
))
2011 ML_(record_fd_open_nameless
) (tid
, RES
);
2015 PRE(sys_inotify_add_watch
)
2017 PRINT( "sys_inotify_add_watch ( %ld, %#lx, %lx )", ARG1
,ARG2
,ARG3
);
2018 PRE_REG_READ3(long, "inotify_add_watch", int, fd
, char *, path
, int, mask
);
2019 PRE_MEM_RASCIIZ( "inotify_add_watch(path)", ARG2
);
2022 PRE(sys_inotify_rm_watch
)
2024 PRINT( "sys_inotify_rm_watch ( %ld, %lx )", ARG1
,ARG2
);
2025 PRE_REG_READ2(long, "inotify_rm_watch", int, fd
, int, wd
);
2028 /* ---------------------------------------------------------------------
2030 ------------------------------------------------------------------ */
2034 PRINT("sys_mq_open( %#lx(%s), %ld, %lld, %#lx )",
2035 ARG1
,(char*)ARG1
,ARG2
,(ULong
)ARG3
,ARG4
);
2036 PRE_REG_READ4(long, "mq_open",
2037 const char *, name
, int, oflag
, vki_mode_t
, mode
,
2038 struct mq_attr
*, attr
);
2039 PRE_MEM_RASCIIZ( "mq_open(name)", ARG1
);
2040 if ((ARG2
& VKI_O_CREAT
) != 0 && ARG4
!= 0) {
2041 const struct vki_mq_attr
*attr
= (struct vki_mq_attr
*)ARG4
;
2042 PRE_MEM_READ( "mq_open(attr->mq_maxmsg)",
2043 (Addr
)&attr
->mq_maxmsg
, sizeof(attr
->mq_maxmsg
) );
2044 PRE_MEM_READ( "mq_open(attr->mq_msgsize)",
2045 (Addr
)&attr
->mq_msgsize
, sizeof(attr
->mq_msgsize
) );
2051 if (!ML_(fd_allowed
)(RES
, "mq_open", tid
, True
)) {
2053 SET_STATUS_Failure( VKI_EMFILE
);
2055 if (VG_(clo_track_fds
))
2056 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG1
);
2062 PRINT("sys_mq_unlink ( %#lx(%s) )", ARG1
,(char*)ARG1
);
2063 PRE_REG_READ1(long, "mq_unlink", const char *, name
);
2064 PRE_MEM_RASCIIZ( "mq_unlink(name)", ARG1
);
2067 PRE(sys_mq_timedsend
)
2069 *flags
|= SfMayBlock
;
2070 PRINT("sys_mq_timedsend ( %ld, %#lx, %llu, %ld, %#lx )",
2071 ARG1
,ARG2
,(ULong
)ARG3
,ARG4
,ARG5
);
2072 PRE_REG_READ5(long, "mq_timedsend",
2073 vki_mqd_t
, mqdes
, const char *, msg_ptr
, vki_size_t
, msg_len
,
2074 unsigned int, msg_prio
, const struct timespec
*, abs_timeout
);
2075 if (!ML_(fd_allowed
)(ARG1
, "mq_timedsend", tid
, False
)) {
2076 SET_STATUS_Failure( VKI_EBADF
);
2078 PRE_MEM_READ( "mq_timedsend(msg_ptr)", ARG2
, ARG3
);
2080 PRE_MEM_READ( "mq_timedsend(abs_timeout)", ARG5
,
2081 sizeof(struct vki_timespec
) );
2085 PRE(sys_mq_timedreceive
)
2087 *flags
|= SfMayBlock
;
2088 PRINT("sys_mq_timedreceive( %ld, %#lx, %llu, %#lx, %#lx )",
2089 ARG1
,ARG2
,(ULong
)ARG3
,ARG4
,ARG5
);
2090 PRE_REG_READ5(ssize_t
, "mq_timedreceive",
2091 vki_mqd_t
, mqdes
, char *, msg_ptr
, vki_size_t
, msg_len
,
2092 unsigned int *, msg_prio
,
2093 const struct timespec
*, abs_timeout
);
2094 if (!ML_(fd_allowed
)(ARG1
, "mq_timedreceive", tid
, False
)) {
2095 SET_STATUS_Failure( VKI_EBADF
);
2097 PRE_MEM_WRITE( "mq_timedreceive(msg_ptr)", ARG2
, ARG3
);
2099 PRE_MEM_WRITE( "mq_timedreceive(msg_prio)",
2100 ARG4
, sizeof(unsigned int) );
2102 PRE_MEM_READ( "mq_timedreceive(abs_timeout)",
2103 ARG5
, sizeof(struct vki_timespec
) );
2106 POST(sys_mq_timedreceive
)
2108 POST_MEM_WRITE( ARG2
, RES
);
2110 POST_MEM_WRITE( ARG4
, sizeof(unsigned int) );
2115 PRINT("sys_mq_notify( %ld, %#lx )", ARG1
,ARG2
);
2116 PRE_REG_READ2(long, "mq_notify",
2117 vki_mqd_t
, mqdes
, const struct sigevent
*, notification
);
2118 if (!ML_(fd_allowed
)(ARG1
, "mq_notify", tid
, False
))
2119 SET_STATUS_Failure( VKI_EBADF
);
2121 PRE_MEM_READ( "mq_notify(notification)",
2122 ARG2
, sizeof(struct vki_sigevent
) );
2125 PRE(sys_mq_getsetattr
)
2127 PRINT("sys_mq_getsetattr( %ld, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
2128 PRE_REG_READ3(long, "mq_getsetattr",
2129 vki_mqd_t
, mqdes
, const struct mq_attr
*, mqstat
,
2130 struct mq_attr
*, omqstat
);
2131 if (!ML_(fd_allowed
)(ARG1
, "mq_getsetattr", tid
, False
)) {
2132 SET_STATUS_Failure( VKI_EBADF
);
2135 const struct vki_mq_attr
*attr
= (struct vki_mq_attr
*)ARG2
;
2136 PRE_MEM_READ( "mq_getsetattr(mqstat->mq_flags)",
2137 (Addr
)&attr
->mq_flags
, sizeof(attr
->mq_flags
) );
2140 PRE_MEM_WRITE( "mq_getsetattr(omqstat)", ARG3
,
2141 sizeof(struct vki_mq_attr
) );
2144 POST(sys_mq_getsetattr
)
2147 POST_MEM_WRITE( ARG3
, sizeof(struct vki_mq_attr
) );
2150 /* ---------------------------------------------------------------------
2152 ------------------------------------------------------------------ */
2154 PRE(sys_clock_settime
)
2156 PRINT("sys_clock_settime( %ld, %#lx )", ARG1
,ARG2
);
2157 PRE_REG_READ2(long, "clock_settime",
2158 vki_clockid_t
, clk_id
, const struct timespec
*, tp
);
2159 PRE_MEM_READ( "clock_settime(tp)", ARG2
, sizeof(struct vki_timespec
) );
2162 PRE(sys_clock_gettime
)
2164 PRINT("sys_clock_gettime( %ld, %#lx )" , ARG1
,ARG2
);
2165 PRE_REG_READ2(long, "clock_gettime",
2166 vki_clockid_t
, clk_id
, struct timespec
*, tp
);
2167 PRE_MEM_WRITE( "clock_gettime(tp)", ARG2
, sizeof(struct vki_timespec
) );
2169 POST(sys_clock_gettime
)
2171 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timespec
) );
2174 PRE(sys_clock_getres
)
2176 PRINT("sys_clock_getres( %ld, %#lx )" , ARG1
,ARG2
);
2177 // Nb: we can't use "RES" as the param name because that's a macro
2179 PRE_REG_READ2(long, "clock_getres",
2180 vki_clockid_t
, clk_id
, struct timespec
*, res
);
2182 PRE_MEM_WRITE( "clock_getres(res)", ARG2
, sizeof(struct vki_timespec
) );
2184 POST(sys_clock_getres
)
2187 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timespec
) );
2190 PRE(sys_clock_nanosleep
)
2192 *flags
|= SfMayBlock
|SfPostOnFail
;
2193 PRINT("sys_clock_nanosleep( %ld, %ld, %#lx, %#lx )", ARG1
,ARG2
,ARG3
,ARG4
);
2194 PRE_REG_READ4(int32_t, "clock_nanosleep",
2195 vki_clockid_t
, clkid
, int, flags
,
2196 const struct timespec
*, rqtp
, struct timespec
*, rmtp
);
2197 PRE_MEM_READ( "clock_nanosleep(rqtp)", ARG3
, sizeof(struct vki_timespec
) );
2199 PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG4
, sizeof(struct vki_timespec
) );
2201 POST(sys_clock_nanosleep
)
2203 if (ARG4
!= 0 && FAILURE
&& ERR
== VKI_EINTR
)
2204 POST_MEM_WRITE( ARG4
, sizeof(struct vki_timespec
) );
2207 /* ---------------------------------------------------------------------
2209 ------------------------------------------------------------------ */
2211 PRE(sys_timer_create
)
2213 PRINT("sys_timer_create( %ld, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
2214 PRE_REG_READ3(long, "timer_create",
2215 vki_clockid_t
, clockid
, struct sigevent
*, evp
,
2216 vki_timer_t
*, timerid
);
2218 struct vki_sigevent
*evp
= (struct vki_sigevent
*) ARG2
;
2219 PRE_MEM_READ( "timer_create(evp.sigev_value)", (Addr
)&evp
->sigev_value
,
2220 sizeof(vki_sigval_t
) );
2221 PRE_MEM_READ( "timer_create(evp.sigev_signo)", (Addr
)&evp
->sigev_signo
,
2223 PRE_MEM_READ( "timer_create(evp.sigev_notify)", (Addr
)&evp
->sigev_notify
,
2225 if (ML_(safe_to_deref
)(&evp
->sigev_notify
, sizeof(int))
2226 && (evp
->sigev_notify
& VKI_SIGEV_THREAD_ID
) != 0)
2227 PRE_MEM_READ( "timer_create(evp.sigev_notify_thread_id)",
2228 (Addr
)&evp
->vki_sigev_notify_thread_id
, sizeof(int) );
2230 PRE_MEM_WRITE( "timer_create(timerid)", ARG3
, sizeof(vki_timer_t
) );
2232 POST(sys_timer_create
)
2234 POST_MEM_WRITE( ARG3
, sizeof(vki_timer_t
) );
2237 PRE(sys_timer_settime
)
2239 PRINT("sys_timer_settime( %lld, %ld, %#lx, %#lx )", (ULong
)ARG1
,ARG2
,ARG3
,ARG4
);
2240 PRE_REG_READ4(long, "timer_settime",
2241 vki_timer_t
, timerid
, int, flags
,
2242 const struct itimerspec
*, value
,
2243 struct itimerspec
*, ovalue
);
2244 PRE_MEM_READ( "timer_settime(value)", ARG3
,
2245 sizeof(struct vki_itimerspec
) );
2247 PRE_MEM_WRITE( "timer_settime(ovalue)", ARG4
,
2248 sizeof(struct vki_itimerspec
) );
2250 POST(sys_timer_settime
)
2253 POST_MEM_WRITE( ARG4
, sizeof(struct vki_itimerspec
) );
2256 PRE(sys_timer_gettime
)
2258 PRINT("sys_timer_gettime( %lld, %#lx )", (ULong
)ARG1
,ARG2
);
2259 PRE_REG_READ2(long, "timer_gettime",
2260 vki_timer_t
, timerid
, struct itimerspec
*, value
);
2261 PRE_MEM_WRITE( "timer_gettime(value)", ARG2
,
2262 sizeof(struct vki_itimerspec
));
2264 POST(sys_timer_gettime
)
2266 POST_MEM_WRITE( ARG2
, sizeof(struct vki_itimerspec
) );
2269 PRE(sys_timer_getoverrun
)
2271 PRINT("sys_timer_getoverrun( %#lx )", ARG1
);
2272 PRE_REG_READ1(long, "timer_getoverrun", vki_timer_t
, timerid
);
2275 PRE(sys_timer_delete
)
2277 PRINT("sys_timer_delete( %#lx )", ARG1
);
2278 PRE_REG_READ1(long, "timer_delete", vki_timer_t
, timerid
);
2281 /* ---------------------------------------------------------------------
2283 See also http://lwn.net/Articles/260172/ for an overview.
2284 See also /usr/src/linux/fs/timerfd.c for the implementation.
2285 ------------------------------------------------------------------ */
2287 /* Returns True if running on 2.6.22, else False (or False if
2288 cannot be determined). */
2289 static Bool
linux_kernel_2_6_22(void)
2291 static Int result
= -1;
2293 HChar release
[64]; // large enough
2297 res
= VG_(open
)("/proc/sys/kernel/osrelease", 0, 0);
2298 if (sr_isError(res
))
2301 read
= VG_(read
)(fd
, release
, sizeof(release
) - 1);
2306 //VG_(printf)("kernel release = %s\n", release);
2307 result
= VG_(strncmp
)(release
, "2.6.22", 6) == 0
2308 && ! VG_(isdigit
)(release
[6]);
2310 vg_assert(result
== 0 || result
== 1);
2314 PRE(sys_timerfd_create
)
2316 if (linux_kernel_2_6_22()) {
2317 /* 2.6.22 kernel: timerfd system call. */
2318 PRINT("sys_timerfd ( %ld, %ld, %#lx )", ARG1
, ARG2
, ARG3
);
2319 PRE_REG_READ3(long, "sys_timerfd",
2320 int, fd
, int, clockid
, const struct itimerspec
*, tmr
);
2321 PRE_MEM_READ("timerfd(tmr)", ARG3
,
2322 sizeof(struct vki_itimerspec
) );
2323 if ((Word
)ARG1
!= -1L && !ML_(fd_allowed
)(ARG1
, "timerfd", tid
, False
))
2324 SET_STATUS_Failure( VKI_EBADF
);
2326 /* 2.6.24 and later kernels: timerfd_create system call. */
2327 PRINT("sys_timerfd_create (%ld, %ld )", ARG1
, ARG2
);
2328 PRE_REG_READ2(long, "timerfd_create", int, clockid
, int, flags
);
2331 POST(sys_timerfd_create
)
2333 if (linux_kernel_2_6_22())
2335 /* 2.6.22 kernel: timerfd system call. */
2336 if (!ML_(fd_allowed
)(RES
, "timerfd", tid
, True
)) {
2338 SET_STATUS_Failure( VKI_EMFILE
);
2340 if (VG_(clo_track_fds
))
2341 ML_(record_fd_open_nameless
) (tid
, RES
);
2346 /* 2.6.24 and later kernels: timerfd_create system call. */
2347 if (!ML_(fd_allowed
)(RES
, "timerfd_create", tid
, True
)) {
2349 SET_STATUS_Failure( VKI_EMFILE
);
2351 if (VG_(clo_track_fds
))
2352 ML_(record_fd_open_nameless
) (tid
, RES
);
2357 PRE(sys_timerfd_gettime
)
2359 PRINT("sys_timerfd_gettime ( %ld, %#lx )", ARG1
, ARG2
);
2360 PRE_REG_READ2(long, "timerfd_gettime",
2362 struct vki_itimerspec
*, otmr
);
2363 if (!ML_(fd_allowed
)(ARG1
, "timerfd_gettime", tid
, False
))
2364 SET_STATUS_Failure(VKI_EBADF
);
2366 PRE_MEM_WRITE("timerfd_gettime(result)",
2367 ARG2
, sizeof(struct vki_itimerspec
));
2369 POST(sys_timerfd_gettime
)
2372 POST_MEM_WRITE(ARG2
, sizeof(struct vki_itimerspec
));
2375 PRE(sys_timerfd_settime
)
2377 PRINT("sys_timerfd_settime ( %ld, %ld, %#lx, %#lx )", ARG1
, ARG2
, ARG3
, ARG4
);
2378 PRE_REG_READ4(long, "timerfd_settime",
2381 const struct vki_itimerspec
*, utmr
,
2382 struct vki_itimerspec
*, otmr
);
2383 if (!ML_(fd_allowed
)(ARG1
, "timerfd_settime", tid
, False
))
2384 SET_STATUS_Failure(VKI_EBADF
);
2387 PRE_MEM_READ("timerfd_settime(result)",
2388 ARG3
, sizeof(struct vki_itimerspec
));
2391 PRE_MEM_WRITE("timerfd_settime(result)",
2392 ARG4
, sizeof(struct vki_itimerspec
));
2396 POST(sys_timerfd_settime
)
2398 if (RES
== 0 && ARG4
!= 0)
2399 POST_MEM_WRITE(ARG4
, sizeof(struct vki_itimerspec
));
2402 /* ---------------------------------------------------------------------
2403 capabilities wrappers
2404 ------------------------------------------------------------------ */
2408 PRINT("sys_capget ( %#lx, %#lx )", ARG1
, ARG2
);
2409 PRE_REG_READ2(long, "capget",
2410 vki_cap_user_header_t
, header
, vki_cap_user_data_t
, data
);
2411 PRE_MEM_READ( "capget(header)", ARG1
,
2412 sizeof(struct __vki_user_cap_header_struct
) );
2413 if (ARG2
!= (Addr
)NULL
)
2414 PRE_MEM_WRITE( "capget(data)", ARG2
,
2415 sizeof(struct __vki_user_cap_data_struct
) );
2419 if (ARG2
!= (Addr
)NULL
)
2420 POST_MEM_WRITE( ARG2
, sizeof(struct __vki_user_cap_data_struct
) );
2425 PRINT("sys_capset ( %#lx, %#lx )", ARG1
, ARG2
);
2426 PRE_REG_READ2(long, "capset",
2427 vki_cap_user_header_t
, header
,
2428 const vki_cap_user_data_t
, data
);
2429 PRE_MEM_READ( "capset(header)",
2430 ARG1
, sizeof(struct __vki_user_cap_header_struct
) );
2431 PRE_MEM_READ( "capset(data)",
2432 ARG2
, sizeof(struct __vki_user_cap_data_struct
) );
2435 /* ---------------------------------------------------------------------
2436 16-bit uid/gid/groups wrappers
2437 ------------------------------------------------------------------ */
2441 PRINT("sys_getuid16 ( )");
2442 PRE_REG_READ0(long, "getuid16");
2447 PRINT("sys_setuid16 ( %ld )", ARG1
);
2448 PRE_REG_READ1(long, "setuid16", vki_old_uid_t
, uid
);
2453 PRINT("sys_getgid16 ( )");
2454 PRE_REG_READ0(long, "getgid16");
2459 PRINT("sys_setgid16 ( %ld )", ARG1
);
2460 PRE_REG_READ1(long, "setgid16", vki_old_gid_t
, gid
);
2465 PRINT("sys_geteuid16 ( )");
2466 PRE_REG_READ0(long, "geteuid16");
2471 PRINT("sys_getegid16 ( )");
2472 PRE_REG_READ0(long, "getegid16");
2477 PRINT("setreuid16 ( 0x%lx, 0x%lx )", ARG1
, ARG2
);
2478 PRE_REG_READ2(long, "setreuid16", vki_old_uid_t
, ruid
, vki_old_uid_t
, euid
);
2483 PRINT("sys_setregid16 ( %ld, %ld )", ARG1
, ARG2
);
2484 PRE_REG_READ2(long, "setregid16", vki_old_gid_t
, rgid
, vki_old_gid_t
, egid
);
2487 PRE(sys_getgroups16
)
2489 PRINT("sys_getgroups16 ( %ld, %#lx )", ARG1
, ARG2
);
2490 PRE_REG_READ2(long, "getgroups16", int, size
, vki_old_gid_t
*, list
);
2492 PRE_MEM_WRITE( "getgroups16(list)", ARG2
, ARG1
* sizeof(vki_old_gid_t
) );
2494 POST(sys_getgroups16
)
2497 if (ARG1
> 0 && RES
> 0)
2498 POST_MEM_WRITE( ARG2
, RES
* sizeof(vki_old_gid_t
) );
2501 PRE(sys_setgroups16
)
2503 PRINT("sys_setgroups16 ( %llu, %#lx )", (ULong
)ARG1
, ARG2
);
2504 PRE_REG_READ2(long, "setgroups16", int, size
, vki_old_gid_t
*, list
);
2506 PRE_MEM_READ( "setgroups16(list)", ARG2
, ARG1
* sizeof(vki_old_gid_t
) );
2509 /* ---------------------------------------------------------------------
2511 ------------------------------------------------------------------ */
2515 PRINT("sys_chown16 ( %#lx, 0x%lx, 0x%lx )", ARG1
,ARG2
,ARG3
);
2516 PRE_REG_READ3(long, "chown16",
2518 vki_old_uid_t
, owner
, vki_old_gid_t
, group
);
2519 PRE_MEM_RASCIIZ( "chown16(path)", ARG1
);
2524 PRINT("sys_fchown16 ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
2525 PRE_REG_READ3(long, "fchown16",
2526 unsigned int, fd
, vki_old_uid_t
, owner
, vki_old_gid_t
, group
);
2529 /* ---------------------------------------------------------------------
2531 ------------------------------------------------------------------ */
2535 *flags
|= SfMayBlock
;
2536 PRINT("sys_setxattr ( %#lx, %#lx, %#lx, %llu, %ld )",
2537 ARG1
, ARG2
, ARG3
, (ULong
)ARG4
, ARG5
);
2538 PRE_REG_READ5(long, "setxattr",
2539 char *, path
, char *, name
,
2540 void *, value
, vki_size_t
, size
, int, flags
);
2541 PRE_MEM_RASCIIZ( "setxattr(path)", ARG1
);
2542 PRE_MEM_RASCIIZ( "setxattr(name)", ARG2
);
2543 PRE_MEM_READ( "setxattr(value)", ARG3
, ARG4
);
2548 *flags
|= SfMayBlock
;
2549 PRINT("sys_lsetxattr ( %#lx, %#lx, %#lx, %llu, %ld )",
2550 ARG1
, ARG2
, ARG3
, (ULong
)ARG4
, ARG5
);
2551 PRE_REG_READ5(long, "lsetxattr",
2552 char *, path
, char *, name
,
2553 void *, value
, vki_size_t
, size
, int, flags
);
2554 PRE_MEM_RASCIIZ( "lsetxattr(path)", ARG1
);
2555 PRE_MEM_RASCIIZ( "lsetxattr(name)", ARG2
);
2556 PRE_MEM_READ( "lsetxattr(value)", ARG3
, ARG4
);
2561 *flags
|= SfMayBlock
;
2562 PRINT("sys_fsetxattr ( %ld, %#lx, %#lx, %llu, %ld )",
2563 ARG1
, ARG2
, ARG3
, (ULong
)ARG4
, ARG5
);
2564 PRE_REG_READ5(long, "fsetxattr",
2565 int, fd
, char *, name
, void *, value
,
2566 vki_size_t
, size
, int, flags
);
2567 PRE_MEM_RASCIIZ( "fsetxattr(name)", ARG2
);
2568 PRE_MEM_READ( "fsetxattr(value)", ARG3
, ARG4
);
2573 *flags
|= SfMayBlock
;
2574 PRINT("sys_getxattr ( %#lx, %#lx, %#lx, %llu )", ARG1
,ARG2
,ARG3
, (ULong
)ARG4
);
2575 PRE_REG_READ4(ssize_t
, "getxattr",
2576 char *, path
, char *, name
, void *, value
, vki_size_t
, size
);
2577 PRE_MEM_RASCIIZ( "getxattr(path)", ARG1
);
2578 PRE_MEM_RASCIIZ( "getxattr(name)", ARG2
);
2579 PRE_MEM_WRITE( "getxattr(value)", ARG3
, ARG4
);
2584 if (RES
> 0 && ARG3
!= (Addr
)NULL
) {
2585 POST_MEM_WRITE( ARG3
, RES
);
2591 *flags
|= SfMayBlock
;
2592 PRINT("sys_lgetxattr ( %#lx, %#lx, %#lx, %llu )", ARG1
,ARG2
,ARG3
, (ULong
)ARG4
);
2593 PRE_REG_READ4(ssize_t
, "lgetxattr",
2594 char *, path
, char *, name
, void *, value
, vki_size_t
, size
);
2595 PRE_MEM_RASCIIZ( "lgetxattr(path)", ARG1
);
2596 PRE_MEM_RASCIIZ( "lgetxattr(name)", ARG2
);
2597 PRE_MEM_WRITE( "lgetxattr(value)", ARG3
, ARG4
);
2602 if (RES
> 0 && ARG3
!= (Addr
)NULL
) {
2603 POST_MEM_WRITE( ARG3
, RES
);
2609 *flags
|= SfMayBlock
;
2610 PRINT("sys_fgetxattr ( %ld, %#lx, %#lx, %llu )", ARG1
, ARG2
, ARG3
, (ULong
)ARG4
);
2611 PRE_REG_READ4(ssize_t
, "fgetxattr",
2612 int, fd
, char *, name
, void *, value
, vki_size_t
, size
);
2613 PRE_MEM_RASCIIZ( "fgetxattr(name)", ARG2
);
2614 PRE_MEM_WRITE( "fgetxattr(value)", ARG3
, ARG4
);
2618 if (RES
> 0 && ARG3
!= (Addr
)NULL
)
2619 POST_MEM_WRITE( ARG3
, RES
);
2624 *flags
|= SfMayBlock
;
2625 PRINT("sys_listxattr ( %#lx, %#lx, %llu )", ARG1
, ARG2
, (ULong
)ARG3
);
2626 PRE_REG_READ3(ssize_t
, "listxattr",
2627 char *, path
, char *, list
, vki_size_t
, size
);
2628 PRE_MEM_RASCIIZ( "listxattr(path)", ARG1
);
2629 PRE_MEM_WRITE( "listxattr(list)", ARG2
, ARG3
);
2633 if (RES
> 0 && ARG2
!= (Addr
)NULL
)
2634 POST_MEM_WRITE( ARG2
, RES
);
2639 *flags
|= SfMayBlock
;
2640 PRINT("sys_llistxattr ( %#lx, %#lx, %llu )", ARG1
, ARG2
, (ULong
)ARG3
);
2641 PRE_REG_READ3(ssize_t
, "llistxattr",
2642 char *, path
, char *, list
, vki_size_t
, size
);
2643 PRE_MEM_RASCIIZ( "llistxattr(path)", ARG1
);
2644 PRE_MEM_WRITE( "llistxattr(list)", ARG2
, ARG3
);
2646 POST(sys_llistxattr
)
2648 if (RES
> 0 && ARG2
!= (Addr
)NULL
)
2649 POST_MEM_WRITE( ARG2
, RES
);
2654 *flags
|= SfMayBlock
;
2655 PRINT("sys_flistxattr ( %ld, %#lx, %llu )", ARG1
, ARG2
, (ULong
)ARG3
);
2656 PRE_REG_READ3(ssize_t
, "flistxattr",
2657 int, fd
, char *, list
, vki_size_t
, size
);
2658 PRE_MEM_WRITE( "flistxattr(list)", ARG2
, ARG3
);
2660 POST(sys_flistxattr
)
2662 if (RES
> 0 && ARG2
!= (Addr
)NULL
)
2663 POST_MEM_WRITE( ARG2
, RES
);
2666 PRE(sys_removexattr
)
2668 *flags
|= SfMayBlock
;
2669 PRINT("sys_removexattr ( %#lx, %#lx )", ARG1
, ARG2
);
2670 PRE_REG_READ2(long, "removexattr", char *, path
, char *, name
);
2671 PRE_MEM_RASCIIZ( "removexattr(path)", ARG1
);
2672 PRE_MEM_RASCIIZ( "removexattr(name)", ARG2
);
2675 PRE(sys_lremovexattr
)
2677 *flags
|= SfMayBlock
;
2678 PRINT("sys_lremovexattr ( %#lx, %#lx )", ARG1
, ARG2
);
2679 PRE_REG_READ2(long, "lremovexattr", char *, path
, char *, name
);
2680 PRE_MEM_RASCIIZ( "lremovexattr(path)", ARG1
);
2681 PRE_MEM_RASCIIZ( "lremovexattr(name)", ARG2
);
2684 PRE(sys_fremovexattr
)
2686 *flags
|= SfMayBlock
;
2687 PRINT("sys_fremovexattr ( %ld, %#lx )", ARG1
, ARG2
);
2688 PRE_REG_READ2(long, "fremovexattr", int, fd
, char *, name
);
2689 PRE_MEM_RASCIIZ( "fremovexattr(name)", ARG2
);
2692 /* ---------------------------------------------------------------------
2694 ------------------------------------------------------------------ */
2696 PRE(sys_sched_setparam
)
2698 PRINT("sched_setparam ( %ld, %#lx )", ARG1
, ARG2
);
2699 PRE_REG_READ2(long, "sched_setparam",
2700 vki_pid_t
, pid
, struct sched_param
*, p
);
2701 PRE_MEM_READ( "sched_setparam(p)", ARG2
, sizeof(struct vki_sched_param
) );
2703 POST(sys_sched_setparam
)
2705 POST_MEM_WRITE( ARG2
, sizeof(struct vki_sched_param
) );
2708 PRE(sys_sched_getparam
)
2710 PRINT("sched_getparam ( %ld, %#lx )", ARG1
, ARG2
);
2711 PRE_REG_READ2(long, "sched_getparam",
2712 vki_pid_t
, pid
, struct sched_param
*, p
);
2713 PRE_MEM_WRITE( "sched_getparam(p)", ARG2
, sizeof(struct vki_sched_param
) );
2715 POST(sys_sched_getparam
)
2717 POST_MEM_WRITE( ARG2
, sizeof(struct vki_sched_param
) );
2720 PRE(sys_sched_getscheduler
)
2722 PRINT("sys_sched_getscheduler ( %ld )", ARG1
);
2723 PRE_REG_READ1(long, "sched_getscheduler", vki_pid_t
, pid
);
2726 PRE(sys_sched_setscheduler
)
2728 PRINT("sys_sched_setscheduler ( %ld, %ld, %#lx )", ARG1
,ARG2
,ARG3
);
2729 PRE_REG_READ3(long, "sched_setscheduler",
2730 vki_pid_t
, pid
, int, policy
, struct sched_param
*, p
);
2732 PRE_MEM_READ( "sched_setscheduler(p)",
2733 ARG3
, sizeof(struct vki_sched_param
));
2736 PRE(sys_sched_yield
)
2738 *flags
|= SfMayBlock
;
2739 PRINT("sched_yield()");
2740 PRE_REG_READ0(long, "sys_sched_yield");
2743 PRE(sys_sched_get_priority_max
)
2745 PRINT("sched_get_priority_max ( %ld )", ARG1
);
2746 PRE_REG_READ1(long, "sched_get_priority_max", int, policy
);
2749 PRE(sys_sched_get_priority_min
)
2751 PRINT("sched_get_priority_min ( %ld )", ARG1
);
2752 PRE_REG_READ1(long, "sched_get_priority_min", int, policy
);
2755 PRE(sys_sched_rr_get_interval
)
2757 PRINT("sys_sched_rr_get_interval ( %ld, %#lx )", ARG1
, ARG2
);
2758 PRE_REG_READ2(int, "sched_rr_get_interval",
2760 struct vki_timespec
*, tp
);
2761 PRE_MEM_WRITE("sched_rr_get_interval(timespec)",
2762 ARG2
, sizeof(struct vki_timespec
));
2765 POST(sys_sched_rr_get_interval
)
2767 POST_MEM_WRITE(ARG2
, sizeof(struct vki_timespec
));
2770 PRE(sys_sched_setaffinity
)
2772 PRINT("sched_setaffinity ( %ld, %ld, %#lx )", ARG1
, ARG2
, ARG3
);
2773 PRE_REG_READ3(long, "sched_setaffinity",
2774 vki_pid_t
, pid
, unsigned int, len
, unsigned long *, mask
);
2775 PRE_MEM_READ( "sched_setaffinity(mask)", ARG3
, ARG2
);
2778 PRE(sys_sched_getaffinity
)
2780 PRINT("sched_getaffinity ( %ld, %ld, %#lx )", ARG1
, ARG2
, ARG3
);
2781 PRE_REG_READ3(long, "sched_getaffinity",
2782 vki_pid_t
, pid
, unsigned int, len
, unsigned long *, mask
);
2783 PRE_MEM_WRITE( "sched_getaffinity(mask)", ARG3
, ARG2
);
2785 POST(sys_sched_getaffinity
)
2787 POST_MEM_WRITE(ARG3
, ARG2
);
2792 PRINT("sys_unshare ( %ld )", ARG1
);
2793 PRE_REG_READ1(int, "unshare", int, flags
);
2796 /* ---------------------------------------------------------------------
2797 miscellaneous wrappers
2798 ------------------------------------------------------------------ */
2802 *flags
|= SfMayBlock
;
2803 PRINT("sys_munlockall ( )");
2804 PRE_REG_READ0(long, "munlockall");
2807 // This has different signatures for different platforms.
2809 // x86: int sys_pipe(unsigned long __user *fildes);
2810 // AMD64: long sys_pipe(int *fildes);
2811 // ppc32: int sys_pipe(int __user *fildes);
2812 // ppc64: int sys_pipe(int __user *fildes);
2814 // The type of the argument is most important, and it is an array of 32 bit
2815 // values in all cases. (The return type differs across platforms, but it
2816 // is not used.) So we use 'int' as its type. This fixed bug #113230 which
2817 // was caused by using an array of 'unsigned long's, which didn't work on
2821 PRINT("sys_pipe ( %#lx )", ARG1
);
2822 PRE_REG_READ1(int, "pipe", int *, filedes
);
2823 PRE_MEM_WRITE( "pipe(filedes)", ARG1
, 2*sizeof(int) );
2827 Int
*p
= (Int
*)ARG1
;
2828 if (!ML_(fd_allowed
)(p
[0], "pipe", tid
, True
) ||
2829 !ML_(fd_allowed
)(p
[1], "pipe", tid
, True
)) {
2832 SET_STATUS_Failure( VKI_EMFILE
);
2834 POST_MEM_WRITE( ARG1
, 2*sizeof(int) );
2835 if (VG_(clo_track_fds
)) {
2836 ML_(record_fd_open_nameless
)(tid
, p
[0]);
2837 ML_(record_fd_open_nameless
)(tid
, p
[1]);
2842 /* pipe2 (a kernel 2.6.twentysomething invention) is like pipe, except
2843 there's a second arg containing flags to be applied to the new file
2844 descriptors. It hardly seems worth the effort to factor out the
2845 duplicated code, hence: */
2848 PRINT("sys_pipe2 ( %#lx, %#lx )", ARG1
, ARG2
);
2849 PRE_REG_READ2(int, "pipe", int *, filedes
, long, flags
);
2850 PRE_MEM_WRITE( "pipe2(filedes)", ARG1
, 2*sizeof(int) );
2854 Int
*p
= (Int
*)ARG1
;
2855 if (!ML_(fd_allowed
)(p
[0], "pipe2", tid
, True
) ||
2856 !ML_(fd_allowed
)(p
[1], "pipe2", tid
, True
)) {
2859 SET_STATUS_Failure( VKI_EMFILE
);
2861 POST_MEM_WRITE( ARG1
, 2*sizeof(int) );
2862 if (VG_(clo_track_fds
)) {
2863 ML_(record_fd_open_nameless
)(tid
, p
[0]);
2864 ML_(record_fd_open_nameless
)(tid
, p
[1]);
2871 PRINT("sys_dup3 ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
2872 PRE_REG_READ3(long, "dup3", unsigned int, oldfd
, unsigned int, newfd
, int, flags
);
2873 if (!ML_(fd_allowed
)(ARG2
, "dup3", tid
, True
))
2874 SET_STATUS_Failure( VKI_EBADF
);
2880 if (VG_(clo_track_fds
))
2881 ML_(record_fd_open_named
)(tid
, RES
);
2886 PRINT("sys_quotactl (0x%lx, %#lx, 0x%lx, 0x%lx )", ARG1
,ARG2
,ARG3
, ARG4
);
2887 PRE_REG_READ4(long, "quotactl",
2888 unsigned int, cmd
, const char *, special
, vki_qid_t
, id
,
2890 PRE_MEM_RASCIIZ( "quotactl(special)", ARG2
);
2895 *flags
|= SfMayBlock
;
2896 PRINT("sys_waitid( %ld, %ld, %#lx, %ld, %#lx )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
2897 PRE_REG_READ5(int32_t, "sys_waitid",
2898 int, which
, vki_pid_t
, pid
, struct vki_siginfo
*, infop
,
2899 int, options
, struct vki_rusage
*, ru
);
2900 PRE_MEM_WRITE( "waitid(infop)", ARG3
, sizeof(struct vki_siginfo
) );
2902 PRE_MEM_WRITE( "waitid(ru)", ARG5
, sizeof(struct vki_rusage
) );
2906 POST_MEM_WRITE( ARG3
, sizeof(struct vki_siginfo
) );
2908 POST_MEM_WRITE( ARG5
, sizeof(struct vki_rusage
) );
2911 PRE(sys_sync_file_range
)
2913 *flags
|= SfMayBlock
;
2914 #if VG_WORDSIZE == 4
2915 PRINT("sys_sync_file_range ( %ld, %lld, %lld, %ld )",
2916 ARG1
,MERGE64(ARG2
,ARG3
),MERGE64(ARG4
,ARG5
),ARG6
);
2917 PRE_REG_READ6(long, "sync_file_range",
2919 unsigned, MERGE64_FIRST(offset
), unsigned, MERGE64_SECOND(offset
),
2920 unsigned, MERGE64_FIRST(nbytes
), unsigned, MERGE64_SECOND(nbytes
),
2921 unsigned int, flags
);
2922 #elif VG_WORDSIZE == 8
2923 PRINT("sys_sync_file_range ( %ld, %lld, %lld, %ld )",
2924 ARG1
,(Long
)ARG2
,(Long
)ARG3
,ARG4
);
2925 PRE_REG_READ4(long, "sync_file_range",
2926 int, fd
, vki_loff_t
, offset
, vki_loff_t
, nbytes
,
2927 unsigned int, flags
);
2929 # error Unexpected word size
2931 if (!ML_(fd_allowed
)(ARG1
, "sync_file_range", tid
, False
))
2932 SET_STATUS_Failure( VKI_EBADF
);
2935 PRE(sys_sync_file_range2
)
2937 *flags
|= SfMayBlock
;
2938 #if VG_WORDSIZE == 4
2939 PRINT("sys_sync_file_range2 ( %ld, %ld, %lld, %lld )",
2940 ARG1
,ARG2
,MERGE64(ARG3
,ARG4
),MERGE64(ARG5
,ARG6
));
2941 PRE_REG_READ6(long, "sync_file_range2",
2942 int, fd
, unsigned int, flags
,
2943 unsigned, MERGE64_FIRST(offset
), unsigned, MERGE64_SECOND(offset
),
2944 unsigned, MERGE64_FIRST(nbytes
), unsigned, MERGE64_SECOND(nbytes
));
2945 #elif VG_WORDSIZE == 8
2946 PRINT("sys_sync_file_range2 ( %ld, %ld, %lld, %lld )",
2947 ARG1
,ARG2
,(Long
)ARG3
,(Long
)ARG4
);
2948 PRE_REG_READ4(long, "sync_file_range2",
2949 int, fd
, unsigned int, flags
,
2950 vki_loff_t
, offset
, vki_loff_t
, nbytes
);
2952 # error Unexpected word size
2954 if (!ML_(fd_allowed
)(ARG1
, "sync_file_range2", tid
, False
))
2955 SET_STATUS_Failure( VKI_EBADF
);
2960 PRINT("sys_stime ( %#lx )", ARG1
);
2961 PRE_REG_READ1(int, "stime", vki_time_t
*, t
);
2962 PRE_MEM_READ( "stime(t)", ARG1
, sizeof(vki_time_t
) );
2965 PRE(sys_perf_event_open
)
2967 struct vki_perf_event_attr
*attr
;
2968 PRINT("sys_perf_event_open ( %#lx, %ld, %ld, %ld, %ld )",
2969 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
2970 PRE_REG_READ5(long, "perf_event_open",
2971 struct vki_perf_event_attr
*, attr
,
2972 vki_pid_t
, pid
, int, cpu
, int, group_fd
,
2973 unsigned long, flags
);
2974 attr
= (struct vki_perf_event_attr
*)ARG1
;
2975 PRE_MEM_READ( "perf_event_open(attr->size)",
2976 (Addr
)&attr
->size
, sizeof(attr
->size
) );
2977 PRE_MEM_READ( "perf_event_open(attr)",
2978 (Addr
)attr
, attr
->size
);
2981 POST(sys_perf_event_open
)
2984 if (!ML_(fd_allowed
)(RES
, "perf_event_open", tid
, True
)) {
2986 SET_STATUS_Failure( VKI_EMFILE
);
2988 if (VG_(clo_track_fds
))
2989 ML_(record_fd_open_nameless
)(tid
, RES
);
2995 PRINT("sys_getcpu ( %#lx, %#lx, %#lx )" , ARG1
,ARG2
,ARG3
);
2996 PRE_REG_READ3(int, "getcpu",
2997 unsigned *, cpu
, unsigned *, node
, struct vki_getcpu_cache
*, tcache
);
2999 PRE_MEM_WRITE( "getcpu(cpu)", ARG1
, sizeof(unsigned) );
3001 PRE_MEM_WRITE( "getcpu(node)", ARG2
, sizeof(unsigned) );
3003 PRE_MEM_WRITE( "getcpu(tcache)", ARG3
, sizeof(struct vki_getcpu_cache
) );
3009 POST_MEM_WRITE( ARG1
, sizeof(unsigned) );
3011 POST_MEM_WRITE( ARG2
, sizeof(unsigned) );
3013 POST_MEM_WRITE( ARG3
, sizeof(struct vki_getcpu_cache
) );
3018 PRINT("sys_move_pages ( %ld, %ld, %#lx, %#lx, %#lx, %lx )",
3019 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
3020 PRE_REG_READ6(int, "move_pages",
3021 vki_pid_t
, pid
, unsigned long, nr_pages
, const void **, pages
,
3022 const int *, nodes
, int *, status
, int, flags
);
3023 PRE_MEM_READ("move_pages(pages)", ARG3
, ARG2
* sizeof(void *));
3025 PRE_MEM_READ("move_pages(nodes)", ARG4
, ARG2
* sizeof(int));
3026 PRE_MEM_WRITE("move_pages(status)", ARG5
, ARG2
* sizeof(int));
3029 POST(sys_move_pages
)
3031 POST_MEM_WRITE(ARG5
, ARG2
* sizeof(int));
3036 PRINT("sys_getrandom ( %#lx, %ld, %ld )" , ARG1
,ARG2
,ARG3
);
3037 PRE_REG_READ3(int, "getrandom",
3038 char *, buf
, vki_size_t
, count
, unsigned int, flags
);
3039 PRE_MEM_WRITE( "getrandom(cpu)", ARG1
, ARG2
);
3044 POST_MEM_WRITE( ARG1
, ARG2
);
3047 PRE(sys_memfd_create
)
3049 PRINT("sys_memfd_create ( %#lx, %ld )" , ARG1
,ARG2
);
3050 PRE_REG_READ2(int, "memfd_create",
3051 char *, uname
, unsigned int, flags
);
3052 PRE_MEM_RASCIIZ( "memfd_create(uname)", ARG1
);
3055 POST(sys_memfd_create
)
3058 if (!ML_(fd_allowed
)(RES
, "memfd_create", tid
, True
)) {
3060 SET_STATUS_Failure( VKI_EMFILE
);
3062 if (VG_(clo_track_fds
))
3063 ML_(record_fd_open_nameless
)(tid
, RES
);
3069 *flags
|= SfMayBlock
;
3070 PRINT("sys_syncfs ( %ld )", ARG1
);
3071 PRE_REG_READ1(long, "syncfs", unsigned int, fd
);
3074 /* ---------------------------------------------------------------------
3076 ------------------------------------------------------------------ */
3080 *flags
|= SfMayBlock
;
3081 PRINT("sys_utime ( %#lx, %#lx )", ARG1
,ARG2
);
3082 PRE_REG_READ2(long, "utime", char *, filename
, struct utimbuf
*, buf
);
3083 PRE_MEM_RASCIIZ( "utime(filename)", ARG1
);
3085 PRE_MEM_READ( "utime(buf)", ARG2
, sizeof(struct vki_utimbuf
) );
3088 /* ---------------------------------------------------------------------
3090 ------------------------------------------------------------------ */
3094 PRINT("sys_lseek ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
3095 PRE_REG_READ3(vki_off_t
, "lseek",
3096 unsigned int, fd
, vki_off_t
, offset
, unsigned int, whence
);
3099 /* ---------------------------------------------------------------------
3101 ------------------------------------------------------------------ */
3105 *flags
|= SfMayBlock
;
3106 #if VG_WORDSIZE == 4
3107 PRINT("sys_readahead ( %ld, %lld, %ld )", ARG1
, MERGE64(ARG2
,ARG3
), ARG4
);
3108 PRE_REG_READ4(vki_off_t
, "readahead",
3109 int, fd
, unsigned, MERGE64_FIRST(offset
),
3110 unsigned, MERGE64_SECOND(offset
), vki_size_t
, count
);
3111 #elif VG_WORDSIZE == 8
3112 PRINT("sys_readahead ( %ld, %lld, %ld )", ARG1
, (Long
)ARG2
, ARG3
);
3113 PRE_REG_READ3(vki_off_t
, "readahead",
3114 int, fd
, vki_loff_t
, offset
, vki_size_t
, count
);
3116 # error Unexpected word size
3118 if (!ML_(fd_allowed
)(ARG1
, "readahead", tid
, False
))
3119 SET_STATUS_Failure( VKI_EBADF
);
3122 /* ---------------------------------------------------------------------
3124 ------------------------------------------------------------------ */
3128 PRINT( "sys_sigpending ( %#lx )", ARG1
);
3129 PRE_REG_READ1(long, "sigpending", vki_old_sigset_t
*, set
);
3130 PRE_MEM_WRITE( "sigpending(set)", ARG1
, sizeof(vki_old_sigset_t
));
3132 POST(sys_sigpending
)
3134 POST_MEM_WRITE( ARG1
, sizeof(vki_old_sigset_t
) ) ;
3137 // This syscall is not used on amd64/Linux -- it only provides
3138 // sys_rt_sigprocmask, which uses sigset_t rather than old_sigset_t.
3139 // This wrapper is only suitable for 32-bit architectures.
3140 // (XXX: so how is it that PRE(sys_sigpending) above doesn't need
3141 // conditional compilation like this?)
3142 #if defined(VGP_x86_linux) || defined(VGP_ppc32_linux) \
3143 || defined(VGP_arm_linux) || defined(VGP_mips32_linux)
3144 PRE(sys_sigprocmask
)
3146 vki_old_sigset_t
* set
;
3147 vki_old_sigset_t
* oldset
;
3148 vki_sigset_t bigger_set
;
3149 vki_sigset_t bigger_oldset
;
3151 PRINT("sys_sigprocmask ( %ld, %#lx, %#lx )",ARG1
,ARG2
,ARG3
);
3152 PRE_REG_READ3(long, "sigprocmask",
3153 int, how
, vki_old_sigset_t
*, set
, vki_old_sigset_t
*, oldset
);
3155 PRE_MEM_READ( "sigprocmask(set)", ARG2
, sizeof(vki_old_sigset_t
));
3157 PRE_MEM_WRITE( "sigprocmask(oldset)", ARG3
, sizeof(vki_old_sigset_t
));
3159 // Nb: We must convert the smaller vki_old_sigset_t params into bigger
3160 // vki_sigset_t params.
3161 set
= (vki_old_sigset_t
*)ARG2
;
3162 oldset
= (vki_old_sigset_t
*)ARG3
;
3164 VG_(memset
)(&bigger_set
, 0, sizeof(vki_sigset_t
));
3165 VG_(memset
)(&bigger_oldset
, 0, sizeof(vki_sigset_t
));
3167 bigger_set
.sig
[0] = *(vki_old_sigset_t
*)set
;
3169 SET_STATUS_from_SysRes(
3170 VG_(do_sys_sigprocmask
) ( tid
, ARG1
/*how*/,
3171 set
? &bigger_set
: NULL
,
3172 oldset
? &bigger_oldset
: NULL
)
3176 *oldset
= bigger_oldset
.sig
[0];
3179 *flags
|= SfPollAfter
;
3181 POST(sys_sigprocmask
)
3184 if (RES
== 0 && ARG3
!= 0)
3185 POST_MEM_WRITE( ARG3
, sizeof(vki_old_sigset_t
));
3188 /* Convert from non-RT to RT sigset_t's */
3190 void convert_sigset_to_rt(const vki_old_sigset_t
*oldset
, vki_sigset_t
*set
)
3192 VG_(sigemptyset
)(set
);
3193 set
->sig
[0] = *oldset
;
3197 vki_sigaction_toK_t
new, *newp
;
3198 vki_sigaction_fromK_t old
, *oldp
;
3200 PRINT("sys_sigaction ( %ld, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
3201 PRE_REG_READ3(int, "sigaction",
3202 int, signum
, const struct old_sigaction
*, act
,
3203 struct old_sigaction
*, oldact
);
3208 struct vki_old_sigaction
*sa
= (struct vki_old_sigaction
*)ARG2
;
3209 PRE_MEM_READ( "sigaction(act->sa_handler)", (Addr
)&sa
->ksa_handler
, sizeof(sa
->ksa_handler
));
3210 PRE_MEM_READ( "sigaction(act->sa_mask)", (Addr
)&sa
->sa_mask
, sizeof(sa
->sa_mask
));
3211 PRE_MEM_READ( "sigaction(act->sa_flags)", (Addr
)&sa
->sa_flags
, sizeof(sa
->sa_flags
));
3212 if (ML_(safe_to_deref
)(sa
,sizeof(sa
))
3213 && (sa
->sa_flags
& VKI_SA_RESTORER
))
3214 PRE_MEM_READ( "sigaction(act->sa_restorer)", (Addr
)&sa
->sa_restorer
, sizeof(sa
->sa_restorer
));
3218 PRE_MEM_WRITE( "sigaction(oldact)", ARG3
, sizeof(struct vki_old_sigaction
));
3223 struct vki_old_sigaction
*oldnew
= (struct vki_old_sigaction
*)ARG2
;
3225 new.ksa_handler
= oldnew
->ksa_handler
;
3226 new.sa_flags
= oldnew
->sa_flags
;
3227 new.sa_restorer
= oldnew
->sa_restorer
;
3228 convert_sigset_to_rt(&oldnew
->sa_mask
, &new.sa_mask
);
3232 SET_STATUS_from_SysRes( VG_(do_sys_sigaction
)(ARG1
, newp
, oldp
) );
3234 if (ARG3
!= 0 && SUCCESS
&& RES
== 0) {
3235 struct vki_old_sigaction
*oldold
= (struct vki_old_sigaction
*)ARG3
;
3237 oldold
->ksa_handler
= oldp
->ksa_handler
;
3238 oldold
->sa_flags
= oldp
->sa_flags
;
3239 oldold
->sa_restorer
= oldp
->sa_restorer
;
3240 oldold
->sa_mask
= oldp
->sa_mask
.sig
[0];
3246 if (RES
== 0 && ARG3
!= 0)
3247 POST_MEM_WRITE( ARG3
, sizeof(struct vki_old_sigaction
));
3253 PRINT("sys_signalfd ( %d, %#lx, %llu )", (Int
)ARG1
,ARG2
,(ULong
)ARG3
);
3254 PRE_REG_READ3(long, "sys_signalfd",
3255 int, fd
, vki_sigset_t
*, sigmask
, vki_size_t
, sigsetsize
);
3256 PRE_MEM_READ( "signalfd(sigmask)", ARG2
, sizeof(vki_sigset_t
) );
3257 if ((int)ARG1
!= -1 && !ML_(fd_allowed
)(ARG1
, "signalfd", tid
, False
))
3258 SET_STATUS_Failure( VKI_EBADF
);
3262 if (!ML_(fd_allowed
)(RES
, "signalfd", tid
, True
)) {
3264 SET_STATUS_Failure( VKI_EMFILE
);
3266 if (VG_(clo_track_fds
))
3267 ML_(record_fd_open_nameless
) (tid
, RES
);
3273 PRINT("sys_signalfd4 ( %d, %#lx, %llu, %ld )", (Int
)ARG1
,ARG2
,(ULong
)ARG3
,ARG4
);
3274 PRE_REG_READ4(long, "sys_signalfd4",
3275 int, fd
, vki_sigset_t
*, sigmask
, vki_size_t
, sigsetsize
, int, flags
);
3276 PRE_MEM_READ( "signalfd(sigmask)", ARG2
, sizeof(vki_sigset_t
) );
3277 if ((int)ARG1
!= -1 && !ML_(fd_allowed
)(ARG1
, "signalfd", tid
, False
))
3278 SET_STATUS_Failure( VKI_EBADF
);
3282 if (!ML_(fd_allowed
)(RES
, "signalfd4", tid
, True
)) {
3284 SET_STATUS_Failure( VKI_EMFILE
);
3286 if (VG_(clo_track_fds
))
3287 ML_(record_fd_open_nameless
) (tid
, RES
);
3292 /* ---------------------------------------------------------------------
3294 ------------------------------------------------------------------ */
3296 PRE(sys_rt_sigaction
)
3298 PRINT("sys_rt_sigaction ( %ld, %#lx, %#lx, %ld )", ARG1
,ARG2
,ARG3
,ARG4
);
3299 PRE_REG_READ4(long, "rt_sigaction",
3300 int, signum
, const struct sigaction
*, act
,
3301 struct sigaction
*, oldact
, vki_size_t
, sigsetsize
);
3304 vki_sigaction_toK_t
*sa
= (vki_sigaction_toK_t
*)ARG2
;
3305 PRE_MEM_READ( "rt_sigaction(act->sa_handler)", (Addr
)&sa
->ksa_handler
, sizeof(sa
->ksa_handler
));
3306 PRE_MEM_READ( "rt_sigaction(act->sa_mask)", (Addr
)&sa
->sa_mask
, sizeof(sa
->sa_mask
));
3307 PRE_MEM_READ( "rt_sigaction(act->sa_flags)", (Addr
)&sa
->sa_flags
, sizeof(sa
->sa_flags
));
3308 if (sa
->sa_flags
& VKI_SA_RESTORER
)
3309 PRE_MEM_READ( "rt_sigaction(act->sa_restorer)", (Addr
)&sa
->sa_restorer
, sizeof(sa
->sa_restorer
));
3312 PRE_MEM_WRITE( "rt_sigaction(oldact)", ARG3
, sizeof(vki_sigaction_fromK_t
));
3314 // XXX: doesn't seem right to be calling do_sys_sigaction for
3315 // sys_rt_sigaction... perhaps this function should be renamed
3316 // VG_(do_sys_rt_sigaction)() --njn
3318 SET_STATUS_from_SysRes(
3319 VG_(do_sys_sigaction
)(ARG1
, (const vki_sigaction_toK_t
*)ARG2
,
3320 (vki_sigaction_fromK_t
*)ARG3
)
3323 POST(sys_rt_sigaction
)
3326 if (RES
== 0 && ARG3
!= 0)
3327 POST_MEM_WRITE( ARG3
, sizeof(vki_sigaction_fromK_t
));
3330 PRE(sys_rt_sigprocmask
)
3332 PRINT("sys_rt_sigprocmask ( %ld, %#lx, %#lx, %llu )",ARG1
,ARG2
,ARG3
,(ULong
)ARG4
);
3333 PRE_REG_READ4(long, "rt_sigprocmask",
3334 int, how
, vki_sigset_t
*, set
, vki_sigset_t
*, oldset
,
3335 vki_size_t
, sigsetsize
);
3337 PRE_MEM_READ( "rt_sigprocmask(set)", ARG2
, sizeof(vki_sigset_t
));
3339 PRE_MEM_WRITE( "rt_sigprocmask(oldset)", ARG3
, sizeof(vki_sigset_t
));
3341 // Like the kernel, we fail if the sigsetsize is not exactly what we expect.
3342 if (sizeof(vki_sigset_t
) != ARG4
)
3343 SET_STATUS_Failure( VKI_EMFILE
);
3345 SET_STATUS_from_SysRes(
3346 VG_(do_sys_sigprocmask
) ( tid
, ARG1
/*how*/,
3347 (vki_sigset_t
*) ARG2
,
3348 (vki_sigset_t
*) ARG3
)
3353 *flags
|= SfPollAfter
;
3355 POST(sys_rt_sigprocmask
)
3358 if (RES
== 0 && ARG3
!= 0)
3359 POST_MEM_WRITE( ARG3
, sizeof(vki_sigset_t
));
3362 PRE(sys_rt_sigpending
)
3364 PRINT( "sys_rt_sigpending ( %#lx )", ARG1
);
3365 PRE_REG_READ2(long, "rt_sigpending",
3366 vki_sigset_t
*, set
, vki_size_t
, sigsetsize
);
3367 PRE_MEM_WRITE( "rt_sigpending(set)", ARG1
, sizeof(vki_sigset_t
));
3369 POST(sys_rt_sigpending
)
3371 POST_MEM_WRITE( ARG1
, sizeof(vki_sigset_t
) ) ;
3374 PRE(sys_rt_sigtimedwait
)
3376 *flags
|= SfMayBlock
;
3377 PRINT("sys_rt_sigtimedwait ( %#lx, %#lx, %#lx, %lld )",
3378 ARG1
,ARG2
,ARG3
,(ULong
)ARG4
);
3379 PRE_REG_READ4(long, "rt_sigtimedwait",
3380 const vki_sigset_t
*, set
, vki_siginfo_t
*, info
,
3381 const struct timespec
*, timeout
, vki_size_t
, sigsetsize
);
3383 PRE_MEM_READ( "rt_sigtimedwait(set)", ARG1
, sizeof(vki_sigset_t
));
3385 PRE_MEM_WRITE( "rt_sigtimedwait(info)", ARG2
, sizeof(vki_siginfo_t
) );
3387 PRE_MEM_READ( "rt_sigtimedwait(timeout)",
3388 ARG3
, sizeof(struct vki_timespec
) );
3390 POST(sys_rt_sigtimedwait
)
3393 POST_MEM_WRITE( ARG2
, sizeof(vki_siginfo_t
) );
3396 PRE(sys_rt_sigqueueinfo
)
3398 PRINT("sys_rt_sigqueueinfo(%ld, %ld, %#lx)", ARG1
, ARG2
, ARG3
);
3399 PRE_REG_READ3(long, "rt_sigqueueinfo",
3400 int, pid
, int, sig
, vki_siginfo_t
*, uinfo
);
3402 PRE_MEM_READ( "rt_sigqueueinfo(uinfo)", ARG3
, VKI_SI_MAX_SIZE
);
3404 POST(sys_rt_sigqueueinfo
)
3406 if (!ML_(client_signal_OK
)(ARG2
))
3407 SET_STATUS_Failure( VKI_EINVAL
);
3410 PRE(sys_rt_tgsigqueueinfo
)
3412 PRINT("sys_rt_tgsigqueueinfo(%ld, %ld, %ld, %#lx)", ARG1
, ARG2
, ARG3
, ARG4
);
3413 PRE_REG_READ4(long, "rt_tgsigqueueinfo",
3414 int, tgid
, int, pid
, int, sig
, vki_siginfo_t
*, uinfo
);
3416 PRE_MEM_READ( "rt_tgsigqueueinfo(uinfo)", ARG4
, VKI_SI_MAX_SIZE
);
3419 POST(sys_rt_tgsigqueueinfo
)
3421 if (!ML_(client_signal_OK
)(ARG3
))
3422 SET_STATUS_Failure( VKI_EINVAL
);
3425 // XXX: x86-specific? The kernel prototypes for the different archs are
3426 // hard to decipher.
3427 PRE(sys_rt_sigsuspend
)
3429 /* The C library interface to sigsuspend just takes a pointer to
3430 a signal mask but this system call has two arguments - a pointer
3431 to the mask and the number of bytes used by it. The kernel insists
3432 on the size being equal to sizeof(sigset_t) however and will just
3433 return EINVAL if it isn't.
3435 *flags
|= SfMayBlock
;
3436 PRINT("sys_rt_sigsuspend ( %#lx, %ld )", ARG1
,ARG2
);
3437 PRE_REG_READ2(int, "rt_sigsuspend", vki_sigset_t
*, mask
, vki_size_t
, size
)
3438 if (ARG1
!= (Addr
)NULL
) {
3439 PRE_MEM_READ( "rt_sigsuspend(mask)", ARG1
, sizeof(vki_sigset_t
) );
3443 /* ---------------------------------------------------------------------
3444 linux msg* wrapper helpers
3445 ------------------------------------------------------------------ */
3448 ML_(linux_PRE_sys_msgsnd
) ( ThreadId tid
,
3449 UWord arg0
, UWord arg1
, UWord arg2
, UWord arg3
)
3451 /* int msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg); */
3452 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)arg1
;
3453 PRE_MEM_READ( "msgsnd(msgp->mtype)", (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
3454 PRE_MEM_READ( "msgsnd(msgp->mtext)", (Addr
)&msgp
->mtext
, arg2
);
3458 ML_(linux_PRE_sys_msgrcv
) ( ThreadId tid
,
3459 UWord arg0
, UWord arg1
, UWord arg2
,
3460 UWord arg3
, UWord arg4
)
3462 /* ssize_t msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz,
3463 long msgtyp, int msgflg); */
3464 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)arg1
;
3465 PRE_MEM_WRITE( "msgrcv(msgp->mtype)", (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
3466 PRE_MEM_WRITE( "msgrcv(msgp->mtext)", (Addr
)&msgp
->mtext
, arg2
);
3469 ML_(linux_POST_sys_msgrcv
) ( ThreadId tid
,
3471 UWord arg0
, UWord arg1
, UWord arg2
,
3472 UWord arg3
, UWord arg4
)
3474 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)arg1
;
3475 POST_MEM_WRITE( (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
3476 POST_MEM_WRITE( (Addr
)&msgp
->mtext
, res
);
3480 ML_(linux_PRE_sys_msgctl
) ( ThreadId tid
,
3481 UWord arg0
, UWord arg1
, UWord arg2
)
3483 /* int msgctl(int msqid, int cmd, struct msqid_ds *buf); */
3484 switch (arg1
/* cmd */) {
3487 case VKI_IPC_INFO
|VKI_IPC_64
:
3488 case VKI_MSG_INFO
|VKI_IPC_64
:
3489 PRE_MEM_WRITE( "msgctl(IPC_INFO, buf)",
3490 arg2
, sizeof(struct vki_msginfo
) );
3494 PRE_MEM_WRITE( "msgctl(IPC_STAT, buf)",
3495 arg2
, sizeof(struct vki_msqid_ds
) );
3497 case VKI_IPC_STAT
|VKI_IPC_64
:
3498 case VKI_MSG_STAT
|VKI_IPC_64
:
3499 PRE_MEM_WRITE( "msgctl(IPC_STAT, arg.buf)",
3500 arg2
, sizeof(struct vki_msqid64_ds
) );
3503 PRE_MEM_READ( "msgctl(IPC_SET, arg.buf)",
3504 arg2
, sizeof(struct vki_msqid_ds
) );
3506 case VKI_IPC_SET
|VKI_IPC_64
:
3507 PRE_MEM_READ( "msgctl(IPC_SET, arg.buf)",
3508 arg2
, sizeof(struct vki_msqid64_ds
) );
3513 ML_(linux_POST_sys_msgctl
) ( ThreadId tid
,
3515 UWord arg0
, UWord arg1
, UWord arg2
)
3517 switch (arg1
/* cmd */) {
3520 case VKI_IPC_INFO
|VKI_IPC_64
:
3521 case VKI_MSG_INFO
|VKI_IPC_64
:
3522 POST_MEM_WRITE( arg2
, sizeof(struct vki_msginfo
) );
3526 POST_MEM_WRITE( arg2
, sizeof(struct vki_msqid_ds
) );
3528 case VKI_IPC_STAT
|VKI_IPC_64
:
3529 case VKI_MSG_STAT
|VKI_IPC_64
:
3530 POST_MEM_WRITE( arg2
, sizeof(struct vki_msqid64_ds
) );
3535 /* ---------------------------------------------------------------------
3536 Generic handler for sys_ipc
3537 Depending on the platform, some syscalls (e.g. semctl, semop, ...)
3538 are either direct system calls, or are all implemented via sys_ipc.
3539 ------------------------------------------------------------------ */
3541 static Addr
deref_Addr ( ThreadId tid
, Addr a
, const HChar
* s
)
3543 Addr
* a_p
= (Addr
*)a
;
3544 PRE_MEM_READ( s
, (Addr
)a_p
, sizeof(Addr
) );
3548 static Bool
semctl_cmd_has_4args (UWord cmd
)
3550 switch (cmd
& ~VKI_IPC_64
)
3567 PRINT("sys_ipc ( %ld, %ld, %ld, %ld, %#lx, %ld )",
3568 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
3570 switch (ARG1
/* call */) {
3572 PRE_REG_READ5(int, "ipc",
3573 vki_uint
, call
, int, first
, int, second
, int, third
,
3575 ML_(generic_PRE_sys_semop
)( tid
, ARG2
, ARG5
, ARG3
);
3576 *flags
|= SfMayBlock
;
3579 PRE_REG_READ4(int, "ipc",
3580 vki_uint
, call
, int, first
, int, second
, int, third
);
3584 PRE_REG_READ5(int, "ipc",
3585 vki_uint
, call
, int, first
, int, second
, int, third
,
3588 if (semctl_cmd_has_4args(ARG4
))
3589 arg
= deref_Addr( tid
, ARG5
, "semctl(arg)" );
3592 ML_(generic_PRE_sys_semctl
)( tid
, ARG2
, ARG3
, ARG4
, arg
);
3595 case VKI_SEMTIMEDOP
:
3596 PRE_REG_READ6(int, "ipc",
3597 vki_uint
, call
, int, first
, int, second
, int, third
,
3598 void *, ptr
, long, fifth
);
3599 ML_(generic_PRE_sys_semtimedop
)( tid
, ARG2
, ARG5
, ARG3
, ARG6
);
3600 *flags
|= SfMayBlock
;
3603 PRE_REG_READ5(int, "ipc",
3604 vki_uint
, call
, int, first
, int, second
, int, third
,
3606 ML_(linux_PRE_sys_msgsnd
)( tid
, ARG2
, ARG5
, ARG3
, ARG4
);
3607 if ((ARG4
& VKI_IPC_NOWAIT
) == 0)
3608 *flags
|= SfMayBlock
;
3612 PRE_REG_READ5(int, "ipc",
3613 vki_uint
, call
, int, first
, int, second
, int, third
,
3618 msgp
= deref_Addr( tid
, (Addr
) (&((struct vki_ipc_kludge
*)ARG5
)->msgp
),
3620 msgtyp
= deref_Addr( tid
,
3621 (Addr
) (&((struct vki_ipc_kludge
*)ARG5
)->msgtyp
),
3624 ML_(linux_PRE_sys_msgrcv
)( tid
, ARG2
, msgp
, ARG3
, msgtyp
, ARG4
);
3626 if ((ARG4
& VKI_IPC_NOWAIT
) == 0)
3627 *flags
|= SfMayBlock
;
3631 PRE_REG_READ3(int, "ipc", vki_uint
, call
, int, first
, int, second
);
3634 PRE_REG_READ5(int, "ipc",
3635 vki_uint
, call
, int, first
, int, second
, int, third
,
3637 ML_(linux_PRE_sys_msgctl
)( tid
, ARG2
, ARG3
, ARG5
);
3641 PRE_REG_READ5(int, "ipc",
3642 vki_uint
, call
, int, first
, int, second
, int, third
,
3645 PRE_MEM_WRITE( "shmat(raddr)", ARG4
, sizeof(Addr
) );
3646 w
= ML_(generic_PRE_sys_shmat
)( tid
, ARG2
, ARG5
, ARG3
);
3648 SET_STATUS_Failure( VKI_EINVAL
);
3654 PRE_REG_READ5(int, "ipc",
3655 vki_uint
, call
, int, first
, int, second
, int, third
,
3657 if (!ML_(generic_PRE_sys_shmdt
)(tid
, ARG5
))
3658 SET_STATUS_Failure( VKI_EINVAL
);
3661 PRE_REG_READ4(int, "ipc",
3662 vki_uint
, call
, int, first
, int, second
, int, third
);
3663 if (ARG4
& VKI_SHM_HUGETLB
) {
3664 static Bool warning_given
= False
;
3665 ARG4
&= ~VKI_SHM_HUGETLB
;
3666 if (!warning_given
) {
3667 warning_given
= True
;
3669 "WARNING: valgrind ignores shmget(shmflg) SHM_HUGETLB\n");
3673 case VKI_SHMCTL
: /* IPCOP_shmctl */
3674 PRE_REG_READ5(int, "ipc",
3675 vki_uint
, call
, int, first
, int, second
, int, third
,
3677 ML_(generic_PRE_sys_shmctl
)( tid
, ARG2
, ARG3
, ARG5
);
3680 VG_(message
)(Vg_DebugMsg
, "FATAL: unhandled syscall(ipc) %ld\n", ARG1
);
3681 VG_(core_panic
)("... bye!\n");
3682 break; /*NOTREACHED*/
3689 switch (ARG1
/* call */) {
3696 if (semctl_cmd_has_4args(ARG4
))
3697 arg
= deref_Addr( tid
, ARG5
, "semctl(arg)" );
3700 ML_(generic_POST_sys_semctl
)( tid
, RES
, ARG2
, ARG3
, ARG4
, arg
);
3703 case VKI_SEMTIMEDOP
:
3711 msgp
= deref_Addr( tid
,
3712 (Addr
) (&((struct vki_ipc_kludge
*)ARG5
)->msgp
),
3714 msgtyp
= deref_Addr( tid
,
3715 (Addr
) (&((struct vki_ipc_kludge
*)ARG5
)->msgtyp
),
3718 ML_(linux_POST_sys_msgrcv
)( tid
, RES
, ARG2
, msgp
, ARG3
, msgtyp
, ARG4
);
3724 ML_(linux_POST_sys_msgctl
)( tid
, RES
, ARG2
, ARG3
, ARG5
);
3730 /* force readability. before the syscall it is
3731 * indeed uninitialized, as can be seen in
3732 * glibc/sysdeps/unix/sysv/linux/shmat.c */
3733 POST_MEM_WRITE( ARG4
, sizeof( Addr
) );
3735 addr
= deref_Addr ( tid
, ARG4
, "shmat(addr)" );
3736 ML_(generic_POST_sys_shmat
)( tid
, addr
, ARG2
, ARG5
, ARG3
);
3740 ML_(generic_POST_sys_shmdt
)( tid
, RES
, ARG5
);
3745 ML_(generic_POST_sys_shmctl
)( tid
, RES
, ARG2
, ARG3
, ARG5
);
3748 VG_(message
)(Vg_DebugMsg
,
3749 "FATAL: unhandled syscall(ipc) %ld\n",
3751 VG_(core_panic
)("... bye!\n");
3752 break; /*NOTREACHED*/
3759 PRINT("sys_semget ( %ld, %ld, %ld )",ARG1
,ARG2
,ARG3
);
3760 PRE_REG_READ3(long, "semget", vki_key_t
, key
, int, nsems
, int, semflg
);
3765 *flags
|= SfMayBlock
;
3766 PRINT("sys_semop ( %ld, %#lx, %lu )",ARG1
,ARG2
,ARG3
);
3767 PRE_REG_READ3(long, "semop",
3768 int, semid
, struct sembuf
*, sops
, unsigned, nsoops
);
3769 ML_(generic_PRE_sys_semop
)(tid
, ARG1
,ARG2
,ARG3
);
3774 switch (ARG3
& ~VKI_IPC_64
) {
3777 PRINT("sys_semctl ( %ld, %ld, %ld, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
);
3778 PRE_REG_READ4(long, "semctl",
3779 int, semid
, int, semnum
, int, cmd
, struct seminfo
*, arg
);
3784 PRINT("sys_semctl ( %ld, %ld, %ld, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
);
3785 PRE_REG_READ4(long, "semctl",
3786 int, semid
, int, semnum
, int, cmd
, struct semid_ds
*, arg
);
3790 PRINT("sys_semctl ( %ld, %ld, %ld, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
);
3791 PRE_REG_READ4(long, "semctl",
3792 int, semid
, int, semnum
, int, cmd
, unsigned short *, arg
);
3795 PRINT("sys_semctl ( %ld, %ld, %ld )",ARG1
,ARG2
,ARG3
);
3796 PRE_REG_READ3(long, "semctl",
3797 int, semid
, int, semnum
, int, cmd
);
3800 #ifdef VGP_amd64_linux
3801 ML_(generic_PRE_sys_semctl
)(tid
, ARG1
,ARG2
,ARG3
|VKI_IPC_64
,ARG4
);
3803 ML_(generic_PRE_sys_semctl
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
3809 #ifdef VGP_amd64_linux
3810 ML_(generic_POST_sys_semctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
|VKI_IPC_64
,ARG4
);
3812 ML_(generic_POST_sys_semctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
,ARG4
);
3818 *flags
|= SfMayBlock
;
3819 PRINT("sys_semtimedop ( %ld, %#lx, %lu, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
);
3820 PRE_REG_READ4(long, "semtimedop",
3821 int, semid
, struct sembuf
*, sops
, unsigned, nsoops
,
3822 struct timespec
*, timeout
);
3823 ML_(generic_PRE_sys_semtimedop
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
3828 PRINT("sys_msgget ( %ld, %ld )",ARG1
,ARG2
);
3829 PRE_REG_READ2(long, "msgget", vki_key_t
, key
, int, msgflg
);
3834 PRINT("sys_msgsnd ( %ld, %#lx, %ld, %ld )",ARG1
,ARG2
,ARG3
,ARG4
);
3835 PRE_REG_READ4(long, "msgsnd",
3836 int, msqid
, struct msgbuf
*, msgp
, vki_size_t
, msgsz
, int, msgflg
);
3837 ML_(linux_PRE_sys_msgsnd
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
3838 if ((ARG4
& VKI_IPC_NOWAIT
) == 0)
3839 *flags
|= SfMayBlock
;
3844 PRINT("sys_msgrcv ( %ld, %#lx, %ld, %ld, %ld )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
3845 PRE_REG_READ5(long, "msgrcv",
3846 int, msqid
, struct msgbuf
*, msgp
, vki_size_t
, msgsz
,
3847 long, msgytp
, int, msgflg
);
3848 ML_(linux_PRE_sys_msgrcv
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
3849 if ((ARG5
& VKI_IPC_NOWAIT
) == 0)
3850 *flags
|= SfMayBlock
;
3854 ML_(linux_POST_sys_msgrcv
)(tid
, RES
,ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
3859 PRINT("sys_msgctl ( %ld, %ld, %#lx )",ARG1
,ARG2
,ARG3
);
3860 PRE_REG_READ3(long, "msgctl",
3861 int, msqid
, int, cmd
, struct msqid_ds
*, buf
);
3862 ML_(linux_PRE_sys_msgctl
)(tid
, ARG1
,ARG2
,ARG3
);
3867 ML_(linux_POST_sys_msgctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
);
3872 PRINT("sys_shmget ( %ld, %ld, %ld )",ARG1
,ARG2
,ARG3
);
3873 PRE_REG_READ3(long, "shmget", vki_key_t
, key
, vki_size_t
, size
, int, shmflg
);
3874 if (ARG3
& VKI_SHM_HUGETLB
) {
3875 static Bool warning_given
= False
;
3876 ARG3
&= ~VKI_SHM_HUGETLB
;
3877 if (!warning_given
) {
3878 warning_given
= True
;
3880 "WARNING: valgrind ignores shmget(shmflg) SHM_HUGETLB\n");
3888 PRINT("wrap_sys_shmat ( %ld, %#lx, %ld )",ARG1
,ARG2
,ARG3
);
3889 PRE_REG_READ3(long, "shmat",
3890 int, shmid
, const void *, shmaddr
, int, shmflg
);
3891 #if defined(VGP_arm_linux)
3892 /* Round the attach address down to an VKI_SHMLBA boundary if the
3893 client requested rounding. See #222545. This is necessary only
3894 on arm-linux because VKI_SHMLBA is 4 * VKI_PAGE size; on all
3895 other linux targets it is the same as the page size. */
3896 if (ARG3
& VKI_SHM_RND
)
3897 ARG2
= VG_ROUNDDN(ARG2
, VKI_SHMLBA
);
3899 arg2tmp
= ML_(generic_PRE_sys_shmat
)(tid
, ARG1
,ARG2
,ARG3
);
3901 SET_STATUS_Failure( VKI_EINVAL
);
3903 ARG2
= arg2tmp
; // used in POST
3906 POST(wrap_sys_shmat
)
3908 ML_(generic_POST_sys_shmat
)(tid
, RES
,ARG1
,ARG2
,ARG3
);
3913 PRINT("sys_shmdt ( %#lx )",ARG1
);
3914 PRE_REG_READ1(long, "shmdt", const void *, shmaddr
);
3915 if (!ML_(generic_PRE_sys_shmdt
)(tid
, ARG1
))
3916 SET_STATUS_Failure( VKI_EINVAL
);
3921 ML_(generic_POST_sys_shmdt
)(tid
, RES
,ARG1
);
3926 PRINT("sys_shmctl ( %ld, %ld, %#lx )",ARG1
,ARG2
,ARG3
);
3927 PRE_REG_READ3(long, "shmctl",
3928 int, shmid
, int, cmd
, struct shmid_ds
*, buf
);
3929 #ifdef VGP_amd64_linux
3930 ML_(generic_PRE_sys_shmctl
)(tid
, ARG1
,ARG2
|VKI_IPC_64
,ARG3
);
3932 ML_(generic_PRE_sys_shmctl
)(tid
, ARG1
,ARG2
,ARG3
);
3938 #ifdef VGP_amd64_linux
3939 ML_(generic_POST_sys_shmctl
)(tid
, RES
,ARG1
,ARG2
|VKI_IPC_64
,ARG3
);
3941 ML_(generic_POST_sys_shmctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
);
3946 /* ---------------------------------------------------------------------
3947 Generic handler for sys_socketcall
3948 Depending on the platform, some socket related syscalls (e.g. socketpair,
3950 are either direct system calls, or are all implemented via sys_socketcall.
3951 ------------------------------------------------------------------ */
3952 #ifdef __NR_socketcall
3955 # define ARG2_0 (((UWord*)ARG2)[0])
3956 # define ARG2_1 (((UWord*)ARG2)[1])
3957 # define ARG2_2 (((UWord*)ARG2)[2])
3958 # define ARG2_3 (((UWord*)ARG2)[3])
3959 # define ARG2_4 (((UWord*)ARG2)[4])
3960 # define ARG2_5 (((UWord*)ARG2)[5])
3962 // call PRE_MEM_READ and check for EFAULT result.
3963 #define PRE_MEM_READ_ef(msg, arg, size) \
3965 PRE_MEM_READ( msg, arg, size); \
3966 if (!ML_(valid_client_addr)(arg, size, tid, NULL)) { \
3967 SET_STATUS_Failure( VKI_EFAULT ); \
3972 *flags
|= SfMayBlock
;
3973 PRINT("sys_socketcall ( %ld, %#lx )",ARG1
,ARG2
);
3974 PRE_REG_READ2(long, "socketcall", int, call
, unsigned long *, args
);
3976 switch (ARG1
/* request */) {
3978 case VKI_SYS_SOCKETPAIR
:
3979 /* int socketpair(int d, int type, int protocol, int sv[2]); */
3980 PRE_MEM_READ_ef( "socketcall.socketpair(args)", ARG2
, 4*sizeof(Addr
) );
3981 ML_(generic_PRE_sys_socketpair
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
);
3984 case VKI_SYS_SOCKET
:
3985 /* int socket(int domain, int type, int protocol); */
3986 PRE_MEM_READ_ef( "socketcall.socket(args)", ARG2
, 3*sizeof(Addr
) );
3990 /* int bind(int sockfd, struct sockaddr *my_addr,
3992 PRE_MEM_READ_ef( "socketcall.bind(args)", ARG2
, 3*sizeof(Addr
) );
3993 ML_(generic_PRE_sys_bind
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
3996 case VKI_SYS_LISTEN
:
3997 /* int listen(int s, int backlog); */
3998 PRE_MEM_READ_ef( "socketcall.listen(args)", ARG2
, 2*sizeof(Addr
) );
4001 case VKI_SYS_ACCEPT
:
4002 /* int accept(int s, struct sockaddr *addr, int *addrlen); */
4003 PRE_MEM_READ_ef( "socketcall.accept(args)", ARG2
, 3*sizeof(Addr
) );
4004 ML_(generic_PRE_sys_accept
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4007 case VKI_SYS_ACCEPT4
:
4008 /* int accept4(int s, struct sockaddr *addr, int *addrlen, int flags); */
4009 PRE_MEM_READ_ef( "socketcall.accept4(args)", ARG2
, 4*sizeof(Addr
) );
4010 ML_(generic_PRE_sys_accept
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4013 case VKI_SYS_SENDTO
:
4014 /* int sendto(int s, const void *msg, int len,
4016 const struct sockaddr *to, int tolen); */
4017 PRE_MEM_READ_ef( "socketcall.sendto(args)", ARG2
, 6*sizeof(Addr
) );
4018 ML_(generic_PRE_sys_sendto
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
,
4019 ARG2_3
, ARG2_4
, ARG2_5
);
4023 /* int send(int s, const void *msg, size_t len, int flags); */
4024 PRE_MEM_READ_ef( "socketcall.send(args)", ARG2
, 4*sizeof(Addr
) );
4025 ML_(generic_PRE_sys_send
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4028 case VKI_SYS_RECVFROM
:
4029 /* int recvfrom(int s, void *buf, int len, unsigned int flags,
4030 struct sockaddr *from, int *fromlen); */
4031 PRE_MEM_READ_ef( "socketcall.recvfrom(args)", ARG2
, 6*sizeof(Addr
) );
4032 ML_(generic_PRE_sys_recvfrom
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
,
4033 ARG2_3
, ARG2_4
, ARG2_5
);
4037 /* int recv(int s, void *buf, int len, unsigned int flags); */
4039 The recv call is normally used only on a connected socket
4040 (see connect(2)) and is identical to recvfrom with a NULL
4043 PRE_MEM_READ_ef( "socketcall.recv(args)", ARG2
, 4*sizeof(Addr
) );
4044 ML_(generic_PRE_sys_recv
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4047 case VKI_SYS_CONNECT
:
4048 /* int connect(int sockfd,
4049 struct sockaddr *serv_addr, int addrlen ); */
4050 PRE_MEM_READ_ef( "socketcall.connect(args)", ARG2
, 3*sizeof(Addr
) );
4051 ML_(generic_PRE_sys_connect
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4054 case VKI_SYS_SETSOCKOPT
:
4055 /* int setsockopt(int s, int level, int optname,
4056 const void *optval, int optlen); */
4057 PRE_MEM_READ_ef( "socketcall.setsockopt(args)", ARG2
, 5*sizeof(Addr
) );
4058 ML_(linux_PRE_sys_setsockopt
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
,
4062 case VKI_SYS_GETSOCKOPT
:
4063 /* int getsockopt(int s, int level, int optname,
4064 void *optval, socklen_t *optlen); */
4065 PRE_MEM_READ_ef( "socketcall.getsockopt(args)", ARG2
, 5*sizeof(Addr
) );
4066 ML_(linux_PRE_sys_getsockopt
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
,
4070 case VKI_SYS_GETSOCKNAME
:
4071 /* int getsockname(int s, struct sockaddr* name, int* namelen) */
4072 PRE_MEM_READ_ef( "socketcall.getsockname(args)", ARG2
, 3*sizeof(Addr
) );
4073 ML_(generic_PRE_sys_getsockname
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4076 case VKI_SYS_GETPEERNAME
:
4077 /* int getpeername(int s, struct sockaddr* name, int* namelen) */
4078 PRE_MEM_READ_ef( "socketcall.getpeername(args)", ARG2
, 3*sizeof(Addr
) );
4079 ML_(generic_PRE_sys_getpeername
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4082 case VKI_SYS_SHUTDOWN
:
4083 /* int shutdown(int s, int how); */
4084 PRE_MEM_READ_ef( "socketcall.shutdown(args)", ARG2
, 2*sizeof(Addr
) );
4087 case VKI_SYS_SENDMSG
:
4088 /* int sendmsg(int s, const struct msghdr *msg, int flags); */
4089 PRE_MEM_READ_ef( "socketcall.sendmsg(args)", ARG2
, 3*sizeof(Addr
) );
4090 ML_(generic_PRE_sys_sendmsg
)( tid
, "msg", (struct vki_msghdr
*)ARG2_1
);
4093 case VKI_SYS_RECVMSG
:
4094 /* int recvmsg(int s, struct msghdr *msg, int flags); */
4095 PRE_MEM_READ_ef("socketcall.recvmsg(args)", ARG2
, 3*sizeof(Addr
) );
4096 ML_(generic_PRE_sys_recvmsg
)( tid
, "msg", (struct vki_msghdr
*)ARG2_1
);
4099 case VKI_SYS_RECVMMSG
:
4100 /* int recvmmsg(int s, struct mmsghdr *mmsg, int vlen, int flags,
4101 struct timespec *timeout); */
4102 PRE_MEM_READ_ef("socketcall.recvmmsg(args)", ARG2
, 5*sizeof(Addr
) );
4103 ML_(linux_PRE_sys_recvmmsg
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
,
4107 case VKI_SYS_SENDMMSG
:
4108 /* int sendmmsg(int s, struct mmsghdr *mmsg, int vlen, int flags); */
4109 PRE_MEM_READ_ef("socketcall.sendmmsg(args)", ARG2
, 4*sizeof(Addr
) );
4110 ML_(linux_PRE_sys_sendmmsg
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
);
4114 VG_(message
)(Vg_DebugMsg
,"Warning: unhandled socketcall 0x%lx\n",ARG1
);
4115 SET_STATUS_Failure( VKI_EINVAL
);
4126 POST(sys_socketcall
)
4128 # define ARG2_0 (((UWord*)ARG2)[0])
4129 # define ARG2_1 (((UWord*)ARG2)[1])
4130 # define ARG2_2 (((UWord*)ARG2)[2])
4131 # define ARG2_3 (((UWord*)ARG2)[3])
4132 # define ARG2_4 (((UWord*)ARG2)[4])
4133 # define ARG2_5 (((UWord*)ARG2)[5])
4137 switch (ARG1
/* request */) {
4139 case VKI_SYS_SOCKETPAIR
:
4140 r
= ML_(generic_POST_sys_socketpair
)(
4141 tid
, VG_(mk_SysRes_Success
)(RES
),
4142 ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
4144 SET_STATUS_from_SysRes(r
);
4147 case VKI_SYS_SOCKET
:
4148 r
= ML_(generic_POST_sys_socket
)( tid
, VG_(mk_SysRes_Success
)(RES
) );
4149 SET_STATUS_from_SysRes(r
);
4153 /* int bind(int sockfd, struct sockaddr *my_addr,
4157 case VKI_SYS_LISTEN
:
4158 /* int listen(int s, int backlog); */
4161 case VKI_SYS_ACCEPT
:
4162 case VKI_SYS_ACCEPT4
:
4163 /* int accept(int s, struct sockaddr *addr, int *addrlen); */
4164 /* int accept4(int s, struct sockaddr *addr, int *addrlen, int flags); */
4165 r
= ML_(generic_POST_sys_accept
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4166 ARG2_0
, ARG2_1
, ARG2_2
);
4167 SET_STATUS_from_SysRes(r
);
4170 case VKI_SYS_SENDTO
:
4176 case VKI_SYS_RECVFROM
:
4177 ML_(generic_POST_sys_recvfrom
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4178 ARG2_0
, ARG2_1
, ARG2_2
,
4179 ARG2_3
, ARG2_4
, ARG2_5
);
4183 ML_(generic_POST_sys_recv
)( tid
, RES
, ARG2_0
, ARG2_1
, ARG2_2
);
4186 case VKI_SYS_CONNECT
:
4189 case VKI_SYS_SETSOCKOPT
:
4192 case VKI_SYS_GETSOCKOPT
:
4193 ML_(linux_POST_sys_getsockopt
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4195 ARG2_2
, ARG2_3
, ARG2_4
);
4198 case VKI_SYS_GETSOCKNAME
:
4199 ML_(generic_POST_sys_getsockname
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4200 ARG2_0
, ARG2_1
, ARG2_2
);
4203 case VKI_SYS_GETPEERNAME
:
4204 ML_(generic_POST_sys_getpeername
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4205 ARG2_0
, ARG2_1
, ARG2_2
);
4208 case VKI_SYS_SHUTDOWN
:
4211 case VKI_SYS_SENDMSG
:
4214 case VKI_SYS_RECVMSG
:
4215 ML_(generic_POST_sys_recvmsg
)( tid
, "msg", (struct vki_msghdr
*)ARG2_1
, RES
);
4218 case VKI_SYS_RECVMMSG
:
4219 ML_(linux_POST_sys_recvmmsg
)( tid
, RES
,
4220 ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
, ARG2_4
);
4223 case VKI_SYS_SENDMMSG
:
4224 ML_(linux_POST_sys_sendmmsg
)( tid
, RES
, ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
);
4228 VG_(message
)(Vg_DebugMsg
,"FATAL: unhandled socketcall 0x%lx\n",ARG1
);
4229 VG_(core_panic
)("... bye!\n");
4230 break; /*NOTREACHED*/
4243 PRINT("sys_socket ( %ld, %ld, %ld )",ARG1
,ARG2
,ARG3
);
4244 PRE_REG_READ3(long, "socket", int, domain
, int, type
, int, protocol
);
4250 r
= ML_(generic_POST_sys_socket
)(tid
, VG_(mk_SysRes_Success
)(RES
));
4251 SET_STATUS_from_SysRes(r
);
4256 PRINT("sys_setsockopt ( %ld, %ld, %ld, %#lx, %ld )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4257 PRE_REG_READ5(long, "setsockopt",
4258 int, s
, int, level
, int, optname
,
4259 const void *, optval
, int, optlen
);
4260 ML_(linux_PRE_sys_setsockopt
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4265 PRINT("sys_getsockopt ( %ld, %ld, %ld, %#lx, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4266 PRE_REG_READ5(long, "getsockopt",
4267 int, s
, int, level
, int, optname
,
4268 void *, optval
, int, *optlen
);
4269 ML_(linux_PRE_sys_getsockopt
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4271 POST(sys_getsockopt
)
4274 ML_(linux_POST_sys_getsockopt
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4275 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4280 *flags
|= SfMayBlock
;
4281 PRINT("sys_connect ( %ld, %#lx, %ld )",ARG1
,ARG2
,ARG3
);
4282 PRE_REG_READ3(long, "connect",
4283 int, sockfd
, struct sockaddr
*, serv_addr
, int, addrlen
);
4284 ML_(generic_PRE_sys_connect
)(tid
, ARG1
,ARG2
,ARG3
);
4289 *flags
|= SfMayBlock
;
4290 PRINT("sys_accept ( %ld, %#lx, %ld )",ARG1
,ARG2
,ARG3
);
4291 PRE_REG_READ3(long, "accept",
4292 int, s
, struct sockaddr
*, addr
, int, *addrlen
);
4293 ML_(generic_PRE_sys_accept
)(tid
, ARG1
,ARG2
,ARG3
);
4299 r
= ML_(generic_POST_sys_accept
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4301 SET_STATUS_from_SysRes(r
);
4306 *flags
|= SfMayBlock
;
4307 PRINT("sys_accept4 ( %ld, %#lx, %ld, %ld )",ARG1
,ARG2
,ARG3
,ARG4
);
4308 PRE_REG_READ4(long, "accept4",
4309 int, s
, struct sockaddr
*, addr
, int, *addrlen
, int, flags
);
4310 ML_(generic_PRE_sys_accept
)(tid
, ARG1
,ARG2
,ARG3
);
4316 r
= ML_(generic_POST_sys_accept
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4318 SET_STATUS_from_SysRes(r
);
4323 *flags
|= SfMayBlock
;
4324 PRINT("sys_send ( %ld, %#lx, %ld, %lu )",ARG1
,ARG2
,ARG3
,ARG4
);
4325 PRE_REG_READ4(long, "send",
4326 int, s
, const void *, msg
, int, len
,
4327 unsigned int, flags
);
4329 ML_(generic_PRE_sys_send
)( tid
, ARG1
, ARG2
, ARG3
);
4334 *flags
|= SfMayBlock
;
4335 PRINT("sys_sendto ( %ld, %#lx, %ld, %lu, %#lx, %ld )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
4336 PRE_REG_READ6(long, "sendto",
4337 int, s
, const void *, msg
, int, len
,
4338 unsigned int, flags
,
4339 const struct sockaddr
*, to
, int, tolen
);
4340 ML_(generic_PRE_sys_sendto
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
4345 *flags
|= SfMayBlock
;
4346 PRINT ("sys_recv ( %ld, %#lx, %ld, %lu )", ARG1
, ARG2
, ARG3
, ARG4
);
4347 PRE_REG_READ4 (long, "recv", int, s
, void *, buf
, int, len
,
4348 unsigned int, flags
);
4349 ML_ (generic_PRE_sys_recv
) (tid
, ARG1
, ARG2
, ARG3
);
4354 ML_ (generic_POST_sys_recv
) (tid
, RES
, ARG1
, ARG2
, ARG3
);
4359 *flags
|= SfMayBlock
;
4360 PRINT("sys_recvfrom ( %ld, %#lx, %ld, %lu, %#lx, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
4361 PRE_REG_READ6(long, "recvfrom",
4362 int, s
, void *, buf
, int, len
, unsigned int, flags
,
4363 struct sockaddr
*, from
, int *, fromlen
);
4364 ML_(generic_PRE_sys_recvfrom
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
4369 ML_(generic_POST_sys_recvfrom
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4370 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
4375 *flags
|= SfMayBlock
;
4376 PRINT("sys_sendmsg ( %ld, %#lx, %ld )",ARG1
,ARG2
,ARG3
);
4377 PRE_REG_READ3(long, "sendmsg",
4378 int, s
, const struct msghdr
*, msg
, int, flags
);
4379 ML_(generic_PRE_sys_sendmsg
)(tid
, "msg", (struct vki_msghdr
*)ARG2
);
4384 *flags
|= SfMayBlock
;
4385 PRINT("sys_recvmsg ( %ld, %#lx, %ld )",ARG1
,ARG2
,ARG3
);
4386 PRE_REG_READ3(long, "recvmsg", int, s
, struct msghdr
*, msg
, int, flags
);
4387 ML_(generic_PRE_sys_recvmsg
)(tid
, "msg", (struct vki_msghdr
*)ARG2
);
4391 ML_(generic_POST_sys_recvmsg
)(tid
, "msg", (struct vki_msghdr
*)ARG2
, RES
);
4396 *flags
|= SfMayBlock
;
4397 PRINT("sys_shutdown ( %ld, %ld )",ARG1
,ARG2
);
4398 PRE_REG_READ2(int, "shutdown", int, s
, int, how
);
4403 PRINT("sys_bind ( %ld, %#lx, %ld )",ARG1
,ARG2
,ARG3
);
4404 PRE_REG_READ3(long, "bind",
4405 int, sockfd
, struct sockaddr
*, my_addr
, int, addrlen
);
4406 ML_(generic_PRE_sys_bind
)(tid
, ARG1
,ARG2
,ARG3
);
4411 PRINT("sys_listen ( %ld, %ld )",ARG1
,ARG2
);
4412 PRE_REG_READ2(long, "listen", int, s
, int, backlog
);
4415 PRE(sys_getsockname
)
4417 PRINT("sys_getsockname ( %ld, %#lx, %#lx )",ARG1
,ARG2
,ARG3
);
4418 PRE_REG_READ3(long, "getsockname",
4419 int, s
, struct sockaddr
*, name
, int *, namelen
);
4420 ML_(generic_PRE_sys_getsockname
)(tid
, ARG1
,ARG2
,ARG3
);
4422 POST(sys_getsockname
)
4425 ML_(generic_POST_sys_getsockname
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4429 PRE(sys_getpeername
)
4431 PRINT("sys_getpeername ( %ld, %#lx, %#lx )",ARG1
,ARG2
,ARG3
);
4432 PRE_REG_READ3(long, "getpeername",
4433 int, s
, struct sockaddr
*, name
, int *, namelen
);
4434 ML_(generic_PRE_sys_getpeername
)(tid
, ARG1
,ARG2
,ARG3
);
4436 POST(sys_getpeername
)
4439 ML_(generic_POST_sys_getpeername
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4445 PRINT("sys_socketpair ( %ld, %ld, %ld, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
);
4446 PRE_REG_READ4(long, "socketpair",
4447 int, d
, int, type
, int, protocol
, int*, sv
);
4448 ML_(generic_PRE_sys_socketpair
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
4450 POST(sys_socketpair
)
4453 ML_(generic_POST_sys_socketpair
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4454 ARG1
,ARG2
,ARG3
,ARG4
);
4458 /* ---------------------------------------------------------------------
4460 ------------------------------------------------------------------ */
4464 HChar name
[30]; // large enough
4467 if (ARG3
& VKI_O_CREAT
) {
4469 PRINT("sys_openat ( %ld, %#lx(%s), %ld, %ld )",ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
);
4470 PRE_REG_READ4(long, "openat",
4471 int, dfd
, const char *, filename
, int, flags
, int, mode
);
4474 PRINT("sys_openat ( %ld, %#lx(%s), %ld )",ARG1
,ARG2
,(char*)ARG2
,ARG3
);
4475 PRE_REG_READ3(long, "openat",
4476 int, dfd
, const char *, filename
, int, flags
);
4479 PRE_MEM_RASCIIZ( "openat(filename)", ARG2
);
4481 /* For absolute filenames, dfd is ignored. If dfd is AT_FDCWD,
4482 filename is relative to cwd. When comparing dfd against AT_FDCWD,
4483 be sure only to compare the bottom 32 bits. */
4484 if (ML_(safe_to_deref
)( (void*)ARG2
, 1 )
4485 && *(Char
*)ARG2
!= '/'
4486 && ((Int
)ARG1
) != ((Int
)VKI_AT_FDCWD
)
4487 && !ML_(fd_allowed
)(ARG1
, "openat", tid
, False
))
4488 SET_STATUS_Failure( VKI_EBADF
);
4490 /* Handle the case where the open is of /proc/self/cmdline or
4491 /proc/<pid>/cmdline, and just give it a copy of the fd for the
4492 fake file we cooked up at startup (in m_main). Also, seek the
4493 cloned fd back to the start. */
4495 VG_(sprintf
)(name
, "/proc/%d/cmdline", VG_(getpid
)());
4496 if (ML_(safe_to_deref
)( (void*)ARG2
, 1 )
4497 && (VG_(strcmp
)((HChar
*)ARG2
, name
) == 0
4498 || VG_(strcmp
)((HChar
*)ARG2
, "/proc/self/cmdline") == 0)) {
4499 sres
= VG_(dup
)( VG_(cl_cmdline_fd
) );
4500 SET_STATUS_from_SysRes( sres
);
4501 if (!sr_isError(sres
)) {
4502 OffT off
= VG_(lseek
)( sr_Res(sres
), 0, VKI_SEEK_SET
);
4504 SET_STATUS_Failure( VKI_EMFILE
);
4509 /* Do the same for /proc/self/auxv or /proc/<pid>/auxv case. */
4511 VG_(sprintf
)(name
, "/proc/%d/auxv", VG_(getpid
)());
4512 if (ML_(safe_to_deref
)( (void*)ARG2
, 1 )
4513 && (VG_(strcmp
)((HChar
*)ARG2
, name
) == 0
4514 || VG_(strcmp
)((HChar
*)ARG2
, "/proc/self/auxv") == 0)) {
4515 sres
= VG_(dup
)( VG_(cl_auxv_fd
) );
4516 SET_STATUS_from_SysRes( sres
);
4517 if (!sr_isError(sres
)) {
4518 OffT off
= VG_(lseek
)( sr_Res(sres
), 0, VKI_SEEK_SET
);
4520 SET_STATUS_Failure( VKI_EMFILE
);
4525 /* Otherwise handle normally */
4526 *flags
|= SfMayBlock
;
4532 if (!ML_(fd_allowed
)(RES
, "openat", tid
, True
)) {
4534 SET_STATUS_Failure( VKI_EMFILE
);
4536 if (VG_(clo_track_fds
))
4537 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG2
);
4543 *flags
|= SfMayBlock
;
4544 PRINT("sys_mkdirat ( %ld, %#lx(%s), %ld )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
4545 PRE_REG_READ3(long, "mkdirat",
4546 int, dfd
, const char *, pathname
, int, mode
);
4547 PRE_MEM_RASCIIZ( "mkdirat(pathname)", ARG2
);
4552 PRINT("sys_mknodat ( %ld, %#lx(%s), 0x%lx, 0x%lx )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
);
4553 PRE_REG_READ4(long, "mknodat",
4554 int, dfd
, const char *, pathname
, int, mode
, unsigned, dev
);
4555 PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2
);
4560 PRINT("sys_fchownat ( %ld, %#lx(%s), 0x%lx, 0x%lx )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
);
4561 PRE_REG_READ4(long, "fchownat",
4562 int, dfd
, const char *, path
,
4563 vki_uid_t
, owner
, vki_gid_t
, group
);
4564 PRE_MEM_RASCIIZ( "fchownat(path)", ARG2
);
4569 PRINT("sys_futimesat ( %ld, %#lx(%s), %#lx )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
4570 PRE_REG_READ3(long, "futimesat",
4571 int, dfd
, char *, filename
, struct timeval
*, tvp
);
4573 PRE_MEM_RASCIIZ( "futimesat(filename)", ARG2
);
4575 PRE_MEM_READ( "futimesat(tvp)", ARG3
, 2 * sizeof(struct vki_timeval
) );
4580 PRINT("sys_utimensat ( %ld, %#lx(%s), %#lx, 0x%lx )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
);
4581 PRE_REG_READ4(long, "utimensat",
4582 int, dfd
, char *, filename
, struct timespec
*, utimes
, int, flags
);
4584 PRE_MEM_RASCIIZ( "utimensat(filename)", ARG2
);
4586 PRE_MEM_READ( "utimensat(tvp)", ARG3
, 2 * sizeof(struct vki_timespec
) );
4591 FUSE_COMPATIBLE_MAY_BLOCK();
4592 PRINT("sys_newfstatat ( %ld, %#lx(%s), %#lx )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
4593 PRE_REG_READ3(long, "fstatat",
4594 int, dfd
, char *, file_name
, struct stat
*, buf
);
4595 PRE_MEM_RASCIIZ( "fstatat(file_name)", ARG2
);
4596 PRE_MEM_WRITE( "fstatat(buf)", ARG3
, sizeof(struct vki_stat
) );
4599 POST(sys_newfstatat
)
4601 POST_MEM_WRITE( ARG3
, sizeof(struct vki_stat
) );
4606 *flags
|= SfMayBlock
;
4607 PRINT("sys_unlinkat ( %ld, %#lx(%s) )", ARG1
,ARG2
,(char*)ARG2
);
4608 PRE_REG_READ2(long, "unlinkat", int, dfd
, const char *, pathname
);
4609 PRE_MEM_RASCIIZ( "unlinkat(pathname)", ARG2
);
4614 PRINT("sys_renameat ( %ld, %#lx(%s), %ld, %#lx(%s) )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
,(char*)ARG4
);
4615 PRE_REG_READ4(long, "renameat",
4616 int, olddfd
, const char *, oldpath
,
4617 int, newdfd
, const char *, newpath
);
4618 PRE_MEM_RASCIIZ( "renameat(oldpath)", ARG2
);
4619 PRE_MEM_RASCIIZ( "renameat(newpath)", ARG4
);
4624 *flags
|= SfMayBlock
;
4625 PRINT("sys_linkat ( %ld, %#lx(%s), %ld, %#lx(%s), %ld )",ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
,(char*)ARG4
,ARG5
);
4626 PRE_REG_READ5(long, "linkat",
4627 int, olddfd
, const char *, oldpath
,
4628 int, newdfd
, const char *, newpath
,
4630 PRE_MEM_RASCIIZ( "linkat(oldpath)", ARG2
);
4631 PRE_MEM_RASCIIZ( "linkat(newpath)", ARG4
);
4636 *flags
|= SfMayBlock
;
4637 PRINT("sys_symlinkat ( %#lx(%s), %ld, %#lx(%s) )",ARG1
,(char*)ARG1
,ARG2
,ARG3
,(char*)ARG3
);
4638 PRE_REG_READ3(long, "symlinkat",
4639 const char *, oldpath
, int, newdfd
, const char *, newpath
);
4640 PRE_MEM_RASCIIZ( "symlinkat(oldpath)", ARG1
);
4641 PRE_MEM_RASCIIZ( "symlinkat(newpath)", ARG3
);
4646 HChar name
[30]; // large enough
4649 PRINT("sys_readlinkat ( %ld, %#lx(%s), %#lx, %llu )", ARG1
,ARG2
,(char*)ARG2
,ARG3
,(ULong
)ARG4
);
4650 PRE_REG_READ4(long, "readlinkat",
4651 int, dfd
, const char *, path
, char *, buf
, int, bufsiz
);
4652 PRE_MEM_RASCIIZ( "readlinkat(path)", ARG2
);
4653 PRE_MEM_WRITE( "readlinkat(buf)", ARG3
,ARG4
);
4656 * Handle the case where readlinkat is looking at /proc/self/exe or
4659 VG_(sprintf
)(name
, "/proc/%d/exe", VG_(getpid
)());
4660 if (ML_(safe_to_deref
)((void*)ARG2
, 1)
4661 && (VG_(strcmp
)((HChar
*)ARG2
, name
) == 0
4662 || VG_(strcmp
)((HChar
*)ARG2
, "/proc/self/exe") == 0)) {
4663 VG_(sprintf
)(name
, "/proc/self/fd/%d", VG_(cl_exec_fd
));
4664 SET_STATUS_from_SysRes( VG_(do_syscall4
)(saved
, ARG1
, (UWord
)name
,
4668 SET_STATUS_from_SysRes( VG_(do_syscall4
)(saved
, ARG1
, ARG2
, ARG3
, ARG4
));
4671 if (SUCCESS
&& RES
> 0)
4672 POST_MEM_WRITE( ARG3
, RES
);
4677 PRINT("sys_fchmodat ( %ld, %#lx(%s), %ld )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
4678 PRE_REG_READ3(long, "fchmodat",
4679 int, dfd
, const char *, path
, vki_mode_t
, mode
);
4680 PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2
);
4685 PRINT("sys_faccessat ( %ld, %#lx(%s), %ld )", ARG1
,ARG2
,(char*)ARG2
,ARG3
);
4686 PRE_REG_READ3(long, "faccessat",
4687 int, dfd
, const char *, pathname
, int, mode
);
4688 PRE_MEM_RASCIIZ( "faccessat(pathname)", ARG2
);
4691 PRE(sys_name_to_handle_at
)
4693 PRINT("sys_name_to_handle_at ( %ld, %#lx(%s), %#lx, %#lx, %ld )", ARG1
, ARG2
, (char*)ARG2
, ARG3
, ARG4
, ARG5
);
4694 PRE_REG_READ5(int, "name_to_handle_at",
4695 int, dfd
, const char *, name
,
4696 struct vki_file_handle
*, handle
,
4697 int *, mnt_id
, int, flag
);
4698 PRE_MEM_RASCIIZ( "name_to_handle_at(name)", ARG2
);
4699 if (ML_(safe_to_deref
)( (void*)ARG3
, sizeof(struct vki_file_handle
))) {
4700 struct vki_file_handle
*fh
= (struct vki_file_handle
*)ARG3
;
4701 PRE_MEM_READ( "name_to_handle_at(handle)", (Addr
)&fh
->handle_bytes
, sizeof(fh
->handle_bytes
) );
4702 PRE_MEM_WRITE( "name_to_handle_at(handle)", (Addr
)fh
, sizeof(struct vki_file_handle
) + fh
->handle_bytes
);
4704 PRE_MEM_WRITE( "name_to_handle_at(mnt_id)", ARG4
, sizeof(int) );
4707 POST(sys_name_to_handle_at
)
4709 struct vki_file_handle
*fh
= (struct vki_file_handle
*)ARG3
;
4710 POST_MEM_WRITE( ARG3
, sizeof(struct vki_file_handle
) + fh
->handle_bytes
);
4711 POST_MEM_WRITE( ARG4
, sizeof(int) );
4714 PRE(sys_open_by_handle_at
)
4716 *flags
|= SfMayBlock
;
4717 PRINT("sys_open_by_handle_at ( %ld, %#lx, %ld )", ARG1
, ARG2
, ARG3
);
4718 PRE_REG_READ3(int, "open_by_handle_at",
4720 struct vki_file_handle
*, handle
,
4722 PRE_MEM_READ( "open_by_handle_at(handle)", ARG2
, sizeof(struct vki_file_handle
) + ((struct vki_file_handle
*)ARG2
)->handle_bytes
);
4725 POST(sys_open_by_handle_at
)
4728 if (!ML_(fd_allowed
)(RES
, "open_by_handle_at", tid
, True
)) {
4730 SET_STATUS_Failure( VKI_EMFILE
);
4732 if (VG_(clo_track_fds
))
4733 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG2
);
4737 /* ---------------------------------------------------------------------
4738 p{read,write}v wrappers
4739 ------------------------------------------------------------------ */
4744 struct vki_iovec
* vec
;
4745 *flags
|= SfMayBlock
;
4746 #if VG_WORDSIZE == 4
4747 /* Note that the offset argument here is in lo+hi order on both
4748 big and little endian platforms... */
4749 PRINT("sys_preadv ( %ld, %#lx, %llu, %lld )",ARG1
,ARG2
,(ULong
)ARG3
,LOHI64(ARG4
,ARG5
));
4750 PRE_REG_READ5(ssize_t
, "preadv",
4751 unsigned long, fd
, const struct iovec
*, vector
,
4752 unsigned long, count
, vki_u32
, offset_low
,
4753 vki_u32
, offset_high
);
4754 #elif VG_WORDSIZE == 8
4755 PRINT("sys_preadv ( %ld, %#lx, %llu, %lld )",ARG1
,ARG2
,(ULong
)ARG3
,(Long
)ARG4
);
4756 PRE_REG_READ4(ssize_t
, "preadv",
4757 unsigned long, fd
, const struct iovec
*, vector
,
4758 unsigned long, count
, Word
, offset
);
4760 # error Unexpected word size
4762 if (!ML_(fd_allowed
)(ARG1
, "preadv", tid
, False
)) {
4763 SET_STATUS_Failure( VKI_EBADF
);
4765 PRE_MEM_READ( "preadv(vector)", ARG2
, ARG3
* sizeof(struct vki_iovec
) );
4768 /* ToDo: don't do any of the following if the vector is invalid */
4769 vec
= (struct vki_iovec
*)ARG2
;
4770 for (i
= 0; i
< (Int
)ARG3
; i
++)
4771 PRE_MEM_WRITE( "preadv(vector[...])",
4772 (Addr
)vec
[i
].iov_base
, vec
[i
].iov_len
);
4782 struct vki_iovec
* vec
= (struct vki_iovec
*)ARG2
;
4785 /* RES holds the number of bytes read. */
4786 for (i
= 0; i
< (Int
)ARG3
; i
++) {
4787 Int nReadThisBuf
= vec
[i
].iov_len
;
4788 if (nReadThisBuf
> remains
) nReadThisBuf
= remains
;
4789 POST_MEM_WRITE( (Addr
)vec
[i
].iov_base
, nReadThisBuf
);
4790 remains
-= nReadThisBuf
;
4791 if (remains
< 0) VG_(core_panic
)("preadv: remains < 0");
4799 struct vki_iovec
* vec
;
4800 *flags
|= SfMayBlock
;
4801 #if VG_WORDSIZE == 4
4802 /* Note that the offset argument here is in lo+hi order on both
4803 big and little endian platforms... */
4804 PRINT("sys_pwritev ( %ld, %#lx, %llu, %lld )",ARG1
,ARG2
,(ULong
)ARG3
,LOHI64(ARG4
,ARG5
));
4805 PRE_REG_READ5(ssize_t
, "pwritev",
4806 unsigned long, fd
, const struct iovec
*, vector
,
4807 unsigned long, count
, vki_u32
, offset_low
,
4808 vki_u32
, offset_high
);
4809 #elif VG_WORDSIZE == 8
4810 PRINT("sys_pwritev ( %ld, %#lx, %llu, %lld )",ARG1
,ARG2
,(ULong
)ARG3
,(Long
)ARG4
);
4811 PRE_REG_READ4(ssize_t
, "pwritev",
4812 unsigned long, fd
, const struct iovec
*, vector
,
4813 unsigned long, count
, Word
, offset
);
4815 # error Unexpected word size
4817 if (!ML_(fd_allowed
)(ARG1
, "pwritev", tid
, False
)) {
4818 SET_STATUS_Failure( VKI_EBADF
);
4820 PRE_MEM_READ( "pwritev(vector)",
4821 ARG2
, ARG3
* sizeof(struct vki_iovec
) );
4823 /* ToDo: don't do any of the following if the vector is invalid */
4824 vec
= (struct vki_iovec
*)ARG2
;
4825 for (i
= 0; i
< (Int
)ARG3
; i
++)
4826 PRE_MEM_READ( "pwritev(vector[...])",
4827 (Addr
)vec
[i
].iov_base
, vec
[i
].iov_len
);
4832 /* ---------------------------------------------------------------------
4833 process_vm_{read,write}v wrappers
4834 ------------------------------------------------------------------ */
4836 PRE(sys_process_vm_readv
)
4838 PRINT("sys_process_vm_readv ( %lu, %#lx, %lu, %#lx, %lu, %lu )",
4839 ARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
4840 PRE_REG_READ6(ssize_t
, "process_vm_readv",
4842 const struct iovec
*, lvec
,
4843 unsigned long, liovcnt
,
4844 const struct iovec
*, rvec
,
4845 unsigned long, riovcnt
,
4846 unsigned long, flags
);
4847 PRE_MEM_READ( "process_vm_readv(lvec)",
4848 ARG2
, ARG3
* sizeof(struct vki_iovec
) );
4849 PRE_MEM_READ( "process_vm_readv(rvec)",
4850 ARG4
, ARG5
* sizeof(struct vki_iovec
) );
4852 /* TODO: Don't do any of the following if lvec is invalid */
4853 const struct vki_iovec
*vec
= (const struct vki_iovec
*)ARG2
;
4855 for (i
= 0; i
< ARG3
; i
++)
4856 PRE_MEM_WRITE( "process_vm_readv(lvec[...])",
4857 (Addr
)vec
[i
].iov_base
, vec
[i
].iov_len
);
4861 POST(sys_process_vm_readv
)
4863 const struct vki_iovec
*vec
= (const struct vki_iovec
*)ARG2
;
4866 for (i
= 0; i
< ARG3
; i
++) {
4867 UInt nReadThisBuf
= vec
[i
].iov_len
<= remains
?
4868 vec
[i
].iov_len
: remains
;
4869 POST_MEM_WRITE( (Addr
)vec
[i
].iov_base
, nReadThisBuf
);
4870 remains
-= nReadThisBuf
;
4874 PRE(sys_process_vm_writev
)
4876 PRINT("sys_process_vm_writev ( %lu, %#lx, %lu, %#lx, %lu, %lu )",
4877 ARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
4878 PRE_REG_READ6(ssize_t
, "process_vm_writev",
4880 const struct iovec
*, lvec
,
4881 unsigned long, liovcnt
,
4882 const struct iovec
*, rvec
,
4883 unsigned long, riovcnt
,
4884 unsigned long, flags
);
4885 PRE_MEM_READ( "process_vm_writev(lvec)",
4886 ARG2
, ARG3
* sizeof(struct vki_iovec
) );
4887 PRE_MEM_READ( "process_vm_writev(rvec)",
4888 ARG4
, ARG5
* sizeof(struct vki_iovec
) );
4890 /* TODO: Don't do any of the following if lvec is invalid */
4891 const struct vki_iovec
*vec
= (const struct vki_iovec
*)ARG2
;
4893 for (i
= 0; i
< ARG3
; i
++)
4894 PRE_MEM_READ( "process_vm_writev(lvec[...])",
4895 (Addr
)vec
[i
].iov_base
, vec
[i
].iov_len
);
4899 /* ---------------------------------------------------------------------
4900 {send,recv}mmsg wrappers
4901 ------------------------------------------------------------------ */
4905 *flags
|= SfMayBlock
;
4906 PRINT("sys_sendmmsg ( %ld, %#lx, %ld, %ld )",ARG1
,ARG2
,ARG3
,ARG4
);
4907 PRE_REG_READ4(long, "sendmmsg",
4908 int, s
, const struct mmsghdr
*, mmsg
, int, vlen
, int, flags
);
4909 ML_(linux_PRE_sys_sendmmsg
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
4914 ML_(linux_POST_sys_sendmmsg
) (tid
, RES
, ARG1
,ARG2
,ARG3
,ARG4
);
4919 *flags
|= SfMayBlock
;
4920 PRINT("sys_recvmmsg ( %ld, %#lx, %ld, %ld, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4921 PRE_REG_READ5(long, "recvmmsg",
4922 int, s
, struct mmsghdr
*, mmsg
, int, vlen
,
4923 int, flags
, struct timespec
*, timeout
);
4924 ML_(linux_PRE_sys_recvmmsg
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4929 ML_(linux_POST_sys_recvmmsg
) (tid
, RES
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4932 /* ---------------------------------------------------------------------
4933 key retention service wrappers
4934 ------------------------------------------------------------------ */
4936 PRE(sys_request_key
)
4938 PRINT("sys_request_key ( %#lx(%s), %#lx(%s), %#lx(%s), %ld )",
4939 ARG1
,(char*)ARG1
,ARG2
,(char*)ARG2
,ARG3
,(char*)ARG3
,ARG4
);
4940 PRE_REG_READ4(long, "request_key",
4941 const char *, type
, const char *, description
,
4942 const char *, callout_info
, vki_key_serial_t
, keyring
);
4943 PRE_MEM_RASCIIZ( "request_key(type)", ARG1
);
4944 PRE_MEM_RASCIIZ( "request_key(description)", ARG2
);
4945 if (ARG3
!= (UWord
)NULL
)
4946 PRE_MEM_RASCIIZ( "request_key(callout_info)", ARG3
);
4951 PRINT("sys_add_key ( %#lx(%s), %#lx(%s), %#lx, %ld, %ld )",
4952 ARG1
,(char*)ARG1
,ARG2
,(char*)ARG2
,ARG3
,ARG4
,ARG5
);
4953 PRE_REG_READ5(long, "add_key",
4954 const char *, type
, const char *, description
,
4955 const void *, payload
, vki_size_t
, plen
,
4956 vki_key_serial_t
, keyring
);
4957 PRE_MEM_RASCIIZ( "add_key(type)", ARG1
);
4958 PRE_MEM_RASCIIZ( "add_key(description)", ARG2
);
4959 if (ARG3
!= (UWord
)NULL
)
4960 PRE_MEM_READ( "request_key(payload)", ARG3
, ARG4
);
4965 switch (ARG1
/* option */) {
4966 case VKI_KEYCTL_GET_KEYRING_ID
:
4967 PRINT("sys_keyctl ( KEYCTL_GET_KEYRING_ID, %ld, %ld )", ARG2
,ARG3
);
4968 PRE_REG_READ3(long, "keyctl(KEYCTL_GET_KEYRING_ID)",
4969 int, option
, vki_key_serial_t
, id
, int, create
);
4971 case VKI_KEYCTL_JOIN_SESSION_KEYRING
:
4972 PRINT("sys_keyctl ( KEYCTL_JOIN_SESSION_KEYRING, %#lx(%s) )", ARG2
,(char*)ARG2
);
4973 PRE_REG_READ2(long, "keyctl(KEYCTL_JOIN_SESSION_KEYRING)",
4974 int, option
, const char *, name
);
4975 if (ARG2
!= (UWord
)NULL
)
4976 PRE_MEM_RASCIIZ("keyctl(KEYCTL_JOIN_SESSION_KEYRING, name)", ARG2
);
4978 case VKI_KEYCTL_UPDATE
:
4979 PRINT("sys_keyctl ( KEYCTL_UPDATE, %ld, %#lx, %ld )", ARG2
,ARG3
,ARG4
);
4980 PRE_REG_READ4(long, "keyctl(KEYCTL_UPDATE)",
4981 int, option
, vki_key_serial_t
, key
,
4982 const void *, payload
, vki_size_t
, plen
);
4983 if (ARG3
!= (UWord
)NULL
)
4984 PRE_MEM_READ("keyctl(KEYCTL_UPDATE, payload)", ARG3
, ARG4
);
4986 case VKI_KEYCTL_REVOKE
:
4987 PRINT("sys_keyctl ( KEYCTL_REVOKE, %ld )", ARG2
);
4988 PRE_REG_READ2(long, "keyctl(KEYCTL_REVOKE)",
4989 int, option
, vki_key_serial_t
, id
);
4991 case VKI_KEYCTL_CHOWN
:
4992 PRINT("sys_keyctl ( KEYCTL_CHOWN, %ld, %ld, %ld )", ARG2
,ARG3
,ARG4
);
4993 PRE_REG_READ4(long, "keyctl(KEYCTL_CHOWN)",
4994 int, option
, vki_key_serial_t
, id
,
4995 vki_uid_t
, uid
, vki_gid_t
, gid
);
4997 case VKI_KEYCTL_SETPERM
:
4998 PRINT("sys_keyctl ( KEYCTL_SETPERM, %ld, %ld )", ARG2
,ARG3
);
4999 PRE_REG_READ3(long, "keyctl(KEYCTL_SETPERM)",
5000 int, option
, vki_key_serial_t
, id
, vki_key_perm_t
, perm
);
5002 case VKI_KEYCTL_DESCRIBE
:
5003 PRINT("sys_keyctl ( KEYCTL_DESCRIBE, %ld, %#lx, %ld )", ARG2
,ARG3
,ARG4
);
5004 PRE_REG_READ4(long, "keyctl(KEYCTL_DESCRIBE)",
5005 int, option
, vki_key_serial_t
, id
,
5006 char *, buffer
, vki_size_t
, buflen
);
5007 if (ARG3
!= (UWord
)NULL
)
5008 PRE_MEM_WRITE("keyctl(KEYCTL_DESCRIBE, buffer)", ARG3
, ARG4
);
5010 case VKI_KEYCTL_CLEAR
:
5011 PRINT("sys_keyctl ( KEYCTL_CLEAR, %ld )", ARG2
);
5012 PRE_REG_READ2(long, "keyctl(KEYCTL_CLEAR)",
5013 int, option
, vki_key_serial_t
, keyring
);
5015 case VKI_KEYCTL_LINK
:
5016 PRINT("sys_keyctl ( KEYCTL_LINK, %ld, %ld )", ARG2
,ARG3
);
5017 PRE_REG_READ3(long, "keyctl(KEYCTL_LINK)", int, option
,
5018 vki_key_serial_t
, keyring
, vki_key_serial_t
, key
);
5020 case VKI_KEYCTL_UNLINK
:
5021 PRINT("sys_keyctl ( KEYCTL_UNLINK, %ld, %ld )", ARG2
,ARG3
);
5022 PRE_REG_READ3(long, "keyctl(KEYCTL_UNLINK)", int, option
,
5023 vki_key_serial_t
, keyring
, vki_key_serial_t
, key
);
5025 case VKI_KEYCTL_SEARCH
:
5026 PRINT("sys_keyctl ( KEYCTL_SEARCH, %ld, %#lx(%s), %#lx(%s), %ld )",
5027 ARG2
,ARG3
,(char*)ARG3
,ARG4
,(char*)ARG4
,ARG5
);
5028 PRE_REG_READ5(long, "keyctl(KEYCTL_SEARCH)",
5029 int, option
, vki_key_serial_t
, keyring
,
5030 const char *, type
, const char *, description
,
5031 vki_key_serial_t
, destring
);
5032 PRE_MEM_RASCIIZ("sys_keyctl(KEYCTL_SEARCH, type)", ARG3
);
5033 PRE_MEM_RASCIIZ("sys_keyctl(KEYCTL_SEARCH, description)", ARG4
);
5035 case VKI_KEYCTL_READ
:
5036 PRINT("sys_keyctl ( KEYCTL_READ, %ld, %#lx, %ld )", ARG2
,ARG3
,ARG4
);
5037 PRE_REG_READ4(long, "keyctl(KEYCTL_READ)",
5038 int, option
, vki_key_serial_t
, keyring
,
5039 char *, buffer
, vki_size_t
, buflen
);
5040 if (ARG3
!= (UWord
)NULL
)
5041 PRE_MEM_WRITE("keyctl(KEYCTL_READ, buffer)", ARG3
, ARG4
);
5043 case VKI_KEYCTL_INSTANTIATE
:
5044 PRINT("sys_keyctl ( KEYCTL_INSTANTIATE, %ld, %#lx, %ld, %ld )",
5045 ARG2
,ARG3
,ARG4
,ARG5
);
5046 PRE_REG_READ5(long, "keyctl(KEYCTL_INSTANTIATE)",
5047 int, option
, vki_key_serial_t
, key
,
5048 char *, payload
, vki_size_t
, plen
,
5049 vki_key_serial_t
, keyring
);
5050 if (ARG3
!= (UWord
)NULL
)
5051 PRE_MEM_READ("keyctl(KEYCTL_INSTANTIATE, payload)", ARG3
, ARG4
);
5053 case VKI_KEYCTL_NEGATE
:
5054 PRINT("sys_keyctl ( KEYCTL_NEGATE, %ld, %lu, %ld )", ARG2
,ARG3
,ARG4
);
5055 PRE_REG_READ4(long, "keyctl(KEYCTL_NEGATE)",
5056 int, option
, vki_key_serial_t
, key
,
5057 unsigned, timeout
, vki_key_serial_t
, keyring
);
5059 case VKI_KEYCTL_SET_REQKEY_KEYRING
:
5060 PRINT("sys_keyctl ( KEYCTL_SET_REQKEY_KEYRING, %ld )", ARG2
);
5061 PRE_REG_READ2(long, "keyctl(KEYCTL_SET_REQKEY_KEYRING)",
5062 int, option
, int, reqkey_defl
);
5064 case VKI_KEYCTL_SET_TIMEOUT
:
5065 PRINT("sys_keyctl ( KEYCTL_SET_TIMEOUT, %ld, %ld )", ARG2
,ARG3
);
5066 PRE_REG_READ3(long, "keyctl(KEYCTL_SET_TIMEOUT)",
5067 int, option
, vki_key_serial_t
, key
, unsigned, timeout
);
5069 case VKI_KEYCTL_ASSUME_AUTHORITY
:
5070 PRINT("sys_keyctl ( KEYCTL_ASSUME_AUTHORITY, %ld )", ARG2
);
5071 PRE_REG_READ2(long, "keyctl(KEYCTL_ASSUME_AUTHORITY)",
5072 int, option
, vki_key_serial_t
, key
);
5075 PRINT("sys_keyctl ( %ld ) ", ARG1
);
5076 PRE_REG_READ1(long, "keyctl", int, option
);
5084 switch (ARG1
/* option */) {
5085 case VKI_KEYCTL_DESCRIBE
:
5086 case VKI_KEYCTL_READ
:
5088 POST_MEM_WRITE(ARG3
, ARG4
);
5090 POST_MEM_WRITE(ARG3
, RES
);
5097 /* ---------------------------------------------------------------------
5099 ------------------------------------------------------------------ */
5103 PRINT("sys_ioprio_set ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
5104 PRE_REG_READ3(int, "ioprio_set", int, which
, int, who
, int, ioprio
);
5109 PRINT("sys_ioprio_get ( %ld, %ld )", ARG1
,ARG2
);
5110 PRE_REG_READ2(int, "ioprio_get", int, which
, int, who
);
5113 /* ---------------------------------------------------------------------
5115 ------------------------------------------------------------------ */
5117 PRE(sys_init_module
)
5119 *flags
|= SfMayBlock
;
5120 PRINT("sys_init_module ( %#lx, %llu, %#lx(\"%s\") )",
5121 ARG1
, (ULong
)ARG2
, ARG3
, (char*)ARG3
);
5122 PRE_REG_READ3(long, "init_module",
5123 void *, umod
, unsigned long, len
, const char *, uargs
);
5124 PRE_MEM_READ( "init_module(umod)", ARG1
, ARG2
);
5125 PRE_MEM_RASCIIZ( "init_module(uargs)", ARG3
);
5128 PRE(sys_delete_module
)
5130 *flags
|= SfMayBlock
;
5131 PRINT("sys_delete_module ( %#lx(\"%s\"), 0x%lx )", ARG1
,(char*)ARG1
, ARG2
);
5132 PRE_REG_READ2(long, "delete_module",
5133 const char *, name_user
, unsigned int, flags
);
5134 PRE_MEM_RASCIIZ("delete_module(name_user)", ARG1
);
5137 /* ---------------------------------------------------------------------
5139 ------------------------------------------------------------------ */
5143 *flags
|= SfMayBlock
;
5144 PRINT("sys_splice ( %ld, %#lx, %ld, %#lx, %ld, %ld )",
5145 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
5146 PRE_REG_READ6(vki_ssize_t
, "splice",
5147 int, fd_in
, vki_loff_t
*, off_in
,
5148 int, fd_out
, vki_loff_t
*, off_out
,
5149 vki_size_t
, len
, unsigned int, flags
);
5150 if (!ML_(fd_allowed
)(ARG1
, "splice(fd_in)", tid
, False
) ||
5151 !ML_(fd_allowed
)(ARG3
, "splice(fd_out)", tid
, False
)) {
5152 SET_STATUS_Failure( VKI_EBADF
);
5155 PRE_MEM_READ( "splice(off_in)", ARG2
, sizeof(vki_loff_t
));
5157 PRE_MEM_READ( "splice(off_out)", ARG4
, sizeof(vki_loff_t
));
5163 *flags
|= SfMayBlock
;
5164 PRINT("sys_tree ( %ld, %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
,ARG4
);
5165 PRE_REG_READ4(vki_ssize_t
, "tee",
5166 int, fd_in
, int, fd_out
,
5167 vki_size_t
, len
, unsigned int, flags
);
5168 if (!ML_(fd_allowed
)(ARG1
, "tee(fd_in)", tid
, False
) ||
5169 !ML_(fd_allowed
)(ARG2
, "tee(fd_out)", tid
, False
)) {
5170 SET_STATUS_Failure( VKI_EBADF
);
5177 *flags
|= SfMayBlock
;
5178 PRINT("sys_vmsplice ( %ld, %#lx, %ld, %ld )",
5179 ARG1
,ARG2
,ARG3
,ARG4
);
5180 PRE_REG_READ4(vki_ssize_t
, "splice",
5181 int, fd
, struct vki_iovec
*, iov
,
5182 unsigned long, nr_segs
, unsigned int, flags
);
5183 if (!ML_(fd_allowed
)(ARG1
, "vmsplice(fd)", tid
, False
)) {
5184 SET_STATUS_Failure( VKI_EBADF
);
5185 } else if ((fdfl
= VG_(fcntl
)(ARG1
, VKI_F_GETFL
, 0)) < 0) {
5186 SET_STATUS_Failure( VKI_EBADF
);
5188 const struct vki_iovec
*iov
;
5189 PRE_MEM_READ( "vmsplice(iov)", ARG2
, sizeof(struct vki_iovec
) * ARG3
);
5190 for (iov
= (struct vki_iovec
*)ARG2
;
5191 iov
< (struct vki_iovec
*)ARG2
+ ARG3
; iov
++)
5193 if ((fdfl
& VKI_O_ACCMODE
) == VKI_O_RDONLY
)
5194 PRE_MEM_WRITE( "vmsplice(iov[...])", (Addr
)iov
->iov_base
, iov
->iov_len
);
5196 PRE_MEM_READ( "vmsplice(iov[...])", (Addr
)iov
->iov_base
, iov
->iov_len
);
5205 Int fdfl
= VG_(fcntl
)(ARG1
, VKI_F_GETFL
, 0);
5206 vg_assert(fdfl
>= 0);
5207 if ((fdfl
& VKI_O_ACCMODE
) == VKI_O_RDONLY
)
5209 const struct vki_iovec
*iov
;
5210 for (iov
= (struct vki_iovec
*)ARG2
;
5211 iov
< (struct vki_iovec
*)ARG2
+ ARG3
; iov
++)
5213 POST_MEM_WRITE( (Addr
)iov
->iov_base
, iov
->iov_len
);
5219 /* ---------------------------------------------------------------------
5220 oprofile-related wrappers
5221 ------------------------------------------------------------------ */
5223 #if defined(VGP_x86_linux)
5224 PRE(sys_lookup_dcookie
)
5226 PRINT("sys_lookup_dcookie (0x%llx, %#lx, %ld)",
5227 MERGE64(ARG1
,ARG2
), ARG3
, ARG4
);
5228 PRE_REG_READ4(long, "lookup_dcookie",
5229 vki_u32
, MERGE64_FIRST(cookie
), vki_u32
, MERGE64_SECOND(cookie
),
5230 char *, buf
, vki_size_t
, len
);
5231 PRE_MEM_WRITE( "lookup_dcookie(buf)", ARG3
, ARG4
);
5233 POST(sys_lookup_dcookie
)
5236 if (ARG3
!= (Addr
)NULL
)
5237 POST_MEM_WRITE( ARG3
, RES
);
5241 #if defined(VGP_amd64_linux) || defined(VGP_s390x_linux) \
5242 || defined(VGP_tilegx_linux)
5243 PRE(sys_lookup_dcookie
)
5245 *flags
|= SfMayBlock
;
5246 PRINT("sys_lookup_dcookie ( %llu, %#lx, %llu )",
5247 (ULong
)ARG1
, ARG2
, (ULong
)ARG3
);
5248 PRE_REG_READ3(int, "lookup_dcookie",
5249 unsigned long long, cookie
, char *, buf
, vki_size_t
, len
);
5251 PRE_MEM_WRITE( "sys_lookup_dcookie(buf)", ARG2
, ARG3
);
5254 POST(sys_lookup_dcookie
)
5257 if (ARG2
!= (Addr
)NULL
)
5258 POST_MEM_WRITE( ARG2
, RES
);
5262 /* ---------------------------------------------------------------------
5264 ------------------------------------------------------------------ */
5269 // These ones ignore ARG3.
5274 case VKI_F_GETLEASE
:
5275 case VKI_F_GETPIPE_SZ
:
5276 PRINT("sys_fcntl ( %ld, %ld )", ARG1
,ARG2
);
5277 PRE_REG_READ2(long, "fcntl", unsigned int, fd
, unsigned int, cmd
);
5280 // These ones use ARG3 as "arg".
5282 case VKI_F_DUPFD_CLOEXEC
:
5285 case VKI_F_SETLEASE
:
5289 case VKI_F_SETPIPE_SZ
:
5290 PRINT("sys_fcntl[ARG3=='arg'] ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
5291 PRE_REG_READ3(long, "fcntl",
5292 unsigned int, fd
, unsigned int, cmd
, unsigned long, arg
);
5295 // These ones use ARG3 as "lock".
5299 # if defined(VGP_x86_linux) || defined(VGP_mips64_linux)
5302 case VKI_F_SETLKW64
:
5304 case VKI_F_OFD_GETLK
:
5305 case VKI_F_OFD_SETLK
:
5306 case VKI_F_OFD_SETLKW
:
5307 PRINT("sys_fcntl[ARG3=='lock'] ( %ld, %ld, %#lx )", ARG1
,ARG2
,ARG3
);
5308 PRE_REG_READ3(long, "fcntl",
5309 unsigned int, fd
, unsigned int, cmd
,
5310 struct flock64
*, lock
);
5313 case VKI_F_SETOWN_EX
:
5314 PRINT("sys_fcntl[F_SETOWN_EX] ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
5315 PRE_REG_READ3(long, "fcntl",
5316 unsigned int, fd
, unsigned int, cmd
,
5317 struct vki_f_owner_ex
*, arg
);
5318 PRE_MEM_READ("fcntl(F_SETOWN_EX)", ARG3
, sizeof(struct vki_f_owner_ex
));
5321 case VKI_F_GETOWN_EX
:
5322 PRINT("sys_fcntl[F_GETOWN_EX] ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
5323 PRE_REG_READ3(long, "fcntl",
5324 unsigned int, fd
, unsigned int, cmd
,
5325 struct vki_f_owner_ex
*, arg
);
5326 PRE_MEM_WRITE("fcntl(F_GETOWN_EX)", ARG3
, sizeof(struct vki_f_owner_ex
));
5330 PRINT("sys_fcntl[UNKNOWN] ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
5335 # if defined(VGP_x86_linux)
5336 if (ARG2
== VKI_F_SETLKW
|| ARG2
== VKI_F_SETLKW64
)
5338 if (ARG2
== VKI_F_SETLKW
)
5340 *flags
|= SfMayBlock
;
5346 if (ARG2
== VKI_F_DUPFD
) {
5347 if (!ML_(fd_allowed
)(RES
, "fcntl(DUPFD)", tid
, True
)) {
5349 SET_STATUS_Failure( VKI_EMFILE
);
5351 if (VG_(clo_track_fds
))
5352 ML_(record_fd_open_named
)(tid
, RES
);
5355 else if (ARG2
== VKI_F_DUPFD_CLOEXEC
) {
5356 if (!ML_(fd_allowed
)(RES
, "fcntl(DUPFD_CLOEXEC)", tid
, True
)) {
5358 SET_STATUS_Failure( VKI_EMFILE
);
5360 if (VG_(clo_track_fds
))
5361 ML_(record_fd_open_named
)(tid
, RES
);
5363 } else if (ARG2
== VKI_F_GETOWN_EX
) {
5364 POST_MEM_WRITE(ARG3
, sizeof(struct vki_f_owner_ex
));
5368 // XXX: wrapper only suitable for 32-bit systems
5372 // These ones ignore ARG3.
5379 case VKI_F_GETLEASE
:
5380 PRINT("sys_fcntl64 ( %ld, %ld )", ARG1
,ARG2
);
5381 PRE_REG_READ2(long, "fcntl64", unsigned int, fd
, unsigned int, cmd
);
5384 // These ones use ARG3 as "arg".
5386 case VKI_F_DUPFD_CLOEXEC
:
5389 case VKI_F_SETLEASE
:
5391 PRINT("sys_fcntl64[ARG3=='arg'] ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
5392 PRE_REG_READ3(long, "fcntl64",
5393 unsigned int, fd
, unsigned int, cmd
, unsigned long, arg
);
5396 // These ones use ARG3 as "lock".
5400 # if defined(VGP_x86_linux)
5403 case VKI_F_SETLKW64
:
5405 case VKI_F_OFD_GETLK
:
5406 case VKI_F_OFD_SETLK
:
5407 case VKI_F_OFD_SETLKW
:
5408 PRINT("sys_fcntl64[ARG3=='lock'] ( %ld, %ld, %#lx )", ARG1
,ARG2
,ARG3
);
5409 PRE_REG_READ3(long, "fcntl64",
5410 unsigned int, fd
, unsigned int, cmd
,
5411 struct flock64
*, lock
);
5414 case VKI_F_SETOWN_EX
:
5415 PRINT("sys_fcntl[F_SETOWN_EX] ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
5416 PRE_REG_READ3(long, "fcntl",
5417 unsigned int, fd
, unsigned int, cmd
,
5418 struct vki_f_owner_ex
*, arg
);
5419 PRE_MEM_READ("fcntl(F_SETOWN_EX)", ARG3
, sizeof(struct vki_f_owner_ex
));
5422 case VKI_F_GETOWN_EX
:
5423 PRINT("sys_fcntl[F_GETOWN_EX] ( %ld, %ld, %ld )", ARG1
,ARG2
,ARG3
);
5424 PRE_REG_READ3(long, "fcntl",
5425 unsigned int, fd
, unsigned int, cmd
,
5426 struct vki_f_owner_ex
*, arg
);
5427 PRE_MEM_WRITE("fcntl(F_GETOWN_EX)", ARG3
, sizeof(struct vki_f_owner_ex
));
5431 # if defined(VGP_x86_linux)
5432 if (ARG2
== VKI_F_SETLKW
|| ARG2
== VKI_F_SETLKW64
)
5434 if (ARG2
== VKI_F_SETLKW
)
5436 *flags
|= SfMayBlock
;
5442 if (ARG2
== VKI_F_DUPFD
) {
5443 if (!ML_(fd_allowed
)(RES
, "fcntl64(DUPFD)", tid
, True
)) {
5445 SET_STATUS_Failure( VKI_EMFILE
);
5447 if (VG_(clo_track_fds
))
5448 ML_(record_fd_open_named
)(tid
, RES
);
5451 else if (ARG2
== VKI_F_DUPFD_CLOEXEC
) {
5452 if (!ML_(fd_allowed
)(RES
, "fcntl64(DUPFD_CLOEXEC)", tid
, True
)) {
5454 SET_STATUS_Failure( VKI_EMFILE
);
5456 if (VG_(clo_track_fds
))
5457 ML_(record_fd_open_named
)(tid
, RES
);
5459 } else if (ARG2
== VKI_F_GETOWN_EX
) {
5460 POST_MEM_WRITE(ARG3
, sizeof(struct vki_f_owner_ex
));
5464 /* ---------------------------------------------------------------------
5466 ------------------------------------------------------------------ */
5470 *flags
|= SfMayBlock
;
5474 // We first handle the ones that don't use ARG3 (even as a
5475 // scalar/non-pointer argument).
5476 switch (ARG2
/* request */) {
5478 /* asm-generic/ioctls.h */
5483 /* linux/soundcard interface (ALSA) */
5484 case VKI_SNDRV_PCM_IOCTL_HW_FREE
:
5485 case VKI_SNDRV_PCM_IOCTL_HWSYNC
:
5486 case VKI_SNDRV_PCM_IOCTL_PREPARE
:
5487 case VKI_SNDRV_PCM_IOCTL_RESET
:
5488 case VKI_SNDRV_PCM_IOCTL_START
:
5489 case VKI_SNDRV_PCM_IOCTL_DROP
:
5490 case VKI_SNDRV_PCM_IOCTL_DRAIN
:
5491 case VKI_SNDRV_PCM_IOCTL_RESUME
:
5492 case VKI_SNDRV_PCM_IOCTL_XRUN
:
5493 case VKI_SNDRV_PCM_IOCTL_UNLINK
:
5494 case VKI_SNDRV_TIMER_IOCTL_START
:
5495 case VKI_SNDRV_TIMER_IOCTL_STOP
:
5496 case VKI_SNDRV_TIMER_IOCTL_CONTINUE
:
5497 case VKI_SNDRV_TIMER_IOCTL_PAUSE
:
5499 /* SCSI no operand */
5500 case VKI_SCSI_IOCTL_DOORLOCK
:
5501 case VKI_SCSI_IOCTL_DOORUNLOCK
:
5504 case VKI_CDROM_DISC_STATUS
:
5506 /* KVM ioctls that dont check for a numeric value as parameter */
5507 case VKI_KVM_S390_ENABLE_SIE
:
5508 case VKI_KVM_CREATE_IRQCHIP
:
5509 case VKI_KVM_S390_INITIAL_RESET
:
5510 case VKI_KVM_KVMCLOCK_CTRL
:
5512 /* vhost without parameter */
5513 case VKI_VHOST_SET_OWNER
:
5514 case VKI_VHOST_RESET_OWNER
:
5516 /* User input device creation */
5517 case VKI_UI_DEV_CREATE
:
5518 case VKI_UI_DEV_DESTROY
:
5521 case VKI_IB_USER_MAD_ENABLE_PKEY
:
5524 case VKI_V4L2_LOG_STATUS
:
5525 PRINT("sys_ioctl ( %ld, 0x%lx )",ARG1
,ARG2
);
5526 PRE_REG_READ2(long, "ioctl",
5527 unsigned int, fd
, unsigned int, request
);
5531 PRINT("sys_ioctl ( %ld, 0x%lx, 0x%lx )",ARG1
,ARG2
,ARG3
);
5532 PRE_REG_READ3(long, "ioctl",
5533 unsigned int, fd
, unsigned int, request
, unsigned long, arg
);
5537 // We now handle those that do look at ARG3 (and unknown ones fall into
5538 // this category). Nb: some of these may well belong in the
5539 // doesn't-use-ARG3 switch above.
5540 switch (ARG2
/* request */) {
5542 case VKI_ION_IOC_ALLOC
: {
5543 struct vki_ion_allocation_data
* data
5544 = (struct vki_ion_allocation_data
*)ARG3
;
5545 PRE_FIELD_READ ("ioctl(ION_IOC_ALLOC).len", data
->len
);
5546 PRE_FIELD_READ ("ioctl(ION_IOC_ALLOC).align", data
->align
);
5547 PRE_FIELD_READ ("ioctl(ION_IOC_ALLOC).heap_id_mask", data
->heap_id_mask
);
5548 PRE_FIELD_READ ("ioctl(ION_IOC_ALLOC).flags", data
->flags
);
5549 PRE_FIELD_WRITE("ioctl(ION_IOC_ALLOC).handle", data
->handle
);
5552 case VKI_ION_IOC_MAP
: {
5553 struct vki_ion_fd_data
* data
= (struct vki_ion_fd_data
*)ARG3
;
5554 PRE_FIELD_READ ("ioctl(ION_IOC_MAP).handle", data
->handle
);
5555 PRE_FIELD_WRITE("ioctl(ION_IOC_MAP).fd", data
->fd
);
5558 case VKI_ION_IOC_IMPORT
: {
5559 struct vki_ion_fd_data
* data
= (struct vki_ion_fd_data
*)ARG3
;
5560 PRE_FIELD_READ ("ioctl(ION_IOC_IMPORT).fd", data
->fd
);
5561 PRE_FIELD_WRITE("ioctl(ION_IOC_IMPORT).handle", data
->handle
);
5565 case VKI_SYNC_IOC_MERGE
: {
5566 struct vki_sync_merge_data
* data
= (struct vki_sync_merge_data
*)ARG3
;
5567 PRE_FIELD_READ ("ioctl(SYNC_IOC_MERGE).fd2", data
->fd2
);
5568 PRE_MEM_RASCIIZ("ioctl(SYNC_IOC_MERGE).name", (Addr
)(&data
->name
[0]));
5569 PRE_FIELD_WRITE("ioctl(SYNC_IOC_MERGE).fence", data
->fence
);
5576 PRE_MEM_READ( "ioctl(TCSET{S,SW,SF})", ARG3
, sizeof(struct vki_termios
) );
5579 PRE_MEM_WRITE( "ioctl(TCGETS)", ARG3
, sizeof(struct vki_termios
) );
5584 PRE_MEM_READ( "ioctl(TCSET{A,AW,AF})", ARG3
, sizeof(struct vki_termio
) );
5587 PRE_MEM_WRITE( "ioctl(TCGETA)", ARG3
, sizeof(struct vki_termio
) );
5594 /* These just take an int by value */
5596 case VKI_TIOCGWINSZ
:
5597 PRE_MEM_WRITE( "ioctl(TIOCGWINSZ)", ARG3
, sizeof(struct vki_winsize
) );
5599 case VKI_TIOCSWINSZ
:
5600 PRE_MEM_READ( "ioctl(TIOCSWINSZ)", ARG3
, sizeof(struct vki_winsize
) );
5603 PRE_MEM_READ( "ioctl(TIOCMBIS)", ARG3
, sizeof(unsigned int) );
5606 PRE_MEM_READ( "ioctl(TIOCMBIC)", ARG3
, sizeof(unsigned int) );
5609 PRE_MEM_READ( "ioctl(TIOCMSET)", ARG3
, sizeof(unsigned int) );
5612 PRE_MEM_WRITE( "ioctl(TIOCMGET)", ARG3
, sizeof(unsigned int) );
5615 PRE_MEM_READ( "ioctl(TIOCLINUX)", ARG3
, sizeof(char *) );
5616 if (*(char *)ARG3
== 11) {
5617 PRE_MEM_READ( "ioctl(TIOCLINUX, 11)", ARG3
, 2 * sizeof(char *) );
5621 /* Get process group ID for foreground processing group. */
5622 PRE_MEM_WRITE( "ioctl(TIOCGPGRP)", ARG3
, sizeof(vki_pid_t
) );
5625 /* Set a process group ID? */
5626 PRE_MEM_WRITE( "ioctl(TIOCGPGRP)", ARG3
, sizeof(vki_pid_t
) );
5628 case VKI_TIOCGPTN
: /* Get Pty Number (of pty-mux device) */
5629 PRE_MEM_WRITE( "ioctl(TIOCGPTN)", ARG3
, sizeof(int) );
5632 /* Just takes an int value. */
5634 case VKI_TIOCSPTLCK
: /* Lock/unlock Pty */
5635 PRE_MEM_READ( "ioctl(TIOCSPTLCK)", ARG3
, sizeof(int) );
5638 PRE_MEM_READ( "ioctl(FIONBIO)", ARG3
, sizeof(int) );
5641 PRE_MEM_READ( "ioctl(FIOASYNC)", ARG3
, sizeof(int) );
5643 case VKI_FIONREAD
: /* identical to SIOCINQ */
5644 PRE_MEM_WRITE( "ioctl(FIONREAD)", ARG3
, sizeof(int) );
5647 PRE_MEM_WRITE( "ioctl(FIOQSIZE)", ARG3
, sizeof(vki_loff_t
) );
5650 case VKI_TIOCSERGETLSR
:
5651 PRE_MEM_WRITE( "ioctl(TIOCSERGETLSR)", ARG3
, sizeof(int) );
5653 case VKI_TIOCGICOUNT
:
5654 PRE_MEM_WRITE( "ioctl(TIOCGICOUNT)", ARG3
,
5655 sizeof(struct vki_serial_icounter_struct
) );
5658 case VKI_SG_SET_COMMAND_Q
:
5659 PRE_MEM_READ( "ioctl(SG_SET_COMMAND_Q)", ARG3
, sizeof(int) );
5662 PRE_MEM_READ( "ioctl(SG_IO)", ARG3
, sizeof(vki_sg_io_hdr_t
) );
5664 vki_sg_io_hdr_t
*sgio
= (vki_sg_io_hdr_t
*)ARG3
;
5665 PRE_MEM_READ( "ioctl(SG_IO)", (Addr
)sgio
->cmdp
, sgio
->cmd_len
);
5666 if ( sgio
->dxfer_direction
== VKI_SG_DXFER_TO_DEV
||
5667 sgio
->dxfer_direction
== VKI_SG_DXFER_TO_FROM_DEV
) {
5668 PRE_MEM_READ( "ioctl(SG_IO)", (Addr
)sgio
->dxferp
, sgio
->dxfer_len
);
5672 case VKI_SG_GET_SCSI_ID
:
5673 PRE_MEM_WRITE( "ioctl(SG_GET_SCSI_ID)", ARG3
, sizeof(vki_sg_scsi_id_t
) );
5675 case VKI_SG_SET_RESERVED_SIZE
:
5676 PRE_MEM_READ( "ioctl(SG_SET_RESERVED_SIZE)", ARG3
, sizeof(int) );
5678 case VKI_SG_SET_TIMEOUT
:
5679 PRE_MEM_READ( "ioctl(SG_SET_TIMEOUT)", ARG3
, sizeof(int) );
5681 case VKI_SG_GET_RESERVED_SIZE
:
5682 PRE_MEM_WRITE( "ioctl(SG_GET_RESERVED_SIZE)", ARG3
, sizeof(int) );
5684 case VKI_SG_GET_TIMEOUT
:
5686 case VKI_SG_GET_VERSION_NUM
:
5687 PRE_MEM_WRITE( "ioctl(SG_GET_VERSION_NUM)", ARG3
, sizeof(int) );
5689 case VKI_SG_EMULATED_HOST
: /* 0x2203 */
5690 PRE_MEM_WRITE( "ioctl(SG_EMULATED_HOST)", ARG3
, sizeof(int) );
5692 case VKI_SG_GET_SG_TABLESIZE
: /* 0x227f */
5693 PRE_MEM_WRITE( "ioctl(SG_GET_SG_TABLESIZE)", ARG3
, sizeof(int) );
5696 case VKI_IIOCGETCPS
:
5697 PRE_MEM_WRITE( "ioctl(IIOCGETCPS)", ARG3
,
5698 VKI_ISDN_MAX_CHANNELS
* 2 * sizeof(unsigned long) );
5700 case VKI_IIOCNETGPN
:
5701 PRE_MEM_READ( "ioctl(IIOCNETGPN)",
5702 (Addr
)&((vki_isdn_net_ioctl_phone
*)ARG3
)->name
,
5703 sizeof(((vki_isdn_net_ioctl_phone
*)ARG3
)->name
) );
5704 PRE_MEM_WRITE( "ioctl(IIOCNETGPN)", ARG3
,
5705 sizeof(vki_isdn_net_ioctl_phone
) );
5708 /* These all use struct ifreq AFAIK */
5709 case VKI_SIOCGIFINDEX
: /* get iface index */
5710 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFINDEX)",
5711 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5712 PRE_MEM_WRITE( "ioctl(SIOCGIFINDEX)", ARG3
, sizeof(struct vki_ifreq
));
5714 case VKI_SIOCGIFFLAGS
: /* get flags */
5715 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFFLAGS)",
5716 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5717 PRE_MEM_WRITE( "ioctl(SIOCGIFFLAGS)", ARG3
, sizeof(struct vki_ifreq
));
5719 case VKI_SIOCGIFHWADDR
: /* Get hardware address */
5720 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFHWADDR)",
5721 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5722 PRE_MEM_WRITE( "ioctl(SIOCGIFHWADDR)", ARG3
, sizeof(struct vki_ifreq
));
5724 case VKI_SIOCGIFMTU
: /* get MTU size */
5725 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMTU)",
5726 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5727 PRE_MEM_WRITE( "ioctl(SIOCGIFMTU)", ARG3
, sizeof(struct vki_ifreq
));
5729 case VKI_SIOCGIFADDR
: /* get PA address */
5730 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFADDR)",
5731 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5732 PRE_MEM_WRITE( "ioctl(SIOCGIFADDR)", ARG3
, sizeof(struct vki_ifreq
));
5734 case VKI_SIOCGIFNETMASK
: /* get network PA mask */
5735 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFNETMASK)",
5736 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5737 PRE_MEM_WRITE( "ioctl(SIOCGIFNETMASK)", ARG3
, sizeof(struct vki_ifreq
));
5739 case VKI_SIOCGIFMETRIC
: /* get metric */
5740 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMETRIC)",
5741 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5742 PRE_MEM_WRITE( "ioctl(SIOCGIFMETRIC)", ARG3
, sizeof(struct vki_ifreq
));
5744 case VKI_SIOCGIFMAP
: /* Get device parameters */
5745 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMAP)",
5746 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5747 PRE_MEM_WRITE( "ioctl(SIOCGIFMAP)", ARG3
, sizeof(struct vki_ifreq
));
5749 case VKI_SIOCGIFTXQLEN
: /* Get the tx queue length */
5750 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFTXQLEN)",
5751 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5752 PRE_MEM_WRITE( "ioctl(SIOCGIFTXQLEN)", ARG3
, sizeof(struct vki_ifreq
));
5754 case VKI_SIOCGIFDSTADDR
: /* get remote PA address */
5755 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFDSTADDR)",
5756 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5757 PRE_MEM_WRITE( "ioctl(SIOCGIFDSTADDR)", ARG3
, sizeof(struct vki_ifreq
));
5759 case VKI_SIOCGIFBRDADDR
: /* get broadcast PA address */
5760 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFBRDADDR)",
5761 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5762 PRE_MEM_WRITE( "ioctl(SIOCGIFBRDADDR)", ARG3
, sizeof(struct vki_ifreq
));
5764 case VKI_SIOCGIFNAME
: /* get iface name */
5765 PRE_MEM_READ( "ioctl(SIOCGIFNAME)",
5766 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_ifindex
,
5767 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_ifindex
) );
5768 PRE_MEM_WRITE( "ioctl(SIOCGIFNAME)", ARG3
, sizeof(struct vki_ifreq
));
5770 case VKI_SIOCETHTOOL
: { /* ethtool(8) interface */
5771 struct vki_ifreq
*ir
= (struct vki_ifreq
*)ARG3
;
5772 PRE_MEM_READ( "ioctl(SIOCETHTOOL)", (Addr
)ir
, sizeof(struct vki_ifreq
) );
5773 PRE_MEM_RASCIIZ( "ioctl(SIOCETHTOOL)", (Addr
)ir
->vki_ifr_name
);
5774 PRE_MEM_READ( "ioctl(SIOCETHTOOL)", (Addr
)ir
->vki_ifr_data
, sizeof(vki_u32
) );
5775 PRINT("SIOCETHTOOL( 0x%x )", *(vki_u32
*)ir
->vki_ifr_data
);
5776 switch ( *(vki_u32
*)ir
->vki_ifr_data
) {
5777 case VKI_ETHTOOL_GSET
:
5778 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GSET)",
5779 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_cmd
) );
5781 case VKI_ETHTOOL_SSET
:
5782 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SSET)",
5783 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_cmd
) );
5785 case VKI_ETHTOOL_GDRVINFO
:
5786 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GDRVINFO)",
5787 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_drvinfo
) );
5789 case VKI_ETHTOOL_GREGS
:
5790 PRE_MEM_READ( "ioctl(SIOCETHTOOL,GREGS)",
5791 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_regs
) );
5792 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GREGS)",
5793 (Addr
)((struct vki_ethtool_regs
*)ir
->vki_ifr_data
)->data
,
5794 ((struct vki_ethtool_regs
*)ir
->vki_ifr_data
)->len
);
5796 case VKI_ETHTOOL_GWOL
:
5797 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GWOL)",
5798 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_wolinfo
) );
5800 case VKI_ETHTOOL_SWOL
:
5801 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SWOL)",
5802 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_wolinfo
) );
5804 case VKI_ETHTOOL_GMSGLVL
:
5805 case VKI_ETHTOOL_GLINK
:
5806 case VKI_ETHTOOL_GRXCSUM
:
5807 case VKI_ETHTOOL_GSG
:
5808 case VKI_ETHTOOL_GTSO
:
5809 case VKI_ETHTOOL_GUFO
:
5810 case VKI_ETHTOOL_GGSO
:
5811 case VKI_ETHTOOL_GFLAGS
:
5812 case VKI_ETHTOOL_GGRO
:
5813 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,Gvalue)",
5814 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_value
) );
5816 case VKI_ETHTOOL_SMSGLVL
:
5817 case VKI_ETHTOOL_SRXCSUM
:
5818 case VKI_ETHTOOL_SSG
:
5819 case VKI_ETHTOOL_STSO
:
5820 case VKI_ETHTOOL_SUFO
:
5821 case VKI_ETHTOOL_SGSO
:
5822 case VKI_ETHTOOL_SFLAGS
:
5823 case VKI_ETHTOOL_SGRO
:
5824 PRE_MEM_READ( "ioctl(SIOCETHTOOL,Svalue)",
5825 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_value
) );
5827 case VKI_ETHTOOL_NWAY_RST
:
5829 case VKI_ETHTOOL_GRINGPARAM
:
5830 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GRINGPARAM)",
5831 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ringparam
) );
5833 case VKI_ETHTOOL_SRINGPARAM
:
5834 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SRINGPARAM)",
5835 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ringparam
) );
5837 case VKI_ETHTOOL_TEST
:
5838 PRE_MEM_READ( "ioctl(SIOCETHTOOL,TEST)",
5839 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_test
) );
5840 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,TEST)",
5841 (Addr
)((struct vki_ethtool_test
*)ir
->vki_ifr_data
)->data
,
5842 ((struct vki_ethtool_test
*)ir
->vki_ifr_data
)->len
* sizeof(__vki_u64
) );
5844 case VKI_ETHTOOL_PHYS_ID
:
5846 case VKI_ETHTOOL_GPERMADDR
:
5847 PRE_MEM_READ( "ioctl(SIOCETHTOOL,GPERMADDR)",
5848 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_perm_addr
) );
5849 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GPERMADDR)",
5850 (Addr
)((struct vki_ethtool_perm_addr
*)ir
->vki_ifr_data
)->data
,
5851 ((struct vki_ethtool_perm_addr
*)ir
->vki_ifr_data
)->size
);
5853 case VKI_ETHTOOL_RESET
:
5855 case VKI_ETHTOOL_GSSET_INFO
:
5856 PRE_MEM_READ( "ioctl(SIOCETHTOOL,GSSET_INFO)",
5857 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_sset_info
) );
5858 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GSSET_INFO)",
5859 (Addr
)((struct vki_ethtool_sset_info
*)ir
->vki_ifr_data
)->data
,
5860 __builtin_popcountll(((struct vki_ethtool_sset_info
*)ir
->vki_ifr_data
)->sset_mask
) * sizeof(__vki_u32
) );
5862 case VKI_ETHTOOL_GFEATURES
:
5863 PRE_MEM_READ( "ioctl(SIOCETHTOOL,GFEATURES)",
5864 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_gfeatures
) );
5865 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GFEATURES)",
5866 (Addr
)((struct vki_ethtool_gfeatures
*)ir
->vki_ifr_data
)->features
,
5867 ((struct vki_ethtool_gfeatures
*)ir
->vki_ifr_data
)->size
* sizeof(struct vki_ethtool_get_features_block
) );
5869 case VKI_ETHTOOL_SFEATURES
:
5870 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SFEATURES)",
5871 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_sfeatures
) );
5872 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SFEATURES)",
5873 (Addr
)((struct vki_ethtool_sfeatures
*)ir
->vki_ifr_data
)->features
,
5874 ((struct vki_ethtool_sfeatures
*)ir
->vki_ifr_data
)->size
* sizeof(struct vki_ethtool_set_features_block
) );
5876 case VKI_ETHTOOL_GCHANNELS
:
5877 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GCHANNELS)",
5878 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_channels
) );
5880 case VKI_ETHTOOL_SCHANNELS
:
5881 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SCHANNELS)",
5882 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_channels
) );
5884 case VKI_ETHTOOL_GET_TS_INFO
:
5885 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GET_TS_INFO)",
5886 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ts_info
) );
5891 case VKI_SIOCGMIIPHY
: /* get hardware entry */
5892 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMIIPHY)",
5893 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5894 PRE_MEM_WRITE( "ioctl(SIOCGIFMIIPHY)", ARG3
, sizeof(struct vki_ifreq
));
5896 case VKI_SIOCGMIIREG
: /* get hardware entry registers */
5897 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMIIREG)",
5898 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5899 PRE_MEM_READ( "ioctl(SIOCGIFMIIREG)",
5900 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
,
5901 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
) );
5902 PRE_MEM_READ( "ioctl(SIOCGIFMIIREG)",
5903 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->reg_num
,
5904 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->reg_num
) );
5905 PRE_MEM_WRITE( "ioctl(SIOCGIFMIIREG)", ARG3
,
5906 sizeof(struct vki_ifreq
));
5908 case VKI_SIOCGIFCONF
: /* get iface list */
5910 PRE_MEM_WRITE( "ioctl(SIOCGIFCONF)", ARG3, sizeof(struct ifconf));
5911 KERNEL_DO_SYSCALL(tid,RES);
5912 if (!VG_(is_kerror)(RES) && RES == 0)
5913 POST_MEM_WRITE(ARG3, sizeof(struct ifconf));
5915 PRE_MEM_READ( "ioctl(SIOCGIFCONF)",
5916 (Addr
)&((struct vki_ifconf
*)ARG3
)->ifc_len
,
5917 sizeof(((struct vki_ifconf
*)ARG3
)->ifc_len
));
5918 PRE_MEM_READ( "ioctl(SIOCGIFCONF)",
5919 (Addr
)&((struct vki_ifconf
*)ARG3
)->vki_ifc_buf
,
5920 sizeof(((struct vki_ifconf
*)ARG3
)->vki_ifc_buf
));
5922 // TODO len must be readable and writable
5923 // buf pointer only needs to be readable
5924 struct vki_ifconf
*ifc
= (struct vki_ifconf
*) ARG3
;
5925 PRE_MEM_WRITE( "ioctl(SIOCGIFCONF).ifc_buf",
5926 (Addr
)(ifc
->vki_ifc_buf
), ifc
->ifc_len
);
5929 case VKI_SIOCGSTAMP
:
5930 PRE_MEM_WRITE( "ioctl(SIOCGSTAMP)", ARG3
, sizeof(struct vki_timeval
));
5932 case VKI_SIOCGSTAMPNS
:
5933 PRE_MEM_WRITE( "ioctl(SIOCGSTAMPNS)", ARG3
, sizeof(struct vki_timespec
));
5935 /* SIOCOUTQ is an ioctl that, when called on a socket, returns
5936 the number of bytes currently in that socket's send buffer.
5937 It writes this value as an int to the memory location
5938 indicated by the third argument of ioctl(2). */
5940 PRE_MEM_WRITE( "ioctl(SIOCOUTQ)", ARG3
, sizeof(int));
5942 case VKI_SIOCGRARP
: /* get RARP table entry */
5943 case VKI_SIOCGARP
: /* get ARP table entry */
5944 PRE_MEM_WRITE( "ioctl(SIOCGARP)", ARG3
, sizeof(struct vki_arpreq
));
5947 case VKI_SIOCSIFFLAGS
: /* set flags */
5948 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFFLAGS)",
5949 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5950 PRE_MEM_READ( "ioctl(SIOCSIFFLAGS)",
5951 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
5952 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
5954 case VKI_SIOCSIFMAP
: /* Set device parameters */
5955 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFMAP)",
5956 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5957 PRE_MEM_READ( "ioctl(SIOCSIFMAP)",
5958 (Addr
)&((struct vki_ifreq
*)ARG3
)->ifr_map
,
5959 sizeof(((struct vki_ifreq
*)ARG3
)->ifr_map
) );
5961 case VKI_SIOCSHWTSTAMP
: /* Set hardware time stamping */
5962 PRE_MEM_RASCIIZ( "ioctl(SIOCSHWTSTAMP)",
5963 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5964 PRE_MEM_READ( "ioctl(SIOCSHWTSTAMP)",
5965 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_data
,
5966 sizeof(struct vki_hwtstamp_config
) );
5968 case VKI_SIOCSIFTXQLEN
: /* Set the tx queue length */
5969 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFTXQLEN)",
5970 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5971 PRE_MEM_READ( "ioctl(SIOCSIFTXQLEN)",
5972 (Addr
)&((struct vki_ifreq
*)ARG3
)->ifr_qlen
,
5973 sizeof(((struct vki_ifreq
*)ARG3
)->ifr_qlen
) );
5975 case VKI_SIOCSIFADDR
: /* set PA address */
5976 case VKI_SIOCSIFDSTADDR
: /* set remote PA address */
5977 case VKI_SIOCSIFBRDADDR
: /* set broadcast PA address */
5978 case VKI_SIOCSIFNETMASK
: /* set network PA mask */
5979 PRE_MEM_RASCIIZ( "ioctl(SIOCSIF*ADDR)",
5980 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5981 PRE_MEM_READ( "ioctl(SIOCSIF*ADDR)",
5982 (Addr
)&((struct vki_ifreq
*)ARG3
)->ifr_addr
,
5983 sizeof(((struct vki_ifreq
*)ARG3
)->ifr_addr
) );
5985 case VKI_SIOCSIFMETRIC
: /* set metric */
5986 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFMETRIC)",
5987 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5988 PRE_MEM_READ( "ioctl(SIOCSIFMETRIC)",
5989 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_metric
,
5990 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_metric
) );
5992 case VKI_SIOCSIFMTU
: /* set MTU size */
5993 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFMTU)",
5994 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
5995 PRE_MEM_READ( "ioctl(SIOCSIFMTU)",
5996 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_mtu
,
5997 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_mtu
) );
5999 case VKI_SIOCSIFHWADDR
: /* set hardware address */
6000 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFHWADDR)",
6001 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6002 PRE_MEM_READ( "ioctl(SIOCSIFHWADDR)",
6003 (Addr
)&((struct vki_ifreq
*)ARG3
)->ifr_hwaddr
,
6004 sizeof(((struct vki_ifreq
*)ARG3
)->ifr_hwaddr
) );
6006 case VKI_SIOCSMIIREG
: /* set hardware entry registers */
6007 PRE_MEM_RASCIIZ( "ioctl(SIOCSMIIREG)",
6008 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6009 PRE_MEM_READ( "ioctl(SIOCSMIIREG)",
6010 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
,
6011 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
) );
6012 PRE_MEM_READ( "ioctl(SIOCSMIIREG)",
6013 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->reg_num
,
6014 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->reg_num
) );
6015 PRE_MEM_READ( "ioctl(SIOCSMIIREG)",
6016 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->val_in
,
6017 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->val_in
) );
6019 /* Routing table calls. */
6020 case VKI_SIOCADDRT
: /* add routing table entry */
6021 case VKI_SIOCDELRT
: /* delete routing table entry */
6022 PRE_MEM_READ( "ioctl(SIOCADDRT/DELRT)", ARG3
,
6023 sizeof(struct vki_rtentry
));
6026 /* tun/tap related ioctls */
6027 case VKI_TUNSETNOCSUM
:
6028 case VKI_TUNSETDEBUG
:
6031 PRE_MEM_RASCIIZ( "ioctl(TUNSETIFF)",
6032 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6033 PRE_MEM_READ( "ioctl(TUNSETIFF)",
6034 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
6035 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
6036 PRE_MEM_WRITE( "ioctl(TUNSETIFF)", ARG3
, sizeof(struct vki_ifreq
) );
6038 case VKI_TUNSETPERSIST
:
6039 case VKI_TUNSETOWNER
:
6040 case VKI_TUNSETLINK
:
6041 case VKI_TUNSETGROUP
:
6043 case VKI_TUNGETFEATURES
:
6044 PRE_MEM_WRITE( "ioctl(TUNGETFEATURES)", ARG3
, sizeof(unsigned int) );
6046 case VKI_TUNSETOFFLOAD
:
6049 PRE_MEM_WRITE( "ioctl(TUNGETIFF)", ARG3
, sizeof(struct vki_ifreq
) );
6051 case VKI_TUNGETSNDBUF
:
6052 PRE_MEM_WRITE( "ioctl(TUNGETSNDBUF)", ARG3
, sizeof(int) );
6054 case VKI_TUNSETSNDBUF
:
6055 PRE_MEM_READ( "ioctl(TUNSETSNDBUF)", ARG3
, sizeof(int) );
6057 case VKI_TUNGETVNETHDRSZ
:
6058 PRE_MEM_WRITE( "ioctl(TUNGETVNETHDRSZ)", ARG3
, sizeof(int) );
6060 case VKI_TUNSETVNETHDRSZ
:
6061 PRE_MEM_READ( "ioctl(TUNSETVNETHDRSZ)", ARG3
, sizeof(int) );
6063 case VKI_TUNSETQUEUE
:
6064 PRE_MEM_READ( "ioctl(TUNSETQUEUE)",
6065 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
6066 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
6068 case VKI_TUNSETIFINDEX
:
6069 PRE_MEM_READ( "ioctl(TUNSETIFINDEX)", ARG3
, sizeof(unsigned int));
6072 /* RARP cache control calls. */
6073 case VKI_SIOCDRARP
: /* delete RARP table entry */
6074 case VKI_SIOCSRARP
: /* set RARP table entry */
6075 /* ARP cache control calls. */
6076 case VKI_SIOCSARP
: /* set ARP table entry */
6077 case VKI_SIOCDARP
: /* delete ARP table entry */
6078 PRE_MEM_READ( "ioctl(SIOCSIFFLAGS)", ARG3
, sizeof(struct vki_ifreq
));
6082 PRE_MEM_WRITE( "ioctl(SIOCGPGRP)", ARG3
, sizeof(int) );
6085 PRE_MEM_READ( "ioctl(SIOCSPGRP)", ARG3
, sizeof(int) );
6086 //tst->sys_flags &= ~SfMayBlock;
6089 case VKI_SIOCATMARK
:
6090 PRE_MEM_READ( "ioctl(SIOCATMARK)", ARG3
, sizeof(int) );
6093 /* linux/soundcard interface (OSS) */
6094 case VKI_SNDCTL_SEQ_GETOUTCOUNT
:
6095 case VKI_SNDCTL_SEQ_GETINCOUNT
:
6096 case VKI_SNDCTL_SEQ_PERCMODE
:
6097 case VKI_SNDCTL_SEQ_TESTMIDI
:
6098 case VKI_SNDCTL_SEQ_RESETSAMPLES
:
6099 case VKI_SNDCTL_SEQ_NRSYNTHS
:
6100 case VKI_SNDCTL_SEQ_NRMIDIS
:
6101 case VKI_SNDCTL_SEQ_GETTIME
:
6102 case VKI_SNDCTL_DSP_GETBLKSIZE
:
6103 case VKI_SNDCTL_DSP_GETFMTS
:
6104 case VKI_SNDCTL_DSP_GETTRIGGER
:
6105 case VKI_SNDCTL_DSP_GETODELAY
:
6106 case VKI_SNDCTL_DSP_GETSPDIF
:
6107 case VKI_SNDCTL_DSP_GETCAPS
:
6108 case VKI_SOUND_PCM_READ_RATE
:
6109 case VKI_SOUND_PCM_READ_CHANNELS
:
6110 case VKI_SOUND_PCM_READ_BITS
:
6111 case VKI_SOUND_PCM_READ_FILTER
:
6112 PRE_MEM_WRITE( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOR, int))",
6115 case VKI_SNDCTL_SEQ_CTRLRATE
:
6116 case VKI_SNDCTL_DSP_SPEED
:
6117 case VKI_SNDCTL_DSP_STEREO
:
6118 case VKI_SNDCTL_DSP_CHANNELS
:
6119 case VKI_SOUND_PCM_WRITE_FILTER
:
6120 case VKI_SNDCTL_DSP_SUBDIVIDE
:
6121 case VKI_SNDCTL_DSP_SETFRAGMENT
:
6122 case VKI_SNDCTL_DSP_SETFMT
:
6123 case VKI_SNDCTL_DSP_GETCHANNELMASK
:
6124 case VKI_SNDCTL_DSP_BIND_CHANNEL
:
6125 case VKI_SNDCTL_TMR_TIMEBASE
:
6126 case VKI_SNDCTL_TMR_TEMPO
:
6127 case VKI_SNDCTL_TMR_SOURCE
:
6128 case VKI_SNDCTL_MIDI_PRETIME
:
6129 case VKI_SNDCTL_MIDI_MPUMODE
:
6130 PRE_MEM_READ( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOWR, int))",
6132 PRE_MEM_WRITE( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOWR, int))",
6135 case VKI_SNDCTL_DSP_GETOSPACE
:
6136 case VKI_SNDCTL_DSP_GETISPACE
:
6137 PRE_MEM_WRITE( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOR, audio_buf_info))",
6138 ARG3
, sizeof(vki_audio_buf_info
));
6140 case VKI_SNDCTL_DSP_NONBLOCK
:
6142 case VKI_SNDCTL_DSP_SETTRIGGER
:
6143 PRE_MEM_READ( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOW, int))",
6147 case VKI_SNDCTL_DSP_POST
:
6148 case VKI_SNDCTL_DSP_RESET
:
6149 case VKI_SNDCTL_DSP_SYNC
:
6150 case VKI_SNDCTL_DSP_SETSYNCRO
:
6151 case VKI_SNDCTL_DSP_SETDUPLEX
:
6154 /* linux/soundcard interface (ALSA) */
6155 case VKI_SNDRV_PCM_IOCTL_PAUSE
:
6156 case VKI_SNDRV_PCM_IOCTL_LINK
:
6157 /* these just take an int by value */
6159 case VKI_SNDRV_CTL_IOCTL_PVERSION
:
6160 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_PVERSION)", (Addr
)ARG3
, sizeof(int) );
6162 case VKI_SNDRV_CTL_IOCTL_CARD_INFO
:
6163 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_CARD_INFO)", (Addr
)ARG3
, sizeof(struct vki_snd_ctl_card_info
) );
6165 case VKI_SNDRV_CTL_IOCTL_ELEM_LIST
: {
6166 struct vki_snd_ctl_elem_list
*data
= (struct vki_snd_ctl_elem_list
*)ARG3
;
6167 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->offset
, sizeof(data
->offset
) );
6168 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->space
, sizeof(data
->space
) );
6169 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->used
, sizeof(data
->used
) );
6170 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->count
, sizeof(data
->count
) );
6171 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->pids
, sizeof(data
->pids
) );
6173 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)data
->pids
, sizeof(struct vki_snd_ctl_elem_id
) * data
->space
);
6177 case VKI_SNDRV_CTL_IOCTL_TLV_READ
: {
6178 struct vki_snd_ctl_tlv
*data
= (struct vki_snd_ctl_tlv
*)ARG3
;
6179 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_READ)", (Addr
)&data
->numid
, sizeof(data
->numid
) );
6180 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_READ)", (Addr
)&data
->length
, sizeof(data
->length
) );
6181 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_TLV_READ)", (Addr
)data
->tlv
, data
->length
);
6184 case VKI_SNDRV_CTL_IOCTL_TLV_WRITE
:
6185 case VKI_SNDRV_CTL_IOCTL_TLV_COMMAND
: {
6186 struct vki_snd_ctl_tlv
*data
= (struct vki_snd_ctl_tlv
*)ARG3
;
6187 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_WRITE)", (Addr
)&data
->numid
, sizeof(data
->numid
) );
6188 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_WRITE)", (Addr
)&data
->length
, sizeof(data
->length
) );
6189 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_WRITE)", (Addr
)data
->tlv
, data
->length
);
6193 /* Real Time Clock (/dev/rtc) ioctls */
6194 case VKI_RTC_UIE_ON
:
6195 case VKI_RTC_UIE_OFF
:
6196 case VKI_RTC_AIE_ON
:
6197 case VKI_RTC_AIE_OFF
:
6198 case VKI_RTC_PIE_ON
:
6199 case VKI_RTC_PIE_OFF
:
6200 case VKI_RTC_IRQP_SET
:
6202 case VKI_RTC_RD_TIME
:
6203 case VKI_RTC_ALM_READ
:
6204 PRE_MEM_WRITE( "ioctl(RTC_RD_TIME/ALM_READ)",
6205 ARG3
, sizeof(struct vki_rtc_time
));
6207 case VKI_RTC_ALM_SET
:
6208 PRE_MEM_READ( "ioctl(RTC_ALM_SET)", ARG3
, sizeof(struct vki_rtc_time
));
6210 case VKI_RTC_IRQP_READ
:
6211 PRE_MEM_WRITE( "ioctl(RTC_IRQP_READ)", ARG3
, sizeof(unsigned long));
6216 PRE_MEM_READ( "ioctl(BLKROSET)", ARG3
, sizeof(int));
6219 PRE_MEM_WRITE( "ioctl(BLKROGET)", ARG3
, sizeof(int));
6221 case VKI_BLKGETSIZE
:
6222 PRE_MEM_WRITE( "ioctl(BLKGETSIZE)", ARG3
, sizeof(unsigned long));
6227 PRE_MEM_WRITE( "ioctl(BLKRAGET)", ARG3
, sizeof(long));
6232 PRE_MEM_WRITE( "ioctl(BLKFRAGET)", ARG3
, sizeof(long));
6234 case VKI_BLKSECTGET
:
6235 PRE_MEM_WRITE( "ioctl(BLKSECTGET)", ARG3
, sizeof(unsigned short));
6238 PRE_MEM_WRITE( "ioctl(BLKSSZGET)", ARG3
, sizeof(int));
6241 PRE_MEM_WRITE( "ioctl(BLKBSZGET)", ARG3
, sizeof(int));
6244 PRE_MEM_READ( "ioctl(BLKBSZSET)", ARG3
, sizeof(int));
6246 case VKI_BLKGETSIZE64
:
6247 PRE_MEM_WRITE( "ioctl(BLKGETSIZE64)", ARG3
, sizeof(unsigned long long));
6249 case VKI_BLKPBSZGET
:
6250 PRE_MEM_WRITE( "ioctl(BLKPBSZGET)", ARG3
, sizeof(int));
6252 case VKI_BLKDISCARDZEROES
:
6253 PRE_MEM_WRITE( "ioctl(BLKDISCARDZEROES)", ARG3
, sizeof(vki_uint
));
6257 case VKI_HDIO_GETGEO
: /* 0x0301 */
6258 PRE_MEM_WRITE( "ioctl(HDIO_GETGEO)", ARG3
, sizeof(struct vki_hd_geometry
));
6260 case VKI_HDIO_GET_DMA
: /* 0x030b */
6261 PRE_MEM_WRITE( "ioctl(HDIO_GET_DMA)", ARG3
, sizeof(long));
6263 case VKI_HDIO_GET_IDENTITY
: /* 0x030d */
6264 PRE_MEM_WRITE( "ioctl(HDIO_GET_IDENTITY)", ARG3
,
6265 VKI_SIZEOF_STRUCT_HD_DRIVEID
);
6269 case VKI_SCSI_IOCTL_GET_IDLUN
: /* 0x5382 */
6270 PRE_MEM_WRITE( "ioctl(SCSI_IOCTL_GET_IDLUN)", ARG3
, sizeof(struct vki_scsi_idlun
));
6272 case VKI_SCSI_IOCTL_GET_BUS_NUMBER
: /* 0x5386 */
6273 PRE_MEM_WRITE( "ioctl(SCSI_IOCTL_GET_BUS_NUMBER)", ARG3
, sizeof(int));
6276 /* CD ROM stuff (??) */
6277 case VKI_CDROM_GET_MCN
:
6278 PRE_MEM_READ( "ioctl(CDROM_GET_MCN)", ARG3
,
6279 sizeof(struct vki_cdrom_mcn
) );
6281 case VKI_CDROM_SEND_PACKET
:
6282 PRE_MEM_READ( "ioctl(CDROM_SEND_PACKET)", ARG3
,
6283 sizeof(struct vki_cdrom_generic_command
));
6285 case VKI_CDROMSUBCHNL
:
6286 PRE_MEM_READ( "ioctl(CDROMSUBCHNL (cdsc_format, char))",
6287 (Addr
) &(((struct vki_cdrom_subchnl
*) ARG3
)->cdsc_format
),
6288 sizeof(((struct vki_cdrom_subchnl
*) ARG3
)->cdsc_format
));
6289 PRE_MEM_WRITE( "ioctl(CDROMSUBCHNL)", ARG3
,
6290 sizeof(struct vki_cdrom_subchnl
));
6292 case VKI_CDROMREADMODE2
:
6293 PRE_MEM_READ( "ioctl(CDROMREADMODE2)", ARG3
, VKI_CD_FRAMESIZE_RAW0
);
6295 case VKI_CDROMREADTOCHDR
:
6296 PRE_MEM_WRITE( "ioctl(CDROMREADTOCHDR)", ARG3
,
6297 sizeof(struct vki_cdrom_tochdr
));
6299 case VKI_CDROMREADTOCENTRY
:
6300 PRE_MEM_READ( "ioctl(CDROMREADTOCENTRY (cdte_format, char))",
6301 (Addr
) &(((struct vki_cdrom_tocentry
*) ARG3
)->cdte_format
),
6302 sizeof(((struct vki_cdrom_tocentry
*) ARG3
)->cdte_format
));
6303 PRE_MEM_READ( "ioctl(CDROMREADTOCENTRY (cdte_track, char))",
6304 (Addr
) &(((struct vki_cdrom_tocentry
*) ARG3
)->cdte_track
),
6305 sizeof(((struct vki_cdrom_tocentry
*) ARG3
)->cdte_track
));
6306 PRE_MEM_WRITE( "ioctl(CDROMREADTOCENTRY)", ARG3
,
6307 sizeof(struct vki_cdrom_tocentry
));
6309 case VKI_CDROMMULTISESSION
: /* 0x5310 */
6310 PRE_MEM_WRITE( "ioctl(CDROMMULTISESSION)", ARG3
,
6311 sizeof(struct vki_cdrom_multisession
));
6313 case VKI_CDROMVOLREAD
: /* 0x5313 */
6314 PRE_MEM_WRITE( "ioctl(CDROMVOLREAD)", ARG3
,
6315 sizeof(struct vki_cdrom_volctrl
));
6317 case VKI_CDROMREADRAW
: /* 0x5314 */
6318 PRE_MEM_READ( "ioctl(CDROMREADRAW)", ARG3
, sizeof(struct vki_cdrom_msf
));
6319 PRE_MEM_WRITE( "ioctl(CDROMREADRAW)", ARG3
, VKI_CD_FRAMESIZE_RAW
);
6321 case VKI_CDROMREADAUDIO
: /* 0x530e */
6322 PRE_MEM_READ( "ioctl(CDROMREADAUDIO)", ARG3
,
6323 sizeof (struct vki_cdrom_read_audio
));
6325 /* ToDo: don't do any of the following if the structure is invalid */
6326 struct vki_cdrom_read_audio
*cra
= (struct vki_cdrom_read_audio
*) ARG3
;
6327 PRE_MEM_WRITE( "ioctl(CDROMREADAUDIO).buf",
6328 (Addr
)(cra
->buf
), cra
->nframes
* VKI_CD_FRAMESIZE_RAW
);
6331 case VKI_CDROMPLAYMSF
:
6332 PRE_MEM_READ( "ioctl(CDROMPLAYMSF)", ARG3
, sizeof(struct vki_cdrom_msf
));
6334 /* The following two are probably bogus (should check args
6335 for readability). JRS 20021117 */
6336 case VKI_CDROM_DRIVE_STATUS
: /* 0x5326 */
6337 case VKI_CDROM_CLEAR_OPTIONS
: /* 0x5321 */
6339 case VKI_CDROM_GET_CAPABILITY
: /* 0x5331 */
6343 PRE_MEM_WRITE( "ioctl(FIGETBSZ)", ARG3
, sizeof(unsigned long));
6346 PRE_MEM_READ( "ioctl(FIBMAP)", ARG3
, sizeof(int));
6349 case VKI_FBIOGET_VSCREENINFO
: /* 0x4600 */
6350 PRE_MEM_WRITE( "ioctl(FBIOGET_VSCREENINFO)", ARG3
,
6351 sizeof(struct vki_fb_var_screeninfo
));
6353 case VKI_FBIOPUT_VSCREENINFO
:
6354 PRE_MEM_READ( "ioctl(FBIOPUT_VSCREENINFO)", ARG3
,
6355 sizeof(struct vki_fb_var_screeninfo
));
6357 case VKI_FBIOGET_FSCREENINFO
: /* 0x4602 */
6358 PRE_MEM_WRITE( "ioctl(FBIOGET_FSCREENINFO)", ARG3
,
6359 sizeof(struct vki_fb_fix_screeninfo
));
6361 case VKI_FBIOPAN_DISPLAY
:
6362 PRE_MEM_READ( "ioctl(FBIOPAN_DISPLAY)", ARG3
,
6363 sizeof(struct vki_fb_var_screeninfo
));
6372 PRE_MEM_READ( "ioctl(PPSETMODE)", ARG3
, sizeof(int) );
6375 PRE_MEM_WRITE( "ioctl(PPGETMODE)", ARG3
, sizeof(int) );
6377 case VKI_PPSETPHASE
:
6378 PRE_MEM_READ( "ioctl(PPSETPHASE)", ARG3
, sizeof(int) );
6380 case VKI_PPGETPHASE
:
6381 PRE_MEM_WRITE( "ioctl(PPGETPHASE)", ARG3
, sizeof(int) );
6383 case VKI_PPGETMODES
:
6384 PRE_MEM_WRITE( "ioctl(PPGETMODES)", ARG3
, sizeof(unsigned int) );
6386 case VKI_PPSETFLAGS
:
6387 PRE_MEM_READ( "ioctl(PPSETFLAGS)", ARG3
, sizeof(int) );
6389 case VKI_PPGETFLAGS
:
6390 PRE_MEM_WRITE( "ioctl(PPGETFLAGS)", ARG3
, sizeof(int) );
6393 PRE_MEM_WRITE( "ioctl(PPRSTATUS)", ARG3
, sizeof(unsigned char) );
6396 PRE_MEM_WRITE( "ioctl(PPRDATA)", ARG3
, sizeof(unsigned char) );
6398 case VKI_PPRCONTROL
:
6399 PRE_MEM_WRITE( "ioctl(PPRCONTROL)", ARG3
, sizeof(unsigned char) );
6402 PRE_MEM_READ( "ioctl(PPWDATA)", ARG3
, sizeof(unsigned char) );
6404 case VKI_PPWCONTROL
:
6405 PRE_MEM_READ( "ioctl(PPWCONTROL)", ARG3
, sizeof(unsigned char) );
6407 case VKI_PPFCONTROL
:
6408 PRE_MEM_READ( "ioctl(PPFCONTROL)", ARG3
, 2 * sizeof(unsigned char) );
6411 PRE_MEM_READ( "ioctl(PPDATADIR)", ARG3
, sizeof(int) );
6414 PRE_MEM_READ( "ioctl(PPNEGOT)", ARG3
, sizeof(int) );
6416 case VKI_PPWCTLONIRQ
:
6417 PRE_MEM_READ( "ioctl(PPWCTLONIRQ)",ARG3
, sizeof(unsigned char) );
6420 PRE_MEM_WRITE( "ioctl(PPCLRIRQ)", ARG3
, sizeof(int) );
6423 PRE_MEM_READ( "ioctl(PPSETTIME)", ARG3
, sizeof(struct vki_timeval
) );
6426 PRE_MEM_WRITE( "ioctl(PPGETTIME)", ARG3
, sizeof(struct vki_timeval
) );
6430 PRE_MEM_WRITE( "ioctl(GIO_FONT)", ARG3
, 32 * 256 );
6433 PRE_MEM_READ( "ioctl(PIO_FONT)", ARG3
, 32 * 256 );
6437 PRE_MEM_READ( "ioctl(GIO_FONTX)", ARG3
, sizeof(struct vki_consolefontdesc
) );
6439 /* ToDo: don't do any of the following if the structure is invalid */
6440 struct vki_consolefontdesc
*cfd
= (struct vki_consolefontdesc
*)ARG3
;
6441 PRE_MEM_WRITE( "ioctl(GIO_FONTX).chardata", (Addr
)cfd
->chardata
,
6442 32 * cfd
->charcount
);
6446 PRE_MEM_READ( "ioctl(PIO_FONTX)", ARG3
, sizeof(struct vki_consolefontdesc
) );
6448 /* ToDo: don't do any of the following if the structure is invalid */
6449 struct vki_consolefontdesc
*cfd
= (struct vki_consolefontdesc
*)ARG3
;
6450 PRE_MEM_READ( "ioctl(PIO_FONTX).chardata", (Addr
)cfd
->chardata
,
6451 32 * cfd
->charcount
);
6455 case VKI_PIO_FONTRESET
:
6459 PRE_MEM_WRITE( "ioctl(GIO_CMAP)", ARG3
, 16 * 3 );
6462 PRE_MEM_READ( "ioctl(PIO_CMAP)", ARG3
, 16 * 3 );
6470 PRE_MEM_WRITE( "ioctl(KDGETLED)", ARG3
, sizeof(char) );
6476 PRE_MEM_WRITE( "ioctl(KDGKBTYPE)", ARG3
, sizeof(char) );
6488 PRE_MEM_WRITE( "ioctl(KDGETMODE)", ARG3
, sizeof(int) );
6492 case VKI_KDUNMAPDISP
:
6495 case VKI_GIO_SCRNMAP
:
6496 PRE_MEM_WRITE( "ioctl(GIO_SCRNMAP)", ARG3
, VKI_E_TABSZ
);
6498 case VKI_PIO_SCRNMAP
:
6499 PRE_MEM_READ( "ioctl(PIO_SCRNMAP)", ARG3
, VKI_E_TABSZ
);
6501 case VKI_GIO_UNISCRNMAP
:
6502 PRE_MEM_WRITE( "ioctl(GIO_UNISCRNMAP)", ARG3
,
6503 VKI_E_TABSZ
* sizeof(unsigned short) );
6505 case VKI_PIO_UNISCRNMAP
:
6506 PRE_MEM_READ( "ioctl(PIO_UNISCRNMAP)", ARG3
,
6507 VKI_E_TABSZ
* sizeof(unsigned short) );
6510 case VKI_GIO_UNIMAP
:
6512 struct vki_unimapdesc
*desc
= (struct vki_unimapdesc
*) ARG3
;
6513 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", (Addr
)&desc
->entry_ct
,
6514 sizeof(unsigned short));
6515 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", (Addr
)&desc
->entries
,
6516 sizeof(struct vki_unipair
*));
6517 PRE_MEM_WRITE( "ioctl(GIO_UNIMAP).entries", (Addr
)desc
->entries
,
6518 desc
->entry_ct
* sizeof(struct vki_unipair
));
6521 case VKI_PIO_UNIMAP
:
6523 struct vki_unimapdesc
*desc
= (struct vki_unimapdesc
*) ARG3
;
6524 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", (Addr
)&desc
->entry_ct
,
6525 sizeof(unsigned short) );
6526 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", (Addr
)&desc
->entries
,
6527 sizeof(struct vki_unipair
*) );
6528 PRE_MEM_READ( "ioctl(PIO_UNIMAP).entries", (Addr
)desc
->entries
,
6529 desc
->entry_ct
* sizeof(struct vki_unipair
) );
6532 case VKI_PIO_UNIMAPCLR
:
6533 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", ARG3
, sizeof(struct vki_unimapinit
));
6537 PRE_MEM_WRITE( "ioctl(KDGKBMODE)", ARG3
, sizeof(int) );
6543 PRE_MEM_WRITE( "ioctl(KDGKBMETA)", ARG3
, sizeof(int) );
6549 PRE_MEM_WRITE( "ioctl(KDGKBLED)", ARG3
, sizeof(char) );
6555 PRE_MEM_READ( "ioctl(KDGKBENT).kb_table",
6556 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_table
,
6557 sizeof(((struct vki_kbentry
*)ARG3
)->kb_table
) );
6558 PRE_MEM_READ( "ioctl(KDGKBENT).kb_index",
6559 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_index
,
6560 sizeof(((struct vki_kbentry
*)ARG3
)->kb_index
) );
6561 PRE_MEM_WRITE( "ioctl(KDGKBENT).kb_value",
6562 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_value
,
6563 sizeof(((struct vki_kbentry
*)ARG3
)->kb_value
) );
6566 PRE_MEM_READ( "ioctl(KDSKBENT).kb_table",
6567 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_table
,
6568 sizeof(((struct vki_kbentry
*)ARG3
)->kb_table
) );
6569 PRE_MEM_READ( "ioctl(KDSKBENT).kb_index",
6570 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_index
,
6571 sizeof(((struct vki_kbentry
*)ARG3
)->kb_index
) );
6572 PRE_MEM_READ( "ioctl(KDSKBENT).kb_value",
6573 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_value
,
6574 sizeof(((struct vki_kbentry
*)ARG3
)->kb_value
) );
6578 PRE_MEM_READ( "ioctl(KDGKBSENT).kb_func",
6579 (Addr
)&((struct vki_kbsentry
*)ARG3
)->kb_func
,
6580 sizeof(((struct vki_kbsentry
*)ARG3
)->kb_func
) );
6581 PRE_MEM_WRITE( "ioctl(KDGKSENT).kb_string",
6582 (Addr
)((struct vki_kbsentry
*)ARG3
)->kb_string
,
6583 sizeof(((struct vki_kbsentry
*)ARG3
)->kb_string
) );
6586 PRE_MEM_READ( "ioctl(KDSKBSENT).kb_func",
6587 (Addr
)&((struct vki_kbsentry
*)ARG3
)->kb_func
,
6588 sizeof(((struct vki_kbsentry
*)ARG3
)->kb_func
) );
6589 PRE_MEM_RASCIIZ( "ioctl(KDSKBSENT).kb_string",
6590 (Addr
)((struct vki_kbsentry
*)ARG3
)->kb_string
);
6593 case VKI_KDGKBDIACR
:
6594 PRE_MEM_WRITE( "ioctl(KDGKBDIACR)", ARG3
, sizeof(struct vki_kbdiacrs
) );
6596 case VKI_KDSKBDIACR
:
6597 PRE_MEM_READ( "ioctl(KDSKBDIACR)", ARG3
, sizeof(struct vki_kbdiacrs
) );
6600 case VKI_KDGETKEYCODE
:
6601 PRE_MEM_READ( "ioctl(KDGETKEYCODE).scancode",
6602 (Addr
)&((struct vki_kbkeycode
*)ARG3
)->scancode
,
6603 sizeof(((struct vki_kbkeycode
*)ARG3
)->scancode
) );
6604 PRE_MEM_WRITE( "ioctl(KDGETKEYCODE).keycode",
6605 (Addr
)((struct vki_kbkeycode
*)ARG3
)->keycode
,
6606 sizeof(((struct vki_kbkeycode
*)ARG3
)->keycode
) );
6608 case VKI_KDSETKEYCODE
:
6609 PRE_MEM_READ( "ioctl(KDSETKEYCODE).scancode",
6610 (Addr
)&((struct vki_kbkeycode
*)ARG3
)->scancode
,
6611 sizeof(((struct vki_kbkeycode
*)ARG3
)->scancode
) );
6612 PRE_MEM_READ( "ioctl(KDSETKEYCODE).keycode",
6613 (Addr
)((struct vki_kbkeycode
*)ARG3
)->keycode
,
6614 sizeof(((struct vki_kbkeycode
*)ARG3
)->keycode
) );
6617 case VKI_KDSIGACCEPT
:
6621 PRE_MEM_READ( "ioctl(KBKBDREP)", ARG3
, sizeof(struct vki_kbd_repeat
) );
6626 struct vki_console_font_op
*op
= (struct vki_console_font_op
*) ARG3
;
6627 PRE_MEM_READ( "ioctl(KDFONTOP)", (Addr
)op
,
6628 sizeof(struct vki_console_font_op
) );
6630 case VKI_KD_FONT_OP_SET
:
6631 PRE_MEM_READ( "ioctl(KDFONTOP,KD_FONT_OP_SET).data",
6633 (op
->width
+ 7) / 8 * 32 * op
->charcount
);
6635 case VKI_KD_FONT_OP_GET
:
6637 PRE_MEM_WRITE( "ioctl(KDFONTOP,KD_FONT_OP_GET).data",
6639 (op
->width
+ 7) / 8 * 32 * op
->charcount
);
6641 case VKI_KD_FONT_OP_SET_DEFAULT
:
6643 PRE_MEM_RASCIIZ( "ioctl(KDFONTOP,KD_FONT_OP_SET_DEFAULT).data",
6646 case VKI_KD_FONT_OP_COPY
:
6652 case VKI_VT_OPENQRY
:
6653 PRE_MEM_WRITE( "ioctl(VT_OPENQRY)", ARG3
, sizeof(int) );
6655 case VKI_VT_GETMODE
:
6656 PRE_MEM_WRITE( "ioctl(VT_GETMODE)", ARG3
, sizeof(struct vki_vt_mode
) );
6658 case VKI_VT_SETMODE
:
6659 PRE_MEM_READ( "ioctl(VT_SETMODE)", ARG3
, sizeof(struct vki_vt_mode
) );
6661 case VKI_VT_GETSTATE
:
6662 PRE_MEM_WRITE( "ioctl(VT_GETSTATE).v_active",
6663 (Addr
) &(((struct vki_vt_stat
*) ARG3
)->v_active
),
6664 sizeof(((struct vki_vt_stat
*) ARG3
)->v_active
));
6665 PRE_MEM_WRITE( "ioctl(VT_GETSTATE).v_state",
6666 (Addr
) &(((struct vki_vt_stat
*) ARG3
)->v_state
),
6667 sizeof(((struct vki_vt_stat
*) ARG3
)->v_state
));
6669 case VKI_VT_RELDISP
:
6670 case VKI_VT_ACTIVATE
:
6671 case VKI_VT_WAITACTIVE
:
6672 case VKI_VT_DISALLOCATE
:
6675 PRE_MEM_READ( "ioctl(VT_RESIZE)", ARG3
, sizeof(struct vki_vt_sizes
) );
6677 case VKI_VT_RESIZEX
:
6678 PRE_MEM_READ( "ioctl(VT_RESIZEX)", ARG3
, sizeof(struct vki_vt_consize
) );
6680 case VKI_VT_LOCKSWITCH
:
6681 case VKI_VT_UNLOCKSWITCH
:
6684 case VKI_USBDEVFS_CONTROL
:
6686 struct vki_usbdevfs_ctrltransfer
*vkuc
= (struct vki_usbdevfs_ctrltransfer
*)ARG3
;
6687 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).bRequestType", (Addr
)&vkuc
->bRequestType
, sizeof(vkuc
->bRequestType
));
6688 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).bRequest", (Addr
)&vkuc
->bRequest
, sizeof(vkuc
->bRequest
));
6689 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).wValue", (Addr
)&vkuc
->wValue
, sizeof(vkuc
->wValue
));
6690 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).wIndex", (Addr
)&vkuc
->wIndex
, sizeof(vkuc
->wIndex
));
6691 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).wLength", (Addr
)&vkuc
->wLength
, sizeof(vkuc
->wLength
));
6692 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).timeout", (Addr
)&vkuc
->timeout
, sizeof(vkuc
->timeout
));
6693 if (vkuc
->bRequestType
& 0x80)
6694 PRE_MEM_WRITE( "ioctl(USBDEVFS_CONTROL).data", (Addr
)vkuc
->data
, vkuc
->wLength
);
6696 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).data", (Addr
)vkuc
->data
, vkuc
->wLength
);
6699 case VKI_USBDEVFS_BULK
:
6701 struct vki_usbdevfs_bulktransfer
*vkub
= (struct vki_usbdevfs_bulktransfer
*)ARG3
;
6702 PRE_MEM_READ( "ioctl(USBDEVFS_BULK)", ARG3
, sizeof(struct vki_usbdevfs_bulktransfer
));
6703 if (vkub
->ep
& 0x80)
6704 PRE_MEM_WRITE( "ioctl(USBDEVFS_BULK).data", (Addr
)vkub
->data
, vkub
->len
);
6706 PRE_MEM_READ( "ioctl(USBDEVFS_BULK).data", (Addr
)vkub
->data
, vkub
->len
);
6709 case VKI_USBDEVFS_GETDRIVER
:
6711 struct vki_usbdevfs_getdriver
*vkugd
= (struct vki_usbdevfs_getdriver
*) ARG3
;
6712 PRE_MEM_WRITE( "ioctl(USBDEVFS_GETDRIVER)", (Addr
)&vkugd
->driver
, sizeof(vkugd
->driver
));
6715 case VKI_USBDEVFS_SUBMITURB
:
6717 struct vki_usbdevfs_urb
*vkuu
= (struct vki_usbdevfs_urb
*)ARG3
;
6719 /* Not the whole struct needs to be initialized */
6720 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).endpoint", (Addr
)&vkuu
->endpoint
, sizeof(vkuu
->endpoint
));
6721 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).type", (Addr
)&vkuu
->type
, sizeof(vkuu
->type
));
6722 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).flags", (Addr
)&vkuu
->flags
, sizeof(vkuu
->flags
));
6723 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)&vkuu
->buffer
, sizeof(vkuu
->buffer
));
6724 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).signr", (Addr
)&vkuu
->signr
, sizeof(vkuu
->signr
));
6725 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).status", (Addr
)&vkuu
->status
, sizeof(vkuu
->status
));
6726 if (vkuu
->type
== VKI_USBDEVFS_URB_TYPE_CONTROL
) {
6727 struct vki_usbdevfs_setuppacket
*vkusp
= (struct vki_usbdevfs_setuppacket
*)vkuu
->buffer
;
6728 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer_length", (Addr
)&vkuu
->buffer_length
, sizeof(vkuu
->buffer_length
));
6729 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer.setup_packet", (Addr
)vkusp
, sizeof(*vkusp
));
6730 if (vkusp
->bRequestType
& 0x80)
6731 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).buffer.data", (Addr
)(vkusp
+1), vkuu
->buffer_length
- sizeof(*vkusp
));
6733 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer.data", (Addr
)(vkusp
+1), vkuu
->buffer_length
- sizeof(*vkusp
));
6734 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).actual_length", (Addr
)&vkuu
->actual_length
, sizeof(vkuu
->actual_length
));
6735 } else if (vkuu
->type
== VKI_USBDEVFS_URB_TYPE_ISO
) {
6736 int total_length
= 0;
6738 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).number_of_packets", (Addr
)&vkuu
->number_of_packets
, sizeof(vkuu
->number_of_packets
));
6739 for(i
=0; i
<vkuu
->number_of_packets
; i
++) {
6740 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).iso_frame_desc[].length", (Addr
)&vkuu
->iso_frame_desc
[i
].length
, sizeof(vkuu
->iso_frame_desc
[i
].length
));
6741 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).iso_frame_desc[].actual_length", (Addr
)&vkuu
->iso_frame_desc
[i
].actual_length
, sizeof(vkuu
->iso_frame_desc
[i
].actual_length
));
6742 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).iso_frame_desc[].status", (Addr
)&vkuu
->iso_frame_desc
[i
].status
, sizeof(vkuu
->iso_frame_desc
[i
].status
));
6743 total_length
+= vkuu
->iso_frame_desc
[i
].length
;
6745 if (vkuu
->endpoint
& 0x80)
6746 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)vkuu
->buffer
, total_length
);
6748 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)vkuu
->buffer
, total_length
);
6749 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).error_count", (Addr
)&vkuu
->error_count
, sizeof(vkuu
->error_count
));
6751 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer_length", (Addr
)&vkuu
->buffer_length
, sizeof(vkuu
->buffer_length
));
6752 if (vkuu
->endpoint
& 0x80)
6753 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)vkuu
->buffer
, vkuu
->buffer_length
);
6755 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)vkuu
->buffer
, vkuu
->buffer_length
);
6756 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).actual_length", (Addr
)&vkuu
->actual_length
, sizeof(vkuu
->actual_length
));
6760 case VKI_USBDEVFS_DISCARDURB
:
6762 case VKI_USBDEVFS_REAPURB
:
6764 PRE_MEM_WRITE( "ioctl(USBDEVFS_REAPURB)", ARG3
, sizeof(struct vki_usbdevfs_urb
**));
6767 case VKI_USBDEVFS_REAPURBNDELAY
:
6769 PRE_MEM_WRITE( "ioctl(USBDEVFS_REAPURBNDELAY)", ARG3
, sizeof(struct vki_usbdevfs_urb
**));
6772 case VKI_USBDEVFS_CONNECTINFO
:
6773 PRE_MEM_WRITE( "ioctl(USBDEVFS_CONNECTINFO)", ARG3
, sizeof(struct vki_usbdevfs_connectinfo
));
6775 case VKI_USBDEVFS_IOCTL
:
6777 struct vki_usbdevfs_ioctl
*vkui
= (struct vki_usbdevfs_ioctl
*)ARG3
;
6779 PRE_MEM_READ("ioctl(USBDEVFS_IOCTL)", (Addr
)vkui
, sizeof(struct vki_usbdevfs_ioctl
));
6780 dir2
= _VKI_IOC_DIR(vkui
->ioctl_code
);
6781 size2
= _VKI_IOC_SIZE(vkui
->ioctl_code
);
6783 if (dir2
& _VKI_IOC_WRITE
)
6784 PRE_MEM_READ("ioctl(USBDEVFS_IOCTL).dataWrite", (Addr
)vkui
->data
, size2
);
6785 else if (dir2
& _VKI_IOC_READ
)
6786 PRE_MEM_WRITE("ioctl(USBDEVFS_IOCTL).dataRead", (Addr
)vkui
->data
, size2
);
6790 case VKI_USBDEVFS_RESET
:
6793 /* I2C (/dev/i2c-*) ioctls */
6795 case VKI_I2C_SLAVE_FORCE
:
6796 case VKI_I2C_TENBIT
:
6800 PRE_MEM_WRITE( "ioctl(I2C_FUNCS)", ARG3
, sizeof(unsigned long) );
6804 struct vki_i2c_rdwr_ioctl_data
*vkui
= (struct vki_i2c_rdwr_ioctl_data
*)ARG3
;
6806 PRE_MEM_READ("ioctl(I2C_RDWR)", (Addr
)vkui
, sizeof(struct vki_i2c_rdwr_ioctl_data
));
6807 for (i
=0; i
< vkui
->nmsgs
; i
++) {
6808 struct vki_i2c_msg
*msg
= vkui
->msgs
+ i
;
6809 PRE_MEM_READ("ioctl(I2C_RDWR).msgs", (Addr
)msg
, sizeof(struct vki_i2c_msg
));
6810 if (msg
->flags
& VKI_I2C_M_RD
)
6811 PRE_MEM_WRITE("ioctl(I2C_RDWR).msgs.buf", (Addr
)msg
->buf
, msg
->len
);
6813 PRE_MEM_READ("ioctl(I2C_RDWR).msgs.buf", (Addr
)msg
->buf
, msg
->len
);
6819 struct vki_i2c_smbus_ioctl_data
*vkis
6820 = (struct vki_i2c_smbus_ioctl_data
*) ARG3
;
6821 PRE_MEM_READ("ioctl(VKI_I2C_SMBUS).i2c_smbus_ioctl_data.read_write",
6822 (Addr
)&vkis
->read_write
, sizeof(vkis
->read_write
));
6823 PRE_MEM_READ("ioctl(VKI_I2C_SMBUS).i2c_smbus_ioctl_data.size",
6824 (Addr
)&vkis
->size
, sizeof(vkis
->size
));
6825 PRE_MEM_READ("ioctl(VKI_I2C_SMBUS).i2c_smbus_ioctl_data.command",
6826 (Addr
)&vkis
->command
, sizeof(vkis
->command
));
6827 /* i2c_smbus_write_quick hides its value in read_write, so
6828 this variable can hava a different meaning */
6829 /* to make matters worse i2c_smbus_write_byte stores its
6831 if ( ! (((vkis
->size
== VKI_I2C_SMBUS_QUICK
)
6832 && (vkis
->command
== VKI_I2C_SMBUS_QUICK
)) ||
6833 ((vkis
->size
== VKI_I2C_SMBUS_BYTE
)
6834 && (vkis
->read_write
== VKI_I2C_SMBUS_WRITE
)))) {
6835 /* the rest uses the byte array to store the data,
6836 some the first byte for size */
6838 switch(vkis
->size
) {
6839 case VKI_I2C_SMBUS_BYTE_DATA
:
6842 case VKI_I2C_SMBUS_WORD_DATA
:
6843 case VKI_I2C_SMBUS_PROC_CALL
:
6846 case VKI_I2C_SMBUS_BLOCK_DATA
:
6847 case VKI_I2C_SMBUS_I2C_BLOCK_BROKEN
:
6848 case VKI_I2C_SMBUS_BLOCK_PROC_CALL
:
6849 case VKI_I2C_SMBUS_I2C_BLOCK_DATA
:
6850 size
= vkis
->data
->block
[0];
6856 if ((vkis
->read_write
== VKI_I2C_SMBUS_READ
)
6857 || (vkis
->size
== VKI_I2C_SMBUS_PROC_CALL
)
6858 || (vkis
->size
== VKI_I2C_SMBUS_BLOCK_PROC_CALL
))
6859 PRE_MEM_WRITE("ioctl(VKI_I2C_SMBUS)"
6860 ".i2c_smbus_ioctl_data.data",
6861 (Addr
)&vkis
->data
->block
[0], size
);
6863 PRE_MEM_READ("ioctl(VKI_I2C_SMBUS)."
6864 "i2c_smbus_ioctl_data.data",
6865 (Addr
)&vkis
->data
->block
[0], size
);
6870 /* Wireless extensions ioctls */
6871 case VKI_SIOCSIWCOMMIT
:
6872 case VKI_SIOCSIWNWID
:
6873 case VKI_SIOCSIWFREQ
:
6874 case VKI_SIOCSIWMODE
:
6875 case VKI_SIOCSIWSENS
:
6876 case VKI_SIOCSIWRANGE
:
6877 case VKI_SIOCSIWPRIV
:
6878 case VKI_SIOCSIWSTATS
:
6879 case VKI_SIOCSIWSPY
:
6880 case VKI_SIOCSIWTHRSPY
:
6882 case VKI_SIOCSIWSCAN
:
6883 case VKI_SIOCSIWESSID
:
6884 case VKI_SIOCSIWRATE
:
6885 case VKI_SIOCSIWNICKN
:
6886 case VKI_SIOCSIWRTS
:
6887 case VKI_SIOCSIWFRAG
:
6888 case VKI_SIOCSIWTXPOW
:
6889 case VKI_SIOCSIWRETRY
:
6890 case VKI_SIOCSIWENCODE
:
6891 case VKI_SIOCSIWPOWER
:
6892 case VKI_SIOCSIWGENIE
:
6893 case VKI_SIOCSIWMLME
:
6894 case VKI_SIOCSIWAUTH
:
6895 case VKI_SIOCSIWENCODEEXT
:
6896 case VKI_SIOCSIWPMKSA
:
6898 case VKI_SIOCGIWNAME
:
6900 PRE_MEM_WRITE("ioctl(SIOCGIWNAME)",
6901 (Addr
)((struct vki_iwreq
*)ARG3
)->u
.name
,
6902 sizeof(((struct vki_iwreq
*)ARG3
)->u
.name
));
6905 case VKI_SIOCGIWNWID
:
6906 case VKI_SIOCGIWSENS
:
6907 case VKI_SIOCGIWRATE
:
6908 case VKI_SIOCGIWRTS
:
6909 case VKI_SIOCGIWFRAG
:
6910 case VKI_SIOCGIWTXPOW
:
6911 case VKI_SIOCGIWRETRY
:
6912 case VKI_SIOCGIWPOWER
:
6913 case VKI_SIOCGIWAUTH
:
6915 PRE_MEM_WRITE("ioctl(SIOCGIW[NWID|SENS|RATE|RTS|FRAG|TXPOW|"
6916 "RETRY|PARAM|AUTH])",
6917 (Addr
)&((struct vki_iwreq
*)ARG3
)->u
.nwid
,
6918 sizeof(struct vki_iw_param
));
6921 case VKI_SIOCGIWFREQ
:
6923 PRE_MEM_WRITE("ioctl(SIOCGIWFREQ",
6924 (Addr
)&((struct vki_iwreq
*)ARG3
)->u
.freq
,
6925 sizeof(struct vki_iw_freq
));
6928 case VKI_SIOCGIWMODE
:
6930 PRE_MEM_WRITE("ioctl(SIOCGIWMODE",
6931 (Addr
)&((struct vki_iwreq
*)ARG3
)->u
.mode
,
6935 case VKI_SIOCGIWRANGE
:
6936 case VKI_SIOCGIWPRIV
:
6937 case VKI_SIOCGIWSTATS
:
6938 case VKI_SIOCGIWSPY
:
6939 case VKI_SIOCGIWTHRSPY
:
6940 case VKI_SIOCGIWAPLIST
:
6941 case VKI_SIOCGIWSCAN
:
6942 case VKI_SIOCGIWESSID
:
6943 case VKI_SIOCGIWNICKN
:
6944 case VKI_SIOCGIWENCODE
:
6945 case VKI_SIOCGIWGENIE
:
6946 case VKI_SIOCGIWENCODEEXT
:
6948 struct vki_iw_point
* point
;
6949 point
= &((struct vki_iwreq
*)ARG3
)->u
.data
;
6950 PRE_MEM_WRITE("ioctl(SIOCGIW[RANGE|PRIV|STATS|SPY|THRSPY|"
6951 "APLIST|SCAN|ESSID|NICKN|ENCODE|GENIE|ENCODEEXT])",
6952 (Addr
)point
->pointer
, point
->length
);
6957 PRE_MEM_WRITE("ioctl(SIOCGIWAP)",
6958 (Addr
)&((struct vki_iwreq
*)ARG3
)->u
.ap_addr
,
6959 sizeof(struct vki_sockaddr
));
6963 /* User input device creation */
6964 case VKI_UI_SET_EVBIT
:
6965 case VKI_UI_SET_KEYBIT
:
6966 case VKI_UI_SET_RELBIT
:
6967 case VKI_UI_SET_ABSBIT
:
6968 case VKI_UI_SET_MSCBIT
:
6969 case VKI_UI_SET_LEDBIT
:
6970 case VKI_UI_SET_SNDBIT
:
6971 case VKI_UI_SET_FFBIT
:
6972 case VKI_UI_SET_SWBIT
:
6973 case VKI_UI_SET_PROPBIT
:
6974 /* These just take an int by value */
6977 # if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
6978 || defined(VGPV_mips32_linux_android)
6980 case VKI_ASHMEM_GET_SIZE
:
6981 case VKI_ASHMEM_SET_SIZE
:
6982 case VKI_ASHMEM_GET_PROT_MASK
:
6983 case VKI_ASHMEM_SET_PROT_MASK
:
6984 case VKI_ASHMEM_GET_PIN_STATUS
:
6985 case VKI_ASHMEM_PURGE_ALL_CACHES
:
6987 case VKI_ASHMEM_GET_NAME
:
6988 PRE_MEM_WRITE( "ioctl(ASHMEM_SET_NAME)", ARG3
, VKI_ASHMEM_NAME_LEN
);
6990 case VKI_ASHMEM_SET_NAME
:
6991 PRE_MEM_RASCIIZ( "ioctl(ASHMEM_SET_NAME)", ARG3
);
6993 case VKI_ASHMEM_PIN
:
6994 case VKI_ASHMEM_UNPIN
:
6995 PRE_MEM_READ( "ioctl(ASHMEM_PIN|ASHMEM_UNPIN)",
6996 ARG3
, sizeof(struct vki_ashmem_pin
) );
7000 case VKI_BINDER_WRITE_READ
:
7002 struct vki_binder_write_read
* bwr
7003 = (struct vki_binder_write_read
*)ARG3
;
7005 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).write_buffer",
7007 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).write_size",
7009 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).write_consumed",
7010 bwr
->write_consumed
);
7011 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).read_buffer",
7013 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).read_size",
7015 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).read_consumed",
7016 bwr
->read_consumed
);
7018 PRE_FIELD_WRITE("ioctl(BINDER_WRITE_READ).write_consumed",
7019 bwr
->write_consumed
);
7020 PRE_FIELD_WRITE("ioctl(BINDER_WRITE_READ).read_consumed",
7021 bwr
->read_consumed
);
7024 PRE_MEM_WRITE("ioctl(BINDER_WRITE_READ).read_buffer[]",
7025 (Addr
)bwr
->read_buffer
, bwr
->read_size
);
7026 if (bwr
->write_size
)
7027 PRE_MEM_READ("ioctl(BINDER_WRITE_READ).write_buffer[]",
7028 (Addr
)bwr
->write_buffer
, bwr
->write_size
);
7032 case VKI_BINDER_SET_IDLE_TIMEOUT
:
7033 case VKI_BINDER_SET_MAX_THREADS
:
7034 case VKI_BINDER_SET_IDLE_PRIORITY
:
7035 case VKI_BINDER_SET_CONTEXT_MGR
:
7036 case VKI_BINDER_THREAD_EXIT
:
7038 case VKI_BINDER_VERSION
:
7040 struct vki_binder_version
* bv
= (struct vki_binder_version
*)ARG3
;
7041 PRE_FIELD_WRITE("ioctl(BINDER_VERSION)", bv
->protocol_version
);
7044 # endif /* defined(VGPV_*_linux_android) */
7046 case VKI_HCIGETDEVLIST
:
7048 struct vki_hci_dev_list_req
* dlr
= (struct vki_hci_dev_list_req
*)ARG3
;
7049 PRE_MEM_READ("ioctl(HCIGETDEVLIST)",
7050 (Addr
)ARG3
, sizeof(struct vki_hci_dev_list_req
));
7051 PRE_MEM_WRITE("ioctl(HCIGETDEVLIST)",
7052 (Addr
)ARG3
+ sizeof(struct vki_hci_dev_list_req
),
7053 dlr
->dev_num
* sizeof(struct vki_hci_dev_req
));
7057 case VKI_HCIINQUIRY
:
7059 struct vki_hci_inquiry_req
* ir
= (struct vki_hci_inquiry_req
*)ARG3
;
7060 PRE_MEM_READ("ioctl(HCIINQUIRY)",
7061 (Addr
)ARG3
, sizeof(struct vki_hci_inquiry_req
));
7062 PRE_MEM_WRITE("ioctl(HCIINQUIRY)",
7063 (Addr
)ARG3
+ sizeof(struct vki_hci_inquiry_req
),
7064 ir
->num_rsp
* sizeof(struct vki_inquiry_info
));
7068 case VKI_DRM_IOCTL_VERSION
:
7070 struct vki_drm_version
*data
= (struct vki_drm_version
*)ARG3
;
7071 PRE_MEM_WRITE("ioctl(DRM_VERSION).version_major", (Addr
)&data
->version_major
, sizeof(data
->version_major
));
7072 PRE_MEM_WRITE("ioctl(DRM_VERSION).version_minor", (Addr
)&data
->version_minor
, sizeof(data
->version_minor
));
7073 PRE_MEM_WRITE("ioctl(DRM_VERSION).version_patchlevel", (Addr
)&data
->version_patchlevel
, sizeof(data
->version_patchlevel
));
7074 PRE_MEM_READ("ioctl(DRM_VERSION).name_len", (Addr
)&data
->name_len
, sizeof(data
->name_len
));
7075 PRE_MEM_READ("ioctl(DRM_VERSION).name", (Addr
)&data
->name
, sizeof(data
->name
));
7076 PRE_MEM_WRITE("ioctl(DRM_VERSION).name", (Addr
)data
->name
, data
->name_len
);
7077 PRE_MEM_READ("ioctl(DRM_VERSION).date_len", (Addr
)&data
->date_len
, sizeof(data
->date_len
));
7078 PRE_MEM_READ("ioctl(DRM_VERSION).date", (Addr
)&data
->date
, sizeof(data
->date
));
7079 PRE_MEM_WRITE("ioctl(DRM_VERSION).date", (Addr
)data
->date
, data
->date_len
);
7080 PRE_MEM_READ("ioctl(DRM_VERSION).desc_len", (Addr
)&data
->desc_len
, sizeof(data
->desc_len
));
7081 PRE_MEM_READ("ioctl(DRM_VERSION).desc", (Addr
)&data
->desc
, sizeof(data
->desc
));
7082 PRE_MEM_WRITE("ioctl(DRM_VERSION).desc", (Addr
)data
->desc
, data
->desc_len
);
7085 case VKI_DRM_IOCTL_GET_UNIQUE
:
7087 struct vki_drm_unique
*data
= (struct vki_drm_unique
*)ARG3
;
7088 PRE_MEM_READ("ioctl(DRM_GET_UNIQUE).unique_len", (Addr
)&data
->unique_len
, sizeof(data
->unique_len
));
7089 PRE_MEM_READ("ioctl(DRM_GET_UNIQUE).unique", (Addr
)&data
->unique
, sizeof(data
->unique
));
7090 PRE_MEM_WRITE("ioctl(DRM_GET_UNIQUE).unique", (Addr
)data
->unique
, data
->unique_len
);
7093 case VKI_DRM_IOCTL_GET_MAGIC
:
7095 struct vki_drm_auth
*data
= (struct vki_drm_auth
*)ARG3
;
7096 PRE_MEM_WRITE("ioctl(DRM_GET_MAGIC).magic", (Addr
)&data
->magic
, sizeof(data
->magic
));
7099 case VKI_DRM_IOCTL_WAIT_VBLANK
:
7101 union vki_drm_wait_vblank
*data
= (union vki_drm_wait_vblank
*)ARG3
;
7102 PRE_MEM_READ("ioctl(DRM_WAIT_VBLANK).request.type", (Addr
)&data
->request
.type
, sizeof(data
->request
.type
));
7103 PRE_MEM_READ("ioctl(DRM_WAIT_VBLANK).request.sequence", (Addr
)&data
->request
.sequence
, sizeof(data
->request
.sequence
));
7104 /* XXX: It seems request.signal isn't used */
7105 PRE_MEM_WRITE("ioctl(DRM_WAIT_VBLANK).reply", (Addr
)&data
->reply
, sizeof(data
->reply
));
7108 case VKI_DRM_IOCTL_GEM_CLOSE
:
7110 struct vki_drm_gem_close
*data
= (struct vki_drm_gem_close
*)ARG3
;
7111 PRE_MEM_READ("ioctl(DRM_GEM_CLOSE).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7114 case VKI_DRM_IOCTL_GEM_FLINK
:
7116 struct vki_drm_gem_flink
*data
= (struct vki_drm_gem_flink
*)ARG3
;
7117 PRE_MEM_READ("ioctl(DRM_GEM_FLINK).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7118 PRE_MEM_WRITE("ioctl(DRM_GEM_FLINK).name", (Addr
)&data
->name
, sizeof(data
->name
));
7121 case VKI_DRM_IOCTL_GEM_OPEN
:
7123 struct vki_drm_gem_open
*data
= (struct vki_drm_gem_open
*)ARG3
;
7124 PRE_MEM_READ("ioctl(DRM_GEM_OPEN).name", (Addr
)&data
->name
, sizeof(data
->name
));
7125 PRE_MEM_WRITE("ioctl(DRM_GEM_OPEN).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7126 PRE_MEM_WRITE("ioctl(DRM_GEM_OPEN).size", (Addr
)&data
->size
, sizeof(data
->size
));
7129 case VKI_DRM_IOCTL_I915_GETPARAM
:
7131 vki_drm_i915_getparam_t
*data
= (vki_drm_i915_getparam_t
*)ARG3
;
7132 PRE_MEM_READ("ioctl(DRM_I915_GETPARAM).param", (Addr
)&data
->param
, sizeof(data
->param
));
7133 PRE_MEM_WRITE("ioctl(DRM_I915_GETPARAM).value", (Addr
)data
->value
, sizeof(int));
7136 case VKI_DRM_IOCTL_I915_GEM_BUSY
:
7138 struct vki_drm_i915_gem_busy
*data
= (struct vki_drm_i915_gem_busy
*)ARG3
;
7139 PRE_MEM_READ("ioctl(DRM_I915_GEM_BUSY).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7140 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_BUSY).busy", (Addr
)&data
->busy
, sizeof(data
->busy
));
7143 case VKI_DRM_IOCTL_I915_GEM_CREATE
:
7145 struct vki_drm_i915_gem_create
*data
= (struct vki_drm_i915_gem_create
*)ARG3
;
7146 PRE_MEM_READ("ioctl(DRM_I915_GEM_CREATE).size", (Addr
)&data
->size
, sizeof(data
->size
));
7147 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_CREATE).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7150 case VKI_DRM_IOCTL_I915_GEM_PREAD
:
7152 struct vki_drm_i915_gem_pread
*data
= (struct vki_drm_i915_gem_pread
*)ARG3
;
7153 PRE_MEM_READ("ioctl(DRM_I915_GEM_PREAD).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7154 PRE_MEM_READ("ioctl(DRM_I915_GEM_PREAD).offset", (Addr
)&data
->offset
, sizeof(data
->offset
));
7155 PRE_MEM_READ("ioctl(DRM_I915_GEM_PREAD).size", (Addr
)&data
->size
, sizeof(data
->size
));
7156 PRE_MEM_READ("ioctl(DRM_I915_GEM_PREAD).data_ptr", (Addr
)&data
->data_ptr
, sizeof(data
->data_ptr
));
7157 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_PREAD).data_ptr", (Addr
)data
->data_ptr
, data
->size
);
7160 case VKI_DRM_IOCTL_I915_GEM_PWRITE
:
7162 struct vki_drm_i915_gem_pwrite
*data
= (struct vki_drm_i915_gem_pwrite
*)ARG3
;
7163 PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7164 PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).offset", (Addr
)&data
->offset
, sizeof(data
->offset
));
7165 PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).size", (Addr
)&data
->size
, sizeof(data
->size
));
7166 PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).data_ptr", (Addr
)&data
->data_ptr
, sizeof(data
->data_ptr
));
7167 /* PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).data_ptr", (Addr)data->data_ptr, data->size);
7168 * NB: the buffer is allowed to contain any amount of uninitialized data (e.g.
7169 * interleaved vertex attributes may have a wide stride with uninitialized data between
7170 * consecutive vertices) */
7173 case VKI_DRM_IOCTL_I915_GEM_MMAP_GTT
:
7175 struct vki_drm_i915_gem_mmap_gtt
*data
= (struct vki_drm_i915_gem_mmap_gtt
*)ARG3
;
7176 PRE_MEM_READ("ioctl(DRM_I915_GEM_MMAP_GTT).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7177 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_MMAP_GTT).offset", (Addr
)&data
->offset
, sizeof(data
->offset
));
7180 case VKI_DRM_IOCTL_I915_GEM_SET_DOMAIN
:
7182 struct vki_drm_i915_gem_set_domain
*data
= (struct vki_drm_i915_gem_set_domain
*)ARG3
;
7183 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_DOMAIN).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7184 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_DOMAIN).read_domains", (Addr
)&data
->read_domains
, sizeof(data
->read_domains
));
7185 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_DOMAIN).write_domain", (Addr
)&data
->write_domain
, sizeof(data
->write_domain
));
7188 case VKI_DRM_IOCTL_I915_GEM_SET_TILING
:
7190 struct vki_drm_i915_gem_set_tiling
*data
= (struct vki_drm_i915_gem_set_tiling
*)ARG3
;
7191 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_TILING).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7192 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_TILING).tiling_mode", (Addr
)&data
->tiling_mode
, sizeof(data
->tiling_mode
));
7193 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_TILING).stride", (Addr
)&data
->stride
, sizeof(data
->stride
));
7194 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_SET_TILING).swizzle_mode", (Addr
)&data
->swizzle_mode
, sizeof(data
->swizzle_mode
));
7197 case VKI_DRM_IOCTL_I915_GEM_GET_TILING
:
7199 struct vki_drm_i915_gem_get_tiling
*data
= (struct vki_drm_i915_gem_get_tiling
*)ARG3
;
7200 PRE_MEM_READ("ioctl(DRM_I915_GEM_GET_TILING).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7201 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_GET_TILING).tiling_mode", (Addr
)&data
->tiling_mode
, sizeof(data
->tiling_mode
));
7202 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_GET_TILING).swizzle_mode", (Addr
)&data
->swizzle_mode
, sizeof(data
->swizzle_mode
));
7205 case VKI_DRM_IOCTL_I915_GEM_GET_APERTURE
:
7207 struct vki_drm_i915_gem_get_aperture
*data
= (struct vki_drm_i915_gem_get_aperture
*)ARG3
;
7208 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_GET_APERTURE).aper_size", (Addr
)&data
->aper_size
, sizeof(data
->aper_size
));
7209 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_GET_APERTURE).aper_available_size", (Addr
)&data
->aper_available_size
, sizeof(data
->aper_available_size
));
7213 /* KVM ioctls that check for a numeric value as parameter */
7214 case VKI_KVM_GET_API_VERSION
:
7215 case VKI_KVM_CREATE_VM
:
7216 case VKI_KVM_GET_VCPU_MMAP_SIZE
:
7217 case VKI_KVM_CHECK_EXTENSION
:
7218 case VKI_KVM_SET_TSS_ADDR
:
7219 case VKI_KVM_CREATE_VCPU
:
7223 case VKI_KVM_S390_MEM_OP
: {
7224 struct vki_kvm_s390_mem_op
*args
=
7225 (struct vki_kvm_s390_mem_op
*)(ARG3
);
7226 PRE_MEM_READ("ioctl(KVM_S390_MEM_OP)", ARG3
,
7227 sizeof(struct vki_kvm_s390_mem_op
));
7228 if (args
->flags
& VKI_KVM_S390_MEMOP_F_CHECK_ONLY
)
7230 if (args
->op
== VKI_KVM_S390_MEMOP_LOGICAL_READ
)
7231 PRE_MEM_WRITE("ioctl(KVM_S390_MEM_OP).buf", (Addr
)args
->buf
, args
->size
);
7232 if (args
->op
== VKI_KVM_S390_MEMOP_LOGICAL_WRITE
)
7233 PRE_MEM_READ("ioctl(KVM_S390_MEM_OP).buf", (Addr
)args
->buf
, args
->size
);
7239 case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL
: {
7240 SyscallArgs harrghs
;
7241 struct vki_xen_privcmd_hypercall
*args
=
7242 (struct vki_xen_privcmd_hypercall
*)(ARG3
);
7247 VG_(memset
)(&harrghs
, 0, sizeof(harrghs
));
7248 harrghs
.sysno
= args
->op
;
7249 harrghs
.arg1
= args
->arg
[0];
7250 harrghs
.arg2
= args
->arg
[1];
7251 harrghs
.arg3
= args
->arg
[2];
7252 harrghs
.arg4
= args
->arg
[3];
7253 harrghs
.arg5
= args
->arg
[4];
7254 harrghs
.arg6
= harrghs
.arg7
= harrghs
.arg8
= 0;
7256 WRAPPER_PRE_NAME(xen
, hypercall
) (tid
, layout
, &harrghs
, status
, flags
);
7258 /* HACK. arg8 is used to return the number of hypercall
7259 * arguments actually consumed! */
7260 PRE_MEM_READ("hypercall", ARG3
, sizeof(args
->op
) +
7261 ( sizeof(args
->arg
[0]) * harrghs
.arg8
) );
7266 case VKI_XEN_IOCTL_PRIVCMD_MMAP
: {
7267 struct vki_xen_privcmd_mmap
*args
=
7268 (struct vki_xen_privcmd_mmap
*)(ARG3
);
7269 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP(num)",
7270 (Addr
)&args
->num
, sizeof(args
->num
));
7271 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP(dom)",
7272 (Addr
)&args
->dom
, sizeof(args
->dom
));
7273 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP(entry)",
7274 (Addr
)args
->entry
, sizeof(*(args
->entry
)) * args
->num
);
7277 case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH
: {
7278 struct vki_xen_privcmd_mmapbatch
*args
=
7279 (struct vki_xen_privcmd_mmapbatch
*)(ARG3
);
7280 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH(num)",
7281 (Addr
)&args
->num
, sizeof(args
->num
));
7282 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH(dom)",
7283 (Addr
)&args
->dom
, sizeof(args
->dom
));
7284 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH(addr)",
7285 (Addr
)&args
->addr
, sizeof(args
->addr
));
7286 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH(arr)",
7287 (Addr
)args
->arr
, sizeof(*(args
->arr
)) * args
->num
);
7290 case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2
: {
7291 struct vki_xen_privcmd_mmapbatch_v2
*args
=
7292 (struct vki_xen_privcmd_mmapbatch_v2
*)(ARG3
);
7293 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2(num)",
7294 (Addr
)&args
->num
, sizeof(args
->num
));
7295 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2(dom)",
7296 (Addr
)&args
->dom
, sizeof(args
->dom
));
7297 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2(addr)",
7298 (Addr
)&args
->addr
, sizeof(args
->addr
));
7299 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2(arr)",
7300 (Addr
)args
->arr
, sizeof(*(args
->arr
)) * args
->num
);
7304 case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ
: {
7305 struct vki_xen_ioctl_evtchn_bind_virq
*args
=
7306 (struct vki_xen_ioctl_evtchn_bind_virq
*)(ARG3
);
7307 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ(virq)",
7308 (Addr
)&args
->virq
, sizeof(args
->virq
));
7311 case VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN
: {
7312 struct vki_xen_ioctl_evtchn_bind_interdomain
*args
=
7313 (struct vki_xen_ioctl_evtchn_bind_interdomain
*)(ARG3
);
7314 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN(remote_domain)",
7315 (Addr
)&args
->remote_domain
, sizeof(args
->remote_domain
));
7316 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN(remote_port)",
7317 (Addr
)&args
->remote_port
, sizeof(args
->remote_port
));
7320 case VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT
: {
7321 struct vki_xen_ioctl_evtchn_bind_unbound_port
*args
=
7322 (struct vki_xen_ioctl_evtchn_bind_unbound_port
*)(ARG3
);
7323 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT(remote_domain)",
7324 (Addr
)&args
->remote_domain
, sizeof(args
->remote_domain
));
7327 case VKI_XEN_IOCTL_EVTCHN_UNBIND
: {
7328 struct vki_xen_ioctl_evtchn_unbind
*args
=
7329 (struct vki_xen_ioctl_evtchn_unbind
*)(ARG3
);
7330 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_UNBIND(port)",
7331 (Addr
)&args
->port
, sizeof(args
->port
));
7334 case VKI_XEN_IOCTL_EVTCHN_NOTIFY
: {
7335 struct vki_xen_ioctl_evtchn_notify
*args
=
7336 (struct vki_xen_ioctl_evtchn_notify
*)(ARG3
);
7337 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_notify(port)",
7338 (Addr
)&args
->port
, sizeof(args
->port
));
7341 case VKI_XEN_IOCTL_EVTCHN_RESET
:
7347 case VKI_OBD_IOC_FID2PATH
: {
7348 struct vki_getinfo_fid2path
*gf
= (struct vki_getinfo_fid2path
*)ARG3
;
7349 PRE_MEM_READ("VKI_OBD_IOC_FID2PATH(args)", ARG3
, sizeof(struct vki_getinfo_fid2path
));
7350 PRE_FIELD_WRITE("VKI_OBD_IOC_FID2PATH(args).gf_recno", gf
->gf_recno
);
7351 PRE_FIELD_WRITE("VKI_OBD_IOC_FID2PATH(args).gf_linkno", gf
->gf_linkno
);
7352 PRE_MEM_WRITE("VKI_OBD_IOC_FID2PATH(args)", (Addr
)gf
->gf_path
, gf
->gf_pathlen
);
7356 case VKI_LL_IOC_PATH2FID
:
7357 PRE_MEM_WRITE("ioctl(VKI_LL_IOC_PATH2FID)", ARG3
, sizeof(struct vki_lu_fid
));
7360 case VKI_LL_IOC_GETPARENT
: {
7361 struct vki_getparent
*gp
= (struct vki_getparent
*)ARG3
;
7362 PRE_FIELD_READ("ioctl(VKI_LL_IOC_GETPARENT).gp_linkno", gp
->gp_linkno
);
7363 PRE_FIELD_READ("ioctl(VKI_LL_IOC_GETPARENT).gp_name_size", gp
->gp_name_size
);
7364 PRE_FIELD_WRITE("ioctl(VKI_LL_IOC_GETPARENT).gp_fid", gp
->gp_fid
);
7365 PRE_MEM_WRITE("ioctl(VKI_LL_IOC_GETPARENT).gp_name", (Addr
)gp
->gp_name
, gp
->gp_name_size
);
7370 case VKI_V4L2_QUERYCAP
: {
7371 struct vki_v4l2_capability
*data
= (struct vki_v4l2_capability
*)ARG3
;
7372 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERYCAP)", (Addr
)data
, sizeof(*data
));
7375 case VKI_V4L2_ENUM_FMT
: {
7376 struct vki_v4l2_fmtdesc
*data
= (struct vki_v4l2_fmtdesc
*)ARG3
;
7377 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FMT).index", data
->index
);
7378 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FMT).type", data
->type
);
7379 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FMT).flags", data
->flags
);
7380 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FMT).description", data
->description
);
7381 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FMT).pixelformat", data
->pixelformat
);
7382 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FMT).reserved", data
->reserved
);
7385 case VKI_V4L2_G_FMT
: {
7386 struct vki_v4l2_format
*data
= (struct vki_v4l2_format
*)ARG3
;
7387 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).type", data
->type
);
7388 switch (data
->type
) {
7389 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
7390 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
7391 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).fmt.pix.priv", data
->fmt
.pix
.priv
);
7392 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.pix", data
->fmt
.pix
);
7393 PRE_MEM_READ("ioctl(VKI_V4L2_G_FMT)",
7394 (Addr
)&data
->type
+ sizeof(data
->type
) + sizeof(data
->fmt
.pix
),
7395 sizeof(*data
) - sizeof(data
->type
) - sizeof(data
->fmt
.pix
));
7397 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
7398 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
7399 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.vbi", data
->fmt
.vbi
);
7401 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
7402 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
7403 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.sliced", data
->fmt
.sliced
);
7405 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
7406 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
7407 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).fmt.win.clips", data
->fmt
.win
.clips
);
7408 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).fmt.win.bitmap", data
->fmt
.win
.bitmap
);
7409 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).fmt.win.clipcount", data
->fmt
.win
.clipcount
);
7410 if (data
->fmt
.win
.clipcount
&& data
->fmt
.win
.clips
)
7411 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.clips[]",
7412 (Addr
)data
->fmt
.win
.clips
,
7413 data
->fmt
.win
.clipcount
* sizeof(data
->fmt
.win
.clips
[0]));
7414 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.clipcount", data
->fmt
.win
.clipcount
);
7415 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.w", data
->fmt
.win
.w
);
7416 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.field", data
->fmt
.win
.field
);
7417 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.chromakey", data
->fmt
.win
.chromakey
);
7418 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.global_alpha", data
->fmt
.win
.global_alpha
);
7420 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
7421 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
7422 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.pix_mp", data
->fmt
.pix_mp
);
7424 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
7425 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.sdr", data
->fmt
.sdr
);
7430 case VKI_V4L2_S_FMT
: {
7431 struct vki_v4l2_format
*data
= (struct vki_v4l2_format
*)ARG3
;
7432 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).type", data
->type
);
7433 switch (data
->type
) {
7434 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
7435 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
7436 PRE_MEM_READ("ioctl(VKI_V4L2_S_FMT)",
7437 (Addr
)&data
->type
+ sizeof(data
->type
),
7438 sizeof(*data
) - sizeof(data
->type
));
7440 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
7441 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
7442 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.vbi", data
->fmt
.vbi
);
7444 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
7445 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
7446 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.sliced", data
->fmt
.sliced
);
7448 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
7449 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
7450 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.win", data
->fmt
.win
);
7451 if (data
->fmt
.win
.clipcount
&& data
->fmt
.win
.clips
)
7452 PRE_MEM_READ("ioctl(VKI_V4L2_S_FMT).fmt.win.clips[]",
7453 (Addr
)data
->fmt
.win
.clips
,
7454 data
->fmt
.win
.clipcount
* sizeof(data
->fmt
.win
.clips
[0]));
7455 if (data
->fmt
.win
.bitmap
)
7456 PRE_MEM_READ("ioctl(VKI_V4L2_S_FMT).fmt.win.bitmap[]",
7457 (Addr
)data
->fmt
.win
.bitmap
,
7458 data
->fmt
.win
.w
.height
* ((data
->fmt
.win
.w
.width
+ 7) / 8));
7460 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
7461 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
7462 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.pix_mp", data
->fmt
.pix_mp
);
7464 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
7465 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.sdr", data
->fmt
.sdr
);
7470 case VKI_V4L2_TRY_FMT
: {
7471 struct vki_v4l2_format
*data
= (struct vki_v4l2_format
*)ARG3
;
7472 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).type", data
->type
);
7473 switch (data
->type
) {
7474 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
7475 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
7476 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_FMT)",
7477 (Addr
)&data
->type
+ sizeof(data
->type
),
7478 sizeof(*data
) - sizeof(data
->type
));
7480 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
7481 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
7482 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.vbi", data
->fmt
.vbi
);
7484 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
7485 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
7486 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.sliced", data
->fmt
.sliced
);
7488 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
7489 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
7490 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.win", data
->fmt
.win
);
7491 if (data
->fmt
.win
.clipcount
&& data
->fmt
.win
.clips
)
7492 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.win.clips[]",
7493 (Addr
)data
->fmt
.win
.clips
,
7494 data
->fmt
.win
.clipcount
* sizeof(data
->fmt
.win
.clips
[0]));
7495 if (data
->fmt
.win
.bitmap
)
7496 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.win.bitmap[]",
7497 (Addr
)data
->fmt
.win
.bitmap
,
7498 data
->fmt
.win
.w
.height
* ((data
->fmt
.win
.w
.width
+ 7) / 8));
7500 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
7501 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
7502 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.pix_mp", data
->fmt
.pix_mp
);
7504 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
7505 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.sdr", data
->fmt
.sdr
);
7510 case VKI_V4L2_REQBUFS
: {
7511 struct vki_v4l2_requestbuffers
*data
= (struct vki_v4l2_requestbuffers
*)ARG3
;
7512 PRE_MEM_READ("ioctl(VKI_V4L2_REQBUFS)", (Addr
)data
, sizeof(*data
));
7515 case VKI_V4L2_QUERYBUF
: {
7516 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
7517 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).type", data
->type
);
7518 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).index", data
->index
);
7519 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).reserved", data
->reserved
);
7520 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).reserved2", data
->reserved2
);
7521 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
7522 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
7525 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).length", data
->length
);
7526 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).m.planes", data
->m
.planes
);
7527 for (i
= 0; i
< data
->length
; i
++) {
7528 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].bytesused", data
->m
.planes
[i
].bytesused
);
7529 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].length", data
->m
.planes
[i
].length
);
7530 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].m", data
->m
.planes
[i
].m
);
7531 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].data_offset", data
->m
.planes
[i
].data_offset
);
7532 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].reserved", data
->m
.planes
[i
].reserved
);
7535 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m", data
->m
);
7536 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).length", data
->length
);
7538 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).bytesused", data
->bytesused
);
7539 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).flags", data
->flags
);
7540 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).field", data
->field
);
7541 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).timestamp", data
->timestamp
);
7542 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).timecode", data
->timecode
);
7543 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).sequence", data
->sequence
);
7544 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).memory", data
->memory
);
7545 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).sequence", data
->sequence
);
7548 case VKI_V4L2_G_FBUF
: {
7549 struct vki_v4l2_framebuffer
*data
= (struct vki_v4l2_framebuffer
*)ARG3
;
7550 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_FBUF)", (Addr
)data
, sizeof(*data
));
7553 case VKI_V4L2_S_FBUF
: {
7554 struct vki_v4l2_framebuffer
*data
= (struct vki_v4l2_framebuffer
*)ARG3
;
7555 PRE_FIELD_WRITE("ioctl(VKI_V4L2_S_FBUF).capability", data
->capability
);
7556 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FBUF).flags", data
->flags
);
7557 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FBUF).base", data
->base
);
7558 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FBUF).fmt", data
->fmt
);
7561 case VKI_V4L2_OVERLAY
: {
7562 int *data
= (int *)ARG3
;
7563 PRE_MEM_READ("ioctl(VKI_V4L2_OVERLAY)", (Addr
)data
, sizeof(*data
));
7566 case VKI_V4L2_QBUF
: {
7567 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
7568 int is_output
= data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
||
7569 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
||
7570 data
->type
== VKI_V4L2_BUF_TYPE_VBI_OUTPUT
||
7571 data
->type
== VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
;
7573 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).type", data
->type
);
7574 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).index", data
->index
);
7575 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).flags", data
->flags
);
7576 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).memory", data
->memory
);
7577 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).reserved", data
->reserved
);
7578 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).reserved2", data
->reserved2
);
7580 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).bytesused", data
->bytesused
);
7581 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).field", data
->field
);
7583 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
7584 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
7587 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).length", data
->length
);
7588 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes", data
->m
.planes
);
7589 for (i
= 0; i
< data
->length
; i
++) {
7591 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].bytesused", data
->m
.planes
[i
].bytesused
);
7592 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].data_offset", data
->m
.planes
[i
].data_offset
);
7594 if (data
->memory
== VKI_V4L2_MEMORY_MMAP
)
7595 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QBUF).m.planes[].m", data
->m
.planes
[i
].m
);
7596 else if (data
->memory
== VKI_V4L2_MEMORY_DMABUF
)
7597 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].m.fd", data
->m
.planes
[i
].m
.fd
);
7599 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].m", data
->m
.planes
[i
].m
);
7600 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].reserved", data
->m
.planes
[i
].reserved
);
7603 if (data
->memory
== VKI_V4L2_MEMORY_MMAP
)
7604 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QBUF).m", data
->m
);
7605 else if (data
->memory
== VKI_V4L2_MEMORY_DMABUF
)
7606 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.fd", data
->m
.fd
);
7608 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m", data
->m
);
7610 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).bytesused", data
->bytesused
);
7611 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).field", data
->field
);
7614 if (is_output
&& (data
->flags
& VKI_V4L2_BUF_FLAG_TIMESTAMP_MASK
) == VKI_V4L2_BUF_FLAG_TIMESTAMP_COPY
) {
7615 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).timestamp", data
->timestamp
);
7616 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).timecode", data
->timecode
);
7620 case VKI_V4L2_EXPBUF
: {
7621 struct vki_v4l2_exportbuffer
*data
= (struct vki_v4l2_exportbuffer
*)ARG3
;
7622 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).type", data
->type
);
7623 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).index", data
->index
);
7624 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).plane", data
->plane
);
7625 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).flags", data
->flags
);
7626 PRE_FIELD_WRITE("ioctl(VKI_V4L2_EXPBUF).fd", data
->fd
);
7627 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).reserved", data
->reserved
);
7630 case VKI_V4L2_DQBUF
: {
7631 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
7632 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).type", data
->type
);
7633 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).index", data
->index
);
7634 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).memory", data
->memory
);
7635 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).reserved", data
->reserved
);
7636 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).reserved2", data
->reserved2
);
7637 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).bytesused", data
->bytesused
);
7638 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).field", data
->field
);
7639 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
7640 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
7643 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).length", data
->length
);
7644 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).m.planes", data
->m
.planes
);
7645 for (i
= 0; i
< data
->length
; i
++) {
7646 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m.planes[].bytesused", data
->m
.planes
[i
].bytesused
);
7647 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m.planes[].data_offset", data
->m
.planes
[i
].data_offset
);
7648 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m.planes[].length", data
->m
.planes
[i
].length
);
7649 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m.planes[].m", data
->m
.planes
[i
].m
);
7650 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).m.planes[].reserved", data
->m
.planes
[i
].reserved
);
7653 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m", data
->m
);
7654 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).length", data
->length
);
7655 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).bytesused", data
->bytesused
);
7656 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).field", data
->field
);
7658 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).timestamp", data
->timestamp
);
7659 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).timecode", data
->timecode
);
7660 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).sequence", data
->sequence
);
7663 case VKI_V4L2_STREAMON
: {
7664 int *data
= (int *)ARG3
;
7665 PRE_MEM_READ("ioctl(VKI_V4L2_STREAMON)", (Addr
)data
, sizeof(*data
));
7668 case VKI_V4L2_STREAMOFF
: {
7669 int *data
= (int *)ARG3
;
7670 PRE_MEM_READ("ioctl(VKI_V4L2_STREAMOFF)", (Addr
)data
, sizeof(*data
));
7673 case VKI_V4L2_G_PARM
: {
7674 struct vki_v4l2_streamparm
*data
= (struct vki_v4l2_streamparm
*)ARG3
;
7675 int is_output
= data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
||
7676 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
||
7677 data
->type
== VKI_V4L2_BUF_TYPE_VBI_OUTPUT
||
7678 data
->type
== VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
;
7680 PRE_FIELD_READ("ioctl(VKI_V4L2_G_PARM).type", data
->type
);
7682 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_PARM)", (Addr
)&data
->parm
.output
,
7683 sizeof(data
->parm
.output
) - sizeof(data
->parm
.output
.reserved
));
7684 PRE_FIELD_READ("ioctl(VKI_V4L2_G_PARM).parm.output.reserved", data
->parm
.output
.reserved
);
7686 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_PARM)", (Addr
)&data
->parm
.capture
,
7687 sizeof(data
->parm
.capture
) - sizeof(data
->parm
.capture
.reserved
));
7688 PRE_FIELD_READ("ioctl(VKI_V4L2_G_PARM).parm.capture.reserved", data
->parm
.capture
.reserved
);
7692 case VKI_V4L2_S_PARM
: {
7693 struct vki_v4l2_streamparm
*data
= (struct vki_v4l2_streamparm
*)ARG3
;
7694 int is_output
= data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
||
7695 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
||
7696 data
->type
== VKI_V4L2_BUF_TYPE_VBI_OUTPUT
||
7697 data
->type
== VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
;
7699 PRE_FIELD_READ("ioctl(VKI_V4L2_S_PARM).type", data
->type
);
7701 PRE_FIELD_READ("ioctl(VKI_V4L2_S_PARM).parm.output", data
->parm
.output
);
7703 PRE_FIELD_READ("ioctl(VKI_V4L2_S_PARM).parm.capture", data
->parm
.capture
);
7706 case VKI_V4L2_G_STD
: {
7707 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
7708 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_STD)", (Addr
)data
, sizeof(*data
));
7711 case VKI_V4L2_S_STD
: {
7712 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
7713 PRE_MEM_READ("ioctl(VKI_V4L2_S_STD)", (Addr
)data
, sizeof(*data
));
7716 case VKI_V4L2_ENUMSTD
: {
7717 struct vki_v4l2_standard
*data
= (struct vki_v4l2_standard
*)ARG3
;
7718 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMSTD).index", data
->index
);
7719 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMSTD)", (Addr
)&data
->id
, sizeof(*data
) - sizeof(data
->index
));
7722 case VKI_V4L2_ENUMINPUT
: {
7723 struct vki_v4l2_input
*data
= (struct vki_v4l2_input
*)ARG3
;
7724 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMINPUT).index", data
->index
);
7725 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMINPUT)", (Addr
)data
->name
, sizeof(*data
) - sizeof(data
->index
));
7728 case VKI_V4L2_G_CTRL
: {
7729 struct vki_v4l2_control
*data
= (struct vki_v4l2_control
*)ARG3
;
7730 PRE_FIELD_READ("ioctl(VKI_V4L2_G_CTRL).id", data
->id
);
7731 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_CTRL).value", data
->value
);
7734 case VKI_V4L2_S_CTRL
: {
7735 struct vki_v4l2_control
*data
= (struct vki_v4l2_control
*)ARG3
;
7736 PRE_MEM_READ("ioctl(VKI_V4L2_S_CTRL)", (Addr
)data
, sizeof(*data
));
7739 case VKI_V4L2_G_TUNER
: {
7740 struct vki_v4l2_tuner
*data
= (struct vki_v4l2_tuner
*)ARG3
;
7741 PRE_FIELD_READ("ioctl(VKI_V4L2_G_TUNER).index", data
->index
);
7742 PRE_FIELD_READ("ioctl(VKI_V4L2_G_TUNER).reserved", data
->reserved
);
7743 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_TUNER)", (Addr
)data
->name
,
7744 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
7747 case VKI_V4L2_S_TUNER
: {
7748 struct vki_v4l2_tuner
*data
= (struct vki_v4l2_tuner
*)ARG3
;
7749 PRE_FIELD_READ("ioctl(VKI_V4L2_S_TUNER).index", data
->index
);
7750 PRE_FIELD_READ("ioctl(VKI_V4L2_S_TUNER).audmode", data
->audmode
);
7751 PRE_FIELD_READ("ioctl(VKI_V4L2_S_TUNER).reserved", data
->reserved
);
7754 case VKI_V4L2_G_AUDIO
: {
7755 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
7756 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_AUDIO)", (Addr
)data
,
7757 sizeof(*data
) - sizeof(data
->reserved
));
7758 PRE_FIELD_READ("ioctl(VKI_V4L2_G_AUDIO).reserved", data
->reserved
);
7761 case VKI_V4L2_S_AUDIO
: {
7762 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
7763 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDIO).index", data
->index
);
7764 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDIO).mode", data
->mode
);
7765 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDIO).reserved", data
->reserved
);
7768 case VKI_V4L2_QUERYCTRL
: {
7769 struct vki_v4l2_queryctrl
*data
= (struct vki_v4l2_queryctrl
*)ARG3
;
7770 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYCTRL).id", data
->id
);
7771 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERYCTRL)", (Addr
)&data
->type
,
7772 sizeof(*data
) - sizeof(data
->id
));
7775 case VKI_V4L2_QUERYMENU
: {
7776 struct vki_v4l2_querymenu
*data
= (struct vki_v4l2_querymenu
*)ARG3
;
7777 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYMENU).id", data
->id
);
7778 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYMENU).index", data
->index
);
7779 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERYMENU)", (Addr
)data
->name
,
7780 sizeof(*data
) - sizeof(data
->id
) - sizeof(data
->index
));
7783 case VKI_V4L2_G_INPUT
: {
7784 int *data
= (int *)ARG3
;
7785 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_INPUT)", (Addr
)data
, sizeof(*data
));
7788 case VKI_V4L2_S_INPUT
: {
7789 int *data
= (int *)ARG3
;
7790 PRE_MEM_READ("ioctl(VKI_V4L2_S_INPUT)", (Addr
)data
, sizeof(*data
));
7793 case VKI_V4L2_G_EDID
: {
7794 struct vki_v4l2_edid
*data
= (struct vki_v4l2_edid
*)ARG3
;
7795 PRE_MEM_READ("ioctl(VKI_V4L2_G_EDID)", (Addr
)data
, sizeof(*data
));
7796 if (data
->blocks
&& data
->edid
)
7797 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_EDID)", (Addr
)data
->edid
, data
->blocks
* 128);
7800 case VKI_V4L2_S_EDID
: {
7801 struct vki_v4l2_edid
*data
= (struct vki_v4l2_edid
*)ARG3
;
7802 PRE_MEM_READ("ioctl(VKI_V4L2_S_EDID)", (Addr
)data
, sizeof(*data
));
7803 if (data
->blocks
&& data
->edid
)
7804 PRE_MEM_READ("ioctl(VKI_V4L2_S_EDID)", (Addr
)data
->edid
, data
->blocks
* 128);
7807 case VKI_V4L2_G_OUTPUT
: {
7808 int *data
= (int *)ARG3
;
7809 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_OUTPUT)", (Addr
)data
, sizeof(*data
));
7812 case VKI_V4L2_S_OUTPUT
: {
7813 int *data
= (int *)ARG3
;
7814 PRE_MEM_READ("ioctl(VKI_V4L2_S_OUTPUT)", (Addr
)data
, sizeof(*data
));
7817 case VKI_V4L2_ENUMOUTPUT
: {
7818 struct vki_v4l2_output
*data
= (struct vki_v4l2_output
*)ARG3
;
7819 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMOUTPUT).index", data
->index
);
7820 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMOUTPUT)", (Addr
)data
->name
, sizeof(*data
) - sizeof(data
->index
));
7823 case VKI_V4L2_G_AUDOUT
: {
7824 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
7825 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_AUDOUT)", (Addr
)data
,
7826 sizeof(*data
) - sizeof(data
->reserved
));
7827 PRE_FIELD_READ("ioctl(VKI_V4L2_G_AUDOUT).reserved", data
->reserved
);
7830 case VKI_V4L2_S_AUDOUT
: {
7831 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
7832 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDOUT).index", data
->index
);
7833 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDOUT).reserved", data
->reserved
);
7834 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDOUT).mode", data
->mode
);
7837 case VKI_V4L2_G_MODULATOR
: {
7838 struct vki_v4l2_modulator
*data
= (struct vki_v4l2_modulator
*)ARG3
;
7839 PRE_FIELD_READ("ioctl(VKI_V4L2_G_MODULATOR).index", data
->index
);
7840 PRE_FIELD_READ("ioctl(VKI_V4L2_G_MODULATOR).reserved", data
->reserved
);
7841 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_MODULATOR)", (Addr
)data
->name
,
7842 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
7845 case VKI_V4L2_S_MODULATOR
: {
7846 struct vki_v4l2_modulator
*data
= (struct vki_v4l2_modulator
*)ARG3
;
7847 PRE_FIELD_READ("ioctl(VKI_V4L2_S_MODULATOR).index", data
->index
);
7848 PRE_FIELD_READ("ioctl(VKI_V4L2_S_MODULATOR).txsubchans", data
->txsubchans
);
7849 PRE_FIELD_READ("ioctl(VKI_V4L2_S_MODULATOR).reserved", data
->reserved
);
7852 case VKI_V4L2_G_FREQUENCY
: {
7853 struct vki_v4l2_frequency
*data
= (struct vki_v4l2_frequency
*)ARG3
;
7854 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FREQUENCY).tuner", data
->tuner
);
7855 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FREQUENCY).reserved", data
->reserved
);
7856 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FREQUENCY).type", data
->type
);
7857 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FREQUENCY).frequency", data
->frequency
);
7860 case VKI_V4L2_S_FREQUENCY
: {
7861 struct vki_v4l2_frequency
*data
= (struct vki_v4l2_frequency
*)ARG3
;
7862 PRE_MEM_READ("ioctl(VKI_V4L2_S_FREQUENCY)", (Addr
)data
, sizeof(*data
));
7865 case VKI_V4L2_CROPCAP
: {
7866 struct vki_v4l2_cropcap
*data
= (struct vki_v4l2_cropcap
*)ARG3
;
7867 PRE_FIELD_READ("ioctl(VKI_V4L2_CROPCAP)", data
->type
);
7868 PRE_MEM_WRITE("ioctl(VKI_V4L2_CROPCAP)", (Addr
)&data
->bounds
, sizeof(*data
) - sizeof(data
->type
));
7871 case VKI_V4L2_G_CROP
: {
7872 struct vki_v4l2_crop
*data
= (struct vki_v4l2_crop
*)ARG3
;
7873 PRE_FIELD_READ("ioctl(VKI_V4L2_G_CROP).type", data
->type
);
7874 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_CROP).c", data
->c
);
7877 case VKI_V4L2_S_CROP
: {
7878 struct vki_v4l2_crop
*data
= (struct vki_v4l2_crop
*)ARG3
;
7879 PRE_MEM_READ("ioctl(VKI_V4L2_S_CROP)", (Addr
)data
, sizeof(*data
));
7882 case VKI_V4L2_G_JPEGCOMP
: {
7883 struct vki_v4l2_jpegcompression
*data
= (struct vki_v4l2_jpegcompression
*)ARG3
;
7884 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_JPEGCOMP)", (Addr
)data
, sizeof(*data
));
7887 case VKI_V4L2_S_JPEGCOMP
: {
7888 struct vki_v4l2_jpegcompression
*data
= (struct vki_v4l2_jpegcompression
*)ARG3
;
7889 PRE_MEM_READ("ioctl(VKI_V4L2_S_JPEGCOMP)", (Addr
)data
, sizeof(*data
));
7892 case VKI_V4L2_QUERYSTD
: {
7893 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
7894 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERYSTD)", (Addr
)data
, sizeof(*data
));
7897 case VKI_V4L2_ENUMAUDIO
: {
7898 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
7899 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMAUDIO).index", data
->index
);
7900 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMAUDIO).reserved", data
->reserved
);
7901 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMAUDIO)", (Addr
)data
->name
,
7902 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
7905 case VKI_V4L2_ENUMAUDOUT
: {
7906 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
7907 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMAUDOUT).index", data
->index
);
7908 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMAUDOUT).reserved", data
->reserved
);
7909 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMAUDOUT)", (Addr
)data
->name
,
7910 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
7913 case VKI_V4L2_G_PRIORITY
: {
7914 __vki_u32
*data
= (__vki_u32
*)ARG3
;
7915 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_PRIORITY)", (Addr
)data
, sizeof(*data
));
7918 case VKI_V4L2_S_PRIORITY
: {
7919 __vki_u32
*data
= (__vki_u32
*)ARG3
;
7920 PRE_MEM_READ("ioctl(VKI_V4L2_S_PRIORITY)", (Addr
)data
, sizeof(*data
));
7923 case VKI_V4L2_G_SLICED_VBI_CAP
: {
7924 struct vki_v4l2_sliced_vbi_cap
*data
= (struct vki_v4l2_sliced_vbi_cap
*)ARG3
;
7925 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SLICED_VBI_CAP).type", data
->type
);
7926 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SLICED_VBI_CAP).reserved", data
->reserved
);
7927 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_SLICED_VBI_CAP)", (Addr
)data
,
7928 sizeof(*data
) - sizeof(data
->type
) - sizeof(data
->reserved
));
7931 case VKI_V4L2_G_EXT_CTRLS
: {
7932 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
7933 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).ctrl_class", data
->ctrl_class
);
7934 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).count", data
->count
);
7938 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls", data
->controls
);
7939 for (i
= 0; i
< data
->count
; i
++) {
7940 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].id", data
->controls
[i
].id
);
7941 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].size", data
->controls
[i
].size
);
7942 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].reserved2", data
->controls
[i
].reserved2
);
7943 if (data
->controls
[i
].size
) {
7944 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].ptr", data
->controls
[i
].ptr
);
7945 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].ptr[]",
7946 (Addr
)data
->controls
[i
].ptr
, data
->controls
[i
].size
);
7948 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].value64",
7949 data
->controls
[i
].value64
);
7953 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_EXT_CTRLS).error_idx", data
->error_idx
);
7954 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).reserved", data
->reserved
);
7957 case VKI_V4L2_S_EXT_CTRLS
: {
7958 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
7959 PRE_FIELD_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).ctrl_class", data
->ctrl_class
);
7960 PRE_FIELD_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).count", data
->count
);
7964 PRE_FIELD_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).controls", data
->controls
);
7965 PRE_MEM_READ("ioctl(VKI_V4L2_S_EXT_CTRLS)", (Addr
)data
->controls
,
7966 data
->count
* sizeof(data
->controls
[0]));
7967 for (i
= 0; i
< data
->count
; i
++) {
7968 if (data
->controls
[i
].size
) {
7969 PRE_MEM_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).controls[].ptr[]",
7970 (Addr
)data
->controls
[i
].ptr
, data
->controls
[i
].size
);
7974 PRE_FIELD_WRITE("ioctl(VKI_V4L2_S_EXT_CTRLS).error_idx", data
->error_idx
);
7975 PRE_FIELD_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).reserved", data
->reserved
);
7978 case VKI_V4L2_TRY_EXT_CTRLS
: {
7979 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
7980 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).ctrl_class", data
->ctrl_class
);
7981 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).count", data
->count
);
7985 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).controls", data
->controls
);
7986 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS)", (Addr
)data
->controls
,
7987 data
->count
* sizeof(data
->controls
[0]));
7988 for (i
= 0; i
< data
->count
; i
++) {
7989 if (data
->controls
[i
].size
) {
7990 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).controls[].ptr[]",
7991 (Addr
)data
->controls
[i
].ptr
, data
->controls
[i
].size
);
7995 PRE_FIELD_WRITE("ioctl(VKI_V4L2_TRY_EXT_CTRLS).error_idx", data
->error_idx
);
7996 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).reserved", data
->reserved
);
7999 case VKI_V4L2_ENUM_FRAMESIZES
: {
8000 struct vki_v4l2_frmsizeenum
*data
= (struct vki_v4l2_frmsizeenum
*)ARG3
;
8001 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMESIZES).index", data
->index
);
8002 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMESIZES).pixel_format", data
->pixel_format
);
8003 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMESIZES).reserved", data
->reserved
);
8004 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FRAMESIZES).type", data
->type
);
8005 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FRAMESIZES).stepwise", data
->stepwise
);
8008 case VKI_V4L2_ENUM_FRAMEINTERVALS
: {
8009 struct vki_v4l2_frmivalenum
*data
= (struct vki_v4l2_frmivalenum
*)ARG3
;
8010 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).index", data
->index
);
8011 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).pixel_format", data
->pixel_format
);
8012 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).width", data
->width
);
8013 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).height", data
->height
);
8014 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).reserved", data
->reserved
);
8015 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).type", data
->type
);
8016 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).stepwise", data
->stepwise
);
8019 case VKI_V4L2_G_ENC_INDEX
: {
8020 struct vki_v4l2_enc_idx
*data
= (struct vki_v4l2_enc_idx
*)ARG3
;
8021 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_ENC_INDEX)", (Addr
)data
, sizeof(*data
));
8024 case VKI_V4L2_ENCODER_CMD
: {
8025 struct vki_v4l2_encoder_cmd
*data
= (struct vki_v4l2_encoder_cmd
*)ARG3
;
8026 PRE_MEM_READ("ioctl(VKI_V4L2_ENCODER_CMD)", (Addr
)data
, sizeof(*data
));
8029 case VKI_V4L2_TRY_ENCODER_CMD
: {
8030 struct vki_v4l2_encoder_cmd
*data
= (struct vki_v4l2_encoder_cmd
*)ARG3
;
8031 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_ENCODER_CMD)", (Addr
)data
, sizeof(*data
));
8034 case VKI_V4L2_DBG_S_REGISTER
: {
8035 struct vki_v4l2_dbg_register
*data
= (struct vki_v4l2_dbg_register
*)ARG3
;
8036 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_S_REGISTER).match.type", data
->match
.type
);
8037 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_S_REGISTER).match.addr", data
->match
.addr
);
8038 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_S_REGISTER).reg", data
->reg
);
8039 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_S_REGISTER).val", data
->val
);
8040 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_S_REGISTER).size", data
->size
);
8043 case VKI_V4L2_DBG_G_REGISTER
: {
8044 struct vki_v4l2_dbg_register
*data
= (struct vki_v4l2_dbg_register
*)ARG3
;
8045 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_REGISTER).match.type", data
->match
.type
);
8046 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_REGISTER).match.addr", data
->match
.addr
);
8047 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_REGISTER).reg", data
->reg
);
8048 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_G_REGISTER).val", data
->val
);
8049 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_G_REGISTER).size", data
->size
);
8052 case VKI_V4L2_S_HW_FREQ_SEEK
: {
8053 struct vki_v4l2_hw_freq_seek
*data
= (struct vki_v4l2_hw_freq_seek
*)ARG3
;
8054 PRE_MEM_READ("ioctl(VKI_V4L2_S_HW_FREQ_SEEK)", (Addr
)data
, sizeof(*data
));
8057 case VKI_V4L2_S_DV_TIMINGS
: {
8058 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
8059 PRE_FIELD_READ("ioctl(VKI_V4L2_S_DV_TIMINGS).type", data
->type
);
8060 PRE_FIELD_READ("ioctl(VKI_V4L2_S_DV_TIMINGS).bt", data
->bt
);
8063 case VKI_V4L2_G_DV_TIMINGS
: {
8064 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
8065 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_DV_TIMINGS)", (Addr
)data
, sizeof(*data
));
8068 case VKI_V4L2_DQEVENT
: {
8069 struct vki_v4l2_event
*data
= (struct vki_v4l2_event
*)ARG3
;
8070 PRE_MEM_WRITE("ioctl(VKI_V4L2_DQEVENT)", (Addr
)data
, sizeof(*data
));
8073 case VKI_V4L2_SUBSCRIBE_EVENT
: {
8074 struct vki_v4l2_event_subscription
*data
= (struct vki_v4l2_event_subscription
*)ARG3
;
8075 PRE_MEM_READ("ioctl(VKI_V4L2_SUBSCRIBE_EVENT)", (Addr
)data
, sizeof(*data
));
8078 case VKI_V4L2_UNSUBSCRIBE_EVENT
: {
8079 struct vki_v4l2_event_subscription
*data
= (struct vki_v4l2_event_subscription
*)ARG3
;
8080 PRE_MEM_READ("ioctl(VKI_V4L2_UNSUBSCRIBE_EVENT)", (Addr
)data
, sizeof(*data
));
8083 case VKI_V4L2_CREATE_BUFS
: {
8084 struct vki_v4l2_create_buffers
*data
= (struct vki_v4l2_create_buffers
*)ARG3
;
8085 struct vki_v4l2_format
*fmt
= &data
->format
;
8086 PRE_FIELD_WRITE("ioctl(VKI_V4L2_CREATE_BUFS).index", data
->index
);
8087 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).count", data
->count
);
8088 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).memory", data
->memory
);
8089 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).reserved", data
->reserved
);
8090 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.type", fmt
->type
);
8091 switch (fmt
->type
) {
8092 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
8093 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
8094 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.pix", fmt
->fmt
.raw_data
);
8096 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
8097 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
8098 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.vbi", fmt
->fmt
.vbi
);
8100 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
8101 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
8102 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.sliced", fmt
->fmt
.sliced
);
8104 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
8105 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
8106 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.win", fmt
->fmt
.win
);
8108 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
8109 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
8110 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.pix_mp", fmt
->fmt
.pix_mp
);
8112 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
8113 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.sdr", fmt
->fmt
.sdr
);
8118 case VKI_V4L2_PREPARE_BUF
: {
8119 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
8120 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).index", data
->index
);
8121 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).type", data
->type
);
8122 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).memory", data
->memory
);
8123 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).reserved", data
->reserved
);
8124 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).reserved2", data
->reserved2
);
8125 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
8126 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
8129 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).length", data
->length
);
8130 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).m.planes", data
->m
.planes
);
8131 for (i
= 0; i
< data
->length
; i
++) {
8132 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).m.planes[].reserved", data
->m
.planes
[i
].reserved
);
8137 case VKI_V4L2_G_SELECTION
: {
8138 struct vki_v4l2_selection
*data
= (struct vki_v4l2_selection
*)ARG3
;
8139 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SELECTION).type", data
->type
);
8140 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SELECTION).target", data
->target
);
8141 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SELECTION).flags", data
->flags
);
8142 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SELECTION).reserved", data
->reserved
);
8143 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_SELECTION).r", data
->r
);
8146 case VKI_V4L2_S_SELECTION
: {
8147 struct vki_v4l2_selection
*data
= (struct vki_v4l2_selection
*)ARG3
;
8148 PRE_MEM_READ("ioctl(VKI_V4L2_S_SELECTION)", (Addr
)data
, sizeof(*data
));
8151 case VKI_V4L2_DECODER_CMD
: {
8152 struct vki_v4l2_decoder_cmd
*data
= (struct vki_v4l2_decoder_cmd
*)ARG3
;
8153 PRE_MEM_READ("ioctl(VKI_V4L2_DECODER_CMD)", (Addr
)data
, sizeof(*data
));
8156 case VKI_V4L2_TRY_DECODER_CMD
: {
8157 struct vki_v4l2_decoder_cmd
*data
= (struct vki_v4l2_decoder_cmd
*)ARG3
;
8158 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_DECODER_CMD)", (Addr
)data
, sizeof(*data
));
8161 case VKI_V4L2_ENUM_DV_TIMINGS
: {
8162 struct vki_v4l2_enum_dv_timings
*data
= (struct vki_v4l2_enum_dv_timings
*)ARG3
;
8163 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_DV_TIMINGS).index", data
->index
);
8164 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_DV_TIMINGS).pad", data
->pad
);
8165 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_DV_TIMINGS).reserved", data
->reserved
);
8166 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_DV_TIMINGS).timings", data
->timings
);
8169 case VKI_V4L2_QUERY_DV_TIMINGS
: {
8170 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
8171 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERY_DV_TIMINGS)", (Addr
)data
, sizeof(*data
));
8174 case VKI_V4L2_DV_TIMINGS_CAP
: {
8175 struct vki_v4l2_dv_timings_cap
*data
= (struct vki_v4l2_dv_timings_cap
*)ARG3
;
8176 PRE_MEM_WRITE("ioctl(VKI_V4L2_DV_TIMINGS_CAP)", (Addr
)data
, sizeof(*data
));
8179 case VKI_V4L2_ENUM_FREQ_BANDS
: {
8180 struct vki_v4l2_frequency_band
*data
= (struct vki_v4l2_frequency_band
*)ARG3
;
8181 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).tuner", data
->tuner
);
8182 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).type", data
->type
);
8183 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).index", data
->index
);
8184 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).reserved", data
->reserved
);
8185 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).capability", data
->capability
);
8186 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).rangelow", data
->rangelow
);
8187 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).rangehigh", data
->rangehigh
);
8188 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).modulation", data
->modulation
);
8191 case VKI_V4L2_DBG_G_CHIP_INFO
: {
8192 struct vki_v4l2_dbg_chip_info
*data
= (struct vki_v4l2_dbg_chip_info
*)ARG3
;
8193 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).match.type", data
->match
.type
);
8194 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).match.addr", data
->match
.addr
);
8195 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).name", data
->name
);
8196 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).flags", data
->flags
);
8197 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).reserved", data
->reserved
);
8200 case VKI_V4L2_QUERY_EXT_CTRL
: {
8201 struct vki_v4l2_query_ext_ctrl
*data
= (struct vki_v4l2_query_ext_ctrl
*)ARG3
;
8202 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERY_EXT_CTRL).id", data
->id
);
8203 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERY_EXT_CTRL).reserved", data
->reserved
);
8204 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERY_EXT_CTRL)", (Addr
)&data
->type
,
8205 sizeof(*data
) - sizeof(data
->id
) - sizeof(data
->reserved
));
8208 case VKI_V4L2_SUBDEV_G_FMT
: {
8209 struct vki_v4l2_subdev_format
*data
= (struct vki_v4l2_subdev_format
*)ARG3
;
8210 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FMT).pad", data
->pad
);
8211 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FMT).which", data
->which
);
8212 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FMT).reserved", data
->reserved
);
8213 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_G_FMT).format", data
->format
);
8216 case VKI_V4L2_SUBDEV_S_FMT
: {
8217 struct vki_v4l2_subdev_format
*data
= (struct vki_v4l2_subdev_format
*)ARG3
;
8218 PRE_MEM_READ("ioctl(VKI_V4L2_SUBDEV_S_FMT)", (Addr
)data
, sizeof(*data
));
8221 case VKI_V4L2_SUBDEV_G_FRAME_INTERVAL
: {
8222 struct vki_v4l2_subdev_frame_interval
*data
= (struct vki_v4l2_subdev_frame_interval
*)ARG3
;
8223 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FRAME_SIZE).pad", data
->pad
);
8224 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FRAME_SIZE).reserved", data
->reserved
);
8225 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_G_FRAME_SIZE).interval", data
->interval
);
8228 case VKI_V4L2_SUBDEV_S_FRAME_INTERVAL
: {
8229 struct vki_v4l2_subdev_frame_interval
*data
= (struct vki_v4l2_subdev_frame_interval
*)ARG3
;
8230 PRE_MEM_READ("ioctl(VKI_V4L2_SUBDEV_S_FRAME_INTERVAL)", (Addr
)data
, sizeof(*data
));
8233 case VKI_V4L2_SUBDEV_ENUM_MBUS_CODE
: {
8234 struct vki_v4l2_subdev_mbus_code_enum
*data
= (struct vki_v4l2_subdev_mbus_code_enum
*)ARG3
;
8235 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).index", data
->index
);
8236 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).pad", data
->pad
);
8237 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).code", data
->code
);
8238 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).which", data
->which
);
8239 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).reserved", data
->reserved
);
8242 case VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE
: {
8243 struct vki_v4l2_subdev_frame_size_enum
*data
= (struct vki_v4l2_subdev_frame_size_enum
*)ARG3
;
8244 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).index", data
->index
);
8245 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).pad", data
->pad
);
8246 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).code", data
->code
);
8247 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).which", data
->which
);
8248 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).reserved", data
->reserved
);
8249 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).min_width", data
->min_width
);
8250 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).min_height", data
->min_height
);
8251 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).max_width", data
->max_width
);
8252 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).max_height", data
->max_height
);
8255 case VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL
: {
8256 struct vki_v4l2_subdev_frame_interval_enum
*data
= (struct vki_v4l2_subdev_frame_interval_enum
*)ARG3
;
8257 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).index", data
->index
);
8258 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).pad", data
->pad
);
8259 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).code", data
->code
);
8260 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).width", data
->width
);
8261 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).height", data
->height
);
8262 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).which", data
->which
);
8263 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).reserved", data
->reserved
);
8264 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).interval", data
->interval
);
8267 case VKI_V4L2_SUBDEV_G_CROP
: {
8268 struct vki_v4l2_subdev_crop
*data
= (struct vki_v4l2_subdev_crop
*)ARG3
;
8269 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_CROP).pad", data
->pad
);
8270 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_CROP).which", data
->which
);
8271 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_CROP).reserved", data
->reserved
);
8272 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_G_CROP).rect", data
->rect
);
8275 case VKI_V4L2_SUBDEV_S_CROP
: {
8276 struct vki_v4l2_subdev_crop
*data
= (struct vki_v4l2_subdev_crop
*)ARG3
;
8277 PRE_MEM_READ("ioctl(VKI_V4L2_SUBDEV_S_CROP)", (Addr
)data
, sizeof(*data
));
8280 case VKI_V4L2_SUBDEV_G_SELECTION
: {
8281 struct vki_v4l2_subdev_selection
*data
= (struct vki_v4l2_subdev_selection
*)ARG3
;
8282 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).pad", data
->pad
);
8283 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).which", data
->which
);
8284 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).target", data
->target
);
8285 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).flags", data
->flags
);
8286 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).reserved", data
->reserved
);
8287 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).r", data
->r
);
8290 case VKI_V4L2_SUBDEV_S_SELECTION
: {
8291 struct vki_v4l2_subdev_selection
*data
= (struct vki_v4l2_subdev_selection
*)ARG3
;
8292 PRE_MEM_READ("ioctl(VKI_V4L2_SUBDEV_S_SELECTION)", (Addr
)data
, sizeof(*data
));
8295 case VKI_MEDIA_IOC_DEVICE_INFO
: {
8296 struct vki_media_device_info
*data
= (struct vki_media_device_info
*)ARG3
;
8297 PRE_FIELD_READ("ioctl(VKI_MEDIA_IOC_DEVICE_INFO).reserved", data
->reserved
);
8298 PRE_MEM_WRITE("ioctl(VKI_MEDIA_IOC_DEVICE_INFO)",
8299 (Addr
)data
, sizeof(*data
) - sizeof(data
->reserved
));
8302 case VKI_MEDIA_IOC_ENUM_ENTITIES
: {
8303 struct vki_media_entity_desc
*data
= (struct vki_media_entity_desc
*)ARG3
;
8304 PRE_FIELD_READ("ioctl(VKI_MEDIA_IOC_ENUM_ENTITIES).id", data
->id
);
8305 PRE_MEM_WRITE("ioctl(VKI_MEDIA_IOC_ENUM_ENTITIES)",
8306 (Addr
)data
->name
, sizeof(*data
) - sizeof(data
->id
));
8309 case VKI_MEDIA_IOC_ENUM_LINKS
: {
8310 struct vki_media_links_enum
*data
= (struct vki_media_links_enum
*)ARG3
;
8311 PRE_MEM_READ("ioctl(VKI_MEDIA_IOC_ENUM_LINKS)", (Addr
)data
, sizeof(*data
));
8314 case VKI_MEDIA_IOC_SETUP_LINK
: {
8315 struct vki_media_link_desc
*data
= (struct vki_media_link_desc
*)ARG3
;
8316 PRE_MEM_READ("ioctl(VKI_MEDIA_IOC_SETUP_LINK)", (Addr
)data
, sizeof(*data
));
8321 /* EVIOC* are variable length and return size written on success */
8322 switch (ARG2
& ~(_VKI_IOC_SIZEMASK
<< _VKI_IOC_SIZESHIFT
)) {
8323 case VKI_EVIOCGNAME(0):
8324 case VKI_EVIOCGPHYS(0):
8325 case VKI_EVIOCGUNIQ(0):
8326 case VKI_EVIOCGKEY(0):
8327 case VKI_EVIOCGLED(0):
8328 case VKI_EVIOCGSND(0):
8329 case VKI_EVIOCGSW(0):
8330 case VKI_EVIOCGBIT(VKI_EV_SYN
,0):
8331 case VKI_EVIOCGBIT(VKI_EV_KEY
,0):
8332 case VKI_EVIOCGBIT(VKI_EV_REL
,0):
8333 case VKI_EVIOCGBIT(VKI_EV_ABS
,0):
8334 case VKI_EVIOCGBIT(VKI_EV_MSC
,0):
8335 case VKI_EVIOCGBIT(VKI_EV_SW
,0):
8336 case VKI_EVIOCGBIT(VKI_EV_LED
,0):
8337 case VKI_EVIOCGBIT(VKI_EV_SND
,0):
8338 case VKI_EVIOCGBIT(VKI_EV_REP
,0):
8339 case VKI_EVIOCGBIT(VKI_EV_FF
,0):
8340 case VKI_EVIOCGBIT(VKI_EV_PWR
,0):
8341 case VKI_EVIOCGBIT(VKI_EV_FF_STATUS
,0):
8342 PRE_MEM_WRITE("ioctl(EVIO*)", ARG3
, _VKI_IOC_SIZE(ARG2
));
8345 ML_(PRE_unknown_ioctl
)(tid
, ARG2
, ARG3
);
8358 /* --- BEGIN special IOCTL handlers for specific Android hardware --- */
8360 /* BEGIN undocumented ioctls for PowerVR SGX 540 (the GPU on Nexus S) */
8361 if (KernelVariantiS(KernelVariant_android_gpu_sgx5xx
,
8362 VG_(clo_kernel_variant
))) {
8364 if (ARG2
>= 0xC01C6700 && ARG2
<= 0xC01C67FF && ARG3
>= 0x1000) {
8365 /* What's going on here: there appear to be a bunch of ioctls
8366 of the form 0xC01C67xx which are undocumented, and if
8367 unhandled give rise to a vast number of false positives in
8370 The "normal" interpretation of an ioctl of this form would
8371 be that the 3rd arg is a pointer to an area of size 0x1C
8372 (28 bytes) which is filled in by the kernel. Hence you
8373 might think that "POST_MEM_WRITE(ARG3, 28)" would fix it.
8376 It requires POST_MEM_WRITE(ARG3, 256) to silence them.
8377 One interpretation of this is that ARG3 really does point
8378 to a 28 byte struct, but inside that are pointers to other
8379 areas also filled in by the kernel. If these happen to be
8380 allocated just back up the stack then the 256 byte paint
8381 might cover them too, somewhat indiscriminately.
8383 By printing out ARG3 and also the 28 bytes that it points
8384 at, it's possible to guess that the 7 word structure has
8388 ioctl-number 0x1C ptr1 ptr1size ptr2 ptr2size aBitMask
8390 Unfortunately that doesn't seem to work for some reason,
8391 so stay with the blunt-instrument approach for the time
8395 /* blunt-instrument approach */
8396 POST_MEM_WRITE(ARG3
, 256);
8398 /* be a bit more sophisticated */
8399 POST_MEM_WRITE(ARG3
, 28);
8400 UInt
* word
= (UInt
*)ARG3
;
8401 if (word
&& word
[2] && word
[3] < 0x200/*stay sane*/)
8402 POST_MEM_WRITE(word
[2], word
[3]); // "ptr1"
8403 if (word
&& word
[4] && word
[5] < 0x200/*stay sane*/)
8404 POST_MEM_WRITE(word
[4], word
[5]); // "ptr2"
8406 goto post_sys_ioctl__out
;
8409 /* END undocumented ioctls for PowerVR SGX 540 (the GPU on Nexus S) */
8411 /* BEGIN undocumented ioctls for Qualcomm Adreno 3xx */
8412 if (KernelVariantiS(KernelVariant_android_gpu_adreno3xx
,
8413 VG_(clo_kernel_variant
))) {
8414 if (ARG2
== 0xC00C0902) {
8415 POST_MEM_WRITE(ARG3
, 24); // 16 is not enough
8416 goto post_sys_ioctl__out
;
8419 /* END undocumented ioctls for Qualcomm Adreno 3xx */
8421 /* --- END special IOCTL handlers for specific Android hardware --- */
8423 /* --- normal handling --- */
8424 switch (ARG2
/* request */) {
8426 /* The Linux kernel "ion" memory allocator, used on Android. Note:
8427 this is pretty poor given that there's no pre-handling to check
8428 that writable areas are addressable. */
8429 case VKI_ION_IOC_ALLOC
: {
8430 struct vki_ion_allocation_data
* data
8431 = (struct vki_ion_allocation_data
*)ARG3
;
8432 POST_FIELD_WRITE(data
->handle
);
8435 case VKI_ION_IOC_MAP
: {
8436 struct vki_ion_fd_data
* data
= (struct vki_ion_fd_data
*)ARG3
;
8437 POST_FIELD_WRITE(data
->fd
);
8440 case VKI_ION_IOC_FREE
: // is this necessary?
8441 POST_MEM_WRITE(ARG3
, sizeof(struct vki_ion_handle_data
));
8443 case VKI_ION_IOC_SHARE
:
8445 case VKI_ION_IOC_IMPORT
: {
8446 struct vki_ion_fd_data
* data
= (struct vki_ion_fd_data
*)ARG3
;
8447 POST_FIELD_WRITE(data
->handle
);
8450 case VKI_ION_IOC_SYNC
:
8452 case VKI_ION_IOC_CUSTOM
: // is this necessary?
8453 POST_MEM_WRITE(ARG3
, sizeof(struct vki_ion_custom_data
));
8456 case VKI_SYNC_IOC_MERGE
: {
8457 struct vki_sync_merge_data
* data
= (struct vki_sync_merge_data
*)ARG3
;
8458 POST_FIELD_WRITE(data
->fence
);
8465 case VKI_IB_USER_MAD_ENABLE_PKEY
:
8468 POST_MEM_WRITE( ARG3
, sizeof(struct vki_termios
) );
8475 POST_MEM_WRITE( ARG3
, sizeof(struct vki_termio
) );
8483 case VKI_TIOCGWINSZ
:
8484 POST_MEM_WRITE( ARG3
, sizeof(struct vki_winsize
) );
8486 case VKI_TIOCSWINSZ
:
8492 POST_MEM_WRITE( ARG3
, sizeof(unsigned int) );
8495 POST_MEM_WRITE( ARG3
, sizeof(char *) );
8498 /* Get process group ID for foreground processing group. */
8499 POST_MEM_WRITE( ARG3
, sizeof(vki_pid_t
) );
8502 /* Set a process group ID? */
8503 POST_MEM_WRITE( ARG3
, sizeof(vki_pid_t
) );
8505 case VKI_TIOCGPTN
: /* Get Pty Number (of pty-mux device) */
8506 POST_MEM_WRITE( ARG3
, sizeof(int));
8510 case VKI_TIOCSPTLCK
: /* Lock/unlock Pty */
8522 case VKI_FIONREAD
: /* identical to SIOCINQ */
8523 POST_MEM_WRITE( ARG3
, sizeof(int) );
8526 POST_MEM_WRITE( ARG3
, sizeof(vki_loff_t
) );
8529 case VKI_TIOCSERGETLSR
:
8530 POST_MEM_WRITE( ARG3
, sizeof(int) );
8532 case VKI_TIOCGICOUNT
:
8533 POST_MEM_WRITE( ARG3
, sizeof(struct vki_serial_icounter_struct
) );
8536 case VKI_SG_SET_COMMAND_Q
:
8540 vki_sg_io_hdr_t
*sgio
= (vki_sg_io_hdr_t
*)ARG3
;
8542 POST_MEM_WRITE( (Addr
)sgio
->sbp
, sgio
->sb_len_wr
);
8544 if ( sgio
->dxfer_direction
== VKI_SG_DXFER_FROM_DEV
||
8545 sgio
->dxfer_direction
== VKI_SG_DXFER_TO_FROM_DEV
) {
8546 int transferred
= sgio
->dxfer_len
- sgio
->resid
;
8547 POST_MEM_WRITE( (Addr
)sgio
->dxferp
, transferred
);
8551 case VKI_SG_GET_SCSI_ID
:
8552 POST_MEM_WRITE(ARG3
, sizeof(vki_sg_scsi_id_t
));
8554 case VKI_SG_SET_RESERVED_SIZE
:
8556 case VKI_SG_SET_TIMEOUT
:
8558 case VKI_SG_GET_RESERVED_SIZE
:
8559 POST_MEM_WRITE(ARG3
, sizeof(int));
8561 case VKI_SG_GET_TIMEOUT
:
8563 case VKI_SG_GET_VERSION_NUM
:
8564 POST_MEM_WRITE(ARG3
, sizeof(int));
8566 case VKI_SG_EMULATED_HOST
:
8567 POST_MEM_WRITE(ARG3
, sizeof(int));
8569 case VKI_SG_GET_SG_TABLESIZE
:
8570 POST_MEM_WRITE(ARG3
, sizeof(int));
8573 case VKI_IIOCGETCPS
:
8574 POST_MEM_WRITE( ARG3
, VKI_ISDN_MAX_CHANNELS
* 2 * sizeof(unsigned long) );
8576 case VKI_IIOCNETGPN
:
8577 POST_MEM_WRITE( ARG3
, sizeof(vki_isdn_net_ioctl_phone
) );
8580 /* These all use struct ifreq AFAIK */
8581 case VKI_SIOCGIFINDEX
: /* get iface index */
8582 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_ifindex
,
8583 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_ifindex
) );
8585 case VKI_SIOCGIFFLAGS
: /* get flags */
8586 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
8587 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
8589 case VKI_SIOCGIFHWADDR
: /* Get hardware address */
8590 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->ifr_hwaddr
,
8591 sizeof(((struct vki_ifreq
*)ARG3
)->ifr_hwaddr
) );
8593 case VKI_SIOCGIFMTU
: /* get MTU size */
8594 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_mtu
,
8595 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_mtu
) );
8597 case VKI_SIOCGIFADDR
: /* get PA address */
8598 case VKI_SIOCGIFDSTADDR
: /* get remote PA address */
8599 case VKI_SIOCGIFBRDADDR
: /* get broadcast PA address */
8600 case VKI_SIOCGIFNETMASK
: /* get network PA mask */
8602 (Addr
)&((struct vki_ifreq
*)ARG3
)->ifr_addr
,
8603 sizeof(((struct vki_ifreq
*)ARG3
)->ifr_addr
) );
8605 case VKI_SIOCGIFMETRIC
: /* get metric */
8607 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_metric
,
8608 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_metric
) );
8610 case VKI_SIOCGIFMAP
: /* Get device parameters */
8612 (Addr
)&((struct vki_ifreq
*)ARG3
)->ifr_map
,
8613 sizeof(((struct vki_ifreq
*)ARG3
)->ifr_map
) );
8616 case VKI_SIOCGIFTXQLEN
: /* Get the tx queue length */
8618 (Addr
)&((struct vki_ifreq
*)ARG3
)->ifr_qlen
,
8619 sizeof(((struct vki_ifreq
*)ARG3
)->ifr_qlen
) );
8621 case VKI_SIOCGIFNAME
: /* get iface name */
8623 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_name
,
8624 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_name
) );
8626 case VKI_SIOCETHTOOL
: { /* ethtool(8) interface */
8627 struct vki_ifreq
*ir
= (struct vki_ifreq
*)ARG3
;
8628 switch ( *(vki_u32
*)ir
->vki_ifr_data
) {
8629 case VKI_ETHTOOL_GSET
:
8630 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_cmd
));
8632 case VKI_ETHTOOL_SSET
:
8634 case VKI_ETHTOOL_GDRVINFO
:
8635 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_drvinfo
) );
8637 case VKI_ETHTOOL_GREGS
:
8638 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_regs
*)ir
->vki_ifr_data
)->data
,
8639 ((struct vki_ethtool_regs
*)ir
->vki_ifr_data
)->len
);
8641 case VKI_ETHTOOL_GWOL
:
8642 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_wolinfo
) );
8644 case VKI_ETHTOOL_SWOL
:
8646 case VKI_ETHTOOL_GMSGLVL
:
8647 case VKI_ETHTOOL_GLINK
:
8648 case VKI_ETHTOOL_GRXCSUM
:
8649 case VKI_ETHTOOL_GSG
:
8650 case VKI_ETHTOOL_GTSO
:
8651 case VKI_ETHTOOL_GUFO
:
8652 case VKI_ETHTOOL_GGSO
:
8653 case VKI_ETHTOOL_GFLAGS
:
8654 case VKI_ETHTOOL_GGRO
:
8655 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_value
));
8657 case VKI_ETHTOOL_SMSGLVL
:
8658 case VKI_ETHTOOL_SRXCSUM
:
8659 case VKI_ETHTOOL_SSG
:
8660 case VKI_ETHTOOL_STSO
:
8661 case VKI_ETHTOOL_SUFO
:
8662 case VKI_ETHTOOL_SGSO
:
8663 case VKI_ETHTOOL_SFLAGS
:
8664 case VKI_ETHTOOL_SGRO
:
8666 case VKI_ETHTOOL_NWAY_RST
:
8668 case VKI_ETHTOOL_GRINGPARAM
:
8669 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ringparam
));
8671 case VKI_ETHTOOL_SRINGPARAM
:
8673 case VKI_ETHTOOL_TEST
:
8674 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_test
*)ir
->vki_ifr_data
)->data
,
8675 ((struct vki_ethtool_test
*)ir
->vki_ifr_data
)->len
* sizeof(__vki_u64
) );
8677 case VKI_ETHTOOL_PHYS_ID
:
8679 case VKI_ETHTOOL_GPERMADDR
:
8680 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_perm_addr
*)ir
->vki_ifr_data
)->data
,
8681 ((struct vki_ethtool_perm_addr
*)ir
->vki_ifr_data
)->size
);
8683 case VKI_ETHTOOL_RESET
:
8685 case VKI_ETHTOOL_GSSET_INFO
:
8686 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_sset_info
*)ir
->vki_ifr_data
)->data
,
8687 __builtin_popcountll(((struct vki_ethtool_sset_info
*)ir
->vki_ifr_data
)->sset_mask
) * sizeof(__vki_u32
) );
8689 case VKI_ETHTOOL_GFEATURES
:
8690 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_gfeatures
*)ir
->vki_ifr_data
)->features
,
8691 ((struct vki_ethtool_gfeatures
*)ir
->vki_ifr_data
)->size
* sizeof(struct vki_ethtool_get_features_block
) );
8693 case VKI_ETHTOOL_SFEATURES
:
8695 case VKI_ETHTOOL_GCHANNELS
:
8696 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_channels
) );
8698 case VKI_ETHTOOL_SCHANNELS
:
8700 case VKI_ETHTOOL_GET_TS_INFO
:
8701 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ts_info
) );
8706 case VKI_SIOCGMIIPHY
: /* get hardware entry */
8708 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
,
8709 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
) );
8711 case VKI_SIOCGMIIREG
: /* get hardware entry registers */
8713 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->val_out
,
8714 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->val_out
) );
8717 /* tun/tap related ioctls */
8719 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_name
,
8720 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_name
) );
8722 case VKI_TUNGETFEATURES
:
8723 POST_MEM_WRITE( ARG3
, sizeof(unsigned int) );
8726 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_name
,
8727 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_name
) );
8728 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
8729 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
8731 case VKI_TUNGETSNDBUF
:
8732 POST_MEM_WRITE( ARG3
, sizeof(int) );
8734 case VKI_TUNGETVNETHDRSZ
:
8735 POST_MEM_WRITE( ARG3
, sizeof(int) );
8738 case VKI_SIOCGIFCONF
: /* get iface list */
8740 PRE_MEM_WRITE("ioctl(SIOCGIFCONF)", ARG3, sizeof(struct ifconf));
8741 KERNEL_DO_SYSCALL(tid,RES);
8742 if (!VG_(is_kerror)(RES) && RES == 0)
8743 POST_MEM_WRITE(ARG3, sizeof(struct ifconf));
8745 if (RES
== 0 && ARG3
) {
8746 struct vki_ifconf
*ifc
= (struct vki_ifconf
*) ARG3
;
8747 if (ifc
->vki_ifc_buf
!= NULL
)
8748 POST_MEM_WRITE( (Addr
)(ifc
->vki_ifc_buf
), ifc
->ifc_len
);
8751 case VKI_SIOCGSTAMP
:
8752 POST_MEM_WRITE( ARG3
, sizeof(struct vki_timeval
) );
8754 case VKI_SIOCGSTAMPNS
:
8755 POST_MEM_WRITE( ARG3
, sizeof(struct vki_timespec
) );
8757 /* SIOCOUTQ is an ioctl that, when called on a socket, returns
8758 the number of bytes currently in that socket's send buffer.
8759 It writes this value as an int to the memory location
8760 indicated by the third argument of ioctl(2). */
8762 POST_MEM_WRITE(ARG3
, sizeof(int));
8764 case VKI_SIOCGRARP
: /* get RARP table entry */
8765 case VKI_SIOCGARP
: /* get ARP table entry */
8766 POST_MEM_WRITE(ARG3
, sizeof(struct vki_arpreq
));
8769 case VKI_SIOCSIFFLAGS
: /* set flags */
8770 case VKI_SIOCSIFMAP
: /* Set device parameters */
8771 case VKI_SIOCSHWTSTAMP
: /* Set hardware time stamping */
8772 case VKI_SIOCSIFTXQLEN
: /* Set the tx queue length */
8773 case VKI_SIOCSIFDSTADDR
: /* set remote PA address */
8774 case VKI_SIOCSIFBRDADDR
: /* set broadcast PA address */
8775 case VKI_SIOCSIFNETMASK
: /* set network PA mask */
8776 case VKI_SIOCSIFMETRIC
: /* set metric */
8777 case VKI_SIOCSIFADDR
: /* set PA address */
8778 case VKI_SIOCSIFMTU
: /* set MTU size */
8779 case VKI_SIOCSIFHWADDR
: /* set hardware address */
8780 case VKI_SIOCSMIIREG
: /* set hardware entry registers */
8782 /* Routing table calls. */
8783 case VKI_SIOCADDRT
: /* add routing table entry */
8784 case VKI_SIOCDELRT
: /* delete routing table entry */
8787 /* RARP cache control calls. */
8788 case VKI_SIOCDRARP
: /* delete RARP table entry */
8789 case VKI_SIOCSRARP
: /* set RARP table entry */
8790 /* ARP cache control calls. */
8791 case VKI_SIOCSARP
: /* set ARP table entry */
8792 case VKI_SIOCDARP
: /* delete ARP table entry */
8796 POST_MEM_WRITE(ARG3
, sizeof(int));
8801 case VKI_SIOCATMARK
:
8802 POST_MEM_WRITE(ARG3
, sizeof(int));
8805 /* linux/soundcard interface (OSS) */
8806 case VKI_SNDCTL_SEQ_GETOUTCOUNT
:
8807 case VKI_SNDCTL_SEQ_GETINCOUNT
:
8808 case VKI_SNDCTL_SEQ_PERCMODE
:
8809 case VKI_SNDCTL_SEQ_TESTMIDI
:
8810 case VKI_SNDCTL_SEQ_RESETSAMPLES
:
8811 case VKI_SNDCTL_SEQ_NRSYNTHS
:
8812 case VKI_SNDCTL_SEQ_NRMIDIS
:
8813 case VKI_SNDCTL_SEQ_GETTIME
:
8814 case VKI_SNDCTL_DSP_GETBLKSIZE
:
8815 case VKI_SNDCTL_DSP_GETFMTS
:
8816 case VKI_SNDCTL_DSP_SETFMT
:
8817 case VKI_SNDCTL_DSP_GETTRIGGER
:
8818 case VKI_SNDCTL_DSP_GETODELAY
:
8819 case VKI_SNDCTL_DSP_GETSPDIF
:
8820 case VKI_SNDCTL_DSP_GETCAPS
:
8821 case VKI_SOUND_PCM_READ_RATE
:
8822 case VKI_SOUND_PCM_READ_CHANNELS
:
8823 case VKI_SOUND_PCM_READ_BITS
:
8824 case VKI_SOUND_PCM_READ_FILTER
:
8825 POST_MEM_WRITE(ARG3
, sizeof(int));
8827 case VKI_SNDCTL_SEQ_CTRLRATE
:
8828 case VKI_SNDCTL_DSP_SPEED
:
8829 case VKI_SNDCTL_DSP_STEREO
:
8830 case VKI_SNDCTL_DSP_CHANNELS
:
8831 case VKI_SOUND_PCM_WRITE_FILTER
:
8832 case VKI_SNDCTL_DSP_SUBDIVIDE
:
8833 case VKI_SNDCTL_DSP_SETFRAGMENT
:
8834 case VKI_SNDCTL_DSP_GETCHANNELMASK
:
8835 case VKI_SNDCTL_DSP_BIND_CHANNEL
:
8836 case VKI_SNDCTL_TMR_TIMEBASE
:
8837 case VKI_SNDCTL_TMR_TEMPO
:
8838 case VKI_SNDCTL_TMR_SOURCE
:
8839 case VKI_SNDCTL_MIDI_PRETIME
:
8840 case VKI_SNDCTL_MIDI_MPUMODE
:
8842 case VKI_SNDCTL_DSP_GETOSPACE
:
8843 case VKI_SNDCTL_DSP_GETISPACE
:
8844 POST_MEM_WRITE(ARG3
, sizeof(vki_audio_buf_info
));
8846 case VKI_SNDCTL_DSP_NONBLOCK
:
8848 case VKI_SNDCTL_DSP_SETTRIGGER
:
8851 case VKI_SNDCTL_DSP_POST
:
8852 case VKI_SNDCTL_DSP_RESET
:
8853 case VKI_SNDCTL_DSP_SYNC
:
8854 case VKI_SNDCTL_DSP_SETSYNCRO
:
8855 case VKI_SNDCTL_DSP_SETDUPLEX
:
8858 /* linux/soundcard interface (ALSA) */
8859 case VKI_SNDRV_PCM_IOCTL_HW_FREE
:
8860 case VKI_SNDRV_PCM_IOCTL_HWSYNC
:
8861 case VKI_SNDRV_PCM_IOCTL_PREPARE
:
8862 case VKI_SNDRV_PCM_IOCTL_RESET
:
8863 case VKI_SNDRV_PCM_IOCTL_START
:
8864 case VKI_SNDRV_PCM_IOCTL_DROP
:
8865 case VKI_SNDRV_PCM_IOCTL_DRAIN
:
8866 case VKI_SNDRV_PCM_IOCTL_RESUME
:
8867 case VKI_SNDRV_PCM_IOCTL_XRUN
:
8868 case VKI_SNDRV_PCM_IOCTL_UNLINK
:
8869 case VKI_SNDRV_TIMER_IOCTL_START
:
8870 case VKI_SNDRV_TIMER_IOCTL_STOP
:
8871 case VKI_SNDRV_TIMER_IOCTL_CONTINUE
:
8872 case VKI_SNDRV_TIMER_IOCTL_PAUSE
:
8873 case VKI_SNDRV_CTL_IOCTL_PVERSION
: {
8874 POST_MEM_WRITE( (Addr
)ARG3
, sizeof(int) );
8877 case VKI_SNDRV_CTL_IOCTL_CARD_INFO
:
8878 POST_MEM_WRITE( (Addr
)ARG3
, sizeof(struct vki_snd_ctl_card_info
) );
8880 case VKI_SNDRV_CTL_IOCTL_ELEM_LIST
: {
8881 struct vki_snd_ctl_elem_list
*data
= (struct vki_snd_ctl_elem_list
*)ARG3
;
8882 POST_MEM_WRITE( (Addr
)&data
->used
, sizeof(data
->used
) );
8883 POST_MEM_WRITE( (Addr
)&data
->count
, sizeof(data
->count
) );
8885 POST_MEM_WRITE( (Addr
)data
->pids
, sizeof(struct vki_snd_ctl_elem_id
) * data
->used
);
8889 case VKI_SNDRV_CTL_IOCTL_TLV_READ
: {
8890 struct vki_snd_ctl_tlv
*data
= (struct vki_snd_ctl_tlv
*)ARG3
;
8891 POST_MEM_WRITE( (Addr
)data
->tlv
, data
->length
);
8894 case VKI_SNDRV_CTL_IOCTL_TLV_WRITE
:
8895 case VKI_SNDRV_CTL_IOCTL_TLV_COMMAND
:
8898 /* SCSI no operand */
8899 case VKI_SCSI_IOCTL_DOORLOCK
:
8900 case VKI_SCSI_IOCTL_DOORUNLOCK
:
8903 /* Real Time Clock (/dev/rtc) ioctls */
8904 case VKI_RTC_UIE_ON
:
8905 case VKI_RTC_UIE_OFF
:
8906 case VKI_RTC_AIE_ON
:
8907 case VKI_RTC_AIE_OFF
:
8908 case VKI_RTC_PIE_ON
:
8909 case VKI_RTC_PIE_OFF
:
8910 case VKI_RTC_IRQP_SET
:
8912 case VKI_RTC_RD_TIME
:
8913 case VKI_RTC_ALM_READ
:
8914 POST_MEM_WRITE(ARG3
, sizeof(struct vki_rtc_time
));
8916 case VKI_RTC_ALM_SET
:
8918 case VKI_RTC_IRQP_READ
:
8919 POST_MEM_WRITE(ARG3
, sizeof(unsigned long));
8926 POST_MEM_WRITE(ARG3
, sizeof(int));
8928 case VKI_BLKGETSIZE
:
8929 POST_MEM_WRITE(ARG3
, sizeof(unsigned long));
8934 POST_MEM_WRITE(ARG3
, sizeof(long));
8939 POST_MEM_WRITE(ARG3
, sizeof(long));
8941 case VKI_BLKSECTGET
:
8942 POST_MEM_WRITE(ARG3
, sizeof(unsigned short));
8945 POST_MEM_WRITE(ARG3
, sizeof(int));
8948 POST_MEM_WRITE(ARG3
, sizeof(int));
8952 case VKI_BLKGETSIZE64
:
8953 POST_MEM_WRITE(ARG3
, sizeof(unsigned long long));
8955 case VKI_BLKPBSZGET
:
8956 POST_MEM_WRITE(ARG3
, sizeof(int));
8958 case VKI_BLKDISCARDZEROES
:
8959 POST_MEM_WRITE(ARG3
, sizeof(vki_uint
));
8963 case VKI_HDIO_GETGEO
: /* 0x0301 */
8964 POST_MEM_WRITE(ARG3
, sizeof(struct vki_hd_geometry
));
8966 case VKI_HDIO_GET_DMA
: /* 0x030b */
8967 POST_MEM_WRITE(ARG3
, sizeof(long));
8969 case VKI_HDIO_GET_IDENTITY
: /* 0x030d */
8970 POST_MEM_WRITE(ARG3
, VKI_SIZEOF_STRUCT_HD_DRIVEID
);
8974 case VKI_SCSI_IOCTL_GET_IDLUN
: /* 0x5382 */
8975 POST_MEM_WRITE(ARG3
, sizeof(struct vki_scsi_idlun
));
8977 case VKI_SCSI_IOCTL_GET_BUS_NUMBER
: /* 0x5386 */
8978 POST_MEM_WRITE(ARG3
, sizeof(int));
8981 /* CD ROM stuff (??) */
8982 case VKI_CDROM_DISC_STATUS
:
8984 case VKI_CDROMSUBCHNL
:
8985 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_subchnl
));
8987 case VKI_CDROMREADTOCHDR
:
8988 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_tochdr
));
8990 case VKI_CDROMREADTOCENTRY
:
8991 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_tocentry
));
8993 case VKI_CDROMMULTISESSION
:
8994 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_multisession
));
8996 case VKI_CDROMVOLREAD
:
8997 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_volctrl
));
8999 case VKI_CDROMREADRAW
:
9000 POST_MEM_WRITE(ARG3
, VKI_CD_FRAMESIZE_RAW
);
9002 case VKI_CDROMREADAUDIO
:
9004 struct vki_cdrom_read_audio
*cra
= (struct vki_cdrom_read_audio
*) ARG3
;
9005 POST_MEM_WRITE( (Addr
)(cra
->buf
), cra
->nframes
* VKI_CD_FRAMESIZE_RAW
);
9009 case VKI_CDROMPLAYMSF
:
9011 /* The following two are probably bogus (should check args
9012 for readability). JRS 20021117 */
9013 case VKI_CDROM_DRIVE_STATUS
: /* 0x5326 */
9014 case VKI_CDROM_CLEAR_OPTIONS
: /* 0x5321 */
9016 case VKI_CDROM_GET_CAPABILITY
: /* 0x5331 */
9020 POST_MEM_WRITE(ARG3
, sizeof(unsigned long));
9023 POST_MEM_WRITE(ARG3
, sizeof(int));
9026 case VKI_FBIOGET_VSCREENINFO
: //0x4600
9027 POST_MEM_WRITE(ARG3
, sizeof(struct vki_fb_var_screeninfo
));
9029 case VKI_FBIOGET_FSCREENINFO
: //0x4602
9030 POST_MEM_WRITE(ARG3
, sizeof(struct vki_fb_fix_screeninfo
));
9038 case VKI_PPSETPHASE
:
9039 case VKI_PPSETFLAGS
:
9041 case VKI_PPWCONTROL
:
9042 case VKI_PPFCONTROL
:
9045 case VKI_PPWCTLONIRQ
:
9049 POST_MEM_WRITE( ARG3
, sizeof(int) );
9051 case VKI_PPGETPHASE
:
9052 POST_MEM_WRITE( ARG3
, sizeof(int) );
9054 case VKI_PPGETMODES
:
9055 POST_MEM_WRITE( ARG3
, sizeof(unsigned int) );
9057 case VKI_PPGETFLAGS
:
9058 POST_MEM_WRITE( ARG3
, sizeof(int) );
9061 POST_MEM_WRITE( ARG3
, sizeof(unsigned char) );
9064 POST_MEM_WRITE( ARG3
, sizeof(unsigned char) );
9066 case VKI_PPRCONTROL
:
9067 POST_MEM_WRITE( ARG3
, sizeof(unsigned char) );
9070 POST_MEM_WRITE( ARG3
, sizeof(int) );
9073 POST_MEM_WRITE( ARG3
, sizeof(struct vki_timeval
) );
9077 POST_MEM_WRITE( ARG3
, 32 * 256 );
9083 POST_MEM_WRITE( (Addr
)((struct vki_consolefontdesc
*)ARG3
)->chardata
,
9084 32 * ((struct vki_consolefontdesc
*)ARG3
)->charcount
);
9089 case VKI_PIO_FONTRESET
:
9093 POST_MEM_WRITE( ARG3
, 16 * 3 );
9103 POST_MEM_WRITE( ARG3
, sizeof(char) );
9109 POST_MEM_WRITE( ARG3
, sizeof(char) );
9121 POST_MEM_WRITE( ARG3
, sizeof(int) );
9125 case VKI_KDUNMAPDISP
:
9128 case VKI_GIO_SCRNMAP
:
9129 POST_MEM_WRITE( ARG3
, VKI_E_TABSZ
);
9131 case VKI_PIO_SCRNMAP
:
9133 case VKI_GIO_UNISCRNMAP
:
9134 POST_MEM_WRITE( ARG3
, VKI_E_TABSZ
* sizeof(unsigned short) );
9136 case VKI_PIO_UNISCRNMAP
:
9139 case VKI_GIO_UNIMAP
:
9141 struct vki_unimapdesc
*desc
= (struct vki_unimapdesc
*) ARG3
;
9142 POST_MEM_WRITE( (Addr
)&desc
->entry_ct
, sizeof(desc
->entry_ct
));
9143 POST_MEM_WRITE( (Addr
)desc
->entries
,
9144 desc
->entry_ct
* sizeof(struct vki_unipair
) );
9147 case VKI_PIO_UNIMAP
:
9149 case VKI_PIO_UNIMAPCLR
:
9153 POST_MEM_WRITE( ARG3
, sizeof(int) );
9159 POST_MEM_WRITE( ARG3
, sizeof(int) );
9165 POST_MEM_WRITE( ARG3
, sizeof(char) );
9171 POST_MEM_WRITE( (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_value
,
9172 sizeof(((struct vki_kbentry
*)ARG3
)->kb_value
) );
9178 POST_MEM_WRITE( (Addr
)((struct vki_kbsentry
*)ARG3
)->kb_string
,
9179 sizeof(((struct vki_kbsentry
*)ARG3
)->kb_string
) );
9184 case VKI_KDGKBDIACR
:
9185 POST_MEM_WRITE( ARG3
, sizeof(struct vki_kbdiacrs
) );
9187 case VKI_KDSKBDIACR
:
9190 case VKI_KDGETKEYCODE
:
9191 POST_MEM_WRITE( (Addr
)((struct vki_kbkeycode
*)ARG3
)->keycode
,
9192 sizeof(((struct vki_kbkeycode
*)ARG3
)->keycode
) );
9194 case VKI_KDSETKEYCODE
:
9197 case VKI_KDSIGACCEPT
:
9205 struct vki_console_font_op
*op
= (struct vki_console_font_op
*) ARG3
;
9207 case VKI_KD_FONT_OP_SET
:
9209 case VKI_KD_FONT_OP_GET
:
9211 POST_MEM_WRITE( (Addr
) op
->data
,
9212 (op
->width
+ 7) / 8 * 32 * op
->charcount
);
9214 case VKI_KD_FONT_OP_SET_DEFAULT
:
9216 case VKI_KD_FONT_OP_COPY
:
9219 POST_MEM_WRITE( (Addr
) op
, sizeof(*op
));
9223 case VKI_VT_OPENQRY
:
9224 POST_MEM_WRITE( ARG3
, sizeof(int) );
9226 case VKI_VT_GETMODE
:
9227 POST_MEM_WRITE( ARG3
, sizeof(struct vki_vt_mode
) );
9229 case VKI_VT_SETMODE
:
9231 case VKI_VT_GETSTATE
:
9232 POST_MEM_WRITE( (Addr
) &(((struct vki_vt_stat
*) ARG3
)->v_active
),
9233 sizeof(((struct vki_vt_stat
*) ARG3
)->v_active
) );
9234 POST_MEM_WRITE( (Addr
) &(((struct vki_vt_stat
*) ARG3
)->v_state
),
9235 sizeof(((struct vki_vt_stat
*) ARG3
)->v_state
) );
9237 case VKI_VT_RELDISP
:
9238 case VKI_VT_ACTIVATE
:
9239 case VKI_VT_WAITACTIVE
:
9240 case VKI_VT_DISALLOCATE
:
9244 case VKI_VT_RESIZEX
:
9246 case VKI_VT_LOCKSWITCH
:
9247 case VKI_VT_UNLOCKSWITCH
:
9250 case VKI_USBDEVFS_CONTROL
:
9252 struct vki_usbdevfs_ctrltransfer
*vkuc
= (struct vki_usbdevfs_ctrltransfer
*)ARG3
;
9253 if (vkuc
->bRequestType
& 0x80)
9254 POST_MEM_WRITE((Addr
)vkuc
->data
, RES
);
9257 case VKI_USBDEVFS_BULK
:
9259 struct vki_usbdevfs_bulktransfer
*vkub
= (struct vki_usbdevfs_bulktransfer
*)ARG3
;
9260 if (vkub
->ep
& 0x80)
9261 POST_MEM_WRITE((Addr
)vkub
->data
, RES
);
9264 case VKI_USBDEVFS_GETDRIVER
:
9266 struct vki_usbdevfs_getdriver
*vkugd
= (struct vki_usbdevfs_getdriver
*)ARG3
;
9267 POST_MEM_WRITE((Addr
)&vkugd
->driver
, sizeof(vkugd
->driver
));
9270 case VKI_USBDEVFS_REAPURB
:
9271 case VKI_USBDEVFS_REAPURBNDELAY
:
9273 struct vki_usbdevfs_urb
**vkuu
= (struct vki_usbdevfs_urb
**)ARG3
;
9274 POST_MEM_WRITE((Addr
)vkuu
, sizeof(*vkuu
));
9277 POST_MEM_WRITE((Addr
) &((*vkuu
)->status
),sizeof((*vkuu
)->status
));
9278 if ((*vkuu
)->type
== VKI_USBDEVFS_URB_TYPE_CONTROL
) {
9279 struct vki_usbdevfs_setuppacket
*vkusp
= (struct vki_usbdevfs_setuppacket
*)(*vkuu
)->buffer
;
9280 if (vkusp
->bRequestType
& 0x80)
9281 POST_MEM_WRITE((Addr
)(vkusp
+1), (*vkuu
)->buffer_length
- sizeof(*vkusp
));
9282 POST_MEM_WRITE((Addr
)&(*vkuu
)->actual_length
, sizeof((*vkuu
)->actual_length
));
9283 } else if ((*vkuu
)->type
== VKI_USBDEVFS_URB_TYPE_ISO
) {
9284 char *bp
= (*vkuu
)->buffer
;
9286 for(i
=0; i
<(*vkuu
)->number_of_packets
; i
++) {
9287 POST_MEM_WRITE((Addr
)&(*vkuu
)->iso_frame_desc
[i
].actual_length
, sizeof((*vkuu
)->iso_frame_desc
[i
].actual_length
));
9288 POST_MEM_WRITE((Addr
)&(*vkuu
)->iso_frame_desc
[i
].status
, sizeof((*vkuu
)->iso_frame_desc
[i
].status
));
9289 if ((*vkuu
)->endpoint
& 0x80)
9290 POST_MEM_WRITE((Addr
)bp
, (*vkuu
)->iso_frame_desc
[i
].actual_length
);
9291 bp
+= (*vkuu
)->iso_frame_desc
[i
].length
; // FIXME: or actual_length??
9293 POST_MEM_WRITE((Addr
)&(*vkuu
)->error_count
, sizeof((*vkuu
)->error_count
));
9295 if ((*vkuu
)->endpoint
& 0x80)
9296 POST_MEM_WRITE((Addr
)(*vkuu
)->buffer
, (*vkuu
)->actual_length
);
9297 POST_MEM_WRITE((Addr
)&(*vkuu
)->actual_length
, sizeof((*vkuu
)->actual_length
));
9301 case VKI_USBDEVFS_CONNECTINFO
:
9302 POST_MEM_WRITE(ARG3
, sizeof(struct vki_usbdevfs_connectinfo
));
9304 case VKI_USBDEVFS_IOCTL
:
9306 struct vki_usbdevfs_ioctl
*vkui
= (struct vki_usbdevfs_ioctl
*)ARG3
;
9308 dir2
= _VKI_IOC_DIR(vkui
->ioctl_code
);
9309 size2
= _VKI_IOC_SIZE(vkui
->ioctl_code
);
9311 if (dir2
& _VKI_IOC_READ
)
9312 POST_MEM_WRITE((Addr
)vkui
->data
, size2
);
9317 /* I2C (/dev/i2c-*) ioctls */
9319 case VKI_I2C_SLAVE_FORCE
:
9320 case VKI_I2C_TENBIT
:
9324 POST_MEM_WRITE( ARG3
, sizeof(unsigned long) );
9328 struct vki_i2c_rdwr_ioctl_data
*vkui
= (struct vki_i2c_rdwr_ioctl_data
*)ARG3
;
9330 for (i
=0; i
< vkui
->nmsgs
; i
++) {
9331 struct vki_i2c_msg
*msg
= vkui
->msgs
+ i
;
9332 if (msg
->flags
& VKI_I2C_M_RD
)
9333 POST_MEM_WRITE((Addr
)msg
->buf
, msg
->len
);
9339 struct vki_i2c_smbus_ioctl_data
*vkis
9340 = (struct vki_i2c_smbus_ioctl_data
*) ARG3
;
9341 /* i2c_smbus_write_quick hides its value in read_write, so
9342 this variable can hava a different meaning */
9343 /* to make matters worse i2c_smbus_write_byte stores its
9345 if ((vkis
->read_write
== VKI_I2C_SMBUS_READ
)
9346 || (vkis
->size
== VKI_I2C_SMBUS_PROC_CALL
)
9347 || (vkis
->size
== VKI_I2C_SMBUS_BLOCK_PROC_CALL
)) {
9348 if ( ! ((vkis
->size
== VKI_I2C_SMBUS_QUICK
)
9349 && (vkis
->command
== VKI_I2C_SMBUS_QUICK
))) {
9351 switch(vkis
->size
) {
9352 case VKI_I2C_SMBUS_BYTE
:
9353 case VKI_I2C_SMBUS_BYTE_DATA
:
9356 case VKI_I2C_SMBUS_WORD_DATA
:
9357 case VKI_I2C_SMBUS_PROC_CALL
:
9360 case VKI_I2C_SMBUS_BLOCK_DATA
:
9361 case VKI_I2C_SMBUS_I2C_BLOCK_BROKEN
:
9362 case VKI_I2C_SMBUS_BLOCK_PROC_CALL
:
9363 case VKI_I2C_SMBUS_I2C_BLOCK_DATA
:
9364 size
= vkis
->data
->block
[0];
9369 POST_MEM_WRITE((Addr
)&vkis
->data
->block
[0], size
);
9375 /* Wireless extensions ioctls */
9376 case VKI_SIOCSIWCOMMIT
:
9377 case VKI_SIOCSIWNWID
:
9378 case VKI_SIOCSIWFREQ
:
9379 case VKI_SIOCSIWMODE
:
9380 case VKI_SIOCSIWSENS
:
9381 case VKI_SIOCSIWRANGE
:
9382 case VKI_SIOCSIWPRIV
:
9383 case VKI_SIOCSIWSTATS
:
9384 case VKI_SIOCSIWSPY
:
9385 case VKI_SIOCSIWTHRSPY
:
9387 case VKI_SIOCSIWSCAN
:
9388 case VKI_SIOCSIWESSID
:
9389 case VKI_SIOCSIWRATE
:
9390 case VKI_SIOCSIWNICKN
:
9391 case VKI_SIOCSIWRTS
:
9392 case VKI_SIOCSIWFRAG
:
9393 case VKI_SIOCSIWTXPOW
:
9394 case VKI_SIOCSIWRETRY
:
9395 case VKI_SIOCSIWENCODE
:
9396 case VKI_SIOCSIWPOWER
:
9397 case VKI_SIOCSIWGENIE
:
9398 case VKI_SIOCSIWMLME
:
9399 case VKI_SIOCSIWAUTH
:
9400 case VKI_SIOCSIWENCODEEXT
:
9401 case VKI_SIOCSIWPMKSA
:
9403 case VKI_SIOCGIWNAME
:
9405 POST_MEM_WRITE((Addr
)((struct vki_iwreq
*)ARG3
)->u
.name
,
9406 sizeof(((struct vki_iwreq
*)ARG3
)->u
.name
));
9409 case VKI_SIOCGIWNWID
:
9410 case VKI_SIOCGIWSENS
:
9411 case VKI_SIOCGIWRATE
:
9412 case VKI_SIOCGIWRTS
:
9413 case VKI_SIOCGIWFRAG
:
9414 case VKI_SIOCGIWTXPOW
:
9415 case VKI_SIOCGIWRETRY
:
9416 case VKI_SIOCGIWPOWER
:
9417 case VKI_SIOCGIWAUTH
:
9419 POST_MEM_WRITE((Addr
)&((struct vki_iwreq
*)ARG3
)->u
.param
,
9420 sizeof(struct vki_iw_param
));
9423 case VKI_SIOCGIWFREQ
:
9425 POST_MEM_WRITE((Addr
)&((struct vki_iwreq
*)ARG3
)->u
.freq
,
9426 sizeof(struct vki_iw_freq
));
9429 case VKI_SIOCGIWMODE
:
9431 POST_MEM_WRITE((Addr
)&((struct vki_iwreq
*)ARG3
)->u
.mode
,
9435 case VKI_SIOCGIWRANGE
:
9436 case VKI_SIOCGIWPRIV
:
9437 case VKI_SIOCGIWSTATS
:
9438 case VKI_SIOCGIWSPY
:
9439 case VKI_SIOCGIWTHRSPY
:
9440 case VKI_SIOCGIWAPLIST
:
9441 case VKI_SIOCGIWSCAN
:
9442 case VKI_SIOCGIWESSID
:
9443 case VKI_SIOCGIWNICKN
:
9444 case VKI_SIOCGIWENCODE
:
9445 case VKI_SIOCGIWGENIE
:
9446 case VKI_SIOCGIWENCODEEXT
:
9448 struct vki_iw_point
* point
;
9449 point
= &((struct vki_iwreq
*)ARG3
)->u
.data
;
9450 POST_MEM_WRITE((Addr
)point
->pointer
, point
->length
);
9455 POST_MEM_WRITE((Addr
)&((struct vki_iwreq
*)ARG3
)->u
.ap_addr
,
9456 sizeof(struct vki_sockaddr
));
9460 # if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
9461 || defined(VGPV_mips32_linux_android)
9463 case VKI_ASHMEM_GET_SIZE
:
9464 case VKI_ASHMEM_SET_SIZE
:
9465 case VKI_ASHMEM_GET_PROT_MASK
:
9466 case VKI_ASHMEM_SET_PROT_MASK
:
9467 case VKI_ASHMEM_GET_PIN_STATUS
:
9468 case VKI_ASHMEM_PURGE_ALL_CACHES
:
9469 case VKI_ASHMEM_SET_NAME
:
9470 case VKI_ASHMEM_PIN
:
9471 case VKI_ASHMEM_UNPIN
:
9473 case VKI_ASHMEM_GET_NAME
:
9474 POST_MEM_WRITE( ARG3
, VKI_ASHMEM_NAME_LEN
);
9478 case VKI_BINDER_WRITE_READ
:
9480 struct vki_binder_write_read
* bwr
9481 = (struct vki_binder_write_read
*)ARG3
;
9482 POST_FIELD_WRITE(bwr
->write_consumed
);
9483 POST_FIELD_WRITE(bwr
->read_consumed
);
9486 POST_MEM_WRITE((Addr
)bwr
->read_buffer
, bwr
->read_consumed
);
9490 case VKI_BINDER_SET_IDLE_TIMEOUT
:
9491 case VKI_BINDER_SET_MAX_THREADS
:
9492 case VKI_BINDER_SET_IDLE_PRIORITY
:
9493 case VKI_BINDER_SET_CONTEXT_MGR
:
9494 case VKI_BINDER_THREAD_EXIT
:
9496 case VKI_BINDER_VERSION
:
9498 struct vki_binder_version
* bv
= (struct vki_binder_version
*)ARG3
;
9499 POST_FIELD_WRITE(bv
->protocol_version
);
9502 # endif /* defined(VGPV_*_linux_android) */
9504 case VKI_HCIGETDEVLIST
:
9506 struct vki_hci_dev_list_req
* dlr
= (struct vki_hci_dev_list_req
*)ARG3
;
9507 POST_MEM_WRITE((Addr
)ARG3
+ sizeof(struct vki_hci_dev_list_req
),
9508 dlr
->dev_num
* sizeof(struct vki_hci_dev_req
));
9512 case VKI_HCIINQUIRY
:
9514 struct vki_hci_inquiry_req
* ir
= (struct vki_hci_inquiry_req
*)ARG3
;
9515 POST_MEM_WRITE((Addr
)ARG3
+ sizeof(struct vki_hci_inquiry_req
),
9516 ir
->num_rsp
* sizeof(struct vki_inquiry_info
));
9520 case VKI_DRM_IOCTL_VERSION
:
9522 struct vki_drm_version
*data
= (struct vki_drm_version
*)ARG3
;
9523 POST_MEM_WRITE((Addr
)&data
->version_major
, sizeof(data
->version_major
));
9524 POST_MEM_WRITE((Addr
)&data
->version_minor
, sizeof(data
->version_minor
));
9525 POST_MEM_WRITE((Addr
)&data
->version_patchlevel
, sizeof(data
->version_patchlevel
));
9526 POST_MEM_WRITE((Addr
)&data
->name_len
, sizeof(data
->name_len
));
9527 POST_MEM_WRITE((Addr
)data
->name
, data
->name_len
);
9528 POST_MEM_WRITE((Addr
)&data
->date_len
, sizeof(data
->date_len
));
9529 POST_MEM_WRITE((Addr
)data
->date
, data
->date_len
);
9530 POST_MEM_WRITE((Addr
)&data
->desc_len
, sizeof(data
->desc_len
));
9531 POST_MEM_WRITE((Addr
)data
->desc
, data
->desc_len
);
9534 case VKI_DRM_IOCTL_GET_UNIQUE
:
9536 struct vki_drm_unique
*data
= (struct vki_drm_unique
*)ARG3
;
9537 POST_MEM_WRITE((Addr
)data
->unique
, sizeof(data
->unique_len
));
9540 case VKI_DRM_IOCTL_GET_MAGIC
:
9542 struct vki_drm_auth
*data
= (struct vki_drm_auth
*)ARG3
;
9543 POST_MEM_WRITE((Addr
)&data
->magic
, sizeof(data
->magic
));
9546 case VKI_DRM_IOCTL_WAIT_VBLANK
:
9548 union vki_drm_wait_vblank
*data
= (union vki_drm_wait_vblank
*)ARG3
;
9549 POST_MEM_WRITE((Addr
)&data
->reply
, sizeof(data
->reply
));
9552 case VKI_DRM_IOCTL_GEM_FLINK
:
9554 struct vki_drm_gem_flink
*data
= (struct vki_drm_gem_flink
*)ARG3
;
9555 POST_MEM_WRITE((Addr
)&data
->name
, sizeof(data
->name
));
9558 case VKI_DRM_IOCTL_GEM_OPEN
:
9560 struct vki_drm_gem_open
*data
= (struct vki_drm_gem_open
*)ARG3
;
9561 POST_MEM_WRITE((Addr
)&data
->handle
, sizeof(data
->handle
));
9562 POST_MEM_WRITE((Addr
)&data
->size
, sizeof(data
->size
));
9565 case VKI_DRM_IOCTL_I915_GETPARAM
:
9567 vki_drm_i915_getparam_t
*data
= (vki_drm_i915_getparam_t
*)ARG3
;
9568 POST_MEM_WRITE((Addr
)data
->value
, sizeof(int));
9571 case VKI_DRM_IOCTL_I915_GEM_BUSY
:
9573 struct vki_drm_i915_gem_busy
*data
= (struct vki_drm_i915_gem_busy
*)ARG3
;
9574 POST_MEM_WRITE((Addr
)&data
->busy
, sizeof(data
->busy
));
9577 case VKI_DRM_IOCTL_I915_GEM_CREATE
:
9579 struct vki_drm_i915_gem_create
*data
= (struct vki_drm_i915_gem_create
*)ARG3
;
9580 POST_MEM_WRITE((Addr
)&data
->handle
, sizeof(data
->handle
));
9583 case VKI_DRM_IOCTL_I915_GEM_PREAD
:
9585 struct vki_drm_i915_gem_pread
*data
= (struct vki_drm_i915_gem_pread
*)ARG3
;
9586 POST_MEM_WRITE((Addr
)data
->data_ptr
, data
->size
);
9589 case VKI_DRM_IOCTL_I915_GEM_MMAP_GTT
:
9591 struct vki_drm_i915_gem_mmap_gtt
*data
= (struct vki_drm_i915_gem_mmap_gtt
*)ARG3
;
9592 POST_MEM_WRITE((Addr
)&data
->offset
, sizeof(data
->offset
));
9595 case VKI_DRM_IOCTL_I915_GEM_SET_TILING
:
9597 struct vki_drm_i915_gem_set_tiling
*data
= (struct vki_drm_i915_gem_set_tiling
*)ARG3
;
9598 POST_MEM_WRITE((Addr
)&data
->tiling_mode
, sizeof(data
->tiling_mode
));
9599 POST_MEM_WRITE((Addr
)&data
->stride
, sizeof(data
->stride
));
9600 POST_MEM_WRITE((Addr
)&data
->swizzle_mode
, sizeof(data
->swizzle_mode
));
9603 case VKI_DRM_IOCTL_I915_GEM_GET_TILING
:
9605 struct vki_drm_i915_gem_get_tiling
*data
= (struct vki_drm_i915_gem_get_tiling
*)ARG3
;
9606 POST_MEM_WRITE((Addr
)&data
->tiling_mode
, sizeof(data
->tiling_mode
));
9607 POST_MEM_WRITE((Addr
)&data
->swizzle_mode
, sizeof(data
->swizzle_mode
));
9610 case VKI_DRM_IOCTL_I915_GEM_GET_APERTURE
:
9612 struct vki_drm_i915_gem_get_aperture
*data
= (struct vki_drm_i915_gem_get_aperture
*)ARG3
;
9613 POST_MEM_WRITE((Addr
)&data
->aper_size
, sizeof(data
->aper_size
));
9614 POST_MEM_WRITE((Addr
)&data
->aper_available_size
, sizeof(data
->aper_available_size
));
9618 /* KVM ioctls that only write the system call return value */
9619 case VKI_KVM_GET_API_VERSION
:
9620 case VKI_KVM_CREATE_VM
:
9621 case VKI_KVM_CHECK_EXTENSION
:
9622 case VKI_KVM_GET_VCPU_MMAP_SIZE
:
9623 case VKI_KVM_S390_ENABLE_SIE
:
9624 case VKI_KVM_CREATE_VCPU
:
9625 case VKI_KVM_SET_TSS_ADDR
:
9626 case VKI_KVM_CREATE_IRQCHIP
:
9628 case VKI_KVM_S390_INITIAL_RESET
:
9629 case VKI_KVM_KVMCLOCK_CTRL
:
9632 case VKI_KVM_S390_MEM_OP
: {
9633 struct vki_kvm_s390_mem_op
*args
=
9634 (struct vki_kvm_s390_mem_op
*)(ARG3
);
9635 if (args
->flags
& VKI_KVM_S390_MEMOP_F_CHECK_ONLY
)
9637 if (args
->op
== VKI_KVM_S390_MEMOP_LOGICAL_READ
)
9638 POST_MEM_WRITE((Addr
)args
->buf
, args
->size
);
9643 case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL
: {
9644 SyscallArgs harrghs
;
9645 struct vki_xen_privcmd_hypercall
*args
=
9646 (struct vki_xen_privcmd_hypercall
*)(ARG3
);
9651 VG_(memset
)(&harrghs
, 0, sizeof(harrghs
));
9652 harrghs
.sysno
= args
->op
;
9653 harrghs
.arg1
= args
->arg
[0];
9654 harrghs
.arg2
= args
->arg
[1];
9655 harrghs
.arg3
= args
->arg
[2];
9656 harrghs
.arg4
= args
->arg
[3];
9657 harrghs
.arg5
= args
->arg
[4];
9658 harrghs
.arg6
= harrghs
.arg7
= harrghs
.arg8
= 0;
9660 WRAPPER_POST_NAME(xen
, hypercall
) (tid
, &harrghs
, status
);
9664 case VKI_XEN_IOCTL_PRIVCMD_MMAP
:
9666 case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH
: {
9667 struct vki_xen_privcmd_mmapbatch
*args
=
9668 (struct vki_xen_privcmd_mmapbatch
*)(ARG3
);
9669 POST_MEM_WRITE((Addr
)args
->arr
, sizeof(*(args
->arr
)) * args
->num
);
9672 case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2
: {
9673 struct vki_xen_privcmd_mmapbatch_v2
*args
=
9674 (struct vki_xen_privcmd_mmapbatch_v2
*)(ARG3
);
9675 POST_MEM_WRITE((Addr
)args
->err
, sizeof(*(args
->err
)) * args
->num
);
9679 case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ
:
9680 case VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN
:
9681 case VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT
:
9682 case VKI_XEN_IOCTL_EVTCHN_UNBIND
:
9683 case VKI_XEN_IOCTL_EVTCHN_NOTIFY
:
9684 case VKI_XEN_IOCTL_EVTCHN_RESET
:
9690 case VKI_OBD_IOC_FID2PATH
: {
9691 struct vki_getinfo_fid2path
*args
= (void *)(ARG3
);
9692 POST_FIELD_WRITE(args
->gf_recno
);
9693 POST_FIELD_WRITE(args
->gf_linkno
);
9694 POST_MEM_WRITE((Addr
)args
->gf_path
, VG_(strlen
)(args
->gf_path
)+1);
9698 case VKI_LL_IOC_PATH2FID
:
9699 POST_MEM_WRITE(ARG3
, sizeof(struct vki_lu_fid
));
9702 case VKI_LL_IOC_GETPARENT
: {
9703 struct vki_getparent
*gp
= (struct vki_getparent
*)ARG3
;
9704 POST_FIELD_WRITE(gp
->gp_fid
);
9705 POST_MEM_WRITE((Addr
)gp
->gp_name
, VG_(strlen
)(gp
->gp_name
)+1);
9710 case VKI_V4L2_S_FMT
:
9711 case VKI_V4L2_TRY_FMT
:
9712 case VKI_V4L2_REQBUFS
:
9713 case VKI_V4L2_OVERLAY
:
9714 case VKI_V4L2_STREAMON
:
9715 case VKI_V4L2_STREAMOFF
:
9716 case VKI_V4L2_S_PARM
:
9717 case VKI_V4L2_S_STD
:
9718 case VKI_V4L2_S_FREQUENCY
:
9719 case VKI_V4L2_S_CTRL
:
9720 case VKI_V4L2_S_TUNER
:
9721 case VKI_V4L2_S_AUDIO
:
9722 case VKI_V4L2_S_INPUT
:
9723 case VKI_V4L2_S_EDID
:
9724 case VKI_V4L2_S_OUTPUT
:
9725 case VKI_V4L2_S_AUDOUT
:
9726 case VKI_V4L2_S_MODULATOR
:
9727 case VKI_V4L2_S_JPEGCOMP
:
9728 case VKI_V4L2_S_CROP
:
9729 case VKI_V4L2_S_PRIORITY
:
9730 case VKI_V4L2_S_HW_FREQ_SEEK
:
9731 case VKI_V4L2_S_DV_TIMINGS
:
9732 case VKI_V4L2_SUBSCRIBE_EVENT
:
9733 case VKI_V4L2_UNSUBSCRIBE_EVENT
:
9734 case VKI_V4L2_PREPARE_BUF
:
9736 case VKI_V4L2_QUERYCAP
: {
9737 struct vki_v4l2_capability
*data
= (struct vki_v4l2_capability
*)ARG3
;
9738 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
9741 case VKI_V4L2_ENUM_FMT
: {
9742 struct vki_v4l2_fmtdesc
*data
= (struct vki_v4l2_fmtdesc
*)ARG3
;
9743 POST_FIELD_WRITE(data
->flags
);
9744 POST_FIELD_WRITE(data
->description
);
9745 POST_FIELD_WRITE(data
->pixelformat
);
9746 POST_FIELD_WRITE(data
->reserved
);
9749 case VKI_V4L2_G_FMT
: {
9750 struct vki_v4l2_format
*data
= (struct vki_v4l2_format
*)ARG3
;
9751 switch (data
->type
) {
9752 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
9753 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
9754 POST_FIELD_WRITE(data
->fmt
.pix
);
9756 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
9757 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
9758 POST_FIELD_WRITE(data
->fmt
.vbi
);
9760 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
9761 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
9762 POST_FIELD_WRITE(data
->fmt
.sliced
);
9764 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
9765 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
9766 POST_FIELD_WRITE(data
->fmt
.win
);
9768 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
9769 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
9770 POST_FIELD_WRITE(data
->fmt
.pix_mp
);
9772 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
9773 POST_FIELD_WRITE(data
->fmt
.sdr
);
9778 case VKI_V4L2_QUERYBUF
: {
9779 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
9780 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
9781 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
9784 for (i
= 0; i
< data
->length
; i
++) {
9785 POST_FIELD_WRITE(data
->m
.planes
[i
].bytesused
);
9786 POST_FIELD_WRITE(data
->m
.planes
[i
].length
);
9787 POST_FIELD_WRITE(data
->m
.planes
[i
].m
);
9788 POST_FIELD_WRITE(data
->m
.planes
[i
].data_offset
);
9789 POST_FIELD_WRITE(data
->m
.planes
[i
].reserved
);
9792 POST_FIELD_WRITE(data
->m
);
9793 POST_FIELD_WRITE(data
->length
);
9795 POST_FIELD_WRITE(data
->bytesused
);
9796 POST_FIELD_WRITE(data
->flags
);
9797 POST_FIELD_WRITE(data
->field
);
9798 POST_FIELD_WRITE(data
->timestamp
);
9799 POST_FIELD_WRITE(data
->timecode
);
9800 POST_FIELD_WRITE(data
->sequence
);
9801 POST_FIELD_WRITE(data
->memory
);
9802 POST_FIELD_WRITE(data
->sequence
);
9805 case VKI_V4L2_G_FBUF
: {
9806 struct vki_v4l2_framebuffer
*data
= (struct vki_v4l2_framebuffer
*)ARG3
;
9807 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
9810 case VKI_V4L2_S_FBUF
: {
9811 struct vki_v4l2_framebuffer
*data
= (struct vki_v4l2_framebuffer
*)ARG3
;
9812 POST_FIELD_WRITE(data
->capability
);
9813 POST_FIELD_WRITE(data
->flags
);
9814 POST_FIELD_WRITE(data
->fmt
);
9817 case VKI_V4L2_QBUF
: {
9818 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
9820 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
9821 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
9824 for (i
= 0; i
< data
->length
; i
++) {
9825 POST_FIELD_WRITE(data
->m
.planes
[i
].length
);
9826 if (data
->memory
== VKI_V4L2_MEMORY_MMAP
)
9827 POST_FIELD_WRITE(data
->m
.planes
[i
].m
);
9830 if (data
->memory
== VKI_V4L2_MEMORY_MMAP
)
9831 POST_FIELD_WRITE(data
->m
);
9832 POST_FIELD_WRITE(data
->length
);
9836 case VKI_V4L2_EXPBUF
: {
9837 struct vki_v4l2_exportbuffer
*data
= (struct vki_v4l2_exportbuffer
*)ARG3
;
9838 POST_FIELD_WRITE(data
->fd
);
9841 case VKI_V4L2_DQBUF
: {
9842 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
9843 POST_FIELD_WRITE(data
->index
);
9844 POST_FIELD_WRITE(data
->bytesused
);
9845 POST_FIELD_WRITE(data
->field
);
9846 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
9847 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
9850 for (i
= 0; i
< data
->length
; i
++) {
9851 POST_FIELD_WRITE(data
->m
.planes
[i
].bytesused
);
9852 POST_FIELD_WRITE(data
->m
.planes
[i
].data_offset
);
9853 POST_FIELD_WRITE(data
->m
.planes
[i
].length
);
9854 POST_FIELD_WRITE(data
->m
.planes
[i
].m
);
9857 POST_FIELD_WRITE(data
->m
);
9858 POST_FIELD_WRITE(data
->length
);
9859 POST_FIELD_WRITE(data
->bytesused
);
9860 POST_FIELD_WRITE(data
->field
);
9862 POST_FIELD_WRITE(data
->timestamp
);
9863 POST_FIELD_WRITE(data
->timecode
);
9864 POST_FIELD_WRITE(data
->sequence
);
9867 case VKI_V4L2_G_PARM
: {
9868 struct vki_v4l2_streamparm
*data
= (struct vki_v4l2_streamparm
*)ARG3
;
9869 int is_output
= data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
||
9870 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
||
9871 data
->type
== VKI_V4L2_BUF_TYPE_VBI_OUTPUT
||
9872 data
->type
== VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
;
9875 POST_MEM_WRITE((Addr
)&data
->parm
.output
,
9876 sizeof(data
->parm
.output
) - sizeof(data
->parm
.output
.reserved
));
9878 POST_MEM_WRITE((Addr
)&data
->parm
.capture
,
9879 sizeof(data
->parm
.capture
) - sizeof(data
->parm
.capture
.reserved
));
9882 case VKI_V4L2_G_STD
: {
9883 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
9884 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
9887 case VKI_V4L2_ENUMSTD
: {
9888 struct vki_v4l2_standard
*data
= (struct vki_v4l2_standard
*)ARG3
;
9889 POST_MEM_WRITE((Addr
)&data
->id
, sizeof(*data
) - sizeof(data
->index
));
9892 case VKI_V4L2_ENUMINPUT
: {
9893 struct vki_v4l2_input
*data
= (struct vki_v4l2_input
*)ARG3
;
9894 POST_MEM_WRITE((Addr
)data
->name
, sizeof(*data
) - sizeof(data
->index
));
9897 case VKI_V4L2_G_CTRL
: {
9898 struct vki_v4l2_control
*data
= (struct vki_v4l2_control
*)ARG3
;
9899 POST_FIELD_WRITE(data
->value
);
9902 case VKI_V4L2_G_TUNER
: {
9903 struct vki_v4l2_tuner
*data
= (struct vki_v4l2_tuner
*)ARG3
;
9904 POST_MEM_WRITE((Addr
)data
->name
,
9905 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
9908 case VKI_V4L2_G_AUDIO
: {
9909 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
9910 POST_MEM_WRITE((Addr
)data
,
9911 sizeof(*data
) - sizeof(data
->reserved
));
9914 case VKI_V4L2_QUERYCTRL
: {
9915 struct vki_v4l2_queryctrl
*data
= (struct vki_v4l2_queryctrl
*)ARG3
;
9916 POST_MEM_WRITE((Addr
)&data
->type
,
9917 sizeof(*data
) - sizeof(data
->id
));
9920 case VKI_V4L2_QUERYMENU
: {
9921 struct vki_v4l2_querymenu
*data
= (struct vki_v4l2_querymenu
*)ARG3
;
9922 POST_MEM_WRITE((Addr
)data
->name
,
9923 sizeof(*data
) - sizeof(data
->id
) - sizeof(data
->index
));
9926 case VKI_V4L2_G_INPUT
: {
9927 int *data
= (int *)ARG3
;
9928 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
9931 case VKI_V4L2_G_EDID
: {
9932 struct vki_v4l2_edid
*data
= (struct vki_v4l2_edid
*)ARG3
;
9933 if (data
->blocks
&& data
->edid
)
9934 POST_MEM_WRITE((Addr
)data
->edid
, data
->blocks
* 128);
9937 case VKI_V4L2_G_OUTPUT
: {
9938 int *data
= (int *)ARG3
;
9939 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
9942 case VKI_V4L2_ENUMOUTPUT
: {
9943 struct vki_v4l2_output
*data
= (struct vki_v4l2_output
*)ARG3
;
9944 POST_MEM_WRITE((Addr
)data
->name
, sizeof(*data
) - sizeof(data
->index
));
9947 case VKI_V4L2_G_AUDOUT
: {
9948 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
9949 POST_MEM_WRITE((Addr
)data
,
9950 sizeof(*data
) - sizeof(data
->reserved
));
9953 case VKI_V4L2_G_MODULATOR
: {
9954 struct vki_v4l2_modulator
*data
= (struct vki_v4l2_modulator
*)ARG3
;
9955 POST_MEM_WRITE((Addr
)data
->name
,
9956 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
9959 case VKI_V4L2_G_FREQUENCY
: {
9960 struct vki_v4l2_frequency
*data
= (struct vki_v4l2_frequency
*)ARG3
;
9961 POST_FIELD_WRITE(data
->type
);
9962 POST_FIELD_WRITE(data
->frequency
);
9965 case VKI_V4L2_CROPCAP
: {
9966 struct vki_v4l2_cropcap
*data
= (struct vki_v4l2_cropcap
*)ARG3
;
9967 POST_MEM_WRITE((Addr
)&data
->bounds
, sizeof(*data
) - sizeof(data
->type
));
9970 case VKI_V4L2_G_CROP
: {
9971 struct vki_v4l2_crop
*data
= (struct vki_v4l2_crop
*)ARG3
;
9972 POST_FIELD_WRITE(data
->c
);
9975 case VKI_V4L2_G_JPEGCOMP
: {
9976 struct vki_v4l2_jpegcompression
*data
= (struct vki_v4l2_jpegcompression
*)ARG3
;
9977 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
9980 case VKI_V4L2_QUERYSTD
: {
9981 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
9982 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
9985 case VKI_V4L2_ENUMAUDIO
: {
9986 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
9987 POST_MEM_WRITE((Addr
)data
->name
,
9988 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
9991 case VKI_V4L2_ENUMAUDOUT
: {
9992 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
9993 POST_MEM_WRITE((Addr
)data
->name
,
9994 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
9997 case VKI_V4L2_G_PRIORITY
: {
9998 __vki_u32
*data
= (__vki_u32
*)ARG3
;
9999 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10002 case VKI_V4L2_G_SLICED_VBI_CAP
: {
10003 struct vki_v4l2_sliced_vbi_cap
*data
= (struct vki_v4l2_sliced_vbi_cap
*)ARG3
;
10004 POST_MEM_WRITE((Addr
)data
,
10005 sizeof(*data
) - sizeof(data
->type
) - sizeof(data
->reserved
));
10008 case VKI_V4L2_G_EXT_CTRLS
: {
10009 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
10013 for (i
= 0; i
< data
->count
; i
++) {
10014 if (data
->controls
[i
].size
)
10015 POST_MEM_WRITE((Addr
)data
->controls
[i
].ptr
, data
->controls
[i
].size
);
10017 POST_FIELD_WRITE(data
->controls
[i
].value64
);
10020 POST_FIELD_WRITE(data
->error_idx
);
10023 case VKI_V4L2_S_EXT_CTRLS
: {
10024 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
10025 POST_FIELD_WRITE(data
->error_idx
);
10028 case VKI_V4L2_TRY_EXT_CTRLS
: {
10029 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
10030 POST_FIELD_WRITE(data
->error_idx
);
10033 case VKI_V4L2_ENUM_FRAMESIZES
: {
10034 struct vki_v4l2_frmsizeenum
*data
= (struct vki_v4l2_frmsizeenum
*)ARG3
;
10035 POST_FIELD_WRITE(data
->type
);
10036 POST_FIELD_WRITE(data
->stepwise
);
10039 case VKI_V4L2_ENUM_FRAMEINTERVALS
: {
10040 struct vki_v4l2_frmivalenum
*data
= (struct vki_v4l2_frmivalenum
*)ARG3
;
10041 POST_FIELD_WRITE(data
->type
);
10042 POST_FIELD_WRITE(data
->stepwise
);
10045 case VKI_V4L2_G_ENC_INDEX
: {
10046 struct vki_v4l2_enc_idx
*data
= (struct vki_v4l2_enc_idx
*)ARG3
;
10047 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10050 case VKI_V4L2_ENCODER_CMD
: {
10051 struct vki_v4l2_encoder_cmd
*data
= (struct vki_v4l2_encoder_cmd
*)ARG3
;
10052 POST_FIELD_WRITE(data
->flags
);
10055 case VKI_V4L2_TRY_ENCODER_CMD
: {
10056 struct vki_v4l2_encoder_cmd
*data
= (struct vki_v4l2_encoder_cmd
*)ARG3
;
10057 POST_FIELD_WRITE(data
->flags
);
10060 case VKI_V4L2_DBG_S_REGISTER
: {
10061 struct vki_v4l2_dbg_register
*data
= (struct vki_v4l2_dbg_register
*)ARG3
;
10062 POST_FIELD_WRITE(data
->size
);
10065 case VKI_V4L2_DBG_G_REGISTER
: {
10066 struct vki_v4l2_dbg_register
*data
= (struct vki_v4l2_dbg_register
*)ARG3
;
10067 POST_FIELD_WRITE(data
->val
);
10068 POST_FIELD_WRITE(data
->size
);
10071 case VKI_V4L2_G_DV_TIMINGS
: {
10072 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
10073 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10076 case VKI_V4L2_DQEVENT
: {
10077 struct vki_v4l2_event
*data
= (struct vki_v4l2_event
*)ARG3
;
10078 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10081 case VKI_V4L2_CREATE_BUFS
: {
10082 struct vki_v4l2_create_buffers
*data
= (struct vki_v4l2_create_buffers
*)ARG3
;
10083 POST_FIELD_WRITE(data
->index
);
10086 case VKI_V4L2_G_SELECTION
: {
10087 struct vki_v4l2_selection
*data
= (struct vki_v4l2_selection
*)ARG3
;
10088 POST_FIELD_WRITE(data
->r
);
10091 case VKI_V4L2_S_SELECTION
: {
10092 struct vki_v4l2_selection
*data
= (struct vki_v4l2_selection
*)ARG3
;
10093 POST_FIELD_WRITE(data
->r
);
10096 case VKI_V4L2_DECODER_CMD
: {
10097 struct vki_v4l2_decoder_cmd
*data
= (struct vki_v4l2_decoder_cmd
*)ARG3
;
10098 POST_FIELD_WRITE(data
->flags
);
10101 case VKI_V4L2_TRY_DECODER_CMD
: {
10102 struct vki_v4l2_decoder_cmd
*data
= (struct vki_v4l2_decoder_cmd
*)ARG3
;
10103 POST_FIELD_WRITE(data
->flags
);
10106 case VKI_V4L2_ENUM_DV_TIMINGS
: {
10107 struct vki_v4l2_enum_dv_timings
*data
= (struct vki_v4l2_enum_dv_timings
*)ARG3
;
10108 POST_FIELD_WRITE(data
->timings
);
10111 case VKI_V4L2_QUERY_DV_TIMINGS
: {
10112 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
10113 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10116 case VKI_V4L2_DV_TIMINGS_CAP
: {
10117 struct vki_v4l2_dv_timings_cap
*data
= (struct vki_v4l2_dv_timings_cap
*)ARG3
;
10118 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10121 case VKI_V4L2_ENUM_FREQ_BANDS
: {
10122 struct vki_v4l2_frequency_band
*data
= (struct vki_v4l2_frequency_band
*)ARG3
;
10123 POST_FIELD_WRITE(data
->capability
);
10124 POST_FIELD_WRITE(data
->rangelow
);
10125 POST_FIELD_WRITE(data
->rangehigh
);
10126 POST_FIELD_WRITE(data
->modulation
);
10129 case VKI_V4L2_DBG_G_CHIP_INFO
: {
10130 struct vki_v4l2_dbg_chip_info
*data
= (struct vki_v4l2_dbg_chip_info
*)ARG3
;
10131 POST_FIELD_WRITE(data
->name
);
10132 POST_FIELD_WRITE(data
->flags
);
10135 case VKI_V4L2_QUERY_EXT_CTRL
: {
10136 struct vki_v4l2_query_ext_ctrl
*data
= (struct vki_v4l2_query_ext_ctrl
*)ARG3
;
10137 POST_MEM_WRITE((Addr
)&data
->type
,
10138 sizeof(*data
) - sizeof(data
->id
) - sizeof(data
->reserved
));
10142 case VKI_V4L2_SUBDEV_S_FMT
:
10143 case VKI_V4L2_SUBDEV_S_FRAME_INTERVAL
:
10144 case VKI_V4L2_SUBDEV_S_CROP
:
10145 case VKI_V4L2_SUBDEV_S_SELECTION
:
10148 case VKI_V4L2_SUBDEV_G_FMT
: {
10149 struct vki_v4l2_subdev_format
*data
= (struct vki_v4l2_subdev_format
*)ARG3
;
10150 POST_FIELD_WRITE(data
->format
);
10153 case VKI_V4L2_SUBDEV_G_FRAME_INTERVAL
: {
10154 struct vki_v4l2_subdev_frame_interval
*data
= (struct vki_v4l2_subdev_frame_interval
*)ARG3
;
10155 POST_FIELD_WRITE(data
->interval
);
10158 case VKI_V4L2_SUBDEV_ENUM_MBUS_CODE
: {
10159 struct vki_v4l2_subdev_mbus_code_enum
*data
= (struct vki_v4l2_subdev_mbus_code_enum
*)ARG3
;
10160 POST_FIELD_WRITE(data
->code
);
10163 case VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE
: {
10164 struct vki_v4l2_subdev_frame_size_enum
*data
= (struct vki_v4l2_subdev_frame_size_enum
*)ARG3
;
10165 POST_FIELD_WRITE(data
->min_width
);
10166 POST_FIELD_WRITE(data
->min_height
);
10167 POST_FIELD_WRITE(data
->max_width
);
10168 POST_FIELD_WRITE(data
->max_height
);
10171 case VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL
: {
10172 struct vki_v4l2_subdev_frame_interval_enum
*data
= (struct vki_v4l2_subdev_frame_interval_enum
*)ARG3
;
10173 POST_FIELD_WRITE(data
->interval
);
10176 case VKI_V4L2_SUBDEV_G_CROP
: {
10177 struct vki_v4l2_subdev_crop
*data
= (struct vki_v4l2_subdev_crop
*)ARG3
;
10178 POST_FIELD_WRITE(data
->rect
);
10181 case VKI_V4L2_SUBDEV_G_SELECTION
: {
10182 struct vki_v4l2_subdev_selection
*data
= (struct vki_v4l2_subdev_selection
*)ARG3
;
10183 POST_FIELD_WRITE(data
->r
);
10186 case VKI_MEDIA_IOC_DEVICE_INFO
: {
10187 struct vki_media_device_info
*data
= (struct vki_media_device_info
*)ARG3
;
10188 POST_MEM_WRITE((Addr
)data
, sizeof(*data
) - sizeof(data
->reserved
));
10191 case VKI_MEDIA_IOC_ENUM_ENTITIES
: {
10192 struct vki_media_entity_desc
*data
= (struct vki_media_entity_desc
*)ARG3
;
10193 POST_MEM_WRITE((Addr
)data
->name
, sizeof(*data
) - sizeof(data
->id
));
10196 case VKI_MEDIA_IOC_ENUM_LINKS
:
10198 * This ioctl does write to the provided pointers, but it's not
10199 * possible to deduce the size of the array those pointers point to.
10202 case VKI_MEDIA_IOC_SETUP_LINK
:
10206 /* EVIOC* are variable length and return size written on success */
10207 switch (ARG2
& ~(_VKI_IOC_SIZEMASK
<< _VKI_IOC_SIZESHIFT
)) {
10208 case VKI_EVIOCGNAME(0):
10209 case VKI_EVIOCGPHYS(0):
10210 case VKI_EVIOCGUNIQ(0):
10211 case VKI_EVIOCGKEY(0):
10212 case VKI_EVIOCGLED(0):
10213 case VKI_EVIOCGSND(0):
10214 case VKI_EVIOCGSW(0):
10215 case VKI_EVIOCGBIT(VKI_EV_SYN
,0):
10216 case VKI_EVIOCGBIT(VKI_EV_KEY
,0):
10217 case VKI_EVIOCGBIT(VKI_EV_REL
,0):
10218 case VKI_EVIOCGBIT(VKI_EV_ABS
,0):
10219 case VKI_EVIOCGBIT(VKI_EV_MSC
,0):
10220 case VKI_EVIOCGBIT(VKI_EV_SW
,0):
10221 case VKI_EVIOCGBIT(VKI_EV_LED
,0):
10222 case VKI_EVIOCGBIT(VKI_EV_SND
,0):
10223 case VKI_EVIOCGBIT(VKI_EV_REP
,0):
10224 case VKI_EVIOCGBIT(VKI_EV_FF
,0):
10225 case VKI_EVIOCGBIT(VKI_EV_PWR
,0):
10226 case VKI_EVIOCGBIT(VKI_EV_FF_STATUS
,0):
10228 POST_MEM_WRITE(ARG3
, RES
);
10231 ML_(POST_unknown_ioctl
)(tid
, RES
, ARG2
, ARG3
);
10237 post_sys_ioctl__out
:
10238 {} /* keep C compilers happy */
10241 /* ---------------------------------------------------------------------
10242 socketcall wrapper helpers
10243 ------------------------------------------------------------------ */
10246 ML_(linux_PRE_sys_getsockopt
) ( ThreadId tid
,
10247 UWord arg0
, UWord arg1
, UWord arg2
,
10248 UWord arg3
, UWord arg4
)
10250 /* int getsockopt(int s, int level, int optname,
10251 void *optval, socklen_t *optlen); */
10252 Addr optval_p
= arg3
;
10253 Addr optlen_p
= arg4
;
10254 /* vg_assert(sizeof(socklen_t) == sizeof(UInt)); */
10255 if (optval_p
!= (Addr
)NULL
) {
10256 ML_(buf_and_len_pre_check
) ( tid
, optval_p
, optlen_p
,
10257 "socketcall.getsockopt(optval)",
10258 "socketcall.getsockopt(optlen)" );
10259 if (arg1
== VKI_SOL_SCTP
&&
10260 (arg2
== VKI_SCTP_GET_PEER_ADDRS
||
10261 arg2
== VKI_SCTP_GET_LOCAL_ADDRS
))
10263 struct vki_sctp_getaddrs
*ga
= (struct vki_sctp_getaddrs
*)arg3
;
10264 int address_bytes
= sizeof(struct vki_sockaddr_in6
) * ga
->addr_num
;
10265 PRE_MEM_WRITE( "socketcall.getsockopt(optval.addrs)",
10266 (Addr
)ga
->addrs
, address_bytes
);
10272 ML_(linux_POST_sys_getsockopt
) ( ThreadId tid
,
10274 UWord arg0
, UWord arg1
, UWord arg2
,
10275 UWord arg3
, UWord arg4
)
10277 Addr optval_p
= arg3
;
10278 Addr optlen_p
= arg4
;
10279 vg_assert(!sr_isError(res
)); /* guaranteed by caller */
10280 if (optval_p
!= (Addr
)NULL
) {
10281 ML_(buf_and_len_post_check
) ( tid
, res
, optval_p
, optlen_p
,
10282 "socketcall.getsockopt(optlen_out)" );
10283 if (arg1
== VKI_SOL_SCTP
&&
10284 (arg2
== VKI_SCTP_GET_PEER_ADDRS
||
10285 arg2
== VKI_SCTP_GET_LOCAL_ADDRS
))
10287 struct vki_sctp_getaddrs
*ga
= (struct vki_sctp_getaddrs
*)arg3
;
10288 struct vki_sockaddr
*a
= ga
->addrs
;
10290 for (i
= 0; i
< ga
->addr_num
; i
++) {
10292 if (a
->sa_family
== VKI_AF_INET
)
10293 sl
= sizeof(struct vki_sockaddr_in
);
10294 else if (a
->sa_family
== VKI_AF_INET6
)
10295 sl
= sizeof(struct vki_sockaddr_in6
);
10297 VG_(message
)(Vg_UserMsg
, "Warning: getsockopt: unhandled "
10298 "address type %d\n", a
->sa_family
);
10300 a
= (struct vki_sockaddr
*)((char*)a
+ sl
);
10302 POST_MEM_WRITE( (Addr
)ga
->addrs
, (char*)a
- (char*)ga
->addrs
);
10308 ML_(linux_PRE_sys_setsockopt
) ( ThreadId tid
,
10309 UWord arg0
, UWord arg1
, UWord arg2
,
10310 UWord arg3
, UWord arg4
)
10312 /* int setsockopt(int s, int level, int optname,
10313 const void *optval, socklen_t optlen); */
10314 Addr optval_p
= arg3
;
10315 if (optval_p
!= (Addr
)NULL
) {
10317 * OK, let's handle at least some setsockopt levels and options
10318 * ourselves, so we don't get false claims of references to
10319 * uninitialized memory (such as padding in structures) and *do*
10320 * check what pointers in the argument point to.
10322 if (arg1
== VKI_SOL_SOCKET
&& arg2
== VKI_SO_ATTACH_FILTER
)
10324 struct vki_sock_fprog
*fp
= (struct vki_sock_fprog
*)optval_p
;
10327 * struct sock_fprog has a 16-bit count of instructions,
10328 * followed by a pointer to an array of those instructions.
10329 * There's padding between those two elements.
10331 * So that we don't bogusly complain about the padding bytes,
10332 * we just report that we read len and and filter.
10334 * We then make sure that what filter points to is valid.
10336 PRE_MEM_READ( "setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, &optval.len)",
10337 (Addr
)&fp
->len
, sizeof(fp
->len
) );
10338 PRE_MEM_READ( "setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, &optval.filter)",
10339 (Addr
)&fp
->filter
, sizeof(fp
->filter
) );
10341 /* len * sizeof (*filter) */
10342 if (fp
->filter
!= NULL
)
10344 PRE_MEM_READ( "setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, optval.filter)",
10345 (Addr
)(fp
->filter
),
10346 fp
->len
* sizeof(*fp
->filter
) );
10351 PRE_MEM_READ( "socketcall.setsockopt(optval)",
10353 arg4
/* optlen */ );
10359 ML_(linux_PRE_sys_recvmmsg
) ( ThreadId tid
,
10360 UWord arg1
, UWord arg2
, UWord arg3
,
10361 UWord arg4
, UWord arg5
)
10363 struct vki_mmsghdr
*mmsg
= (struct vki_mmsghdr
*)arg2
;
10364 HChar name
[40]; // large enough
10366 for (i
= 0; i
< arg3
; i
++) {
10367 VG_(sprintf
)(name
, "mmsg[%u].msg_hdr", i
);
10368 ML_(generic_PRE_sys_recvmsg
)(tid
, name
, &mmsg
[i
].msg_hdr
);
10369 VG_(sprintf
)(name
, "recvmmsg(mmsg[%u].msg_len)", i
);
10370 PRE_MEM_WRITE( name
, (Addr
)&mmsg
[i
].msg_len
, sizeof(mmsg
[i
].msg_len
) );
10373 PRE_MEM_READ( "recvmmsg(timeout)", arg5
, sizeof(struct vki_timespec
) );
10377 ML_(linux_POST_sys_recvmmsg
) (ThreadId tid
, UWord res
,
10378 UWord arg1
, UWord arg2
, UWord arg3
,
10379 UWord arg4
, UWord arg5
)
10382 struct vki_mmsghdr
*mmsg
= (struct vki_mmsghdr
*)arg2
;
10383 HChar name
[32]; // large enough
10385 for (i
= 0; i
< res
; i
++) {
10386 VG_(sprintf
)(name
, "mmsg[%u].msg_hdr", i
);
10387 ML_(generic_POST_sys_recvmsg
)(tid
, name
, &mmsg
[i
].msg_hdr
, mmsg
[i
].msg_len
);
10388 POST_MEM_WRITE( (Addr
)&mmsg
[i
].msg_len
, sizeof(mmsg
[i
].msg_len
) );
10394 ML_(linux_PRE_sys_sendmmsg
) ( ThreadId tid
,
10395 UWord arg1
, UWord arg2
, UWord arg3
, UWord arg4
)
10397 struct vki_mmsghdr
*mmsg
= (struct vki_mmsghdr
*)arg2
;
10398 HChar name
[40]; // large enough
10400 for (i
= 0; i
< arg3
; i
++) {
10401 VG_(sprintf
)(name
, "mmsg[%u].msg_hdr", i
);
10402 ML_(generic_PRE_sys_sendmsg
)(tid
, name
, &mmsg
[i
].msg_hdr
);
10403 VG_(sprintf
)(name
, "sendmmsg(mmsg[%u].msg_len)", i
);
10404 PRE_MEM_WRITE( name
, (Addr
)&mmsg
[i
].msg_len
, sizeof(mmsg
[i
].msg_len
) );
10409 ML_(linux_POST_sys_sendmmsg
) (ThreadId tid
, UWord res
,
10410 UWord arg1
, UWord arg2
, UWord arg3
, UWord arg4
)
10413 struct vki_mmsghdr
*mmsg
= (struct vki_mmsghdr
*)arg2
;
10415 for (i
= 0; i
< res
; i
++) {
10416 POST_MEM_WRITE( (Addr
)&mmsg
[i
].msg_len
, sizeof(mmsg
[i
].msg_len
) );
10421 /* ---------------------------------------------------------------------
10422 ptrace wrapper helpers
10423 ------------------------------------------------------------------ */
10426 ML_(linux_PRE_getregset
) ( ThreadId tid
, long arg3
, long arg4
)
10428 struct vki_iovec
*iov
= (struct vki_iovec
*) arg4
;
10430 PRE_MEM_READ("ptrace(getregset iovec->iov_base)",
10431 (unsigned long) &iov
->iov_base
, sizeof(iov
->iov_base
));
10432 PRE_MEM_READ("ptrace(getregset iovec->iov_len)",
10433 (unsigned long) &iov
->iov_len
, sizeof(iov
->iov_len
));
10434 PRE_MEM_WRITE("ptrace(getregset *(iovec->iov_base))",
10435 (unsigned long) iov
->iov_base
, iov
->iov_len
);
10439 ML_(linux_PRE_setregset
) ( ThreadId tid
, long arg3
, long arg4
)
10441 struct vki_iovec
*iov
= (struct vki_iovec
*) arg4
;
10443 PRE_MEM_READ("ptrace(setregset iovec->iov_base)",
10444 (unsigned long) &iov
->iov_base
, sizeof(iov
->iov_base
));
10445 PRE_MEM_READ("ptrace(setregset iovec->iov_len)",
10446 (unsigned long) &iov
->iov_len
, sizeof(iov
->iov_len
));
10447 PRE_MEM_READ("ptrace(setregset *(iovec->iov_base))",
10448 (unsigned long) iov
->iov_base
, iov
->iov_len
);
10452 ML_(linux_POST_getregset
) ( ThreadId tid
, long arg3
, long arg4
)
10454 struct vki_iovec
*iov
= (struct vki_iovec
*) arg4
;
10456 /* XXX: The actual amount of data written by the kernel might be
10457 less than iov_len, depending on the regset (arg3). */
10458 POST_MEM_WRITE((unsigned long) iov
->iov_base
, iov
->iov_len
);
10463 PRINT("kcmp ( %ld, %ld, %ld, %lu, %lu )", ARG1
, ARG2
, ARG3
, ARG4
, ARG5
);
10465 case VKI_KCMP_VM
: case VKI_KCMP_FILES
: case VKI_KCMP_FS
:
10466 case VKI_KCMP_SIGHAND
: case VKI_KCMP_IO
: case VKI_KCMP_SYSVSEM
:
10467 /* Most of the comparison types don't look at |idx1| or
10469 PRE_REG_READ3(long, "kcmp",
10470 vki_pid_t
, pid1
, vki_pid_t
, pid2
, int, type
);
10472 case VKI_KCMP_FILE
:
10474 PRE_REG_READ5(long, "kcmp",
10475 vki_pid_t
, pid1
, vki_pid_t
, pid2
, int, type
,
10476 unsigned long, idx1
, unsigned long, idx2
);
10484 #endif // defined(VGO_linux)
10486 /*--------------------------------------------------------------------*/
10488 /*--------------------------------------------------------------------*/