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-2017 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_stacks.h"
56 #include "pub_core_syscall.h"
57 #include "pub_core_syswrap.h"
58 #include "pub_core_inner.h"
59 #if defined(ENABLE_INNER_CLIENT_REQUEST)
60 #include "pub_core_clreq.h"
63 #include "priv_types_n_macros.h"
64 #include "priv_syswrap-generic.h"
65 #include "priv_syswrap-linux.h"
66 #include "priv_syswrap-main.h"
67 #include "priv_syswrap-xen.h"
69 // Run a thread from beginning to end and return the thread's
70 // scheduler-return-code.
71 static VgSchedReturnCode
thread_wrapper(Word
/*ThreadId*/ tidW
)
73 VgSchedReturnCode ret
;
74 ThreadId tid
= (ThreadId
)tidW
;
75 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
77 VG_(debugLog
)(1, "syswrap-linux",
78 "thread_wrapper(tid=%u): entry\n",
81 vg_assert(tst
->status
== VgTs_Init
);
83 /* make sure we get the CPU lock before doing anything significant */
84 VG_(acquire_BigLock
)(tid
, "thread_wrapper(starting new thread)");
87 VG_(printf
)("thread tid %u started: stack = %p\n",
90 /* Make sure error reporting is enabled in the new thread. */
91 tst
->err_disablement_level
= 0;
93 VG_TRACK(pre_thread_first_insn
, tid
);
95 tst
->os_state
.lwpid
= VG_(gettid
)();
96 /* Set the threadgroup for real. This overwrites the provisional value set
97 in do_clone(). See comments in do_clone for background, also #226116. */
98 tst
->os_state
.threadgroup
= VG_(getpid
)();
100 /* Thread created with all signals blocked; scheduler will set the
103 ret
= VG_(scheduler
)(tid
);
105 vg_assert(VG_(is_exiting
)(tid
));
107 vg_assert(tst
->status
== VgTs_Runnable
);
108 vg_assert(VG_(is_running_thread
)(tid
));
110 VG_(debugLog
)(1, "syswrap-linux",
111 "thread_wrapper(tid=%u): exit, schedreturncode %s\n",
112 tid
, VG_(name_of_VgSchedReturnCode
)(ret
));
114 /* Return to caller, still holding the lock. */
119 /* ---------------------------------------------------------------------
121 ------------------------------------------------------------------ */
123 /* Run a thread all the way to the end, then do appropriate exit actions
124 (this is the last-one-out-turn-off-the-lights bit). */
125 static void run_a_thread_NORETURN ( Word tidW
)
127 ThreadId tid
= (ThreadId
)tidW
;
128 VgSchedReturnCode src
;
131 #ifdef ENABLE_INNER_CLIENT_REQUEST
132 Int registered_vgstack_id
;
135 VG_(debugLog
)(1, "syswrap-linux",
136 "run_a_thread_NORETURN(tid=%u): pre-thread_wrapper\n",
139 tst
= VG_(get_ThreadState
)(tid
);
142 /* An thread has two stacks:
143 * the simulated stack (used by the synthetic cpu. Guest process
144 is using this stack).
145 * the valgrind stack (used by the real cpu. Valgrind code is running
147 When Valgrind runs as an inner, it must signals that its (real) stack
148 is the stack to use by the outer to e.g. do stacktraces.
151 (registered_vgstack_id
152 = VALGRIND_STACK_REGISTER (tst
->os_state
.valgrind_stack_base
,
153 tst
->os_state
.valgrind_stack_init_SP
));
155 /* Run the thread all the way through. */
156 src
= thread_wrapper(tid
);
158 VG_(debugLog
)(1, "syswrap-linux",
159 "run_a_thread_NORETURN(tid=%u): post-thread_wrapper\n",
162 c
= VG_(count_living_threads
)();
163 vg_assert(c
>= 1); /* stay sane */
165 /* Deregister thread's stack. */
166 if (tst
->os_state
.stk_id
!= NULL_STK_ID
)
167 VG_(deregister_stack
)(tst
->os_state
.stk_id
);
169 // Tell the tool this thread is exiting
170 VG_TRACK( pre_thread_ll_exit
, tid
);
172 /* If the thread is exiting with errors disabled, complain loudly;
173 doing so is bad (does the user know this has happened?) Also,
174 in all cases, be paranoid and clear the flag anyway so that the
175 thread slot is safe in this respect if later reallocated. This
176 should be unnecessary since the flag should be cleared when the
177 slot is reallocated, in thread_wrapper(). */
178 if (tst
->err_disablement_level
> 0) {
180 "WARNING: exiting thread has error reporting disabled.\n"
181 "WARNING: possibly as a result of some mistake in the use\n"
182 "WARNING: of the VALGRIND_DISABLE_ERROR_REPORTING macros.\n"
186 "run_a_thread_NORETURN(tid=%u): "
187 "WARNING: exiting thread has err_disablement_level = %u\n",
188 tid
, tst
->err_disablement_level
191 tst
->err_disablement_level
= 0;
195 VG_(debugLog
)(1, "syswrap-linux",
196 "run_a_thread_NORETURN(tid=%u): "
197 "last one standing\n",
200 /* We are the last one standing. Keep hold of the lock and
201 carry on to show final tool results, then exit the entire system.
202 Use the continuation pointer set at startup in m_main. */
203 ( * VG_(address_of_m_main_shutdown_actions_NORETURN
) ) (tid
, src
);
206 VG_(debugLog
)(1, "syswrap-linux",
207 "run_a_thread_NORETURN(tid=%u): "
208 "not last one standing\n",
211 /* OK, thread is dead, but others still exist. Just exit. */
213 /* This releases the run lock */
214 VG_(exit_thread
)(tid
);
215 vg_assert(tst
->status
== VgTs_Zombie
);
216 vg_assert(sizeof(tst
->status
) == 4);
217 vg_assert(sizeof(tst
->os_state
.exitcode
) == sizeof(Word
));
219 INNER_REQUEST (VALGRIND_STACK_DEREGISTER (registered_vgstack_id
));
221 /* We have to use this sequence to terminate the thread to
222 prevent a subtle race. If VG_(exit_thread)() had left the
223 ThreadState as Empty, then it could have been reallocated,
224 reusing the stack while we're doing these last cleanups.
225 Instead, VG_(exit_thread) leaves it as Zombie to prevent
226 reallocation. We need to make sure we don't touch the stack
227 between marking it Empty and exiting. Hence the
229 #if defined(VGP_x86_linux)
232 "movl %1, %0\n" /* set tst->status = VgTs_Empty */
233 "movl %2, %%eax\n" /* set %eax = __NR_exit */
234 "movl %3, %%ebx\n" /* set %ebx = tst->os_state.exitcode */
235 "int $0x80\n" /* exit(tst->os_state.exitcode) */
238 : "n" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
241 #elif defined(VGP_amd64_linux)
243 "movl %1, %0\n" /* set tst->status = VgTs_Empty */
244 "movq %2, %%rax\n" /* set %rax = __NR_exit */
245 "movq %3, %%rdi\n" /* set %rdi = tst->os_state.exitcode */
246 "syscall\n" /* exit(tst->os_state.exitcode) */
248 : "n" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
251 #elif defined(VGP_ppc32_linux) || defined(VGP_ppc64be_linux) \
252 || defined(VGP_ppc64le_linux)
253 { UInt vgts_empty
= (UInt
)VgTs_Empty
;
255 "stw %1,%0\n\t" /* set tst->status = VgTs_Empty */
256 "li 0,%2\n\t" /* set r0 = __NR_exit */
257 "lwz 3,%3\n\t" /* set r3 = tst->os_state.exitcode */
258 "sc\n\t" /* exit(tst->os_state.exitcode) */
260 : "r" (vgts_empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
264 #elif defined(VGP_arm_linux)
266 "str %1, %0\n" /* set tst->status = VgTs_Empty */
267 "mov r7, %2\n" /* set %r7 = __NR_exit */
268 "ldr r0, %3\n" /* set %r0 = tst->os_state.exitcode */
269 "svc 0x00000000\n" /* exit(tst->os_state.exitcode) */
271 : "r" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
274 #elif defined(VGP_arm64_linux)
276 "str %w1, %0\n" /* set tst->status = VgTs_Empty (32-bit store) */
277 "mov x8, %2\n" /* set %x8 = __NR_exit */
278 "ldr x0, %3\n" /* set %x0 = tst->os_state.exitcode */
279 "svc 0x00000000\n" /* exit(tst->os_state.exitcode) */
281 : "r" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
284 #elif defined(VGP_s390x_linux)
286 "st %1, %0\n" /* set tst->status = VgTs_Empty */
287 "lg 2, %3\n" /* set r2 = tst->os_state.exitcode */
288 "svc %2\n" /* exit(tst->os_state.exitcode) */
290 : "d" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
293 #elif defined(VGP_mips32_linux) || defined(VGP_mips64_linux)
295 "sw %1, %0\n\t" /* set tst->status = VgTs_Empty */
296 "li $2, %2\n\t" /* set v0 = __NR_exit */
297 "lw $4, %3\n\t" /* set a0 = tst->os_state.exitcode */
298 "syscall\n\t" /* exit(tst->os_state.exitcode) */
301 : "r" (VgTs_Empty
), "n" (__NR_exit
), "m" (tst
->os_state
.exitcode
)
302 : "cc", "memory" , "v0", "a0"
305 # error Unknown platform
308 VG_(core_panic
)("Thread exit failed?\n");
315 Word
ML_(start_thread_NORETURN
) ( void* arg
)
317 ThreadState
* tst
= (ThreadState
*)arg
;
318 ThreadId tid
= tst
->tid
;
320 run_a_thread_NORETURN ( (Word
)tid
);
325 /* Allocate a stack for this thread, if it doesn't already have one.
326 They're allocated lazily, and never freed. Returns the initial stack
327 pointer value to use, or 0 if allocation failed. */
328 Addr
ML_(allocstack
)(ThreadId tid
)
330 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
334 /* Either the stack_base and stack_init_SP are both zero (in which
335 case a stack hasn't been allocated) or they are both non-zero,
336 in which case it has. */
338 if (tst
->os_state
.valgrind_stack_base
== 0)
339 vg_assert(tst
->os_state
.valgrind_stack_init_SP
== 0);
341 if (tst
->os_state
.valgrind_stack_base
!= 0)
342 vg_assert(tst
->os_state
.valgrind_stack_init_SP
!= 0);
344 /* If no stack is present, allocate one. */
346 if (tst
->os_state
.valgrind_stack_base
== 0) {
347 stack
= VG_(am_alloc_VgStack
)( &initial_SP
);
349 tst
->os_state
.valgrind_stack_base
= (Addr
)stack
;
350 tst
->os_state
.valgrind_stack_init_SP
= initial_SP
;
355 VG_(printf
)( "stack for tid %u at %p; init_SP=%p\n",
357 (void*)tst
->os_state
.valgrind_stack_base
,
358 (void*)tst
->os_state
.valgrind_stack_init_SP
);
360 return tst
->os_state
.valgrind_stack_init_SP
;
363 /* Allocate a stack for the main thread, and run it all the way to the
364 end. Although we already have a working VgStack
365 (VG_(interim_stack)) it's better to allocate a new one, so that
366 overflow detection works uniformly for all threads.
368 void VG_(main_thread_wrapper_NORETURN
)(ThreadId tid
)
371 VG_(debugLog
)(1, "syswrap-linux",
372 "entering VG_(main_thread_wrapper_NORETURN)\n");
374 sp
= ML_(allocstack
)(tid
);
375 #if defined(ENABLE_INNER_CLIENT_REQUEST)
377 // we must register the main thread stack before the call
378 // to ML_(call_on_new_stack_0_1), otherwise the outer valgrind
379 // reports 'write error' on the non registered stack.
380 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
383 VALGRIND_STACK_REGISTER (tst
->os_state
.valgrind_stack_base
,
384 tst
->os_state
.valgrind_stack_init_SP
));
388 #if defined(VGP_ppc32_linux)
389 /* make a stack frame */
393 #elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
394 /* make a stack frame */
398 #elif defined(VGP_s390x_linux)
399 /* make a stack frame */
405 /* If we can't even allocate the first thread's stack, we're hosed.
407 vg_assert2(sp
!= 0, "Cannot allocate main thread's stack.");
409 /* shouldn't be any other threads around yet */
410 vg_assert( VG_(count_living_threads
)() == 1 );
412 ML_(call_on_new_stack_0_1
)(
413 (Addr
)sp
, /* stack */
414 0, /* bogus return address */
415 run_a_thread_NORETURN
, /* fn to call */
416 (Word
)tid
/* arg to give it */
423 /* Clone a new thread. Note that in the clone syscalls, we hard-code
424 tlsaddr argument as NULL : the guest TLS is emulated via guest
425 registers, and Valgrind itself has no thread local storage. */
426 static SysRes
clone_new_thread ( Word (*fn
)(void *),
434 /* Note that in all the below, we make sys_clone appear to have returned
435 Success(0) in the child, by assigning the relevant child guest
436 register(s) just before the clone syscall. */
437 #if defined(VGP_x86_linux)
439 ctst
->arch
.vex
.guest_EAX
= 0;
440 eax
= do_syscall_clone_x86_linux
441 (ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
442 child_tidptr
, parent_tidptr
, NULL
);
443 res
= VG_(mk_SysRes_x86_linux
)( eax
);
444 #elif defined(VGP_amd64_linux)
446 ctst
->arch
.vex
.guest_RAX
= 0;
447 rax
= do_syscall_clone_amd64_linux
448 (ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
449 child_tidptr
, parent_tidptr
, NULL
);
450 res
= VG_(mk_SysRes_amd64_linux
)( rax
);
451 #elif defined(VGP_ppc32_linux)
453 UInt old_cr
= LibVEX_GuestPPC32_get_CR( &ctst
->arch
.vex
);
455 ctst
->arch
.vex
.guest_GPR3
= 0;
457 LibVEX_GuestPPC32_put_CR( old_cr
& ~(1<<28), &ctst
->arch
.vex
);
458 word64
= do_syscall_clone_ppc32_linux
459 (ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
460 child_tidptr
, parent_tidptr
, NULL
);
461 /* High half word64 is syscall return value. Low half is
462 the entire CR, from which we need to extract CR0.SO. */
463 /* VG_(printf)("word64 = 0x%llx\n", word64); */
464 res
= VG_(mk_SysRes_ppc32_linux
)(/*val*/(UInt
)(word64
>> 32),
465 /*errflag*/ (((UInt
)word64
) >> 28) & 1);
466 #elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
468 UInt old_cr
= LibVEX_GuestPPC64_get_CR( &ctst
->arch
.vex
);
470 ctst
->arch
.vex
.guest_GPR3
= 0;
472 LibVEX_GuestPPC64_put_CR( old_cr
& ~(1<<28), &ctst
->arch
.vex
);
473 word64
= do_syscall_clone_ppc64_linux
474 (ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
475 child_tidptr
, parent_tidptr
, NULL
);
476 /* Low half word64 is syscall return value. Hi half is
477 the entire CR, from which we need to extract CR0.SO. */
478 /* VG_(printf)("word64 = 0x%llx\n", word64); */
479 res
= VG_(mk_SysRes_ppc64_linux
)
480 (/*val*/(UInt
)(word64
& 0xFFFFFFFFULL
),
481 /*errflag*/ (UInt
)((word64
>> (32+28)) & 1));
482 #elif defined(VGP_s390x_linux)
484 ctst
->arch
.vex
.guest_r2
= 0;
485 r2
= do_syscall_clone_s390x_linux
486 (stack
, flags
, parent_tidptr
, child_tidptr
, NULL
,
487 ML_(start_thread_NORETURN
), ctst
);
488 res
= VG_(mk_SysRes_s390x_linux
)( r2
);
489 #elif defined(VGP_arm64_linux)
491 ctst
->arch
.vex
.guest_X0
= 0;
492 x0
= do_syscall_clone_arm64_linux
493 (ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
494 child_tidptr
, parent_tidptr
, NULL
);
495 res
= VG_(mk_SysRes_arm64_linux
)( x0
);
496 #elif defined(VGP_arm_linux)
498 ctst
->arch
.vex
.guest_R0
= 0;
499 r0
= do_syscall_clone_arm_linux
500 (ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
501 child_tidptr
, parent_tidptr
, NULL
);
502 res
= VG_(mk_SysRes_arm_linux
)( r0
);
503 #elif defined(VGP_mips64_linux)
505 ctst
->arch
.vex
.guest_r2
= 0;
506 ctst
->arch
.vex
.guest_r7
= 0;
507 ret
= do_syscall_clone_mips64_linux
508 (ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
509 parent_tidptr
, NULL
, child_tidptr
);
510 res
= VG_(mk_SysRes_mips64_linux
)( /* val */ ret
, 0, /* errflag */ 0);
511 #elif defined(VGP_mips32_linux)
513 ctst
->arch
.vex
.guest_r2
= 0;
514 ctst
->arch
.vex
.guest_r7
= 0;
515 ret
= do_syscall_clone_mips_linux
516 (ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
517 child_tidptr
, parent_tidptr
, NULL
);
518 /* High half word64 is syscall return value. Low half is
519 the entire CR, from which we need to extract CR0.SO. */
520 res
= VG_ (mk_SysRes_mips32_linux
) (/*val */ ret
, 0, /*errflag */ 0);
522 # error Unknown platform
527 static void setup_child ( /*OUT*/ ThreadArchState
*child
,
528 /*IN*/ ThreadArchState
*parent
)
530 /* We inherit our parent's guest state. */
531 child
->vex
= parent
->vex
;
532 child
->vex_shadow1
= parent
->vex_shadow1
;
533 child
->vex_shadow2
= parent
->vex_shadow2
;
535 #if defined(VGP_x86_linux)
536 extern void ML_(x86_setup_LDT_GDT
) ( /*OUT*/ ThreadArchState
*child
,
537 /*IN*/ ThreadArchState
*parent
);
538 ML_(x86_setup_LDT_GDT
)(child
, parent
);
542 static SysRes
setup_child_tls (ThreadId ctid
, Addr tlsaddr
)
544 static const Bool debug
= False
;
545 ThreadState
* ctst
= VG_(get_ThreadState
)(ctid
);
546 // res is succesful by default, overriden if a real syscall is needed/done.
547 SysRes res
= VG_(mk_SysRes_Success
)(0);
550 VG_(printf
)("clone child has SETTLS: tls at %#lx\n", tlsaddr
);
552 #if defined(VGP_x86_linux)
553 vki_modify_ldt_t
* tlsinfo
= (vki_modify_ldt_t
*)tlsaddr
;
555 VG_(printf
)("clone child has SETTLS: tls info at %p: idx=%u "
556 "base=%#lx limit=%x; esp=%#x fs=%x gs=%x\n",
557 tlsinfo
, tlsinfo
->entry_number
,
558 tlsinfo
->base_addr
, tlsinfo
->limit
,
559 ctst
->arch
.vex
.guest_ESP
,
560 ctst
->arch
.vex
.guest_FS
, ctst
->arch
.vex
.guest_GS
);
561 res
= ML_(x86_sys_set_thread_area
)(ctid
, tlsinfo
);
562 #elif defined(VGP_amd64_linux)
563 ctst
->arch
.vex
.guest_FS_CONST
= tlsaddr
;
564 #elif defined(VGP_ppc32_linux)
565 ctst
->arch
.vex
.guest_GPR2
= tlsaddr
;
566 #elif defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux)
567 ctst
->arch
.vex
.guest_GPR13
= tlsaddr
;
568 #elif defined(VGP_s390x_linux)
569 ctst
->arch
.vex
.guest_a0
= (UInt
) (tlsaddr
>> 32);
570 ctst
->arch
.vex
.guest_a1
= (UInt
) tlsaddr
;
571 #elif defined(VGP_arm64_linux)
572 /* Just assign the tls pointer in the guest TPIDR_EL0. */
573 ctst
->arch
.vex
.guest_TPIDR_EL0
= tlsaddr
;
574 #elif defined(VGP_arm_linux)
575 /* Just assign the tls pointer in the guest TPIDRURO. */
576 ctst
->arch
.vex
.guest_TPIDRURO
= tlsaddr
;
577 #elif defined(VGP_mips64_linux)
578 ctst
->arch
.vex
.guest_ULR
= tlsaddr
;
579 ctst
->arch
.vex
.guest_r27
= tlsaddr
;
580 #elif defined(VGP_mips32_linux)
581 ctst
->arch
.vex
.guest_ULR
= tlsaddr
;
582 ctst
->arch
.vex
.guest_r27
= tlsaddr
;
584 # error Unknown platform
590 When a client clones, we need to keep track of the new thread. This means:
591 1. allocate a ThreadId+ThreadState+stack for the thread
593 2. initialize the thread's new VCPU state
595 3. create the thread using the same args as the client requested,
596 but using the scheduler entrypoint for EIP, and a separate stack
599 static SysRes
do_clone ( ThreadId ptid
,
600 UWord flags
, Addr sp
,
605 ThreadId ctid
= VG_(alloc_ThreadState
)();
606 ThreadState
* ptst
= VG_(get_ThreadState
)(ptid
);
607 ThreadState
* ctst
= VG_(get_ThreadState
)(ctid
);
610 vki_sigset_t blockall
, savedmask
;
612 VG_(sigfillset
)(&blockall
);
614 vg_assert(VG_(is_running_thread
)(ptid
));
615 vg_assert(VG_(is_valid_tid
)(ctid
));
617 stack
= (UWord
*)ML_(allocstack
)(ctid
);
619 res
= VG_(mk_SysRes_Error
)( VKI_ENOMEM
);
623 /* Copy register state
625 Both parent and child return to the same place, and the code
626 following the clone syscall works out which is which, so we
627 don't need to worry about it.
629 The parent gets the child's new tid returned from clone, but the
632 If the clone call specifies a NULL sp for the new thread, then
633 it actually gets a copy of the parent's sp.
635 setup_child( &ctst
->arch
, &ptst
->arch
);
638 VG_(set_SP
)(ctid
, sp
);
640 ctst
->os_state
.parent
= ptid
;
642 /* inherit signal mask */
643 ctst
->sig_mask
= ptst
->sig_mask
;
644 ctst
->tmp_sig_mask
= ptst
->sig_mask
;
646 /* Start the child with its threadgroup being the same as the
647 parent's. This is so that any exit_group calls that happen
648 after the child is created but before it sets its
649 os_state.threadgroup field for real (in thread_wrapper in
650 syswrap-linux.c), really kill the new thread. a.k.a this avoids
651 a race condition in which the thread is unkillable (via
652 exit_group) because its threadgroup is not set. The race window
653 is probably only a few hundred or a few thousand cycles long.
655 ctst
->os_state
.threadgroup
= ptst
->os_state
.threadgroup
;
657 ML_(guess_and_register_stack
) (sp
, ctst
);
659 /* Assume the clone will succeed, and tell any tool that wants to
660 know that this thread has come into existence. We cannot defer
661 it beyond this point because setup_tls, just below,
662 causes checks to assert by making references to the new ThreadId
663 if we don't state the new thread exists prior to that point.
664 If the clone fails, we'll send out a ll_exit notification for it
665 at the out: label below, to clean up. */
666 vg_assert(VG_(owns_BigLock_LL
)(ptid
));
667 VG_TRACK ( pre_thread_ll_create
, ptid
, ctid
);
669 if (flags
& VKI_CLONE_SETTLS
) {
670 res
= setup_child_tls(ctid
, tlsaddr
);
674 flags
&= ~VKI_CLONE_SETTLS
;
676 /* start the thread with everything blocked */
677 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &blockall
, &savedmask
);
679 /* Create the new thread */
680 res
= clone_new_thread ( ML_(start_thread_NORETURN
), stack
, flags
, ctst
,
681 child_tidptr
, parent_tidptr
);
683 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &savedmask
, NULL
);
686 if (sr_isError(res
)) {
688 VG_(cleanup_thread
)(&ctst
->arch
);
689 ctst
->status
= VgTs_Empty
;
690 /* oops. Better tell the tool the thread exited in a hurry :-) */
691 VG_TRACK( pre_thread_ll_exit
, ctid
);
697 /* Do a clone which is really a fork().
698 ML_(do_fork_clone) uses the clone syscall to fork a child process.
699 Note that this should not be called for a thread creation.
700 Also, some flags combinations are not supported, and such combinations
701 are handled either by masking the non supported flags or by asserting.
703 The CLONE_VFORK flag is accepted, as this just tells that the parent is
704 suspended till the child exits or calls execve. We better keep this flag,
705 just in case the guests parent/client code depends on this synchronisation.
707 We cannot keep the flag CLONE_VM, as Valgrind will do whatever host
708 instructions in the child process, that will mess up the parent host
709 memory. So, we hope for the best and assumes that the guest application does
710 not (really) depends on sharing the memory between parent and child in the
711 interval between clone and exits/execve.
713 If child_sp != 0, the child (guest) sp will be set to child_sp just after the
714 clone syscall, before child guest instructions are executed. */
715 static SysRes
ML_(do_fork_clone
) ( ThreadId tid
, UInt flags
,
716 Int
* parent_tidptr
, Int
* child_tidptr
,
719 vki_sigset_t fork_saved_mask
;
723 if (flags
& (VKI_CLONE_SETTLS
| VKI_CLONE_FS
| VKI_CLONE_VM
725 return VG_(mk_SysRes_Error
)( VKI_EINVAL
);
727 /* Block all signals during fork, so that we can fix things up in
728 the child without being interrupted. */
729 VG_(sigfillset
)(&mask
);
730 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &mask
, &fork_saved_mask
);
732 VG_(do_atfork_pre
)(tid
);
734 /* Since this is the fork() form of clone, we don't need all that
736 #if defined(VGP_x86_linux) \
737 || defined(VGP_ppc32_linux) \
738 || defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) \
739 || defined(VGP_arm_linux) || defined(VGP_mips32_linux) \
740 || defined(VGP_mips64_linux) || defined(VGP_arm64_linux)
741 res
= VG_(do_syscall5
)( __NR_clone
, flags
,
742 (UWord
)NULL
, (UWord
)parent_tidptr
,
743 (UWord
)NULL
, (UWord
)child_tidptr
);
744 #elif defined(VGP_amd64_linux)
745 /* note that the last two arguments are the opposite way round to x86 and
746 ppc32 as the amd64 kernel expects the arguments in a different order */
747 res
= VG_(do_syscall5
)( __NR_clone
, flags
,
748 (UWord
)NULL
, (UWord
)parent_tidptr
,
749 (UWord
)child_tidptr
, (UWord
)NULL
);
750 #elif defined(VGP_s390x_linux)
751 /* Note that s390 has the stack first and then the flags */
752 res
= VG_(do_syscall4
)( __NR_clone
, (UWord
) NULL
, flags
,
753 (UWord
)parent_tidptr
, (UWord
)child_tidptr
);
755 # error Unknown platform
758 if (!sr_isError(res
) && sr_Res(res
) == 0) {
761 VG_(set_SP
)(tid
, child_sp
);
762 VG_(do_atfork_child
)(tid
);
764 /* restore signal mask */
765 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &fork_saved_mask
, NULL
);
768 if (!sr_isError(res
) && sr_Res(res
) > 0) {
770 VG_(do_atfork_parent
)(tid
);
772 if (VG_(clo_trace_syscalls
))
773 VG_(printf
)(" clone(fork): process %d created child %lu\n",
774 VG_(getpid
)(), sr_Res(res
));
776 /* restore signal mask */
777 VG_(sigprocmask
)(VKI_SIG_SETMASK
, &fork_saved_mask
, NULL
);
783 /* ---------------------------------------------------------------------
784 PRE/POST wrappers for arch-generic, Linux-specific syscalls
785 ------------------------------------------------------------------ */
787 // Nb: See the comment above the generic PRE/POST wrappers in
788 // m_syswrap/syswrap-generic.c for notes about how they work.
790 #define PRE(name) DEFN_PRE_TEMPLATE(linux, name)
791 #define POST(name) DEFN_POST_TEMPLATE(linux, name)
798 PRINT("sys_clone ( %lx, %#lx, %#lx, %#lx, %#lx )",ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
800 // Order of arguments differs between platforms.
801 #if defined(VGP_x86_linux) \
802 || defined(VGP_ppc32_linux) \
803 || defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) \
804 || defined(VGP_arm_linux) || defined(VGP_mips32_linux) \
805 || defined(VGP_mips64_linux) || defined(VGP_arm64_linux)
806 #define ARG_CHILD_TIDPTR ARG5
807 #define PRA_CHILD_TIDPTR PRA5
810 #elif defined(VGP_amd64_linux) || defined(VGP_s390x_linux)
811 #define ARG_CHILD_TIDPTR ARG4
812 #define PRA_CHILD_TIDPTR PRA4
816 # error Unknown platform
818 // And s390x is even more special, and inverts flags and child stack args
819 #if defined(VGP_s390x_linux)
820 #define ARG_FLAGS ARG2
821 #define PRA_FLAGS PRA2
822 #define ARG_CHILD_STACK ARG1
823 #define PRA_CHILD_STACK PRA1
825 #define ARG_FLAGS ARG1
826 #define PRA_FLAGS PRA1
827 #define ARG_CHILD_STACK ARG2
828 #define PRA_CHILD_STACK PRA2
831 if (VG_(tdict
).track_pre_reg_read
) {
832 PRA_FLAGS("clone", unsigned long, flags
);
833 PRA_CHILD_STACK("clone", void *, child_stack
);
836 if (ARG_FLAGS
& VKI_CLONE_PARENT_SETTID
) {
837 if (VG_(tdict
).track_pre_reg_read
) {
838 PRA3("clone", int *, parent_tidptr
);
840 PRE_MEM_WRITE("clone(parent_tidptr)", ARG3
, sizeof(Int
));
841 if (!VG_(am_is_valid_for_client
)(ARG3
, sizeof(Int
),
846 if (ARG_FLAGS
& VKI_CLONE_SETTLS
) {
847 if (VG_(tdict
).track_pre_reg_read
) {
848 PRA_TLS("clone", vki_modify_ldt_t
*, tlsinfo
);
850 /* Not very clear what is vki_modify_ldt_t: for many platforms, it is a
851 dummy type (that we define as a char). We only dereference/check the
852 ARG_TLS pointer if the type looks like a real type, i.e. sizeof > 1. */
853 if (sizeof(vki_modify_ldt_t
) > 1) {
854 PRE_MEM_READ("clone(tlsinfo)", ARG_TLS
, sizeof(vki_modify_ldt_t
));
855 if (!VG_(am_is_valid_for_client
)(ARG_TLS
, sizeof(vki_modify_ldt_t
),
861 if (ARG_FLAGS
& (VKI_CLONE_CHILD_SETTID
| VKI_CLONE_CHILD_CLEARTID
)) {
862 if (VG_(tdict
).track_pre_reg_read
) {
863 PRA_CHILD_TIDPTR("clone", int *, child_tidptr
);
865 PRE_MEM_WRITE("clone(child_tidptr)", ARG_CHILD_TIDPTR
, sizeof(Int
));
866 if (!VG_(am_is_valid_for_client
)(ARG_CHILD_TIDPTR
, sizeof(Int
),
873 SET_STATUS_Failure( VKI_EFAULT
);
877 cloneflags
= ARG_FLAGS
;
879 if (!ML_(client_signal_OK
)(ARG_FLAGS
& VKI_CSIGNAL
)) {
880 SET_STATUS_Failure( VKI_EINVAL
);
884 /* Only look at the flags we really care about */
885 switch (cloneflags
& (VKI_CLONE_VM
| VKI_CLONE_FS
886 | VKI_CLONE_FILES
| VKI_CLONE_VFORK
)) {
887 case VKI_CLONE_VM
| VKI_CLONE_FS
| VKI_CLONE_FILES
:
888 /* thread creation */
889 SET_STATUS_from_SysRes(
891 ARG_FLAGS
, /* flags */
892 (Addr
)ARG_CHILD_STACK
, /* child ESP */
893 (Int
*)ARG3
, /* parent_tidptr */
894 (Int
*)ARG_CHILD_TIDPTR
, /* child_tidptr */
895 (Addr
)ARG_TLS
)); /* set_tls */
898 case VKI_CLONE_VFORK
| VKI_CLONE_VM
: /* vfork */
899 // FALLTHROUGH - assume vfork (somewhat) == fork, see ML_(do_fork_clone).
900 cloneflags
&= ~VKI_CLONE_VM
;
902 case 0: /* plain fork */
903 SET_STATUS_from_SysRes(
904 ML_(do_fork_clone
)(tid
,
905 cloneflags
, /* flags */
906 (Int
*)ARG3
, /* parent_tidptr */
907 (Int
*)ARG_CHILD_TIDPTR
, /* child_tidptr */
908 (Addr
)ARG_CHILD_STACK
));
912 /* should we just ENOSYS? */
913 VG_(message
)(Vg_UserMsg
, "Unsupported clone() flags: 0x%lx\n", ARG_FLAGS
);
914 VG_(message
)(Vg_UserMsg
, "\n");
915 VG_(message
)(Vg_UserMsg
, "The only supported clone() uses are:\n");
916 VG_(message
)(Vg_UserMsg
, " - via a threads library (LinuxThreads or NPTL)\n");
917 VG_(message
)(Vg_UserMsg
, " - via the implementation of fork or vfork\n");
919 ("Valgrind does not support general clone().");
923 if (ARG_FLAGS
& VKI_CLONE_PARENT_SETTID
)
924 POST_MEM_WRITE(ARG3
, sizeof(Int
));
925 if (ARG_FLAGS
& (VKI_CLONE_CHILD_SETTID
| VKI_CLONE_CHILD_CLEARTID
))
926 POST_MEM_WRITE(ARG_CHILD_TIDPTR
, sizeof(Int
));
928 /* Thread creation was successful; let the child have the chance
930 *flags
|= SfYieldAfter
;
933 #undef ARG_CHILD_TIDPTR
934 #undef PRA_CHILD_TIDPTR
939 #undef ARG_CHILD_STACK
940 #undef PRA_CHILD_STACK
943 /* ---------------------------------------------------------------------
945 ------------------------------------------------------------------ */
949 // Nb: depending on 'flags', the 'type' and 'data' args may be ignored.
950 // We are conservative and check everything, except the memory pointed to
952 *flags
|= SfMayBlock
;
953 PRINT("sys_mount( %#lx(%s), %#lx(%s), %#lx(%s), %#lx, %#lx )",
954 ARG1
,(HChar
*)ARG1
, ARG2
,(HChar
*)ARG2
, ARG3
,(HChar
*)ARG3
, ARG4
, ARG5
);
955 PRE_REG_READ5(long, "mount",
956 char *, source
, char *, target
, char *, type
,
957 unsigned long, flags
, void *, data
);
959 PRE_MEM_RASCIIZ( "mount(source)", ARG1
);
960 PRE_MEM_RASCIIZ( "mount(target)", ARG2
);
961 PRE_MEM_RASCIIZ( "mount(type)", ARG3
);
966 PRINT("sys_oldumount( %#lx )", ARG1
);
967 PRE_REG_READ1(long, "umount", char *, path
);
968 PRE_MEM_RASCIIZ( "umount(path)", ARG1
);
973 PRINT("sys_umount( %#lx, %ld )", ARG1
, SARG2
);
974 PRE_REG_READ2(long, "umount2", char *, path
, int, flags
);
975 PRE_MEM_RASCIIZ( "umount2(path)", ARG1
);
978 /* Not actually wrapped by GLibc but does things with the system
979 * mounts so it is put here.
983 PRINT("sys_pivot_root ( %s %s )", (HChar
*)ARG1
, (HChar
*)ARG2
);
984 PRE_REG_READ2(int, "pivot_root", char *, new_root
, char *, old_root
);
985 PRE_MEM_RASCIIZ( "pivot_root(new_root)", ARG1
);
986 PRE_MEM_RASCIIZ( "pivot_root(old_root)", ARG2
);
990 /* ---------------------------------------------------------------------
991 16- and 32-bit uid/gid wrappers
992 ------------------------------------------------------------------ */
996 PRINT("sys_setfsuid16 ( %lu )", ARG1
);
997 PRE_REG_READ1(long, "setfsuid16", vki_old_uid_t
, uid
);
1002 PRINT("sys_setfsuid ( %lu )", ARG1
);
1003 PRE_REG_READ1(long, "setfsuid", vki_uid_t
, uid
);
1008 PRINT("sys_setfsgid16 ( %lu )", ARG1
);
1009 PRE_REG_READ1(long, "setfsgid16", vki_old_gid_t
, gid
);
1014 PRINT("sys_setfsgid ( %lu )", ARG1
);
1015 PRE_REG_READ1(long, "setfsgid", vki_gid_t
, gid
);
1018 PRE(sys_setresuid16
)
1020 PRINT("sys_setresuid16 ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
1021 PRE_REG_READ3(long, "setresuid16",
1022 vki_old_uid_t
, ruid
, vki_old_uid_t
, euid
, vki_old_uid_t
, suid
);
1027 PRINT("sys_setresuid ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
1028 PRE_REG_READ3(long, "setresuid",
1029 vki_uid_t
, ruid
, vki_uid_t
, euid
, vki_uid_t
, suid
);
1032 PRE(sys_getresuid16
)
1034 PRINT("sys_getresuid16 ( %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
1035 PRE_REG_READ3(long, "getresuid16",
1036 vki_old_uid_t
*, ruid
, vki_old_uid_t
*, euid
,
1037 vki_old_uid_t
*, suid
);
1038 PRE_MEM_WRITE( "getresuid16(ruid)", ARG1
, sizeof(vki_old_uid_t
) );
1039 PRE_MEM_WRITE( "getresuid16(euid)", ARG2
, sizeof(vki_old_uid_t
) );
1040 PRE_MEM_WRITE( "getresuid16(suid)", ARG3
, sizeof(vki_old_uid_t
) );
1042 POST(sys_getresuid16
)
1046 POST_MEM_WRITE( ARG1
, sizeof(vki_old_uid_t
) );
1047 POST_MEM_WRITE( ARG2
, sizeof(vki_old_uid_t
) );
1048 POST_MEM_WRITE( ARG3
, sizeof(vki_old_uid_t
) );
1054 PRINT("sys_getresuid ( %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
1055 PRE_REG_READ3(long, "getresuid",
1056 vki_uid_t
*, ruid
, vki_uid_t
*, euid
, vki_uid_t
*, suid
);
1057 PRE_MEM_WRITE( "getresuid(ruid)", ARG1
, sizeof(vki_uid_t
) );
1058 PRE_MEM_WRITE( "getresuid(euid)", ARG2
, sizeof(vki_uid_t
) );
1059 PRE_MEM_WRITE( "getresuid(suid)", ARG3
, sizeof(vki_uid_t
) );
1065 POST_MEM_WRITE( ARG1
, sizeof(vki_uid_t
) );
1066 POST_MEM_WRITE( ARG2
, sizeof(vki_uid_t
) );
1067 POST_MEM_WRITE( ARG3
, sizeof(vki_uid_t
) );
1071 PRE(sys_setresgid16
)
1073 PRINT("sys_setresgid16 ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
1074 PRE_REG_READ3(long, "setresgid16",
1075 vki_old_gid_t
, rgid
,
1076 vki_old_gid_t
, egid
, vki_old_gid_t
, sgid
);
1081 PRINT("sys_setresgid ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
1082 PRE_REG_READ3(long, "setresgid",
1083 vki_gid_t
, rgid
, vki_gid_t
, egid
, vki_gid_t
, sgid
);
1086 PRE(sys_getresgid16
)
1088 PRINT("sys_getresgid16 ( %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
1089 PRE_REG_READ3(long, "getresgid16",
1090 vki_old_gid_t
*, rgid
, vki_old_gid_t
*, egid
,
1091 vki_old_gid_t
*, sgid
);
1092 PRE_MEM_WRITE( "getresgid16(rgid)", ARG1
, sizeof(vki_old_gid_t
) );
1093 PRE_MEM_WRITE( "getresgid16(egid)", ARG2
, sizeof(vki_old_gid_t
) );
1094 PRE_MEM_WRITE( "getresgid16(sgid)", ARG3
, sizeof(vki_old_gid_t
) );
1096 POST(sys_getresgid16
)
1100 POST_MEM_WRITE( ARG1
, sizeof(vki_old_gid_t
) );
1101 POST_MEM_WRITE( ARG2
, sizeof(vki_old_gid_t
) );
1102 POST_MEM_WRITE( ARG3
, sizeof(vki_old_gid_t
) );
1108 PRINT("sys_getresgid ( %#lx, %#lx, %#lx )", ARG1
,ARG2
,ARG3
);
1109 PRE_REG_READ3(long, "getresgid",
1110 vki_gid_t
*, rgid
, vki_gid_t
*, egid
, vki_gid_t
*, sgid
);
1111 PRE_MEM_WRITE( "getresgid(rgid)", ARG1
, sizeof(vki_gid_t
) );
1112 PRE_MEM_WRITE( "getresgid(egid)", ARG2
, sizeof(vki_gid_t
) );
1113 PRE_MEM_WRITE( "getresgid(sgid)", ARG3
, sizeof(vki_gid_t
) );
1119 POST_MEM_WRITE( ARG1
, sizeof(vki_gid_t
) );
1120 POST_MEM_WRITE( ARG2
, sizeof(vki_gid_t
) );
1121 POST_MEM_WRITE( ARG3
, sizeof(vki_gid_t
) );
1125 /* ---------------------------------------------------------------------
1126 miscellaneous wrappers
1127 ------------------------------------------------------------------ */
1134 PRINT("exit_group( %ld )", SARG1
);
1135 PRE_REG_READ1(void, "exit_group", int, status
);
1137 tst
= VG_(get_ThreadState
)(tid
);
1138 /* A little complex; find all the threads with the same threadgroup
1139 as this one (including this one), and mark them to exit */
1140 /* It is unclear how one can get a threadgroup in this process which
1141 is not the threadgroup of the calling thread:
1142 The assignments to threadgroups are:
1143 = 0; /// scheduler.c os_state_clear
1144 = getpid(); /// scheduler.c in child after fork
1145 = getpid(); /// this file, in thread_wrapper
1146 = ptst->os_state.threadgroup; /// syswrap-*-linux.c,
1147 copying the thread group of the thread doing clone
1148 So, the only case where the threadgroup might be different to the getpid
1149 value is in the child, just after fork. But then the fork syscall is
1150 still going on, the forked thread has had no chance yet to make this
1152 for (t
= 1; t
< VG_N_THREADS
; t
++) {
1153 if ( /* not alive */
1154 VG_(threads
)[t
].status
== VgTs_Empty
1157 VG_(threads
)[t
].os_state
.threadgroup
!= tst
->os_state
.threadgroup
1160 /* Assign the exit code, VG_(nuke_all_threads_except) will assign
1162 VG_(threads
)[t
].os_state
.exitcode
= ARG1
;
1165 /* Indicate in all other threads that the process is exiting.
1166 Then wait using VG_(reap_threads) for these threads to disappear.
1168 Can this give a deadlock if another thread is calling exit in parallel
1169 and would then wait for this thread to disappear ?
1171 Other threads are either blocked in a syscall or have yielded the CPU.
1173 A thread that has yielded the CPU is trying to get the big lock in
1174 VG_(scheduler). This thread will get the CPU thanks to the call
1175 to VG_(reap_threads). The scheduler will then check for signals,
1176 kill the process if this is a fatal signal, and otherwise prepare
1177 the thread for handling this signal. After this preparation, if
1178 the thread status is VG_(is_exiting), the scheduler exits the thread.
1179 So, a thread that has yielded the CPU does not have a chance to
1180 call exit => no deadlock for this thread.
1182 VG_(nuke_all_threads_except) will send the VG_SIGVGKILL signal
1183 to all threads blocked in a syscall.
1184 The syscall will be interrupted, and the control will go to the
1185 scheduler. The scheduler will then return, as the thread is in
1188 VG_(nuke_all_threads_except
)( tid
, VgSrc_ExitProcess
);
1189 VG_(reap_threads
)(tid
);
1190 VG_(threads
)[tid
].exitreason
= VgSrc_ExitThread
;
1191 /* we do assign VgSrc_ExitThread and not VgSrc_ExitProcess, as this thread
1192 is the thread calling exit_group and so its registers must be considered
1193 as not reachable. See pub_tool_machine.h VG_(apply_to_GP_regs). */
1195 /* We have to claim the syscall already succeeded. */
1196 SET_STATUS_Success(0);
1201 PRINT("sys_llseek ( %lu, 0x%lx, 0x%lx, %#lx, %lu )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
1202 PRE_REG_READ5(long, "llseek",
1203 unsigned int, fd
, unsigned long, offset_high
,
1204 unsigned long, offset_low
, vki_loff_t
*, result
,
1205 unsigned int, whence
);
1206 if (!ML_(fd_allowed
)(ARG1
, "llseek", tid
, False
))
1207 SET_STATUS_Failure( VKI_EBADF
);
1209 PRE_MEM_WRITE( "llseek(result)", ARG4
, sizeof(vki_loff_t
));
1215 POST_MEM_WRITE( ARG4
, sizeof(vki_loff_t
) );
1220 struct vki_timex
*tx
= (struct vki_timex
*)ARG1
;
1221 PRINT("sys_adjtimex ( %#lx )", ARG1
);
1222 PRE_REG_READ1(long, "adjtimex", struct timex
*, buf
);
1224 if (ML_(safe_to_deref
) (tx
, sizeof(struct vki_timex
))) {
1225 PRE_MEM_READ( "adjtimex(timex->modes)", ARG1
, sizeof(tx
->modes
));
1227 #define ADJX(bits,field) \
1228 if (tx->modes & (bits)) \
1229 PRE_MEM_READ( "adjtimex(timex->"#field")", \
1230 (Addr)&tx->field, sizeof(tx->field))
1232 if (tx
->modes
& VKI_ADJ_ADJTIME
) {
1233 if (!(tx
->modes
& VKI_ADJ_OFFSET_READONLY
))
1234 PRE_MEM_READ( "adjtimex(timex->offset)", (Addr
)&tx
->offset
, sizeof(tx
->offset
));
1236 ADJX(VKI_ADJ_OFFSET
, offset
);
1237 ADJX(VKI_ADJ_FREQUENCY
, freq
);
1238 ADJX(VKI_ADJ_MAXERROR
, maxerror
);
1239 ADJX(VKI_ADJ_ESTERROR
, esterror
);
1240 ADJX(VKI_ADJ_STATUS
, status
);
1241 ADJX(VKI_ADJ_TIMECONST
|VKI_ADJ_TAI
, constant
);
1242 ADJX(VKI_ADJ_TICK
, tick
);
1247 PRE_MEM_WRITE( "adjtimex(timex)", ARG1
, sizeof(struct vki_timex
));
1252 POST_MEM_WRITE( ARG1
, sizeof(struct vki_timex
) );
1255 PRE(sys_clock_adjtime
)
1257 struct vki_timex
*tx
= (struct vki_timex
*)ARG2
;
1258 PRINT("sys_clock_adjtime ( %ld, %#lx )", SARG1
,ARG2
);
1259 PRE_REG_READ2(long, "clock_adjtime", vki_clockid_t
, id
, struct timex
*, buf
);
1260 PRE_MEM_READ( "clock_adjtime(timex->modes)", ARG2
, sizeof(tx
->modes
));
1262 #define ADJX(bits,field) \
1263 if (tx->modes & (bits)) \
1264 PRE_MEM_READ( "clock_adjtime(timex->"#field")", \
1265 (Addr)&tx->field, sizeof(tx->field))
1267 if (tx
->modes
& VKI_ADJ_ADJTIME
) {
1268 if (!(tx
->modes
& VKI_ADJ_OFFSET_READONLY
))
1269 PRE_MEM_READ( "clock_adjtime(timex->offset)", (Addr
)&tx
->offset
, sizeof(tx
->offset
));
1271 ADJX(VKI_ADJ_OFFSET
, offset
);
1272 ADJX(VKI_ADJ_FREQUENCY
, freq
);
1273 ADJX(VKI_ADJ_MAXERROR
, maxerror
);
1274 ADJX(VKI_ADJ_ESTERROR
, esterror
);
1275 ADJX(VKI_ADJ_STATUS
, status
);
1276 ADJX(VKI_ADJ_TIMECONST
|VKI_ADJ_TAI
, constant
);
1277 ADJX(VKI_ADJ_TICK
, tick
);
1281 PRE_MEM_WRITE( "adjtimex(timex)", ARG2
, sizeof(struct vki_timex
));
1284 POST(sys_clock_adjtime
)
1286 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timex
) );
1291 PRINT("sys_ioperm ( %lu, %lu, %ld )", ARG1
, ARG2
, SARG3
);
1292 PRE_REG_READ3(long, "ioperm",
1293 unsigned long, from
, unsigned long, num
, int, turn_on
);
1298 *flags
|= SfMayBlock
;
1299 PRINT("sys_syslog (%ld, %#lx, %ld)", SARG1
, ARG2
, SARG3
);
1300 PRE_REG_READ3(long, "syslog", int, type
, char *, bufp
, int, len
);
1302 // The kernel uses magic numbers here, rather than named constants,
1303 // therefore so do we.
1304 case 2: case 3: case 4:
1305 PRE_MEM_WRITE( "syslog(bufp)", ARG2
, ARG3
);
1314 case 2: case 3: case 4:
1315 POST_MEM_WRITE( ARG2
, ARG3
);
1324 PRINT("sys_vhangup ( )");
1325 PRE_REG_READ0(long, "vhangup");
1330 PRINT("sys_sysinfo ( %#lx )",ARG1
);
1331 PRE_REG_READ1(long, "sysinfo", struct sysinfo
*, info
);
1332 PRE_MEM_WRITE( "sysinfo(info)", ARG1
, sizeof(struct vki_sysinfo
) );
1336 POST_MEM_WRITE( ARG1
, sizeof(struct vki_sysinfo
) );
1339 PRE(sys_personality
)
1341 PRINT("sys_personality ( %llu )", (ULong
)ARG1
);
1342 PRE_REG_READ1(long, "personality", vki_u_long
, persona
);
1347 struct __vki_sysctl_args
*args
;
1348 PRINT("sys_sysctl ( %#lx )", ARG1
);
1349 args
= (struct __vki_sysctl_args
*)ARG1
;
1350 PRE_REG_READ1(long, "sysctl", struct __sysctl_args
*, args
);
1351 PRE_MEM_WRITE( "sysctl(args)", ARG1
, sizeof(struct __vki_sysctl_args
) );
1352 if (!VG_(am_is_valid_for_client
)(ARG1
, sizeof(struct __vki_sysctl_args
),
1354 SET_STATUS_Failure( VKI_EFAULT
);
1358 PRE_MEM_READ("sysctl(name)", (Addr
)args
->name
, args
->nlen
* sizeof(*args
->name
));
1359 if (args
->newval
!= NULL
)
1360 PRE_MEM_READ("sysctl(newval)", (Addr
)args
->newval
, args
->newlen
);
1361 if (args
->oldlenp
!= NULL
) {
1362 PRE_MEM_READ("sysctl(oldlenp)", (Addr
)args
->oldlenp
, sizeof(*args
->oldlenp
));
1363 PRE_MEM_WRITE("sysctl(oldval)", (Addr
)args
->oldval
, *args
->oldlenp
);
1368 struct __vki_sysctl_args
*args
;
1369 args
= (struct __vki_sysctl_args
*)ARG1
;
1370 if (args
->oldlenp
!= NULL
) {
1371 POST_MEM_WRITE((Addr
)args
->oldlenp
, sizeof(*args
->oldlenp
));
1372 POST_MEM_WRITE((Addr
)args
->oldval
, 1 + *args
->oldlenp
);
1378 *flags
|= SfMayBlock
;
1379 PRINT( "sys_prctl ( %ld, %ld, %ld, %ld, %ld )", SARG1
, SARG2
, SARG3
, SARG4
, SARG5
);
1381 case VKI_PR_SET_PDEATHSIG
:
1382 PRE_REG_READ2(int, "prctl", int, option
, int, signal
);
1384 case VKI_PR_GET_PDEATHSIG
:
1385 PRE_REG_READ2(int, "prctl", int, option
, int *, signal
);
1386 PRE_MEM_WRITE("prctl(get-death-signal)", ARG2
, sizeof(Int
));
1388 case VKI_PR_GET_DUMPABLE
:
1389 PRE_REG_READ1(int, "prctl", int, option
);
1391 case VKI_PR_SET_DUMPABLE
:
1392 PRE_REG_READ2(int, "prctl", int, option
, int, dump
);
1394 case VKI_PR_GET_UNALIGN
:
1395 PRE_REG_READ2(int, "prctl", int, option
, int *, value
);
1396 PRE_MEM_WRITE("prctl(get-unalign)", ARG2
, sizeof(Int
));
1398 case VKI_PR_SET_UNALIGN
:
1399 PRE_REG_READ2(int, "prctl", int, option
, int, value
);
1401 case VKI_PR_GET_KEEPCAPS
:
1402 PRE_REG_READ1(int, "prctl", int, option
);
1404 case VKI_PR_SET_KEEPCAPS
:
1405 PRE_REG_READ2(int, "prctl", int, option
, int, keepcaps
);
1407 case VKI_PR_GET_FPEMU
:
1408 PRE_REG_READ2(int, "prctl", int, option
, int *, value
);
1409 PRE_MEM_WRITE("prctl(get-fpemu)", ARG2
, sizeof(Int
));
1411 case VKI_PR_SET_FPEMU
:
1412 PRE_REG_READ2(int, "prctl", int, option
, int, value
);
1414 case VKI_PR_GET_FPEXC
:
1415 PRE_REG_READ2(int, "prctl", int, option
, int *, value
);
1416 PRE_MEM_WRITE("prctl(get-fpexc)", ARG2
, sizeof(Int
));
1418 case VKI_PR_SET_FPEXC
:
1419 PRE_REG_READ2(int, "prctl", int, option
, int, value
);
1421 case VKI_PR_GET_TIMING
:
1422 PRE_REG_READ1(int, "prctl", int, option
);
1424 case VKI_PR_SET_TIMING
:
1425 PRE_REG_READ2(int, "prctl", int, option
, int, timing
);
1427 case VKI_PR_SET_NAME
:
1428 PRE_REG_READ2(int, "prctl", int, option
, char *, name
);
1429 /* The name can be up to TASK_COMM_LEN(16) bytes long, including
1430 the terminating null byte. So do not check more than 16 bytes. */
1431 if (ML_(safe_to_deref
)((const HChar
*) ARG2
, VKI_TASK_COMM_LEN
)) {
1432 SizeT len
= VG_(strnlen
)((const HChar
*) ARG2
, VKI_TASK_COMM_LEN
);
1433 if (len
< VKI_TASK_COMM_LEN
) {
1434 PRE_MEM_RASCIIZ("prctl(set-name)", ARG2
);
1436 PRE_MEM_READ("prctl(set-name)", ARG2
, VKI_TASK_COMM_LEN
);
1439 /* Do it the slow way, one byte at a time, while checking for
1440 terminating '\0'. */
1441 const HChar
*name
= (const HChar
*) ARG2
;
1442 for (UInt i
= 0; i
< VKI_TASK_COMM_LEN
; i
++) {
1443 PRE_MEM_READ("prctl(set-name)", (Addr
) &name
[i
], 1);
1444 if (!ML_(safe_to_deref
)(&name
[i
], 1) || name
[i
] == '\0') {
1450 case VKI_PR_GET_NAME
:
1451 PRE_REG_READ2(int, "prctl", int, option
, char *, name
);
1452 PRE_MEM_WRITE("prctl(get-name)", ARG2
, VKI_TASK_COMM_LEN
);
1454 case VKI_PR_GET_ENDIAN
:
1455 PRE_REG_READ2(int, "prctl", int, option
, int *, value
);
1456 PRE_MEM_WRITE("prctl(get-endian)", ARG2
, sizeof(Int
));
1458 case VKI_PR_SET_ENDIAN
:
1459 PRE_REG_READ2(int, "prctl", int, option
, int, value
);
1461 case VKI_PR_SET_PTRACER
:
1462 PRE_REG_READ2(int, "prctl", int, option
, int, ptracer_process_ID
);
1464 case VKI_PR_SET_SECCOMP
:
1465 /* This is a bit feeble in that it uses |option| before checking
1466 it, but at least both sides of the conditional check it. */
1467 if (ARG2
== VKI_SECCOMP_MODE_FILTER
) {
1468 PRE_REG_READ3(int, "prctl", int, option
, int, mode
, char*, filter
);
1470 /* Should check that ARG3 points at a valid struct sock_fprog.
1471 Sounds complex; hence be lame. */
1472 PRE_MEM_READ( "prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, filter)",
1476 PRE_REG_READ2(int, "prctl", int, option
, int, mode
);
1480 PRE_REG_READ5(long, "prctl",
1481 int, option
, unsigned long, arg2
, unsigned long, arg3
,
1482 unsigned long, arg4
, unsigned long, arg5
);
1489 case VKI_PR_GET_PDEATHSIG
:
1490 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1492 case VKI_PR_GET_UNALIGN
:
1493 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1495 case VKI_PR_GET_FPEMU
:
1496 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1498 case VKI_PR_GET_FPEXC
:
1499 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1501 case VKI_PR_GET_NAME
:
1502 POST_MEM_WRITE(ARG2
, VKI_TASK_COMM_LEN
);
1504 case VKI_PR_GET_ENDIAN
:
1505 POST_MEM_WRITE(ARG2
, sizeof(Int
));
1507 case VKI_PR_SET_NAME
:
1509 const HChar
* new_name
= (const HChar
*) ARG2
;
1510 if (new_name
) { // Paranoia
1511 ThreadState
* tst
= VG_(get_ThreadState
)(tid
);
1512 SizeT new_len
= VG_(strnlen
)(new_name
, VKI_TASK_COMM_LEN
);
1514 /* Don't bother reusing the memory. This is a rare event. */
1516 VG_(realloc
)("syswrap.prctl", tst
->thread_name
, new_len
+ 1);
1517 VG_(strlcpy
)(tst
->thread_name
, new_name
, new_len
+ 1);
1526 *flags
|= SfMayBlock
;
1527 PRINT("sys_sendfile ( %ld, %ld, %#lx, %lu )", SARG1
,SARG2
,ARG3
,ARG4
);
1528 PRE_REG_READ4(ssize_t
, "sendfile",
1529 int, out_fd
, int, in_fd
, vki_off_t
*, offset
,
1532 PRE_MEM_WRITE( "sendfile(offset)", ARG3
, sizeof(vki_off_t
) );
1537 POST_MEM_WRITE( ARG3
, sizeof( vki_off_t
) );
1543 *flags
|= SfMayBlock
;
1544 PRINT("sendfile64 ( %ld, %ld, %#lx, %lu )",SARG1
,SARG2
,ARG3
,ARG4
);
1545 PRE_REG_READ4(ssize_t
, "sendfile64",
1546 int, out_fd
, int, in_fd
, vki_loff_t
*, offset
,
1549 PRE_MEM_WRITE( "sendfile64(offset)", ARG3
, sizeof(vki_loff_t
) );
1551 POST(sys_sendfile64
)
1554 POST_MEM_WRITE( ARG3
, sizeof(vki_loff_t
) );
1561 arg param used by ops
1563 ARG1 - u32 *futex all
1565 ARG3 - int val WAIT,WAKE,FD,REQUEUE,CMP_REQUEUE
1566 ARG4 - struct timespec *utime WAIT:time* REQUEUE,CMP_REQUEUE:val2
1567 ARG5 - u32 *uaddr2 REQUEUE,CMP_REQUEUE
1568 ARG6 - int val3 CMP_REQUEUE
1570 PRINT("sys_futex ( %#lx, %ld, %ld, %#lx, %#lx )", ARG1
,SARG2
,SARG3
,ARG4
,ARG5
);
1571 switch(ARG2
& ~(VKI_FUTEX_PRIVATE_FLAG
|VKI_FUTEX_CLOCK_REALTIME
)) {
1572 case VKI_FUTEX_CMP_REQUEUE
:
1573 case VKI_FUTEX_WAKE_OP
:
1574 case VKI_FUTEX_CMP_REQUEUE_PI
:
1575 PRE_REG_READ6(long, "futex",
1576 vki_u32
*, futex
, int, op
, int, val
,
1577 struct timespec
*, utime
, vki_u32
*, uaddr2
, int, val3
);
1579 case VKI_FUTEX_REQUEUE
:
1580 case VKI_FUTEX_WAIT_REQUEUE_PI
:
1581 PRE_REG_READ5(long, "futex",
1582 vki_u32
*, futex
, int, op
, int, val
,
1583 struct timespec
*, utime
, vki_u32
*, uaddr2
);
1585 case VKI_FUTEX_WAIT_BITSET
:
1586 /* Check that the address at least begins in client-accessible area. */
1587 if (!VG_(am_is_valid_for_client
)( ARG1
, 1, VKI_PROT_READ
)) {
1588 SET_STATUS_Failure( VKI_EFAULT
);
1591 if (*(vki_u32
*)ARG1
!= ARG3
) {
1592 PRE_REG_READ4(long, "futex",
1593 vki_u32
*, futex
, int, op
, int, val
,
1594 struct timespec
*, utime
);
1596 /* Note argument 5 is unused, but argument 6 is used.
1597 So we cannot just PRE_REG_READ6. Read argument 6 separately. */
1598 PRE_REG_READ4(long, "futex",
1599 vki_u32
*, futex
, int, op
, int, val
,
1600 struct timespec
*, utime
);
1601 if (VG_(tdict
).track_pre_reg_read
)
1602 PRA6("futex",int,val3
);
1605 case VKI_FUTEX_WAKE_BITSET
:
1606 PRE_REG_READ3(long, "futex",
1607 vki_u32
*, futex
, int, op
, int, val
);
1608 if (VG_(tdict
).track_pre_reg_read
) {
1609 PRA6("futex", int, val3
);
1612 case VKI_FUTEX_WAIT
:
1613 case VKI_FUTEX_LOCK_PI
:
1614 PRE_REG_READ4(long, "futex",
1615 vki_u32
*, futex
, int, op
, int, val
,
1616 struct timespec
*, utime
);
1618 case VKI_FUTEX_WAKE
:
1620 PRE_REG_READ3(long, "futex",
1621 vki_u32
*, futex
, int, op
, int, val
);
1623 case VKI_FUTEX_TRYLOCK_PI
:
1624 case VKI_FUTEX_UNLOCK_PI
:
1626 PRE_REG_READ2(long, "futex", vki_u32
*, futex
, int, op
);
1630 *flags
|= SfMayBlock
;
1632 switch(ARG2
& ~(VKI_FUTEX_PRIVATE_FLAG
|VKI_FUTEX_CLOCK_REALTIME
)) {
1633 case VKI_FUTEX_WAIT
:
1634 case VKI_FUTEX_LOCK_PI
:
1635 case VKI_FUTEX_WAIT_BITSET
:
1636 case VKI_FUTEX_WAIT_REQUEUE_PI
:
1637 PRE_MEM_READ( "futex(futex)", ARG1
, sizeof(Int
) );
1639 PRE_MEM_READ( "futex(timeout)", ARG4
, sizeof(struct vki_timespec
) );
1642 case VKI_FUTEX_REQUEUE
:
1643 case VKI_FUTEX_CMP_REQUEUE
:
1644 case VKI_FUTEX_CMP_REQUEUE_PI
:
1645 case VKI_FUTEX_WAKE_OP
:
1646 PRE_MEM_READ( "futex(futex)", ARG1
, sizeof(Int
) );
1647 PRE_MEM_READ( "futex(futex2)", ARG5
, sizeof(Int
) );
1651 case VKI_FUTEX_TRYLOCK_PI
:
1652 case VKI_FUTEX_UNLOCK_PI
:
1653 case VKI_FUTEX_WAKE
:
1654 case VKI_FUTEX_WAKE_BITSET
:
1655 PRE_MEM_READ( "futex(futex)", ARG1
, sizeof(Int
) );
1659 SET_STATUS_Failure( VKI_ENOSYS
); // some futex function we don't understand
1666 POST_MEM_WRITE( ARG1
, sizeof(int) );
1667 if (ARG2
== VKI_FUTEX_FD
) {
1668 if (!ML_(fd_allowed
)(RES
, "futex", tid
, True
)) {
1670 SET_STATUS_Failure( VKI_EMFILE
);
1672 if (VG_(clo_track_fds
))
1673 ML_(record_fd_open_nameless
)(tid
, RES
);
1678 PRE(sys_set_robust_list
)
1680 PRINT("sys_set_robust_list ( %#lx, %lu )", ARG1
,ARG2
);
1681 PRE_REG_READ2(long, "set_robust_list",
1682 struct vki_robust_list_head
*, head
, vki_size_t
, len
);
1684 /* Just check the robust_list_head structure is readable - don't
1685 try and chase the list as the kernel will only read it when
1686 the thread exits so the current contents is irrelevant. */
1688 PRE_MEM_READ("set_robust_list(head)", ARG1
, ARG2
);
1691 PRE(sys_get_robust_list
)
1693 PRINT("sys_get_robust_list ( %ld, %#lx, %#lx )", SARG1
,ARG2
,ARG3
);
1694 PRE_REG_READ3(long, "get_robust_list",
1696 struct vki_robust_list_head
**, head_ptr
,
1697 vki_size_t
*, len_ptr
);
1698 PRE_MEM_WRITE("get_robust_list(head_ptr)",
1699 ARG2
, sizeof(struct vki_robust_list_head
*));
1700 PRE_MEM_WRITE("get_robust_list(len_ptr)",
1701 ARG3
, sizeof(struct vki_size_t
*));
1703 POST(sys_get_robust_list
)
1705 POST_MEM_WRITE(ARG2
, sizeof(struct vki_robust_list_head
*));
1706 POST_MEM_WRITE(ARG3
, sizeof(struct vki_size_t
*));
1709 struct pselect_sized_sigset
{
1710 const vki_sigset_t
*ss
;
1713 struct pselect_adjusted_sigset
{
1714 struct pselect_sized_sigset ss
; /* The actual syscall arg */
1715 vki_sigset_t adjusted_ss
;
1720 *flags
|= SfMayBlock
| SfPostOnFail
;
1721 PRINT("sys_pselect6 ( %ld, %#lx, %#lx, %#lx, %#lx, %#lx )",
1722 SARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
1723 PRE_REG_READ6(long, "pselect6",
1724 int, n
, vki_fd_set
*, readfds
, vki_fd_set
*, writefds
,
1725 vki_fd_set
*, exceptfds
, struct vki_timeval
*, timeout
,
1727 // XXX: this possibly understates how much memory is read.
1729 PRE_MEM_READ( "pselect6(readfds)",
1730 ARG2
, ARG1
/8 /* __FD_SETSIZE/8 */ );
1732 PRE_MEM_READ( "pselect6(writefds)",
1733 ARG3
, ARG1
/8 /* __FD_SETSIZE/8 */ );
1735 PRE_MEM_READ( "pselect6(exceptfds)",
1736 ARG4
, ARG1
/8 /* __FD_SETSIZE/8 */ );
1738 PRE_MEM_READ( "pselect6(timeout)", ARG5
, sizeof(struct vki_timeval
) );
1740 const struct pselect_sized_sigset
*pss
=
1741 (struct pselect_sized_sigset
*)ARG6
;
1742 PRE_MEM_READ( "pselect6(sig)", ARG6
, sizeof(*pss
) );
1743 if (!ML_(safe_to_deref
)(pss
, sizeof(*pss
))) {
1744 ARG6
= 1; /* Something recognisable to POST() hook. */
1746 struct pselect_adjusted_sigset
*pas
;
1747 pas
= VG_(malloc
)("syswrap.pselect6.1", sizeof(*pas
));
1749 pas
->ss
.ss
= (void *)1;
1750 pas
->ss
.ss_len
= pss
->ss_len
;
1751 if (pss
->ss_len
== sizeof(*pss
->ss
)) {
1752 if (pss
->ss
== NULL
) {
1755 PRE_MEM_READ("pselect6(sig->ss)", (Addr
)pss
->ss
, pss
->ss_len
);
1756 if (ML_(safe_to_deref
)(pss
->ss
, sizeof(*pss
->ss
))) {
1757 pas
->adjusted_ss
= *pss
->ss
;
1758 pas
->ss
.ss
= &pas
->adjusted_ss
;
1759 VG_(sanitize_client_sigmask
)(&pas
->adjusted_ss
);
1768 if (ARG6
!= 0 && ARG6
!= 1) {
1769 VG_(free
)((struct pselect_adjusted_sigset
*)ARG6
);
1776 struct vki_pollfd
* ufds
= (struct vki_pollfd
*)ARG1
;
1777 *flags
|= SfMayBlock
| SfPostOnFail
;
1778 PRINT("sys_ppoll ( %#lx, %lu, %#lx, %#lx, %lu )\n", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
1779 PRE_REG_READ5(long, "ppoll",
1780 struct vki_pollfd
*, ufds
, unsigned int, nfds
,
1781 struct vki_timespec
*, tsp
, vki_sigset_t
*, sigmask
,
1782 vki_size_t
, sigsetsize
);
1784 for (i
= 0; i
< ARG2
; i
++) {
1785 PRE_MEM_READ( "ppoll(ufds.fd)",
1786 (Addr
)(&ufds
[i
].fd
), sizeof(ufds
[i
].fd
) );
1787 PRE_MEM_READ( "ppoll(ufds.events)",
1788 (Addr
)(&ufds
[i
].events
), sizeof(ufds
[i
].events
) );
1789 PRE_MEM_WRITE( "ppoll(ufds.revents)",
1790 (Addr
)(&ufds
[i
].revents
), sizeof(ufds
[i
].revents
) );
1794 PRE_MEM_READ( "ppoll(tsp)", ARG3
, sizeof(struct vki_timespec
) );
1795 if (ARG4
!= 0 && sizeof(vki_sigset_t
) == ARG5
) {
1796 const vki_sigset_t
*guest_sigmask
= (vki_sigset_t
*)ARG4
;
1797 PRE_MEM_READ( "ppoll(sigmask)", ARG4
, ARG5
);
1798 if (!ML_(safe_to_deref
)(guest_sigmask
, sizeof(*guest_sigmask
))) {
1799 ARG4
= 1; /* Something recognisable to POST() hook. */
1801 vki_sigset_t
*vg_sigmask
=
1802 VG_(malloc
)("syswrap.ppoll.1", sizeof(*vg_sigmask
));
1803 ARG4
= (Addr
)vg_sigmask
;
1804 *vg_sigmask
= *guest_sigmask
;
1805 VG_(sanitize_client_sigmask
)(vg_sigmask
);
1812 vg_assert(SUCCESS
|| FAILURE
);
1813 if (SUCCESS
&& (RES
>= 0)) {
1815 struct vki_pollfd
* ufds
= (struct vki_pollfd
*)ARG1
;
1816 for (i
= 0; i
< ARG2
; i
++)
1817 POST_MEM_WRITE( (Addr
)(&ufds
[i
].revents
), sizeof(ufds
[i
].revents
) );
1819 if (ARG4
!= 0 && ARG5
== sizeof(vki_sigset_t
) && ARG4
!= 1) {
1820 VG_(free
)((vki_sigset_t
*) ARG4
);
1825 /* ---------------------------------------------------------------------
1827 ------------------------------------------------------------------ */
1829 PRE(sys_epoll_create
)
1831 PRINT("sys_epoll_create ( %ld )", SARG1
);
1832 PRE_REG_READ1(long, "epoll_create", int, size
);
1834 POST(sys_epoll_create
)
1837 if (!ML_(fd_allowed
)(RES
, "epoll_create", tid
, True
)) {
1839 SET_STATUS_Failure( VKI_EMFILE
);
1841 if (VG_(clo_track_fds
))
1842 ML_(record_fd_open_nameless
) (tid
, RES
);
1846 PRE(sys_epoll_create1
)
1848 PRINT("sys_epoll_create1 ( %ld )", SARG1
);
1849 PRE_REG_READ1(long, "epoll_create1", int, flags
);
1851 POST(sys_epoll_create1
)
1854 if (!ML_(fd_allowed
)(RES
, "epoll_create1", tid
, True
)) {
1856 SET_STATUS_Failure( VKI_EMFILE
);
1858 if (VG_(clo_track_fds
))
1859 ML_(record_fd_open_nameless
) (tid
, RES
);
1865 static const HChar
* epoll_ctl_s
[3] = {
1870 PRINT("sys_epoll_ctl ( %ld, %s, %ld, %#lx )",
1871 SARG1
, ( ARG2
<3 ? epoll_ctl_s
[ARG2
] : "?" ), SARG3
, ARG4
);
1872 PRE_REG_READ4(long, "epoll_ctl",
1873 int, epfd
, int, op
, int, fd
, struct vki_epoll_event
*, event
);
1874 if (ARG2
!= VKI_EPOLL_CTL_DEL
)
1875 PRE_MEM_READ( "epoll_ctl(event)", ARG4
, sizeof(struct vki_epoll_event
) );
1880 *flags
|= SfMayBlock
;
1881 PRINT("sys_epoll_wait ( %ld, %#lx, %ld, %ld )", SARG1
, ARG2
, SARG3
, SARG4
);
1882 PRE_REG_READ4(long, "epoll_wait",
1883 int, epfd
, struct vki_epoll_event
*, events
,
1884 int, maxevents
, int, timeout
);
1885 PRE_MEM_WRITE( "epoll_wait(events)", ARG2
, sizeof(struct vki_epoll_event
)*ARG3
);
1887 POST(sys_epoll_wait
)
1891 POST_MEM_WRITE( ARG2
, sizeof(struct vki_epoll_event
)*RES
) ;
1894 PRE(sys_epoll_pwait
)
1896 *flags
|= SfMayBlock
;
1897 PRINT("sys_epoll_pwait ( %ld, %#lx, %ld, %ld, %#lx, %lu )",
1898 SARG1
, ARG2
, SARG3
, SARG4
, ARG5
, ARG6
);
1899 PRE_REG_READ6(long, "epoll_pwait",
1900 int, epfd
, struct vki_epoll_event
*, events
,
1901 int, maxevents
, int, timeout
, vki_sigset_t
*, sigmask
,
1902 vki_size_t
, sigsetsize
);
1903 PRE_MEM_WRITE( "epoll_pwait(events)", ARG2
, sizeof(struct vki_epoll_event
)*ARG3
);
1905 PRE_MEM_READ( "epoll_pwait(sigmask)", ARG5
, sizeof(vki_sigset_t
) );
1907 POST(sys_epoll_pwait
)
1911 POST_MEM_WRITE( ARG2
, sizeof(struct vki_epoll_event
)*RES
) ;
1916 PRINT("sys_eventfd ( %lu )", ARG1
);
1917 PRE_REG_READ1(long, "sys_eventfd", unsigned int, count
);
1921 if (!ML_(fd_allowed
)(RES
, "eventfd", tid
, True
)) {
1923 SET_STATUS_Failure( VKI_EMFILE
);
1925 if (VG_(clo_track_fds
))
1926 ML_(record_fd_open_nameless
) (tid
, RES
);
1932 PRINT("sys_eventfd2 ( %lu, %ld )", ARG1
, SARG2
);
1933 PRE_REG_READ2(long, "sys_eventfd2", unsigned int, count
, int, flags
);
1937 if (!ML_(fd_allowed
)(RES
, "eventfd2", tid
, True
)) {
1939 SET_STATUS_Failure( VKI_EMFILE
);
1941 if (VG_(clo_track_fds
))
1942 ML_(record_fd_open_nameless
) (tid
, RES
);
1948 *flags
|= SfMayBlock
;
1949 #if VG_WORDSIZE == 4
1950 PRINT("sys_fallocate ( %ld, %ld, %lld, %lld )",
1951 SARG1
, SARG2
, (Long
)MERGE64(ARG3
,ARG4
), (Long
)MERGE64(ARG5
,ARG6
));
1952 PRE_REG_READ6(long, "fallocate",
1954 unsigned, MERGE64_FIRST(offset
), unsigned, MERGE64_SECOND(offset
),
1955 unsigned, MERGE64_FIRST(len
), unsigned, MERGE64_SECOND(len
));
1956 #elif VG_WORDSIZE == 8
1957 PRINT("sys_fallocate ( %ld, %ld, %ld, %ld )",
1958 SARG1
, SARG2
, SARG3
, SARG4
);
1959 PRE_REG_READ4(long, "fallocate",
1960 int, fd
, int, mode
, vki_loff_t
, offset
, vki_loff_t
, len
);
1962 # error Unexpected word size
1964 if (!ML_(fd_allowed
)(ARG1
, "fallocate", tid
, False
))
1965 SET_STATUS_Failure( VKI_EBADF
);
1970 PRINT("sys_prlimit64 ( %ld, %lu, %#lx, %#lx )", SARG1
,ARG2
,ARG3
,ARG4
);
1971 PRE_REG_READ4(long, "prlimit64",
1972 vki_pid_t
, pid
, unsigned int, resource
,
1973 const struct rlimit64
*, new_rlim
,
1974 struct rlimit64
*, old_rlim
);
1976 PRE_MEM_READ( "rlimit64(new_rlim)", ARG3
, sizeof(struct vki_rlimit64
) );
1978 PRE_MEM_WRITE( "rlimit64(old_rlim)", ARG4
, sizeof(struct vki_rlimit64
) );
1981 ((struct vki_rlimit64
*)ARG3
)->rlim_cur
> ((struct vki_rlimit64
*)ARG3
)->rlim_max
) {
1982 SET_STATUS_Failure( VKI_EINVAL
);
1984 else if (ARG1
== 0 || ARG1
== VG_(getpid
)()) {
1986 case VKI_RLIMIT_NOFILE
:
1987 SET_STATUS_Success( 0 );
1989 ((struct vki_rlimit64
*)ARG4
)->rlim_cur
= VG_(fd_soft_limit
);
1990 ((struct vki_rlimit64
*)ARG4
)->rlim_max
= VG_(fd_hard_limit
);
1993 if (((struct vki_rlimit64
*)ARG3
)->rlim_cur
> VG_(fd_hard_limit
) ||
1994 ((struct vki_rlimit64
*)ARG3
)->rlim_max
!= VG_(fd_hard_limit
)) {
1995 SET_STATUS_Failure( VKI_EPERM
);
1998 VG_(fd_soft_limit
) = ((struct vki_rlimit64
*)ARG3
)->rlim_cur
;
2003 case VKI_RLIMIT_DATA
:
2004 SET_STATUS_Success( 0 );
2006 ((struct vki_rlimit64
*)ARG4
)->rlim_cur
= VG_(client_rlimit_data
).rlim_cur
;
2007 ((struct vki_rlimit64
*)ARG4
)->rlim_max
= VG_(client_rlimit_data
).rlim_max
;
2010 if (((struct vki_rlimit64
*)ARG3
)->rlim_cur
> VG_(client_rlimit_data
).rlim_max
||
2011 ((struct vki_rlimit64
*)ARG3
)->rlim_max
> VG_(client_rlimit_data
).rlim_max
) {
2012 SET_STATUS_Failure( VKI_EPERM
);
2015 VG_(client_rlimit_data
).rlim_cur
= ((struct vki_rlimit64
*)ARG3
)->rlim_cur
;
2016 VG_(client_rlimit_data
).rlim_max
= ((struct vki_rlimit64
*)ARG3
)->rlim_max
;
2021 case VKI_RLIMIT_STACK
:
2022 SET_STATUS_Success( 0 );
2024 ((struct vki_rlimit64
*)ARG4
)->rlim_cur
= VG_(client_rlimit_stack
).rlim_cur
;
2025 ((struct vki_rlimit64
*)ARG4
)->rlim_max
= VG_(client_rlimit_stack
).rlim_max
;
2028 if (((struct vki_rlimit64
*)ARG3
)->rlim_cur
> VG_(client_rlimit_stack
).rlim_max
||
2029 ((struct vki_rlimit64
*)ARG3
)->rlim_max
> VG_(client_rlimit_stack
).rlim_max
) {
2030 SET_STATUS_Failure( VKI_EPERM
);
2033 VG_(threads
)[tid
].client_stack_szB
= ((struct vki_rlimit64
*)ARG3
)->rlim_cur
;
2034 VG_(client_rlimit_stack
).rlim_cur
= ((struct vki_rlimit64
*)ARG3
)->rlim_cur
;
2035 VG_(client_rlimit_stack
).rlim_max
= ((struct vki_rlimit64
*)ARG3
)->rlim_max
;
2046 POST_MEM_WRITE( ARG4
, sizeof(struct vki_rlimit64
) );
2049 /* ---------------------------------------------------------------------
2050 tid-related wrappers
2051 ------------------------------------------------------------------ */
2055 PRINT("sys_gettid ()");
2056 PRE_REG_READ0(long, "gettid");
2059 PRE(sys_set_tid_address
)
2061 PRINT("sys_set_tid_address ( %#lx )", ARG1
);
2062 PRE_REG_READ1(long, "set_tid_address", int *, tidptr
);
2067 PRINT("sys_tkill ( %ld, %ld )", SARG1
, SARG2
);
2068 PRE_REG_READ2(long, "tkill", int, tid
, int, sig
);
2069 if (!ML_(client_signal_OK
)(ARG2
)) {
2070 SET_STATUS_Failure( VKI_EINVAL
);
2074 /* Check to see if this kill gave us a pending signal */
2075 *flags
|= SfPollAfter
;
2077 if (VG_(clo_trace_signals
))
2078 VG_(message
)(Vg_DebugMsg
, "tkill: sending signal %ld to pid %ld\n",
2081 /* If we're sending SIGKILL, check to see if the target is one of
2082 our threads and handle it specially. */
2083 if (ARG2
== VKI_SIGKILL
&& ML_(do_sigkill
)(ARG1
, -1)) {
2084 SET_STATUS_Success(0);
2088 /* Ask to handle this syscall via the slow route, since that's the
2089 only one that sets tst->status to VgTs_WaitSys. If the result
2090 of doing the syscall is an immediate run of
2091 async_signalhandler() in m_signals, then we need the thread to
2092 be properly tidied away. I have the impression the previous
2093 version of this wrapper worked on x86/amd64 only because the
2094 kernel did not immediately deliver the async signal to this
2095 thread (on ppc it did, which broke the assertion re tst->status
2096 at the top of async_signalhandler()). */
2097 *flags
|= SfMayBlock
;
2101 if (VG_(clo_trace_signals
))
2102 VG_(message
)(Vg_DebugMsg
, "tkill: sent signal %ld to pid %ld\n",
2108 PRINT("sys_tgkill ( %ld, %ld, %ld )", SARG1
, SARG2
, SARG3
);
2109 PRE_REG_READ3(long, "tgkill", int, tgid
, int, tid
, int, sig
);
2110 if (!ML_(client_signal_OK
)(ARG3
)) {
2111 SET_STATUS_Failure( VKI_EINVAL
);
2115 /* Check to see if this kill gave us a pending signal */
2116 *flags
|= SfPollAfter
;
2118 if (VG_(clo_trace_signals
))
2119 VG_(message
)(Vg_DebugMsg
,
2120 "tgkill: sending signal %ld to pid %ld/%ld\n",
2121 SARG3
, SARG1
, SARG2
);
2123 /* If we're sending SIGKILL, check to see if the target is one of
2124 our threads and handle it specially. */
2125 if (ARG3
== VKI_SIGKILL
&& ML_(do_sigkill
)(ARG2
, ARG1
)) {
2126 SET_STATUS_Success(0);
2130 /* Ask to handle this syscall via the slow route, since that's the
2131 only one that sets tst->status to VgTs_WaitSys. If the result
2132 of doing the syscall is an immediate run of
2133 async_signalhandler() in m_signals, then we need the thread to
2134 be properly tidied away. I have the impression the previous
2135 version of this wrapper worked on x86/amd64 only because the
2136 kernel did not immediately deliver the async signal to this
2137 thread (on ppc it did, which broke the assertion re tst->status
2138 at the top of async_signalhandler()). */
2139 *flags
|= SfMayBlock
;
2143 if (VG_(clo_trace_signals
))
2144 VG_(message
)(Vg_DebugMsg
,
2145 "tgkill: sent signal %ld to pid %ld/%ld\n",
2146 SARG3
, SARG1
, SARG2
);
2149 /* ---------------------------------------------------------------------
2151 ------------------------------------------------------------------ */
2155 PRINT("sys_fadvise64 ( %ld, %llu, %lu, %ld )",
2156 SARG1
, MERGE64(ARG2
,ARG3
), ARG4
, SARG5
);
2157 PRE_REG_READ5(long, "fadvise64",
2158 int, fd
, vki_u32
, MERGE64_FIRST(offset
), vki_u32
, MERGE64_SECOND(offset
),
2159 vki_size_t
, len
, int, advice
);
2162 PRE(sys_fadvise64_64
)
2164 PRINT("sys_fadvise64_64 ( %ld, %llu, %llu, %ld )",
2165 SARG1
, MERGE64(ARG2
,ARG3
), MERGE64(ARG4
,ARG5
), SARG6
);
2166 PRE_REG_READ6(long, "fadvise64_64",
2167 int, fd
, vki_u32
, MERGE64_FIRST(offset
), vki_u32
, MERGE64_SECOND(offset
),
2168 vki_u32
, MERGE64_FIRST(len
), vki_u32
, MERGE64_SECOND(len
), int, advice
);
2171 /* ---------------------------------------------------------------------
2173 ------------------------------------------------------------------ */
2175 // Nb: this wrapper has to pad/unpad memory around the syscall itself,
2176 // and this allows us to control exactly the code that gets run while
2177 // the padding is in place.
2181 PRINT("sys_io_setup ( %lu, %#lx )", ARG1
,ARG2
);
2182 PRE_REG_READ2(long, "io_setup",
2183 unsigned, nr_events
, vki_aio_context_t
*, ctxp
);
2184 PRE_MEM_WRITE( "io_setup(ctxp)", ARG2
, sizeof(vki_aio_context_t
) );
2190 struct vki_aio_ring
*r
;
2192 size
= VG_PGROUNDUP(sizeof(struct vki_aio_ring
) +
2193 ARG1
*sizeof(struct vki_io_event
));
2194 r
= *(struct vki_aio_ring
**)ARG2
;
2195 vg_assert(ML_(valid_client_addr
)((Addr
)r
, size
, tid
, "io_setup"));
2197 ML_(notify_core_and_tool_of_mmap
)( (Addr
)r
, size
,
2198 VKI_PROT_READ
| VKI_PROT_WRITE
,
2199 VKI_MAP_ANONYMOUS
, -1, 0 );
2201 POST_MEM_WRITE( ARG2
, sizeof(vki_aio_context_t
) );
2204 // Nb: This wrapper is "Special" because we need 'size' to do the unmap
2205 // after the syscall. We must get 'size' from the aio_ring structure,
2206 // before the syscall, while the aio_ring structure still exists. (And we
2207 // know that we must look at the aio_ring structure because Tom inspected the
2208 // kernel and glibc sources to see what they do, yuk.)
2210 // XXX This segment can be implicitly unmapped when aio
2211 // file-descriptors are closed...
2216 PRINT("sys_io_destroy ( %llu )", (ULong
)ARG1
);
2217 PRE_REG_READ1(long, "io_destroy", vki_aio_context_t
, ctx
);
2219 // If we are going to seg fault (due to a bogus ARG1) do it as late as
2221 if (ML_(safe_to_deref
)( (void*)ARG1
, sizeof(struct vki_aio_ring
))) {
2222 struct vki_aio_ring
*r
= (struct vki_aio_ring
*)ARG1
;
2223 size
= VG_PGROUNDUP(sizeof(struct vki_aio_ring
) +
2224 r
->nr
*sizeof(struct vki_io_event
));
2227 SET_STATUS_from_SysRes( VG_(do_syscall1
)(SYSNO
, ARG1
) );
2229 if (SUCCESS
&& RES
== 0) {
2230 Bool d
= VG_(am_notify_munmap
)( ARG1
, size
);
2231 VG_TRACK( die_mem_munmap
, ARG1
, size
);
2233 VG_(discard_translations
)( (Addr
)ARG1
, (ULong
)size
,
2234 "PRE(sys_io_destroy)" );
2238 PRE(sys_io_getevents
)
2240 *flags
|= SfMayBlock
;
2241 PRINT("sys_io_getevents ( %llu, %lld, %lld, %#lx, %#lx )",
2242 (ULong
)ARG1
,(Long
)ARG2
,(Long
)ARG3
,ARG4
,ARG5
);
2243 PRE_REG_READ5(long, "io_getevents",
2244 vki_aio_context_t
, ctx_id
, long, min_nr
, long, nr
,
2245 struct io_event
*, events
,
2246 struct timespec
*, timeout
);
2248 PRE_MEM_WRITE( "io_getevents(events)",
2249 ARG4
, sizeof(struct vki_io_event
)*ARG3
);
2251 PRE_MEM_READ( "io_getevents(timeout)",
2252 ARG5
, sizeof(struct vki_timespec
));
2254 POST(sys_io_getevents
)
2259 POST_MEM_WRITE( ARG4
, sizeof(struct vki_io_event
)*RES
);
2260 for (i
= 0; i
< RES
; i
++) {
2261 const struct vki_io_event
*vev
= ((struct vki_io_event
*)ARG4
) + i
;
2262 const struct vki_iocb
*cb
= (struct vki_iocb
*)(Addr
)vev
->obj
;
2264 switch (cb
->aio_lio_opcode
) {
2265 case VKI_IOCB_CMD_PREAD
:
2266 if (vev
->result
> 0)
2267 POST_MEM_WRITE( cb
->aio_buf
, vev
->result
);
2270 case VKI_IOCB_CMD_PWRITE
:
2273 case VKI_IOCB_CMD_FSYNC
:
2276 case VKI_IOCB_CMD_FDSYNC
:
2279 case VKI_IOCB_CMD_PREADV
:
2280 if (vev
->result
> 0) {
2281 struct vki_iovec
* vec
= (struct vki_iovec
*)(Addr
)cb
->aio_buf
;
2282 Int remains
= vev
->result
;
2285 for (j
= 0; j
< cb
->aio_nbytes
; j
++) {
2286 Int nReadThisBuf
= vec
[j
].iov_len
;
2287 if (nReadThisBuf
> remains
) nReadThisBuf
= remains
;
2288 POST_MEM_WRITE( (Addr
)vec
[j
].iov_base
, nReadThisBuf
);
2289 remains
-= nReadThisBuf
;
2290 if (remains
< 0) VG_(core_panic
)("io_getevents(PREADV): remains < 0");
2295 case VKI_IOCB_CMD_PWRITEV
:
2299 VG_(message
)(Vg_DebugMsg
,
2300 "Warning: unhandled io_getevents opcode: %u\n",
2301 cb
->aio_lio_opcode
);
2312 PRINT("sys_io_submit ( %lu, %ld, %#lx )", ARG1
, SARG2
, ARG3
);
2313 PRE_REG_READ3(long, "io_submit",
2314 vki_aio_context_t
, ctx_id
, long, nr
,
2315 struct iocb
**, iocbpp
);
2316 PRE_MEM_READ( "io_submit(iocbpp)", ARG3
, ARG2
*sizeof(struct vki_iocb
*) );
2318 for (i
= 0; i
< ARG2
; i
++) {
2319 struct vki_iocb
*cb
= ((struct vki_iocb
**)ARG3
)[i
];
2320 struct vki_iovec
*iov
;
2322 PRE_MEM_READ( "io_submit(iocb)", (Addr
)cb
, sizeof(struct vki_iocb
) );
2323 switch (cb
->aio_lio_opcode
) {
2324 case VKI_IOCB_CMD_PREAD
:
2325 PRE_MEM_WRITE( "io_submit(PREAD)", cb
->aio_buf
, cb
->aio_nbytes
);
2328 case VKI_IOCB_CMD_PWRITE
:
2329 PRE_MEM_READ( "io_submit(PWRITE)", cb
->aio_buf
, cb
->aio_nbytes
);
2332 case VKI_IOCB_CMD_FSYNC
:
2335 case VKI_IOCB_CMD_FDSYNC
:
2338 case VKI_IOCB_CMD_PREADV
:
2339 iov
= (struct vki_iovec
*)(Addr
)cb
->aio_buf
;
2340 PRE_MEM_READ( "io_submit(PREADV)", cb
->aio_buf
, cb
->aio_nbytes
* sizeof(struct vki_iovec
) );
2341 for (j
= 0; j
< cb
->aio_nbytes
; j
++)
2342 PRE_MEM_WRITE( "io_submit(PREADV(iov[i]))", (Addr
)iov
[j
].iov_base
, iov
[j
].iov_len
);
2345 case VKI_IOCB_CMD_PWRITEV
:
2346 iov
= (struct vki_iovec
*)(Addr
)cb
->aio_buf
;
2347 PRE_MEM_READ( "io_submit(PWRITEV)", cb
->aio_buf
, cb
->aio_nbytes
* sizeof(struct vki_iovec
) );
2348 for (j
= 0; j
< cb
->aio_nbytes
; j
++)
2349 PRE_MEM_READ( "io_submit(PWRITEV(iov[i]))", (Addr
)iov
[j
].iov_base
, iov
[j
].iov_len
);
2353 VG_(message
)(Vg_DebugMsg
,"Warning: unhandled io_submit opcode: %u\n",
2354 cb
->aio_lio_opcode
);
2363 PRINT("sys_io_cancel ( %llu, %#lx, %#lx )", (ULong
)ARG1
,ARG2
,ARG3
);
2364 PRE_REG_READ3(long, "io_cancel",
2365 vki_aio_context_t
, ctx_id
, struct iocb
*, iocb
,
2366 struct io_event
*, result
);
2367 PRE_MEM_READ( "io_cancel(iocb)", ARG2
, sizeof(struct vki_iocb
) );
2368 PRE_MEM_WRITE( "io_cancel(result)", ARG3
, sizeof(struct vki_io_event
) );
2372 POST_MEM_WRITE( ARG3
, sizeof(struct vki_io_event
) );
2375 /* ---------------------------------------------------------------------
2376 *_mempolicy wrappers
2377 ------------------------------------------------------------------ */
2381 PRINT("sys_mbind ( %#lx, %lu, %lu, %#lx, %lu, %lu )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
2382 PRE_REG_READ6(long, "mbind",
2383 unsigned long, start
, unsigned long, len
,
2384 unsigned long, policy
, unsigned long *, nodemask
,
2385 unsigned long, maxnode
, unsigned, flags
);
2387 PRE_MEM_READ( "mbind(nodemask)", ARG4
,
2388 VG_ROUNDUP( ARG5
-1, sizeof(UWord
) * 8 ) / 8 );
2391 PRE(sys_set_mempolicy
)
2393 PRINT("sys_set_mempolicy ( %ld, %#lx, %lu )", SARG1
, ARG2
, ARG3
);
2394 PRE_REG_READ3(long, "set_mempolicy",
2395 int, policy
, unsigned long *, nodemask
,
2396 unsigned long, maxnode
);
2397 PRE_MEM_READ( "set_mempolicy(nodemask)", ARG2
,
2398 VG_ROUNDUP( ARG3
-1, sizeof(UWord
) * 8 ) / 8 );
2401 PRE(sys_get_mempolicy
)
2403 PRINT("sys_get_mempolicy ( %#lx, %#lx, %lu, %#lx, %lx )", ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
2404 PRE_REG_READ5(long, "get_mempolicy",
2405 int *, policy
, unsigned long *, nodemask
,
2406 unsigned long, maxnode
, unsigned long, addr
,
2407 unsigned long, flags
);
2409 PRE_MEM_WRITE( "get_mempolicy(policy)", ARG1
, sizeof(Int
) );
2411 PRE_MEM_WRITE( "get_mempolicy(nodemask)", ARG2
,
2412 VG_ROUNDUP( ARG3
-1, sizeof(UWord
) * 8 ) / 8 );
2414 POST(sys_get_mempolicy
)
2417 POST_MEM_WRITE( ARG1
, sizeof(Int
) );
2419 POST_MEM_WRITE( ARG2
, VG_ROUNDUP( ARG3
-1, sizeof(UWord
) * 8 ) / 8 );
2422 /* ---------------------------------------------------------------------
2424 ------------------------------------------------------------------ */
2426 PRE(sys_fanotify_init
)
2428 PRINT("sys_fanotify_init ( %lu, %lu )", ARG1
,ARG2
);
2429 PRE_REG_READ2(long, "fanotify_init",
2430 unsigned int, flags
, unsigned int, event_f_flags
);
2433 POST(sys_fanotify_init
)
2436 if (!ML_(fd_allowed
)(RES
, "fanotify_init", tid
, True
)) {
2438 SET_STATUS_Failure( VKI_EMFILE
);
2440 if (VG_(clo_track_fds
))
2441 ML_(record_fd_open_nameless
) (tid
, RES
);
2445 PRE(sys_fanotify_mark
)
2447 #if VG_WORDSIZE == 4
2448 PRINT( "sys_fanotify_mark ( %ld, %lu, %llu, %ld, %#lx(%s))",
2449 SARG1
, ARG2
, MERGE64(ARG3
,ARG4
), SARG5
, ARG6
, (HChar
*)ARG6
);
2450 PRE_REG_READ6(long, "sys_fanotify_mark",
2451 int, fanotify_fd
, unsigned int, flags
,
2452 __vki_u32
, mask0
, __vki_u32
, mask1
,
2453 int, dfd
, const char *, pathname
);
2455 PRE_MEM_RASCIIZ( "fanotify_mark(path)", ARG6
);
2456 #elif VG_WORDSIZE == 8
2457 PRINT( "sys_fanotify_mark ( %ld, %lu, %lu, %ld, %#lx(%s))",
2458 SARG1
, ARG2
, ARG3
, SARG4
, ARG5
, (HChar
*)ARG5
);
2459 PRE_REG_READ5(long, "sys_fanotify_mark",
2460 int, fanotify_fd
, unsigned int, flags
,
2462 int, dfd
, const char *, pathname
);
2464 PRE_MEM_RASCIIZ( "fanotify_mark(path)", ARG5
);
2466 # error Unexpected word size
2470 /* ---------------------------------------------------------------------
2472 ------------------------------------------------------------------ */
2474 PRE(sys_inotify_init
)
2476 PRINT("sys_inotify_init ( )");
2477 PRE_REG_READ0(long, "inotify_init");
2479 POST(sys_inotify_init
)
2482 if (!ML_(fd_allowed
)(RES
, "inotify_init", tid
, True
)) {
2484 SET_STATUS_Failure( VKI_EMFILE
);
2486 if (VG_(clo_track_fds
))
2487 ML_(record_fd_open_nameless
) (tid
, RES
);
2491 PRE(sys_inotify_init1
)
2493 PRINT("sys_inotify_init ( %ld )", SARG1
);
2494 PRE_REG_READ1(long, "inotify_init", int, flag
);
2497 POST(sys_inotify_init1
)
2500 if (!ML_(fd_allowed
)(RES
, "inotify_init", tid
, True
)) {
2502 SET_STATUS_Failure( VKI_EMFILE
);
2504 if (VG_(clo_track_fds
))
2505 ML_(record_fd_open_nameless
) (tid
, RES
);
2509 PRE(sys_inotify_add_watch
)
2511 PRINT( "sys_inotify_add_watch ( %ld, %#lx, %lx )", SARG1
, ARG2
, ARG3
);
2512 PRE_REG_READ3(long, "inotify_add_watch", int, fd
, char *, path
, int, mask
);
2513 PRE_MEM_RASCIIZ( "inotify_add_watch(path)", ARG2
);
2516 PRE(sys_inotify_rm_watch
)
2518 PRINT( "sys_inotify_rm_watch ( %ld, %lx )", SARG1
, ARG2
);
2519 PRE_REG_READ2(long, "inotify_rm_watch", int, fd
, int, wd
);
2522 /* ---------------------------------------------------------------------
2524 ------------------------------------------------------------------ */
2528 PRINT("sys_mq_open( %#lx(%s), %ld, %lu, %#lx )",
2529 ARG1
, (HChar
*)ARG1
, SARG2
, ARG3
, ARG4
);
2530 PRE_REG_READ4(long, "mq_open",
2531 const char *, name
, int, oflag
, vki_mode_t
, mode
,
2532 struct mq_attr
*, attr
);
2533 PRE_MEM_RASCIIZ( "mq_open(name)", ARG1
);
2534 if ((ARG2
& VKI_O_CREAT
) != 0 && ARG4
!= 0) {
2535 const struct vki_mq_attr
*attr
= (struct vki_mq_attr
*)ARG4
;
2536 PRE_MEM_READ( "mq_open(attr->mq_maxmsg)",
2537 (Addr
)&attr
->mq_maxmsg
, sizeof(attr
->mq_maxmsg
) );
2538 PRE_MEM_READ( "mq_open(attr->mq_msgsize)",
2539 (Addr
)&attr
->mq_msgsize
, sizeof(attr
->mq_msgsize
) );
2545 if (!ML_(fd_allowed
)(RES
, "mq_open", tid
, True
)) {
2547 SET_STATUS_Failure( VKI_EMFILE
);
2549 if (VG_(clo_track_fds
))
2550 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG1
);
2556 PRINT("sys_mq_unlink ( %#lx(%s) )", ARG1
,(char*)ARG1
);
2557 PRE_REG_READ1(long, "mq_unlink", const char *, name
);
2558 PRE_MEM_RASCIIZ( "mq_unlink(name)", ARG1
);
2561 PRE(sys_mq_timedsend
)
2563 *flags
|= SfMayBlock
;
2564 PRINT("sys_mq_timedsend ( %ld, %#lx, %lu, %lu, %#lx )",
2565 SARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
2566 PRE_REG_READ5(long, "mq_timedsend",
2567 vki_mqd_t
, mqdes
, const char *, msg_ptr
, vki_size_t
, msg_len
,
2568 unsigned int, msg_prio
, const struct timespec
*, abs_timeout
);
2569 if (!ML_(fd_allowed
)(ARG1
, "mq_timedsend", tid
, False
)) {
2570 SET_STATUS_Failure( VKI_EBADF
);
2572 PRE_MEM_READ( "mq_timedsend(msg_ptr)", ARG2
, ARG3
);
2574 PRE_MEM_READ( "mq_timedsend(abs_timeout)", ARG5
,
2575 sizeof(struct vki_timespec
) );
2579 PRE(sys_mq_timedreceive
)
2581 *flags
|= SfMayBlock
;
2582 PRINT("sys_mq_timedreceive( %ld, %#lx, %lu, %#lx, %#lx )",
2583 SARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
2584 PRE_REG_READ5(ssize_t
, "mq_timedreceive",
2585 vki_mqd_t
, mqdes
, char *, msg_ptr
, vki_size_t
, msg_len
,
2586 unsigned int *, msg_prio
,
2587 const struct timespec
*, abs_timeout
);
2588 if (!ML_(fd_allowed
)(ARG1
, "mq_timedreceive", tid
, False
)) {
2589 SET_STATUS_Failure( VKI_EBADF
);
2591 PRE_MEM_WRITE( "mq_timedreceive(msg_ptr)", ARG2
, ARG3
);
2593 PRE_MEM_WRITE( "mq_timedreceive(msg_prio)",
2594 ARG4
, sizeof(unsigned int) );
2596 PRE_MEM_READ( "mq_timedreceive(abs_timeout)",
2597 ARG5
, sizeof(struct vki_timespec
) );
2600 POST(sys_mq_timedreceive
)
2602 POST_MEM_WRITE( ARG2
, RES
);
2604 POST_MEM_WRITE( ARG4
, sizeof(unsigned int) );
2609 PRINT("sys_mq_notify( %ld, %#lx )", SARG1
, ARG2
);
2610 PRE_REG_READ2(long, "mq_notify",
2611 vki_mqd_t
, mqdes
, const struct sigevent
*, notification
);
2612 if (!ML_(fd_allowed
)(ARG1
, "mq_notify", tid
, False
))
2613 SET_STATUS_Failure( VKI_EBADF
);
2615 PRE_MEM_READ( "mq_notify(notification)",
2616 ARG2
, sizeof(struct vki_sigevent
) );
2619 PRE(sys_mq_getsetattr
)
2621 PRINT("sys_mq_getsetattr( %ld, %#lx, %#lx )", SARG1
,ARG2
,ARG3
);
2622 PRE_REG_READ3(long, "mq_getsetattr",
2623 vki_mqd_t
, mqdes
, const struct mq_attr
*, mqstat
,
2624 struct mq_attr
*, omqstat
);
2625 if (!ML_(fd_allowed
)(ARG1
, "mq_getsetattr", tid
, False
)) {
2626 SET_STATUS_Failure( VKI_EBADF
);
2629 const struct vki_mq_attr
*attr
= (struct vki_mq_attr
*)ARG2
;
2630 PRE_MEM_READ( "mq_getsetattr(mqstat->mq_flags)",
2631 (Addr
)&attr
->mq_flags
, sizeof(attr
->mq_flags
) );
2634 PRE_MEM_WRITE( "mq_getsetattr(omqstat)", ARG3
,
2635 sizeof(struct vki_mq_attr
) );
2638 POST(sys_mq_getsetattr
)
2641 POST_MEM_WRITE( ARG3
, sizeof(struct vki_mq_attr
) );
2644 /* ---------------------------------------------------------------------
2646 ------------------------------------------------------------------ */
2648 PRE(sys_clock_settime
)
2650 PRINT("sys_clock_settime( %ld, %#lx )", SARG1
, ARG2
);
2651 PRE_REG_READ2(long, "clock_settime",
2652 vki_clockid_t
, clk_id
, const struct timespec
*, tp
);
2653 PRE_MEM_READ( "clock_settime(tp)", ARG2
, sizeof(struct vki_timespec
) );
2656 PRE(sys_clock_gettime
)
2658 PRINT("sys_clock_gettime( %ld, %#lx )" , SARG1
, ARG2
);
2659 PRE_REG_READ2(long, "clock_gettime",
2660 vki_clockid_t
, clk_id
, struct timespec
*, tp
);
2661 PRE_MEM_WRITE( "clock_gettime(tp)", ARG2
, sizeof(struct vki_timespec
) );
2663 POST(sys_clock_gettime
)
2665 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timespec
) );
2668 PRE(sys_clock_getres
)
2670 PRINT("sys_clock_getres( %ld, %#lx )" , SARG1
, ARG2
);
2671 // Nb: we can't use "RES" as the param name because that's a macro
2673 PRE_REG_READ2(long, "clock_getres",
2674 vki_clockid_t
, clk_id
, struct timespec
*, res
);
2676 PRE_MEM_WRITE( "clock_getres(res)", ARG2
, sizeof(struct vki_timespec
) );
2678 POST(sys_clock_getres
)
2681 POST_MEM_WRITE( ARG2
, sizeof(struct vki_timespec
) );
2684 PRE(sys_clock_nanosleep
)
2686 *flags
|= SfMayBlock
|SfPostOnFail
;
2687 PRINT("sys_clock_nanosleep( %ld, %ld, %#lx, %#lx )",
2688 SARG1
, SARG2
, ARG3
, ARG4
);
2689 PRE_REG_READ4(int32_t, "clock_nanosleep",
2690 vki_clockid_t
, clkid
, int, flags
,
2691 const struct timespec
*, rqtp
, struct timespec
*, rmtp
);
2692 PRE_MEM_READ( "clock_nanosleep(rqtp)", ARG3
, sizeof(struct vki_timespec
) );
2694 PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG4
, sizeof(struct vki_timespec
) );
2696 POST(sys_clock_nanosleep
)
2698 if (ARG4
!= 0 && FAILURE
&& ERR
== VKI_EINTR
)
2699 POST_MEM_WRITE( ARG4
, sizeof(struct vki_timespec
) );
2702 /* ---------------------------------------------------------------------
2704 ------------------------------------------------------------------ */
2706 PRE(sys_timer_create
)
2708 PRINT("sys_timer_create( %ld, %#lx, %#lx )", SARG1
, ARG2
, ARG3
);
2709 PRE_REG_READ3(long, "timer_create",
2710 vki_clockid_t
, clockid
, struct sigevent
*, evp
,
2711 vki_timer_t
*, timerid
);
2713 struct vki_sigevent
*evp
= (struct vki_sigevent
*) ARG2
;
2714 PRE_MEM_READ( "timer_create(evp.sigev_value)", (Addr
)&evp
->sigev_value
,
2715 sizeof(vki_sigval_t
) );
2716 PRE_MEM_READ( "timer_create(evp.sigev_signo)", (Addr
)&evp
->sigev_signo
,
2718 PRE_MEM_READ( "timer_create(evp.sigev_notify)", (Addr
)&evp
->sigev_notify
,
2720 if (ML_(safe_to_deref
)(&evp
->sigev_notify
, sizeof(int))
2721 && (evp
->sigev_notify
& VKI_SIGEV_THREAD_ID
) != 0)
2722 PRE_MEM_READ( "timer_create(evp.sigev_notify_thread_id)",
2723 (Addr
)&evp
->vki_sigev_notify_thread_id
, sizeof(int) );
2725 PRE_MEM_WRITE( "timer_create(timerid)", ARG3
, sizeof(vki_timer_t
) );
2727 POST(sys_timer_create
)
2729 POST_MEM_WRITE( ARG3
, sizeof(vki_timer_t
) );
2732 PRE(sys_timer_settime
)
2734 PRINT("sys_timer_settime( %ld, %ld, %#lx, %#lx )", SARG1
,SARG2
,ARG3
,ARG4
);
2735 PRE_REG_READ4(long, "timer_settime",
2736 vki_timer_t
, timerid
, int, flags
,
2737 const struct itimerspec
*, value
,
2738 struct itimerspec
*, ovalue
);
2739 PRE_MEM_READ( "timer_settime(value)", ARG3
,
2740 sizeof(struct vki_itimerspec
) );
2742 PRE_MEM_WRITE( "timer_settime(ovalue)", ARG4
,
2743 sizeof(struct vki_itimerspec
) );
2745 POST(sys_timer_settime
)
2748 POST_MEM_WRITE( ARG4
, sizeof(struct vki_itimerspec
) );
2751 PRE(sys_timer_gettime
)
2753 PRINT("sys_timer_gettime( %ld, %#lx )", SARG1
, ARG2
);
2754 PRE_REG_READ2(long, "timer_gettime",
2755 vki_timer_t
, timerid
, struct itimerspec
*, value
);
2756 PRE_MEM_WRITE( "timer_gettime(value)", ARG2
,
2757 sizeof(struct vki_itimerspec
));
2759 POST(sys_timer_gettime
)
2761 POST_MEM_WRITE( ARG2
, sizeof(struct vki_itimerspec
) );
2764 PRE(sys_timer_getoverrun
)
2766 PRINT("sys_timer_getoverrun( %#lx )", ARG1
);
2767 PRE_REG_READ1(long, "timer_getoverrun", vki_timer_t
, timerid
);
2770 PRE(sys_timer_delete
)
2772 PRINT("sys_timer_delete( %#lx )", ARG1
);
2773 PRE_REG_READ1(long, "timer_delete", vki_timer_t
, timerid
);
2776 /* ---------------------------------------------------------------------
2778 See also http://lwn.net/Articles/260172/ for an overview.
2779 See also /usr/src/linux/fs/timerfd.c for the implementation.
2780 ------------------------------------------------------------------ */
2782 /* Returns True if running on 2.6.22, else False (or False if
2783 cannot be determined). */
2784 static Bool
linux_kernel_2_6_22(void)
2786 static Int result
= -1;
2788 HChar release
[64]; // large enough
2792 res
= VG_(open
)("/proc/sys/kernel/osrelease", 0, 0);
2793 if (sr_isError(res
))
2796 read
= VG_(read
)(fd
, release
, sizeof(release
) - 1);
2801 //VG_(printf)("kernel release = %s\n", release);
2802 result
= VG_(strncmp
)(release
, "2.6.22", 6) == 0
2803 && ! VG_(isdigit
)(release
[6]);
2805 vg_assert(result
== 0 || result
== 1);
2809 PRE(sys_timerfd_create
)
2811 if (linux_kernel_2_6_22()) {
2812 /* 2.6.22 kernel: timerfd system call. */
2813 PRINT("sys_timerfd ( %ld, %ld, %#lx )", SARG1
, SARG2
, ARG3
);
2814 PRE_REG_READ3(long, "sys_timerfd",
2815 int, fd
, int, clockid
, const struct itimerspec
*, tmr
);
2816 PRE_MEM_READ("timerfd(tmr)", ARG3
,
2817 sizeof(struct vki_itimerspec
) );
2818 if ((Word
)ARG1
!= -1L && !ML_(fd_allowed
)(ARG1
, "timerfd", tid
, False
))
2819 SET_STATUS_Failure( VKI_EBADF
);
2821 /* 2.6.24 and later kernels: timerfd_create system call. */
2822 PRINT("sys_timerfd_create (%ld, %ld )", SARG1
, SARG2
);
2823 PRE_REG_READ2(long, "timerfd_create", int, clockid
, int, flags
);
2826 POST(sys_timerfd_create
)
2828 if (linux_kernel_2_6_22())
2830 /* 2.6.22 kernel: timerfd system call. */
2831 if (!ML_(fd_allowed
)(RES
, "timerfd", tid
, True
)) {
2833 SET_STATUS_Failure( VKI_EMFILE
);
2835 if (VG_(clo_track_fds
))
2836 ML_(record_fd_open_nameless
) (tid
, RES
);
2841 /* 2.6.24 and later kernels: timerfd_create system call. */
2842 if (!ML_(fd_allowed
)(RES
, "timerfd_create", tid
, True
)) {
2844 SET_STATUS_Failure( VKI_EMFILE
);
2846 if (VG_(clo_track_fds
))
2847 ML_(record_fd_open_nameless
) (tid
, RES
);
2852 PRE(sys_timerfd_gettime
)
2854 PRINT("sys_timerfd_gettime ( %ld, %#lx )", SARG1
, ARG2
);
2855 PRE_REG_READ2(long, "timerfd_gettime",
2857 struct vki_itimerspec
*, otmr
);
2858 if (!ML_(fd_allowed
)(ARG1
, "timerfd_gettime", tid
, False
))
2859 SET_STATUS_Failure(VKI_EBADF
);
2861 PRE_MEM_WRITE("timerfd_gettime(result)",
2862 ARG2
, sizeof(struct vki_itimerspec
));
2864 POST(sys_timerfd_gettime
)
2867 POST_MEM_WRITE(ARG2
, sizeof(struct vki_itimerspec
));
2870 PRE(sys_timerfd_settime
)
2872 PRINT("sys_timerfd_settime ( %ld, %ld, %#lx, %#lx )",
2873 SARG1
, SARG2
, ARG3
, ARG4
);
2874 PRE_REG_READ4(long, "timerfd_settime",
2877 const struct vki_itimerspec
*, utmr
,
2878 struct vki_itimerspec
*, otmr
);
2879 if (!ML_(fd_allowed
)(ARG1
, "timerfd_settime", tid
, False
))
2880 SET_STATUS_Failure(VKI_EBADF
);
2883 PRE_MEM_READ("timerfd_settime(result)",
2884 ARG3
, sizeof(struct vki_itimerspec
));
2887 PRE_MEM_WRITE("timerfd_settime(result)",
2888 ARG4
, sizeof(struct vki_itimerspec
));
2892 POST(sys_timerfd_settime
)
2894 if (RES
== 0 && ARG4
!= 0)
2895 POST_MEM_WRITE(ARG4
, sizeof(struct vki_itimerspec
));
2898 /* ---------------------------------------------------------------------
2899 capabilities wrappers
2900 ------------------------------------------------------------------ */
2904 PRINT("sys_capget ( %#lx, %#lx )", ARG1
, ARG2
);
2905 PRE_REG_READ2(long, "capget",
2906 vki_cap_user_header_t
, header
, vki_cap_user_data_t
, data
);
2907 PRE_MEM_READ( "capget(header)", ARG1
,
2908 sizeof(struct __vki_user_cap_header_struct
) );
2909 if (ARG2
!= (Addr
)NULL
)
2910 PRE_MEM_WRITE( "capget(data)", ARG2
,
2911 sizeof(struct __vki_user_cap_data_struct
) );
2915 if (ARG2
!= (Addr
)NULL
)
2916 POST_MEM_WRITE( ARG2
, sizeof(struct __vki_user_cap_data_struct
) );
2921 PRINT("sys_capset ( %#lx, %#lx )", ARG1
, ARG2
);
2922 PRE_REG_READ2(long, "capset",
2923 vki_cap_user_header_t
, header
,
2924 const vki_cap_user_data_t
, data
);
2925 PRE_MEM_READ( "capset(header)",
2926 ARG1
, sizeof(struct __vki_user_cap_header_struct
) );
2927 PRE_MEM_READ( "capset(data)",
2928 ARG2
, sizeof(struct __vki_user_cap_data_struct
) );
2931 /* ---------------------------------------------------------------------
2932 16-bit uid/gid/groups wrappers
2933 ------------------------------------------------------------------ */
2937 PRINT("sys_getuid16 ( )");
2938 PRE_REG_READ0(long, "getuid16");
2943 PRINT("sys_setuid16 ( %lu )", ARG1
);
2944 PRE_REG_READ1(long, "setuid16", vki_old_uid_t
, uid
);
2949 PRINT("sys_getgid16 ( )");
2950 PRE_REG_READ0(long, "getgid16");
2955 PRINT("sys_setgid16 ( %lu )", ARG1
);
2956 PRE_REG_READ1(long, "setgid16", vki_old_gid_t
, gid
);
2961 PRINT("sys_geteuid16 ( )");
2962 PRE_REG_READ0(long, "geteuid16");
2967 PRINT("sys_getegid16 ( )");
2968 PRE_REG_READ0(long, "getegid16");
2973 PRINT("setreuid16 ( 0x%lx, 0x%lx )", ARG1
, ARG2
);
2974 PRE_REG_READ2(long, "setreuid16", vki_old_uid_t
, ruid
, vki_old_uid_t
, euid
);
2979 PRINT("sys_setregid16 ( %lu, %lu )", ARG1
, ARG2
);
2980 PRE_REG_READ2(long, "setregid16", vki_old_gid_t
, rgid
, vki_old_gid_t
, egid
);
2983 PRE(sys_getgroups16
)
2985 PRINT("sys_getgroups16 ( %ld, %#lx )", SARG1
, ARG2
);
2986 PRE_REG_READ2(long, "getgroups16", int, size
, vki_old_gid_t
*, list
);
2988 PRE_MEM_WRITE( "getgroups16(list)", ARG2
, ARG1
* sizeof(vki_old_gid_t
) );
2990 POST(sys_getgroups16
)
2993 if (ARG1
> 0 && RES
> 0)
2994 POST_MEM_WRITE( ARG2
, RES
* sizeof(vki_old_gid_t
) );
2997 PRE(sys_setgroups16
)
2999 PRINT("sys_setgroups16 ( %llu, %#lx )", (ULong
)ARG1
, ARG2
);
3000 PRE_REG_READ2(long, "setgroups16", int, size
, vki_old_gid_t
*, list
);
3002 PRE_MEM_READ( "setgroups16(list)", ARG2
, ARG1
* sizeof(vki_old_gid_t
) );
3005 /* ---------------------------------------------------------------------
3007 ------------------------------------------------------------------ */
3011 PRINT("sys_chown16 ( %#lx, 0x%lx, 0x%lx )", ARG1
,ARG2
,ARG3
);
3012 PRE_REG_READ3(long, "chown16",
3014 vki_old_uid_t
, owner
, vki_old_gid_t
, group
);
3015 PRE_MEM_RASCIIZ( "chown16(path)", ARG1
);
3020 PRINT("sys_fchown16 ( %lu, %lu, %lu )", ARG1
,ARG2
,ARG3
);
3021 PRE_REG_READ3(long, "fchown16",
3022 unsigned int, fd
, vki_old_uid_t
, owner
, vki_old_gid_t
, group
);
3025 /* ---------------------------------------------------------------------
3027 ------------------------------------------------------------------ */
3031 *flags
|= SfMayBlock
;
3032 PRINT("sys_setxattr ( %#lx, %#lx, %#lx, %lu, %ld )",
3033 ARG1
, ARG2
, ARG3
, ARG4
, SARG5
);
3034 PRE_REG_READ5(long, "setxattr",
3035 char *, path
, char *, name
,
3036 void *, value
, vki_size_t
, size
, int, flags
);
3037 PRE_MEM_RASCIIZ( "setxattr(path)", ARG1
);
3038 PRE_MEM_RASCIIZ( "setxattr(name)", ARG2
);
3039 PRE_MEM_READ( "setxattr(value)", ARG3
, ARG4
);
3044 *flags
|= SfMayBlock
;
3045 PRINT("sys_lsetxattr ( %#lx, %#lx, %#lx, %lu, %ld )",
3046 ARG1
, ARG2
, ARG3
, ARG4
, SARG5
);
3047 PRE_REG_READ5(long, "lsetxattr",
3048 char *, path
, char *, name
,
3049 void *, value
, vki_size_t
, size
, int, flags
);
3050 PRE_MEM_RASCIIZ( "lsetxattr(path)", ARG1
);
3051 PRE_MEM_RASCIIZ( "lsetxattr(name)", ARG2
);
3052 PRE_MEM_READ( "lsetxattr(value)", ARG3
, ARG4
);
3057 *flags
|= SfMayBlock
;
3058 PRINT("sys_fsetxattr ( %ld, %#lx, %#lx, %lu, %ld )",
3059 SARG1
, ARG2
, ARG3
, ARG4
, SARG5
);
3060 PRE_REG_READ5(long, "fsetxattr",
3061 int, fd
, char *, name
, void *, value
,
3062 vki_size_t
, size
, int, flags
);
3063 PRE_MEM_RASCIIZ( "fsetxattr(name)", ARG2
);
3064 PRE_MEM_READ( "fsetxattr(value)", ARG3
, ARG4
);
3069 *flags
|= SfMayBlock
;
3070 PRINT("sys_getxattr ( %#lx, %#lx, %#lx, %llu )", ARG1
,ARG2
,ARG3
, (ULong
)ARG4
);
3071 PRE_REG_READ4(ssize_t
, "getxattr",
3072 char *, path
, char *, name
, void *, value
, vki_size_t
, size
);
3073 PRE_MEM_RASCIIZ( "getxattr(path)", ARG1
);
3074 PRE_MEM_RASCIIZ( "getxattr(name)", ARG2
);
3075 PRE_MEM_WRITE( "getxattr(value)", ARG3
, ARG4
);
3080 if (RES
> 0 && ARG3
!= (Addr
)NULL
) {
3081 POST_MEM_WRITE( ARG3
, RES
);
3087 *flags
|= SfMayBlock
;
3088 PRINT("sys_lgetxattr ( %#lx, %#lx, %#lx, %llu )", ARG1
,ARG2
,ARG3
, (ULong
)ARG4
);
3089 PRE_REG_READ4(ssize_t
, "lgetxattr",
3090 char *, path
, char *, name
, void *, value
, vki_size_t
, size
);
3091 PRE_MEM_RASCIIZ( "lgetxattr(path)", ARG1
);
3092 PRE_MEM_RASCIIZ( "lgetxattr(name)", ARG2
);
3093 PRE_MEM_WRITE( "lgetxattr(value)", ARG3
, ARG4
);
3098 if (RES
> 0 && ARG3
!= (Addr
)NULL
) {
3099 POST_MEM_WRITE( ARG3
, RES
);
3105 *flags
|= SfMayBlock
;
3106 PRINT("sys_fgetxattr ( %ld, %#lx, %#lx, %lu )", SARG1
, ARG2
, ARG3
, ARG4
);
3107 PRE_REG_READ4(ssize_t
, "fgetxattr",
3108 int, fd
, char *, name
, void *, value
, vki_size_t
, size
);
3109 PRE_MEM_RASCIIZ( "fgetxattr(name)", ARG2
);
3110 PRE_MEM_WRITE( "fgetxattr(value)", ARG3
, ARG4
);
3114 if (RES
> 0 && ARG3
!= (Addr
)NULL
)
3115 POST_MEM_WRITE( ARG3
, RES
);
3120 *flags
|= SfMayBlock
;
3121 PRINT("sys_listxattr ( %#lx, %#lx, %llu )", ARG1
, ARG2
, (ULong
)ARG3
);
3122 PRE_REG_READ3(ssize_t
, "listxattr",
3123 char *, path
, char *, list
, vki_size_t
, size
);
3124 PRE_MEM_RASCIIZ( "listxattr(path)", ARG1
);
3125 PRE_MEM_WRITE( "listxattr(list)", ARG2
, ARG3
);
3129 if (RES
> 0 && ARG2
!= (Addr
)NULL
)
3130 POST_MEM_WRITE( ARG2
, RES
);
3135 *flags
|= SfMayBlock
;
3136 PRINT("sys_llistxattr ( %#lx, %#lx, %llu )", ARG1
, ARG2
, (ULong
)ARG3
);
3137 PRE_REG_READ3(ssize_t
, "llistxattr",
3138 char *, path
, char *, list
, vki_size_t
, size
);
3139 PRE_MEM_RASCIIZ( "llistxattr(path)", ARG1
);
3140 PRE_MEM_WRITE( "llistxattr(list)", ARG2
, ARG3
);
3142 POST(sys_llistxattr
)
3144 if (RES
> 0 && ARG2
!= (Addr
)NULL
)
3145 POST_MEM_WRITE( ARG2
, RES
);
3150 *flags
|= SfMayBlock
;
3151 PRINT("sys_flistxattr ( %ld, %#lx, %lu )", SARG1
, ARG2
, ARG3
);
3152 PRE_REG_READ3(ssize_t
, "flistxattr",
3153 int, fd
, char *, list
, vki_size_t
, size
);
3154 PRE_MEM_WRITE( "flistxattr(list)", ARG2
, ARG3
);
3156 POST(sys_flistxattr
)
3158 if (RES
> 0 && ARG2
!= (Addr
)NULL
)
3159 POST_MEM_WRITE( ARG2
, RES
);
3162 PRE(sys_removexattr
)
3164 *flags
|= SfMayBlock
;
3165 PRINT("sys_removexattr ( %#lx, %#lx )", ARG1
, ARG2
);
3166 PRE_REG_READ2(long, "removexattr", char *, path
, char *, name
);
3167 PRE_MEM_RASCIIZ( "removexattr(path)", ARG1
);
3168 PRE_MEM_RASCIIZ( "removexattr(name)", ARG2
);
3171 PRE(sys_lremovexattr
)
3173 *flags
|= SfMayBlock
;
3174 PRINT("sys_lremovexattr ( %#lx, %#lx )", ARG1
, ARG2
);
3175 PRE_REG_READ2(long, "lremovexattr", char *, path
, char *, name
);
3176 PRE_MEM_RASCIIZ( "lremovexattr(path)", ARG1
);
3177 PRE_MEM_RASCIIZ( "lremovexattr(name)", ARG2
);
3180 PRE(sys_fremovexattr
)
3182 *flags
|= SfMayBlock
;
3183 PRINT("sys_fremovexattr ( %ld, %#lx )", SARG1
, ARG2
);
3184 PRE_REG_READ2(long, "fremovexattr", int, fd
, char *, name
);
3185 PRE_MEM_RASCIIZ( "fremovexattr(name)", ARG2
);
3188 /* ---------------------------------------------------------------------
3190 ------------------------------------------------------------------ */
3192 PRE(sys_sched_setparam
)
3194 PRINT("sched_setparam ( %ld, %#lx )", SARG1
, ARG2
);
3195 PRE_REG_READ2(long, "sched_setparam",
3196 vki_pid_t
, pid
, struct sched_param
*, p
);
3197 PRE_MEM_READ( "sched_setparam(p)", ARG2
, sizeof(struct vki_sched_param
) );
3199 POST(sys_sched_setparam
)
3201 POST_MEM_WRITE( ARG2
, sizeof(struct vki_sched_param
) );
3204 PRE(sys_sched_getparam
)
3206 PRINT("sched_getparam ( %ld, %#lx )", SARG1
, ARG2
);
3207 PRE_REG_READ2(long, "sched_getparam",
3208 vki_pid_t
, pid
, struct sched_param
*, p
);
3209 PRE_MEM_WRITE( "sched_getparam(p)", ARG2
, sizeof(struct vki_sched_param
) );
3211 POST(sys_sched_getparam
)
3213 POST_MEM_WRITE( ARG2
, sizeof(struct vki_sched_param
) );
3216 PRE(sys_sched_getscheduler
)
3218 PRINT("sys_sched_getscheduler ( %ld )", SARG1
);
3219 PRE_REG_READ1(long, "sched_getscheduler", vki_pid_t
, pid
);
3222 PRE(sys_sched_setscheduler
)
3224 PRINT("sys_sched_setscheduler ( %ld, %ld, %#lx )", SARG1
, SARG2
, ARG3
);
3225 PRE_REG_READ3(long, "sched_setscheduler",
3226 vki_pid_t
, pid
, int, policy
, struct sched_param
*, p
);
3228 PRE_MEM_READ( "sched_setscheduler(p)",
3229 ARG3
, sizeof(struct vki_sched_param
));
3232 PRE(sys_sched_yield
)
3234 *flags
|= SfMayBlock
;
3235 PRINT("sched_yield()");
3236 PRE_REG_READ0(long, "sys_sched_yield");
3239 PRE(sys_sched_get_priority_max
)
3241 PRINT("sched_get_priority_max ( %ld )", SARG1
);
3242 PRE_REG_READ1(long, "sched_get_priority_max", int, policy
);
3245 PRE(sys_sched_get_priority_min
)
3247 PRINT("sched_get_priority_min ( %ld )", SARG1
);
3248 PRE_REG_READ1(long, "sched_get_priority_min", int, policy
);
3251 PRE(sys_sched_rr_get_interval
)
3253 PRINT("sys_sched_rr_get_interval ( %ld, %#lx )", SARG1
, ARG2
);
3254 PRE_REG_READ2(int, "sched_rr_get_interval",
3256 struct vki_timespec
*, tp
);
3257 PRE_MEM_WRITE("sched_rr_get_interval(timespec)",
3258 ARG2
, sizeof(struct vki_timespec
));
3261 POST(sys_sched_rr_get_interval
)
3263 POST_MEM_WRITE(ARG2
, sizeof(struct vki_timespec
));
3266 PRE(sys_sched_setaffinity
)
3268 PRINT("sched_setaffinity ( %ld, %lu, %#lx )", SARG1
, ARG2
, ARG3
);
3269 PRE_REG_READ3(long, "sched_setaffinity",
3270 vki_pid_t
, pid
, unsigned int, len
, unsigned long *, mask
);
3271 PRE_MEM_READ( "sched_setaffinity(mask)", ARG3
, ARG2
);
3274 PRE(sys_sched_getaffinity
)
3276 PRINT("sched_getaffinity ( %ld, %lu, %#lx )", SARG1
, ARG2
, ARG3
);
3277 PRE_REG_READ3(long, "sched_getaffinity",
3278 vki_pid_t
, pid
, unsigned int, len
, unsigned long *, mask
);
3279 PRE_MEM_WRITE( "sched_getaffinity(mask)", ARG3
, ARG2
);
3281 POST(sys_sched_getaffinity
)
3283 POST_MEM_WRITE(ARG3
, ARG2
);
3288 PRINT("sys_unshare ( %#lx )", ARG1
);
3289 PRE_REG_READ1(int, "unshare", unsigned long, flags
);
3292 /* ---------------------------------------------------------------------
3293 miscellaneous wrappers
3294 ------------------------------------------------------------------ */
3298 *flags
|= SfMayBlock
;
3299 PRINT("sys_munlockall ( )");
3300 PRE_REG_READ0(long, "munlockall");
3303 // This has different signatures for different platforms.
3305 // x86: int sys_pipe(unsigned long __user *fildes);
3306 // AMD64: long sys_pipe(int *fildes);
3307 // ppc32: int sys_pipe(int __user *fildes);
3308 // ppc64: int sys_pipe(int __user *fildes);
3310 // The type of the argument is most important, and it is an array of 32 bit
3311 // values in all cases. (The return type differs across platforms, but it
3312 // is not used.) So we use 'int' as its type. This fixed bug #113230 which
3313 // was caused by using an array of 'unsigned long's, which didn't work on
3317 PRINT("sys_pipe ( %#lx )", ARG1
);
3318 PRE_REG_READ1(int, "pipe", int *, filedes
);
3319 PRE_MEM_WRITE( "pipe(filedes)", ARG1
, 2*sizeof(int) );
3323 Int
*p
= (Int
*)ARG1
;
3324 if (!ML_(fd_allowed
)(p
[0], "pipe", tid
, True
) ||
3325 !ML_(fd_allowed
)(p
[1], "pipe", tid
, True
)) {
3328 SET_STATUS_Failure( VKI_EMFILE
);
3330 POST_MEM_WRITE( ARG1
, 2*sizeof(int) );
3331 if (VG_(clo_track_fds
)) {
3332 ML_(record_fd_open_nameless
)(tid
, p
[0]);
3333 ML_(record_fd_open_nameless
)(tid
, p
[1]);
3338 /* pipe2 (a kernel 2.6.twentysomething invention) is like pipe, except
3339 there's a second arg containing flags to be applied to the new file
3340 descriptors. It hardly seems worth the effort to factor out the
3341 duplicated code, hence: */
3344 PRINT("sys_pipe2 ( %#lx, %#lx )", ARG1
, ARG2
);
3345 PRE_REG_READ2(int, "pipe", int *, filedes
, long, flags
);
3346 PRE_MEM_WRITE( "pipe2(filedes)", ARG1
, 2*sizeof(int) );
3350 Int
*p
= (Int
*)ARG1
;
3351 if (!ML_(fd_allowed
)(p
[0], "pipe2", tid
, True
) ||
3352 !ML_(fd_allowed
)(p
[1], "pipe2", tid
, True
)) {
3355 SET_STATUS_Failure( VKI_EMFILE
);
3357 POST_MEM_WRITE( ARG1
, 2*sizeof(int) );
3358 if (VG_(clo_track_fds
)) {
3359 ML_(record_fd_open_nameless
)(tid
, p
[0]);
3360 ML_(record_fd_open_nameless
)(tid
, p
[1]);
3367 PRINT("sys_dup3 ( %lu, %lu, %#lx )", ARG1
, ARG2
, ARG3
);
3368 PRE_REG_READ3(long, "dup3", unsigned int, oldfd
, unsigned int, newfd
, int, flags
);
3369 if (!ML_(fd_allowed
)(ARG2
, "dup3", tid
, True
))
3370 SET_STATUS_Failure( VKI_EBADF
);
3376 if (VG_(clo_track_fds
))
3377 ML_(record_fd_open_named
)(tid
, RES
);
3382 PRINT("sys_quotactl (0x%lx, %#lx, 0x%lx, 0x%lx )", ARG1
,ARG2
,ARG3
, ARG4
);
3383 PRE_REG_READ4(long, "quotactl",
3384 unsigned int, cmd
, const char *, special
, vki_qid_t
, id
,
3386 PRE_MEM_RASCIIZ( "quotactl(special)", ARG2
);
3391 *flags
|= SfMayBlock
;
3392 PRINT("sys_waitid( %ld, %ld, %#lx, %ld, %#lx )",
3393 SARG1
, SARG2
, ARG3
, SARG4
, ARG5
);
3394 PRE_REG_READ5(int32_t, "sys_waitid",
3395 int, which
, vki_pid_t
, pid
, struct vki_siginfo
*, infop
,
3396 int, options
, struct vki_rusage
*, ru
);
3397 PRE_MEM_WRITE( "waitid(infop)", ARG3
, sizeof(struct vki_siginfo
) );
3399 PRE_MEM_WRITE( "waitid(ru)", ARG5
, sizeof(struct vki_rusage
) );
3403 POST_MEM_WRITE( ARG3
, sizeof(struct vki_siginfo
) );
3405 POST_MEM_WRITE( ARG5
, sizeof(struct vki_rusage
) );
3408 PRE(sys_sync_file_range
)
3410 *flags
|= SfMayBlock
;
3411 #if VG_WORDSIZE == 4
3412 PRINT("sys_sync_file_range ( %ld, %lld, %lld, %#lx )",
3413 SARG1
, (Long
)MERGE64(ARG2
,ARG3
), (Long
)MERGE64(ARG4
,ARG5
),ARG6
);
3414 PRE_REG_READ6(long, "sync_file_range",
3416 unsigned, MERGE64_FIRST(offset
), unsigned, MERGE64_SECOND(offset
),
3417 unsigned, MERGE64_FIRST(nbytes
), unsigned, MERGE64_SECOND(nbytes
),
3418 unsigned int, flags
);
3419 #elif VG_WORDSIZE == 8
3420 PRINT("sys_sync_file_range ( %ld, %ld, %ld, %#lx )",
3421 SARG1
, SARG2
, SARG3
, ARG4
);
3422 PRE_REG_READ4(long, "sync_file_range",
3423 int, fd
, vki_loff_t
, offset
, vki_loff_t
, nbytes
,
3424 unsigned int, flags
);
3426 # error Unexpected word size
3428 if (!ML_(fd_allowed
)(ARG1
, "sync_file_range", tid
, False
))
3429 SET_STATUS_Failure( VKI_EBADF
);
3432 PRE(sys_sync_file_range2
)
3434 *flags
|= SfMayBlock
;
3435 #if VG_WORDSIZE == 4
3436 PRINT("sys_sync_file_range2 ( %ld, %lu, %lld, %lld )",
3437 SARG1
, ARG2
, (Long
)MERGE64(ARG3
,ARG4
), (Long
)MERGE64(ARG5
,ARG6
));
3438 PRE_REG_READ6(long, "sync_file_range2",
3439 int, fd
, unsigned int, flags
,
3440 unsigned, MERGE64_FIRST(offset
), unsigned, MERGE64_SECOND(offset
),
3441 unsigned, MERGE64_FIRST(nbytes
), unsigned, MERGE64_SECOND(nbytes
));
3442 #elif VG_WORDSIZE == 8
3443 PRINT("sys_sync_file_range2 ( %ld, %lu, %ld, %ld )",
3444 SARG1
, ARG2
, SARG3
, SARG4
);
3445 PRE_REG_READ4(long, "sync_file_range2",
3446 int, fd
, unsigned int, flags
,
3447 vki_loff_t
, offset
, vki_loff_t
, nbytes
);
3449 # error Unexpected word size
3451 if (!ML_(fd_allowed
)(ARG1
, "sync_file_range2", tid
, False
))
3452 SET_STATUS_Failure( VKI_EBADF
);
3457 PRINT("sys_stime ( %#lx )", ARG1
);
3458 PRE_REG_READ1(int, "stime", vki_time_t
*, t
);
3459 PRE_MEM_READ( "stime(t)", ARG1
, sizeof(vki_time_t
) );
3462 PRE(sys_perf_event_open
)
3464 struct vki_perf_event_attr
*attr
;
3465 PRINT("sys_perf_event_open ( %#lx, %ld, %ld, %ld, %#lx )",
3466 ARG1
, SARG2
, SARG3
, SARG4
, ARG5
);
3467 PRE_REG_READ5(long, "perf_event_open",
3468 struct vki_perf_event_attr
*, attr
,
3469 vki_pid_t
, pid
, int, cpu
, int, group_fd
,
3470 unsigned long, flags
);
3471 attr
= (struct vki_perf_event_attr
*)ARG1
;
3472 PRE_MEM_READ( "perf_event_open(attr->size)",
3473 (Addr
)&attr
->size
, sizeof(attr
->size
) );
3474 PRE_MEM_READ( "perf_event_open(attr)",
3475 (Addr
)attr
, attr
->size
);
3478 POST(sys_perf_event_open
)
3481 if (!ML_(fd_allowed
)(RES
, "perf_event_open", tid
, True
)) {
3483 SET_STATUS_Failure( VKI_EMFILE
);
3485 if (VG_(clo_track_fds
))
3486 ML_(record_fd_open_nameless
)(tid
, RES
);
3492 PRINT("sys_getcpu ( %#lx, %#lx, %#lx )" , ARG1
,ARG2
,ARG3
);
3493 PRE_REG_READ3(int, "getcpu",
3494 unsigned *, cpu
, unsigned *, node
, struct vki_getcpu_cache
*, tcache
);
3496 PRE_MEM_WRITE( "getcpu(cpu)", ARG1
, sizeof(unsigned) );
3498 PRE_MEM_WRITE( "getcpu(node)", ARG2
, sizeof(unsigned) );
3500 PRE_MEM_WRITE( "getcpu(tcache)", ARG3
, sizeof(struct vki_getcpu_cache
) );
3506 POST_MEM_WRITE( ARG1
, sizeof(unsigned) );
3508 POST_MEM_WRITE( ARG2
, sizeof(unsigned) );
3510 POST_MEM_WRITE( ARG3
, sizeof(struct vki_getcpu_cache
) );
3515 PRINT("sys_move_pages ( %ld, %lu, %#lx, %#lx, %#lx, %#lx )",
3516 SARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
3517 PRE_REG_READ6(int, "move_pages",
3518 vki_pid_t
, pid
, unsigned long, nr_pages
, const void **, pages
,
3519 const int *, nodes
, int *, status
, int, flags
);
3520 PRE_MEM_READ("move_pages(pages)", ARG3
, ARG2
* sizeof(void *));
3522 PRE_MEM_READ("move_pages(nodes)", ARG4
, ARG2
* sizeof(int));
3523 PRE_MEM_WRITE("move_pages(status)", ARG5
, ARG2
* sizeof(int));
3526 POST(sys_move_pages
)
3528 POST_MEM_WRITE(ARG5
, ARG2
* sizeof(int));
3533 PRINT("sys_getrandom ( %#lx, %lu, %lu )" , ARG1
, ARG2
, ARG3
);
3534 PRE_REG_READ3(int, "getrandom",
3535 char *, buf
, vki_size_t
, count
, unsigned int, flags
);
3536 PRE_MEM_WRITE( "getrandom(cpu)", ARG1
, ARG2
);
3541 POST_MEM_WRITE( ARG1
, ARG2
);
3544 PRE(sys_memfd_create
)
3546 PRINT("sys_memfd_create ( %#lx, %lu )" , ARG1
, ARG2
);
3547 PRE_REG_READ2(int, "memfd_create",
3548 char *, uname
, unsigned int, flags
);
3549 PRE_MEM_RASCIIZ( "memfd_create(uname)", ARG1
);
3552 POST(sys_memfd_create
)
3555 if (!ML_(fd_allowed
)(RES
, "memfd_create", tid
, True
)) {
3557 SET_STATUS_Failure( VKI_EMFILE
);
3559 if (VG_(clo_track_fds
))
3560 ML_(record_fd_open_nameless
)(tid
, RES
);
3566 *flags
|= SfMayBlock
;
3567 PRINT("sys_syncfs ( %lu )", ARG1
);
3568 PRE_REG_READ1(long, "syncfs", unsigned int, fd
);
3571 /* ---------------------------------------------------------------------
3573 ------------------------------------------------------------------ */
3577 *flags
|= SfMayBlock
;
3578 PRINT("sys_utime ( %#lx, %#lx )", ARG1
,ARG2
);
3579 PRE_REG_READ2(long, "utime", char *, filename
, struct utimbuf
*, buf
);
3580 PRE_MEM_RASCIIZ( "utime(filename)", ARG1
);
3582 PRE_MEM_READ( "utime(buf)", ARG2
, sizeof(struct vki_utimbuf
) );
3585 /* ---------------------------------------------------------------------
3587 ------------------------------------------------------------------ */
3591 PRINT("sys_lseek ( %lu, %ld, %lu )", ARG1
, SARG2
, ARG3
);
3592 PRE_REG_READ3(vki_off_t
, "lseek",
3593 unsigned int, fd
, vki_off_t
, offset
, unsigned int, whence
);
3596 /* ---------------------------------------------------------------------
3598 ------------------------------------------------------------------ */
3602 *flags
|= SfMayBlock
;
3603 #if VG_WORDSIZE == 4
3604 PRINT("sys_readahead ( %ld, %lld, %lu )",
3605 SARG1
, (Long
)MERGE64(ARG2
,ARG3
), ARG4
);
3606 PRE_REG_READ4(vki_off_t
, "readahead",
3607 int, fd
, unsigned, MERGE64_FIRST(offset
),
3608 unsigned, MERGE64_SECOND(offset
), vki_size_t
, count
);
3609 #elif VG_WORDSIZE == 8
3610 PRINT("sys_readahead ( %ld, %ld, %lu )", SARG1
, SARG2
, ARG3
);
3611 PRE_REG_READ3(vki_off_t
, "readahead",
3612 int, fd
, vki_loff_t
, offset
, vki_size_t
, count
);
3614 # error Unexpected word size
3616 if (!ML_(fd_allowed
)(ARG1
, "readahead", tid
, False
))
3617 SET_STATUS_Failure( VKI_EBADF
);
3620 /* ---------------------------------------------------------------------
3622 ------------------------------------------------------------------ */
3626 PRINT( "sys_sigpending ( %#lx )", ARG1
);
3627 PRE_REG_READ1(long, "sigpending", vki_old_sigset_t
*, set
);
3628 PRE_MEM_WRITE( "sigpending(set)", ARG1
, sizeof(vki_old_sigset_t
));
3630 POST(sys_sigpending
)
3632 POST_MEM_WRITE( ARG1
, sizeof(vki_old_sigset_t
) ) ;
3635 // This syscall is not used on amd64/Linux -- it only provides
3636 // sys_rt_sigprocmask, which uses sigset_t rather than old_sigset_t.
3637 // This wrapper is only suitable for 32-bit architectures.
3638 // (XXX: so how is it that PRE(sys_sigpending) above doesn't need
3639 // conditional compilation like this?)
3640 #if defined(VGP_x86_linux) || defined(VGP_ppc32_linux) \
3641 || defined(VGP_arm_linux) || defined(VGP_mips32_linux)
3642 PRE(sys_sigprocmask
)
3644 vki_old_sigset_t
* set
;
3645 vki_old_sigset_t
* oldset
;
3646 vki_sigset_t bigger_set
;
3647 vki_sigset_t bigger_oldset
;
3649 PRINT("sys_sigprocmask ( %ld, %#lx, %#lx )", SARG1
, ARG2
, ARG3
);
3650 PRE_REG_READ3(long, "sigprocmask",
3651 int, how
, vki_old_sigset_t
*, set
, vki_old_sigset_t
*, oldset
);
3653 PRE_MEM_READ( "sigprocmask(set)", ARG2
, sizeof(vki_old_sigset_t
));
3655 PRE_MEM_WRITE( "sigprocmask(oldset)", ARG3
, sizeof(vki_old_sigset_t
));
3657 // Nb: We must convert the smaller vki_old_sigset_t params into bigger
3658 // vki_sigset_t params.
3659 set
= (vki_old_sigset_t
*)ARG2
;
3660 oldset
= (vki_old_sigset_t
*)ARG3
;
3662 VG_(memset
)(&bigger_set
, 0, sizeof(vki_sigset_t
));
3663 VG_(memset
)(&bigger_oldset
, 0, sizeof(vki_sigset_t
));
3665 bigger_set
.sig
[0] = *(vki_old_sigset_t
*)set
;
3667 SET_STATUS_from_SysRes(
3668 VG_(do_sys_sigprocmask
) ( tid
, ARG1
/*how*/,
3669 set
? &bigger_set
: NULL
,
3670 oldset
? &bigger_oldset
: NULL
)
3674 *oldset
= bigger_oldset
.sig
[0];
3677 *flags
|= SfPollAfter
;
3679 POST(sys_sigprocmask
)
3682 if (RES
== 0 && ARG3
!= 0)
3683 POST_MEM_WRITE( ARG3
, sizeof(vki_old_sigset_t
));
3686 /* Convert from non-RT to RT sigset_t's */
3688 void convert_sigset_to_rt(const vki_old_sigset_t
*oldset
, vki_sigset_t
*set
)
3690 VG_(sigemptyset
)(set
);
3691 set
->sig
[0] = *oldset
;
3695 vki_sigaction_toK_t
new, *newp
;
3696 vki_sigaction_fromK_t old
, *oldp
;
3698 PRINT("sys_sigaction ( %ld, %#lx, %#lx )", SARG1
, ARG2
, ARG3
);
3699 PRE_REG_READ3(int, "sigaction",
3700 int, signum
, const struct old_sigaction
*, act
,
3701 struct old_sigaction
*, oldact
);
3706 struct vki_old_sigaction
*sa
= (struct vki_old_sigaction
*)ARG2
;
3707 PRE_MEM_READ( "sigaction(act->sa_handler)", (Addr
)&sa
->ksa_handler
, sizeof(sa
->ksa_handler
));
3708 PRE_MEM_READ( "sigaction(act->sa_mask)", (Addr
)&sa
->sa_mask
, sizeof(sa
->sa_mask
));
3709 PRE_MEM_READ( "sigaction(act->sa_flags)", (Addr
)&sa
->sa_flags
, sizeof(sa
->sa_flags
));
3710 if (ML_(safe_to_deref
)(sa
,sizeof(struct vki_old_sigaction
))
3711 && (sa
->sa_flags
& VKI_SA_RESTORER
))
3712 PRE_MEM_READ( "sigaction(act->sa_restorer)", (Addr
)&sa
->sa_restorer
, sizeof(sa
->sa_restorer
));
3716 PRE_MEM_WRITE( "sigaction(oldact)", ARG3
, sizeof(struct vki_old_sigaction
));
3720 /* If the new or old sigaction is not NULL, but the structs
3721 aren't accessible then sigaction returns EFAULT and we cannot
3722 use either struct for our own bookkeeping. Just fail early. */
3724 && ! ML_(safe_to_deref
)((void *)ARG2
,
3725 sizeof(struct vki_old_sigaction
))) {
3726 VG_(umsg
)("Warning: bad act handler address %p in sigaction()\n",
3728 SET_STATUS_Failure ( VKI_EFAULT
);
3729 } else if ((ARG3
!= 0
3730 && ! ML_(safe_to_deref
)((void *)ARG3
,
3731 sizeof(struct vki_old_sigaction
)))) {
3732 VG_(umsg
)("Warning: bad oldact handler address %p in sigaction()\n",
3734 SET_STATUS_Failure ( VKI_EFAULT
);
3737 struct vki_old_sigaction
*oldnew
= (struct vki_old_sigaction
*)ARG2
;
3739 new.ksa_handler
= oldnew
->ksa_handler
;
3740 new.sa_flags
= oldnew
->sa_flags
;
3741 new.sa_restorer
= oldnew
->sa_restorer
;
3742 convert_sigset_to_rt(&oldnew
->sa_mask
, &new.sa_mask
);
3746 SET_STATUS_from_SysRes( VG_(do_sys_sigaction
)(ARG1
, newp
, oldp
) );
3748 if (ARG3
!= 0 && SUCCESS
&& RES
== 0) {
3749 struct vki_old_sigaction
*oldold
= (struct vki_old_sigaction
*)ARG3
;
3751 oldold
->ksa_handler
= oldp
->ksa_handler
;
3752 oldold
->sa_flags
= oldp
->sa_flags
;
3753 oldold
->sa_restorer
= oldp
->sa_restorer
;
3754 oldold
->sa_mask
= oldp
->sa_mask
.sig
[0];
3761 if (RES
== 0 && ARG3
!= 0)
3762 POST_MEM_WRITE( ARG3
, sizeof(struct vki_old_sigaction
));
3768 PRINT("sys_signalfd ( %d, %#lx, %llu )", (Int
)ARG1
,ARG2
,(ULong
)ARG3
);
3769 PRE_REG_READ3(long, "sys_signalfd",
3770 int, fd
, vki_sigset_t
*, sigmask
, vki_size_t
, sigsetsize
);
3771 PRE_MEM_READ( "signalfd(sigmask)", ARG2
, sizeof(vki_sigset_t
) );
3772 if ((int)ARG1
!= -1 && !ML_(fd_allowed
)(ARG1
, "signalfd", tid
, False
))
3773 SET_STATUS_Failure( VKI_EBADF
);
3777 if (!ML_(fd_allowed
)(RES
, "signalfd", tid
, True
)) {
3779 SET_STATUS_Failure( VKI_EMFILE
);
3781 if (VG_(clo_track_fds
))
3782 ML_(record_fd_open_nameless
) (tid
, RES
);
3788 PRINT("sys_signalfd4 ( %ld, %#lx, %lu, %ld )", SARG1
, ARG2
, ARG3
, SARG4
);
3789 PRE_REG_READ4(long, "sys_signalfd4",
3790 int, fd
, vki_sigset_t
*, sigmask
, vki_size_t
, sigsetsize
, int, flags
);
3791 PRE_MEM_READ( "signalfd(sigmask)", ARG2
, sizeof(vki_sigset_t
) );
3792 if ((int)ARG1
!= -1 && !ML_(fd_allowed
)(ARG1
, "signalfd", tid
, False
))
3793 SET_STATUS_Failure( VKI_EBADF
);
3797 if (!ML_(fd_allowed
)(RES
, "signalfd4", tid
, True
)) {
3799 SET_STATUS_Failure( VKI_EMFILE
);
3801 if (VG_(clo_track_fds
))
3802 ML_(record_fd_open_nameless
) (tid
, RES
);
3807 /* ---------------------------------------------------------------------
3809 ------------------------------------------------------------------ */
3811 PRE(sys_rt_sigaction
)
3813 PRINT("sys_rt_sigaction ( %ld, %#lx, %#lx, %lu )", SARG1
, ARG2
, ARG3
, ARG4
);
3814 PRE_REG_READ4(long, "rt_sigaction",
3815 int, signum
, const struct sigaction
*, act
,
3816 struct sigaction
*, oldact
, vki_size_t
, sigsetsize
);
3819 vki_sigaction_toK_t
*sa
= (vki_sigaction_toK_t
*)ARG2
;
3820 PRE_MEM_READ( "rt_sigaction(act->sa_handler)", (Addr
)&sa
->ksa_handler
, sizeof(sa
->ksa_handler
));
3821 PRE_MEM_READ( "rt_sigaction(act->sa_mask)", (Addr
)&sa
->sa_mask
, sizeof(sa
->sa_mask
));
3822 PRE_MEM_READ( "rt_sigaction(act->sa_flags)", (Addr
)&sa
->sa_flags
, sizeof(sa
->sa_flags
));
3823 if (ML_(safe_to_deref
)(sa
,sizeof(vki_sigaction_toK_t
))
3824 && (sa
->sa_flags
& VKI_SA_RESTORER
))
3825 PRE_MEM_READ( "rt_sigaction(act->sa_restorer)", (Addr
)&sa
->sa_restorer
, sizeof(sa
->sa_restorer
));
3828 PRE_MEM_WRITE( "rt_sigaction(oldact)", ARG3
, sizeof(vki_sigaction_fromK_t
));
3830 /* If the new or old sigaction is not NULL, but the structs
3831 aren't accessible then sigaction returns EFAULT and we cannot
3832 use either struct for our own bookkeeping. Just fail early. */
3834 && ! ML_(safe_to_deref
)((void *)ARG2
,
3835 sizeof(vki_sigaction_toK_t
))) {
3836 VG_(umsg
)("Warning: bad act handler address %p in rt_sigaction()\n",
3838 SET_STATUS_Failure ( VKI_EFAULT
);
3839 } else if ((ARG3
!= 0
3840 && ! ML_(safe_to_deref
)((void *)ARG3
,
3841 sizeof(vki_sigaction_fromK_t
)))) {
3842 VG_(umsg
)("Warning: bad oldact handler address %p in rt_sigaction()\n",
3844 SET_STATUS_Failure ( VKI_EFAULT
);
3847 // XXX: doesn't seem right to be calling do_sys_sigaction for
3848 // sys_rt_sigaction... perhaps this function should be renamed
3849 // VG_(do_sys_rt_sigaction)() --njn
3851 SET_STATUS_from_SysRes(
3852 VG_(do_sys_sigaction
)(ARG1
, (const vki_sigaction_toK_t
*)ARG2
,
3853 (vki_sigaction_fromK_t
*)ARG3
)
3857 POST(sys_rt_sigaction
)
3860 if (RES
== 0 && ARG3
!= 0)
3861 POST_MEM_WRITE( ARG3
, sizeof(vki_sigaction_fromK_t
));
3864 PRE(sys_rt_sigprocmask
)
3866 PRINT("sys_rt_sigprocmask ( %ld, %#lx, %#lx, %lu )",
3867 SARG1
, ARG2
, ARG3
, ARG4
);
3868 PRE_REG_READ4(long, "rt_sigprocmask",
3869 int, how
, vki_sigset_t
*, set
, vki_sigset_t
*, oldset
,
3870 vki_size_t
, sigsetsize
);
3872 PRE_MEM_READ( "rt_sigprocmask(set)", ARG2
, sizeof(vki_sigset_t
));
3874 PRE_MEM_WRITE( "rt_sigprocmask(oldset)", ARG3
, sizeof(vki_sigset_t
));
3876 // Like the kernel, we fail if the sigsetsize is not exactly what we expect.
3877 // Since we want to use the set and oldset for bookkeeping we also want
3878 // to make sure they are addressable otherwise, like the kernel, we EFAULT.
3879 if (sizeof(vki_sigset_t
) != ARG4
)
3880 SET_STATUS_Failure( VKI_EINVAL
);
3882 && ! ML_(safe_to_deref
)((void *)ARG2
, sizeof(vki_sigset_t
))) {
3883 VG_(dmsg
)("Warning: Bad set handler address %p in sigprocmask\n",
3885 SET_STATUS_Failure ( VKI_EFAULT
);
3888 && ! ML_(safe_to_deref
)((void *)ARG3
, sizeof(vki_sigset_t
))) {
3889 VG_(dmsg
)("Warning: Bad oldset address %p in sigprocmask\n",
3891 SET_STATUS_Failure ( VKI_EFAULT
);
3895 SET_STATUS_from_SysRes(
3896 VG_(do_sys_sigprocmask
) ( tid
, ARG1
/*how*/,
3897 (vki_sigset_t
*) ARG2
,
3898 (vki_sigset_t
*) ARG3
)
3903 *flags
|= SfPollAfter
;
3905 POST(sys_rt_sigprocmask
)
3908 if (RES
== 0 && ARG3
!= 0)
3909 POST_MEM_WRITE( ARG3
, sizeof(vki_sigset_t
));
3912 PRE(sys_rt_sigpending
)
3914 PRINT( "sys_rt_sigpending ( %#lx )", ARG1
);
3915 PRE_REG_READ2(long, "rt_sigpending",
3916 vki_sigset_t
*, set
, vki_size_t
, sigsetsize
);
3917 PRE_MEM_WRITE( "rt_sigpending(set)", ARG1
, sizeof(vki_sigset_t
));
3919 POST(sys_rt_sigpending
)
3921 POST_MEM_WRITE( ARG1
, sizeof(vki_sigset_t
) ) ;
3924 PRE(sys_rt_sigtimedwait
)
3926 *flags
|= SfMayBlock
;
3927 PRINT("sys_rt_sigtimedwait ( %#lx, %#lx, %#lx, %lu )",
3928 ARG1
, ARG2
, ARG3
, ARG4
);
3929 PRE_REG_READ4(long, "rt_sigtimedwait",
3930 const vki_sigset_t
*, set
, vki_siginfo_t
*, info
,
3931 const struct timespec
*, timeout
, vki_size_t
, sigsetsize
);
3933 PRE_MEM_READ( "rt_sigtimedwait(set)", ARG1
, sizeof(vki_sigset_t
));
3935 PRE_MEM_WRITE( "rt_sigtimedwait(info)", ARG2
, sizeof(vki_siginfo_t
) );
3937 PRE_MEM_READ( "rt_sigtimedwait(timeout)",
3938 ARG3
, sizeof(struct vki_timespec
) );
3940 POST(sys_rt_sigtimedwait
)
3943 POST_MEM_WRITE( ARG2
, sizeof(vki_siginfo_t
) );
3946 PRE(sys_rt_sigqueueinfo
)
3948 PRINT("sys_rt_sigqueueinfo(%ld, %ld, %#lx)", SARG1
, SARG2
, ARG3
);
3949 PRE_REG_READ3(long, "rt_sigqueueinfo",
3950 int, pid
, int, sig
, vki_siginfo_t
*, uinfo
);
3952 PRE_MEM_READ( "rt_sigqueueinfo(uinfo)", ARG3
, VKI_SI_MAX_SIZE
);
3954 POST(sys_rt_sigqueueinfo
)
3956 if (!ML_(client_signal_OK
)(ARG2
))
3957 SET_STATUS_Failure( VKI_EINVAL
);
3960 PRE(sys_rt_tgsigqueueinfo
)
3962 PRINT("sys_rt_tgsigqueueinfo(%ld, %ld, %ld, %#lx)",
3963 SARG1
, SARG2
, SARG3
, ARG4
);
3964 PRE_REG_READ4(long, "rt_tgsigqueueinfo",
3965 int, tgid
, int, pid
, int, sig
, vki_siginfo_t
*, uinfo
);
3967 PRE_MEM_READ( "rt_tgsigqueueinfo(uinfo)", ARG4
, VKI_SI_MAX_SIZE
);
3970 POST(sys_rt_tgsigqueueinfo
)
3972 if (!ML_(client_signal_OK
)(ARG3
))
3973 SET_STATUS_Failure( VKI_EINVAL
);
3976 // XXX: x86-specific? The kernel prototypes for the different archs are
3977 // hard to decipher.
3978 PRE(sys_rt_sigsuspend
)
3980 /* The C library interface to sigsuspend just takes a pointer to
3981 a signal mask but this system call has two arguments - a pointer
3982 to the mask and the number of bytes used by it. The kernel insists
3983 on the size being equal to sizeof(sigset_t) however and will just
3984 return EINVAL if it isn't.
3986 *flags
|= SfMayBlock
;
3987 PRINT("sys_rt_sigsuspend ( %#lx, %lu )", ARG1
, ARG2
);
3988 PRE_REG_READ2(int, "rt_sigsuspend", vki_sigset_t
*, mask
, vki_size_t
, size
)
3989 if (ARG1
!= (Addr
)NULL
) {
3990 PRE_MEM_READ( "rt_sigsuspend(mask)", ARG1
, sizeof(vki_sigset_t
) );
3991 if (ML_(safe_to_deref
)((vki_sigset_t
*) ARG1
, sizeof(vki_sigset_t
))) {
3992 VG_(sigdelset
)((vki_sigset_t
*) ARG1
, VG_SIGVGKILL
);
3993 /* We cannot mask VG_SIGVGKILL, as otherwise this thread would not
3994 be killable by VG_(nuke_all_threads_except).
3995 We thus silently ignore the user request to mask this signal.
3996 Note that this is similar to what is done for e.g.
3997 sigprocmask (see m_signals.c calculate_SKSS_from_SCSS). */
3999 SET_STATUS_Failure(VKI_EFAULT
);
4004 /* ---------------------------------------------------------------------
4005 linux msg* wrapper helpers
4006 ------------------------------------------------------------------ */
4009 ML_(linux_PRE_sys_msgsnd
) ( ThreadId tid
,
4010 UWord arg0
, UWord arg1
, UWord arg2
, UWord arg3
)
4012 /* int msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg); */
4013 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)arg1
;
4014 PRE_MEM_READ( "msgsnd(msgp->mtype)", (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
4015 PRE_MEM_READ( "msgsnd(msgp->mtext)", (Addr
)&msgp
->mtext
, arg2
);
4019 ML_(linux_PRE_sys_msgrcv
) ( ThreadId tid
,
4020 UWord arg0
, UWord arg1
, UWord arg2
,
4021 UWord arg3
, UWord arg4
)
4023 /* ssize_t msgrcv(int msqid, struct msgbuf *msgp, size_t msgsz,
4024 long msgtyp, int msgflg); */
4025 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)arg1
;
4026 PRE_MEM_WRITE( "msgrcv(msgp->mtype)", (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
4027 PRE_MEM_WRITE( "msgrcv(msgp->mtext)", (Addr
)&msgp
->mtext
, arg2
);
4030 ML_(linux_POST_sys_msgrcv
) ( ThreadId tid
,
4032 UWord arg0
, UWord arg1
, UWord arg2
,
4033 UWord arg3
, UWord arg4
)
4035 struct vki_msgbuf
*msgp
= (struct vki_msgbuf
*)arg1
;
4036 POST_MEM_WRITE( (Addr
)&msgp
->mtype
, sizeof(msgp
->mtype
) );
4037 POST_MEM_WRITE( (Addr
)&msgp
->mtext
, res
);
4041 ML_(linux_PRE_sys_msgctl
) ( ThreadId tid
,
4042 UWord arg0
, UWord arg1
, UWord arg2
)
4044 /* int msgctl(int msqid, int cmd, struct msqid_ds *buf); */
4045 switch (arg1
/* cmd */) {
4048 case VKI_IPC_INFO
|VKI_IPC_64
:
4049 case VKI_MSG_INFO
|VKI_IPC_64
:
4050 PRE_MEM_WRITE( "msgctl(IPC_INFO, buf)",
4051 arg2
, sizeof(struct vki_msginfo
) );
4055 PRE_MEM_WRITE( "msgctl(IPC_STAT, buf)",
4056 arg2
, sizeof(struct vki_msqid_ds
) );
4058 case VKI_IPC_STAT
|VKI_IPC_64
:
4059 case VKI_MSG_STAT
|VKI_IPC_64
:
4060 PRE_MEM_WRITE( "msgctl(IPC_STAT, arg.buf)",
4061 arg2
, sizeof(struct vki_msqid64_ds
) );
4064 PRE_MEM_READ( "msgctl(IPC_SET, arg.buf)",
4065 arg2
, sizeof(struct vki_msqid_ds
) );
4067 case VKI_IPC_SET
|VKI_IPC_64
:
4068 PRE_MEM_READ( "msgctl(IPC_SET, arg.buf)",
4069 arg2
, sizeof(struct vki_msqid64_ds
) );
4074 ML_(linux_POST_sys_msgctl
) ( ThreadId tid
,
4076 UWord arg0
, UWord arg1
, UWord arg2
)
4078 switch (arg1
/* cmd */) {
4081 case VKI_IPC_INFO
|VKI_IPC_64
:
4082 case VKI_MSG_INFO
|VKI_IPC_64
:
4083 POST_MEM_WRITE( arg2
, sizeof(struct vki_msginfo
) );
4087 POST_MEM_WRITE( arg2
, sizeof(struct vki_msqid_ds
) );
4089 case VKI_IPC_STAT
|VKI_IPC_64
:
4090 case VKI_MSG_STAT
|VKI_IPC_64
:
4091 POST_MEM_WRITE( arg2
, sizeof(struct vki_msqid64_ds
) );
4096 /* ---------------------------------------------------------------------
4097 Generic handler for sys_ipc
4098 Depending on the platform, some syscalls (e.g. semctl, semop, ...)
4099 are either direct system calls, or are all implemented via sys_ipc.
4100 ------------------------------------------------------------------ */
4102 static Addr
deref_Addr ( ThreadId tid
, Addr a
, const HChar
* s
)
4104 Addr
* a_p
= (Addr
*)a
;
4105 PRE_MEM_READ( s
, (Addr
)a_p
, sizeof(Addr
) );
4109 static Bool
semctl_cmd_has_4args (UWord cmd
)
4111 switch (cmd
& ~VKI_IPC_64
)
4128 PRINT("sys_ipc ( %lu, %ld, %ld, %ld, %#lx, %ld )",
4129 ARG1
, SARG2
, SARG3
, SARG4
, ARG5
, SARG6
);
4131 switch (ARG1
/* call */) {
4133 PRE_REG_READ5(int, "ipc",
4134 vki_uint
, call
, int, first
, int, second
, int, third
,
4136 ML_(generic_PRE_sys_semop
)( tid
, ARG2
, ARG5
, ARG3
);
4137 *flags
|= SfMayBlock
;
4140 PRE_REG_READ4(int, "ipc",
4141 vki_uint
, call
, int, first
, int, second
, int, third
);
4145 PRE_REG_READ5(int, "ipc",
4146 vki_uint
, call
, int, first
, int, second
, int, third
,
4149 if (semctl_cmd_has_4args(ARG4
))
4150 arg
= deref_Addr( tid
, ARG5
, "semctl(arg)" );
4153 ML_(generic_PRE_sys_semctl
)( tid
, ARG2
, ARG3
, ARG4
, arg
);
4156 case VKI_SEMTIMEDOP
:
4157 PRE_REG_READ6(int, "ipc",
4158 vki_uint
, call
, int, first
, int, second
, int, third
,
4159 void *, ptr
, long, fifth
);
4160 ML_(generic_PRE_sys_semtimedop
)( tid
, ARG2
, ARG5
, ARG3
, ARG6
);
4161 *flags
|= SfMayBlock
;
4164 PRE_REG_READ5(int, "ipc",
4165 vki_uint
, call
, int, first
, int, second
, int, third
,
4167 ML_(linux_PRE_sys_msgsnd
)( tid
, ARG2
, ARG5
, ARG3
, ARG4
);
4168 if ((ARG4
& VKI_IPC_NOWAIT
) == 0)
4169 *flags
|= SfMayBlock
;
4173 PRE_REG_READ5(int, "ipc",
4174 vki_uint
, call
, int, first
, int, second
, int, third
,
4179 msgp
= deref_Addr( tid
, (Addr
) (&((struct vki_ipc_kludge
*)ARG5
)->msgp
),
4181 msgtyp
= deref_Addr( tid
,
4182 (Addr
) (&((struct vki_ipc_kludge
*)ARG5
)->msgtyp
),
4185 ML_(linux_PRE_sys_msgrcv
)( tid
, ARG2
, msgp
, ARG3
, msgtyp
, ARG4
);
4187 if ((ARG4
& VKI_IPC_NOWAIT
) == 0)
4188 *flags
|= SfMayBlock
;
4192 PRE_REG_READ3(int, "ipc", vki_uint
, call
, int, first
, int, second
);
4195 PRE_REG_READ5(int, "ipc",
4196 vki_uint
, call
, int, first
, int, second
, int, third
,
4198 ML_(linux_PRE_sys_msgctl
)( tid
, ARG2
, ARG3
, ARG5
);
4202 PRE_REG_READ5(int, "ipc",
4203 vki_uint
, call
, int, first
, int, second
, int, third
,
4206 PRE_MEM_WRITE( "shmat(raddr)", ARG4
, sizeof(Addr
) );
4207 w
= ML_(generic_PRE_sys_shmat
)( tid
, ARG2
, ARG5
, ARG3
);
4209 SET_STATUS_Failure( VKI_EINVAL
);
4215 PRE_REG_READ5(int, "ipc",
4216 vki_uint
, call
, int, first
, int, second
, int, third
,
4218 if (!ML_(generic_PRE_sys_shmdt
)(tid
, ARG5
))
4219 SET_STATUS_Failure( VKI_EINVAL
);
4222 PRE_REG_READ4(int, "ipc",
4223 vki_uint
, call
, int, first
, int, second
, int, third
);
4224 if (ARG4
& VKI_SHM_HUGETLB
) {
4225 static Bool warning_given
= False
;
4226 ARG4
&= ~VKI_SHM_HUGETLB
;
4227 if (!warning_given
) {
4228 warning_given
= True
;
4230 "WARNING: valgrind ignores shmget(shmflg) SHM_HUGETLB\n");
4234 case VKI_SHMCTL
: /* IPCOP_shmctl */
4235 PRE_REG_READ5(int, "ipc",
4236 vki_uint
, call
, int, first
, int, second
, int, third
,
4238 ML_(generic_PRE_sys_shmctl
)( tid
, ARG2
, ARG3
, ARG5
);
4241 VG_(message
)(Vg_DebugMsg
, "FATAL: unhandled syscall(ipc) %lu\n", ARG1
);
4242 VG_(core_panic
)("... bye!\n");
4243 break; /*NOTREACHED*/
4250 switch (ARG1
/* call */) {
4257 if (semctl_cmd_has_4args(ARG4
))
4258 arg
= deref_Addr( tid
, ARG5
, "semctl(arg)" );
4261 ML_(generic_POST_sys_semctl
)( tid
, RES
, ARG2
, ARG3
, ARG4
, arg
);
4264 case VKI_SEMTIMEDOP
:
4272 msgp
= deref_Addr( tid
,
4273 (Addr
) (&((struct vki_ipc_kludge
*)ARG5
)->msgp
),
4275 msgtyp
= deref_Addr( tid
,
4276 (Addr
) (&((struct vki_ipc_kludge
*)ARG5
)->msgtyp
),
4279 ML_(linux_POST_sys_msgrcv
)( tid
, RES
, ARG2
, msgp
, ARG3
, msgtyp
, ARG4
);
4285 ML_(linux_POST_sys_msgctl
)( tid
, RES
, ARG2
, ARG3
, ARG5
);
4291 /* force readability. before the syscall it is
4292 * indeed uninitialized, as can be seen in
4293 * glibc/sysdeps/unix/sysv/linux/shmat.c */
4294 POST_MEM_WRITE( ARG4
, sizeof( Addr
) );
4296 addr
= deref_Addr ( tid
, ARG4
, "shmat(addr)" );
4297 ML_(generic_POST_sys_shmat
)( tid
, addr
, ARG2
, ARG5
, ARG3
);
4301 ML_(generic_POST_sys_shmdt
)( tid
, RES
, ARG5
);
4306 ML_(generic_POST_sys_shmctl
)( tid
, RES
, ARG2
, ARG3
, ARG5
);
4309 VG_(message
)(Vg_DebugMsg
,
4310 "FATAL: unhandled syscall(ipc) %lu\n",
4312 VG_(core_panic
)("... bye!\n");
4313 break; /*NOTREACHED*/
4320 PRINT("sys_semget ( %ld, %ld, %ld )", SARG1
, SARG2
, SARG3
);
4321 PRE_REG_READ3(long, "semget", vki_key_t
, key
, int, nsems
, int, semflg
);
4326 *flags
|= SfMayBlock
;
4327 PRINT("sys_semop ( %ld, %#lx, %lu )", SARG1
, ARG2
, ARG3
);
4328 PRE_REG_READ3(long, "semop",
4329 int, semid
, struct sembuf
*, sops
, unsigned, nsoops
);
4330 ML_(generic_PRE_sys_semop
)(tid
, ARG1
,ARG2
,ARG3
);
4335 switch (ARG3
& ~VKI_IPC_64
) {
4338 PRINT("sys_semctl ( %ld, %ld, %ld, %#lx )", SARG1
, SARG2
, SARG3
, ARG4
);
4339 PRE_REG_READ4(long, "semctl",
4340 int, semid
, int, semnum
, int, cmd
, struct seminfo
*, arg
);
4345 PRINT("sys_semctl ( %ld, %ld, %ld, %#lx )", SARG1
, SARG2
, SARG3
, ARG4
);
4346 PRE_REG_READ4(long, "semctl",
4347 int, semid
, int, semnum
, int, cmd
, struct semid_ds
*, arg
);
4351 PRINT("sys_semctl ( %ld, %ld, %ld, %#lx )", SARG1
, SARG2
, SARG3
, ARG4
);
4352 PRE_REG_READ4(long, "semctl",
4353 int, semid
, int, semnum
, int, cmd
, unsigned short *, arg
);
4356 PRINT("sys_semctl ( %ld, %ld, %ld )", SARG1
, SARG2
, SARG3
);
4357 PRE_REG_READ3(long, "semctl",
4358 int, semid
, int, semnum
, int, cmd
);
4361 #ifdef VGP_amd64_linux
4362 ML_(generic_PRE_sys_semctl
)(tid
, ARG1
,ARG2
,ARG3
|VKI_IPC_64
,ARG4
);
4364 ML_(generic_PRE_sys_semctl
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
4370 #ifdef VGP_amd64_linux
4371 ML_(generic_POST_sys_semctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
|VKI_IPC_64
,ARG4
);
4373 ML_(generic_POST_sys_semctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
,ARG4
);
4379 *flags
|= SfMayBlock
;
4380 PRINT("sys_semtimedop ( %ld, %#lx, %lu, %#lx )", SARG1
, ARG2
, ARG3
, ARG4
);
4381 PRE_REG_READ4(long, "semtimedop",
4382 int, semid
, struct sembuf
*, sops
, unsigned, nsoops
,
4383 struct timespec
*, timeout
);
4384 ML_(generic_PRE_sys_semtimedop
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
4389 PRINT("sys_msgget ( %ld, %ld )", SARG1
, SARG2
);
4390 PRE_REG_READ2(long, "msgget", vki_key_t
, key
, int, msgflg
);
4395 PRINT("sys_msgsnd ( %ld, %#lx, %lu, %ld )", SARG1
, ARG2
, ARG3
, SARG4
);
4396 PRE_REG_READ4(long, "msgsnd",
4397 int, msqid
, struct msgbuf
*, msgp
, vki_size_t
, msgsz
, int, msgflg
);
4398 ML_(linux_PRE_sys_msgsnd
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
4399 if ((ARG4
& VKI_IPC_NOWAIT
) == 0)
4400 *flags
|= SfMayBlock
;
4405 PRINT("sys_msgrcv ( %ld, %#lx, %lu, %ld, %ld )",
4406 SARG1
, ARG2
, ARG3
, SARG4
, SARG5
);
4407 PRE_REG_READ5(long, "msgrcv",
4408 int, msqid
, struct msgbuf
*, msgp
, vki_size_t
, msgsz
,
4409 long, msgytp
, int, msgflg
);
4410 ML_(linux_PRE_sys_msgrcv
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4411 if ((ARG5
& VKI_IPC_NOWAIT
) == 0)
4412 *flags
|= SfMayBlock
;
4416 ML_(linux_POST_sys_msgrcv
)(tid
, RES
,ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4421 PRINT("sys_msgctl ( %ld, %ld, %#lx )", SARG1
, SARG2
, ARG3
);
4422 PRE_REG_READ3(long, "msgctl",
4423 int, msqid
, int, cmd
, struct msqid_ds
*, buf
);
4424 ML_(linux_PRE_sys_msgctl
)(tid
, ARG1
,ARG2
,ARG3
);
4429 ML_(linux_POST_sys_msgctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
);
4434 PRINT("sys_shmget ( %ld, %lu, %ld )", SARG1
, ARG2
, SARG3
);
4435 PRE_REG_READ3(long, "shmget", vki_key_t
, key
, vki_size_t
, size
, int, shmflg
);
4436 if (ARG3
& VKI_SHM_HUGETLB
) {
4437 static Bool warning_given
= False
;
4438 ARG3
&= ~VKI_SHM_HUGETLB
;
4439 if (!warning_given
) {
4440 warning_given
= True
;
4442 "WARNING: valgrind ignores shmget(shmflg) SHM_HUGETLB\n");
4450 PRINT("sys_shmat ( %ld, %#lx, %ld )", SARG1
, ARG2
, SARG3
);
4451 PRE_REG_READ3(long, "shmat",
4452 int, shmid
, const void *, shmaddr
, int, shmflg
);
4453 #if defined(VGP_arm_linux)
4454 /* Round the attach address down to an VKI_SHMLBA boundary if the
4455 client requested rounding. See #222545. This is necessary only
4456 on arm-linux because VKI_SHMLBA is 4 * VKI_PAGE size; on all
4457 other linux targets it is the same as the page size. */
4458 if (ARG3
& VKI_SHM_RND
)
4459 ARG2
= VG_ROUNDDN(ARG2
, VKI_SHMLBA
);
4461 arg2tmp
= ML_(generic_PRE_sys_shmat
)(tid
, ARG1
,ARG2
,ARG3
);
4463 SET_STATUS_Failure( VKI_EINVAL
);
4465 ARG2
= arg2tmp
; // used in POST
4470 ML_(generic_POST_sys_shmat
)(tid
, RES
,ARG1
,ARG2
,ARG3
);
4475 PRINT("sys_shmdt ( %#lx )",ARG1
);
4476 PRE_REG_READ1(long, "shmdt", const void *, shmaddr
);
4477 if (!ML_(generic_PRE_sys_shmdt
)(tid
, ARG1
))
4478 SET_STATUS_Failure( VKI_EINVAL
);
4483 ML_(generic_POST_sys_shmdt
)(tid
, RES
,ARG1
);
4488 PRINT("sys_shmctl ( %ld, %ld, %#lx )", SARG1
, SARG2
, ARG3
);
4489 PRE_REG_READ3(long, "shmctl",
4490 int, shmid
, int, cmd
, struct shmid_ds
*, buf
);
4491 #ifdef VGP_amd64_linux
4492 ML_(generic_PRE_sys_shmctl
)(tid
, ARG1
,ARG2
|VKI_IPC_64
,ARG3
);
4494 ML_(generic_PRE_sys_shmctl
)(tid
, ARG1
,ARG2
,ARG3
);
4500 #ifdef VGP_amd64_linux
4501 ML_(generic_POST_sys_shmctl
)(tid
, RES
,ARG1
,ARG2
|VKI_IPC_64
,ARG3
);
4503 ML_(generic_POST_sys_shmctl
)(tid
, RES
,ARG1
,ARG2
,ARG3
);
4508 /* ---------------------------------------------------------------------
4509 Generic handler for sys_socketcall
4510 Depending on the platform, some socket related syscalls (e.g. socketpair,
4512 are either direct system calls, or are all implemented via sys_socketcall.
4513 ------------------------------------------------------------------ */
4514 #ifdef __NR_socketcall
4517 # define ARG2_0 (((UWord*)ARG2)[0])
4518 # define ARG2_1 (((UWord*)ARG2)[1])
4519 # define ARG2_2 (((UWord*)ARG2)[2])
4520 # define ARG2_3 (((UWord*)ARG2)[3])
4521 # define ARG2_4 (((UWord*)ARG2)[4])
4522 # define ARG2_5 (((UWord*)ARG2)[5])
4524 // call PRE_MEM_READ and check for EFAULT result.
4525 #define PRE_MEM_READ_ef(msg, arg, size) \
4527 PRE_MEM_READ( msg, arg, size); \
4528 if (!ML_(valid_client_addr)(arg, size, tid, NULL)) { \
4529 SET_STATUS_Failure( VKI_EFAULT ); \
4534 *flags
|= SfMayBlock
;
4535 PRINT("sys_socketcall ( %ld, %#lx )", SARG1
, ARG2
);
4536 PRE_REG_READ2(long, "socketcall", int, call
, unsigned long *, args
);
4538 switch (ARG1
/* request */) {
4540 case VKI_SYS_SOCKETPAIR
:
4541 /* int socketpair(int d, int type, int protocol, int sv[2]); */
4542 PRE_MEM_READ_ef( "socketcall.socketpair(args)", ARG2
, 4*sizeof(Addr
) );
4543 ML_(generic_PRE_sys_socketpair
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
);
4546 case VKI_SYS_SOCKET
:
4547 /* int socket(int domain, int type, int protocol); */
4548 PRE_MEM_READ_ef( "socketcall.socket(args)", ARG2
, 3*sizeof(Addr
) );
4552 /* int bind(int sockfd, struct sockaddr *my_addr,
4554 PRE_MEM_READ_ef( "socketcall.bind(args)", ARG2
, 3*sizeof(Addr
) );
4555 ML_(generic_PRE_sys_bind
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4558 case VKI_SYS_LISTEN
:
4559 /* int listen(int s, int backlog); */
4560 PRE_MEM_READ_ef( "socketcall.listen(args)", ARG2
, 2*sizeof(Addr
) );
4563 case VKI_SYS_ACCEPT
:
4564 /* int accept(int s, struct sockaddr *addr, int *addrlen); */
4565 PRE_MEM_READ_ef( "socketcall.accept(args)", ARG2
, 3*sizeof(Addr
) );
4566 ML_(generic_PRE_sys_accept
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4569 case VKI_SYS_ACCEPT4
:
4570 /* int accept4(int s, struct sockaddr *addr, int *addrlen, int flags); */
4571 PRE_MEM_READ_ef( "socketcall.accept4(args)", ARG2
, 4*sizeof(Addr
) );
4572 ML_(generic_PRE_sys_accept
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4575 case VKI_SYS_SENDTO
:
4576 /* int sendto(int s, const void *msg, int len,
4578 const struct sockaddr *to, int tolen); */
4579 PRE_MEM_READ_ef( "socketcall.sendto(args)", ARG2
, 6*sizeof(Addr
) );
4580 ML_(generic_PRE_sys_sendto
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
,
4581 ARG2_3
, ARG2_4
, ARG2_5
);
4585 /* int send(int s, const void *msg, size_t len, int flags); */
4586 PRE_MEM_READ_ef( "socketcall.send(args)", ARG2
, 4*sizeof(Addr
) );
4587 ML_(generic_PRE_sys_send
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4590 case VKI_SYS_RECVFROM
:
4591 /* int recvfrom(int s, void *buf, int len, unsigned int flags,
4592 struct sockaddr *from, int *fromlen); */
4593 PRE_MEM_READ_ef( "socketcall.recvfrom(args)", ARG2
, 6*sizeof(Addr
) );
4594 ML_(generic_PRE_sys_recvfrom
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
,
4595 ARG2_3
, ARG2_4
, ARG2_5
);
4599 /* int recv(int s, void *buf, int len, unsigned int flags); */
4601 The recv call is normally used only on a connected socket
4602 (see connect(2)) and is identical to recvfrom with a NULL
4605 PRE_MEM_READ_ef( "socketcall.recv(args)", ARG2
, 4*sizeof(Addr
) );
4606 ML_(generic_PRE_sys_recv
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4609 case VKI_SYS_CONNECT
:
4610 /* int connect(int sockfd,
4611 struct sockaddr *serv_addr, int addrlen ); */
4612 PRE_MEM_READ_ef( "socketcall.connect(args)", ARG2
, 3*sizeof(Addr
) );
4613 ML_(generic_PRE_sys_connect
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4616 case VKI_SYS_SETSOCKOPT
:
4617 /* int setsockopt(int s, int level, int optname,
4618 const void *optval, int optlen); */
4619 PRE_MEM_READ_ef( "socketcall.setsockopt(args)", ARG2
, 5*sizeof(Addr
) );
4620 ML_(linux_PRE_sys_setsockopt
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
,
4624 case VKI_SYS_GETSOCKOPT
:
4625 /* int getsockopt(int s, int level, int optname,
4626 void *optval, socklen_t *optlen); */
4627 PRE_MEM_READ_ef( "socketcall.getsockopt(args)", ARG2
, 5*sizeof(Addr
) );
4628 ML_(linux_PRE_sys_getsockopt
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
,
4632 case VKI_SYS_GETSOCKNAME
:
4633 /* int getsockname(int s, struct sockaddr* name, int* namelen) */
4634 PRE_MEM_READ_ef( "socketcall.getsockname(args)", ARG2
, 3*sizeof(Addr
) );
4635 ML_(generic_PRE_sys_getsockname
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4638 case VKI_SYS_GETPEERNAME
:
4639 /* int getpeername(int s, struct sockaddr* name, int* namelen) */
4640 PRE_MEM_READ_ef( "socketcall.getpeername(args)", ARG2
, 3*sizeof(Addr
) );
4641 ML_(generic_PRE_sys_getpeername
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
);
4644 case VKI_SYS_SHUTDOWN
:
4645 /* int shutdown(int s, int how); */
4646 PRE_MEM_READ_ef( "socketcall.shutdown(args)", ARG2
, 2*sizeof(Addr
) );
4649 case VKI_SYS_SENDMSG
:
4650 /* int sendmsg(int s, const struct msghdr *msg, int flags); */
4651 PRE_MEM_READ_ef( "socketcall.sendmsg(args)", ARG2
, 3*sizeof(Addr
) );
4652 ML_(generic_PRE_sys_sendmsg
)( tid
, "msg", (struct vki_msghdr
*)ARG2_1
);
4655 case VKI_SYS_RECVMSG
:
4656 /* int recvmsg(int s, struct msghdr *msg, int flags); */
4657 PRE_MEM_READ_ef("socketcall.recvmsg(args)", ARG2
, 3*sizeof(Addr
) );
4658 ML_(generic_PRE_sys_recvmsg
)( tid
, "msg", (struct vki_msghdr
*)ARG2_1
);
4661 case VKI_SYS_RECVMMSG
:
4662 /* int recvmmsg(int s, struct mmsghdr *mmsg, int vlen, int flags,
4663 struct timespec *timeout); */
4664 PRE_MEM_READ_ef("socketcall.recvmmsg(args)", ARG2
, 5*sizeof(Addr
) );
4665 ML_(linux_PRE_sys_recvmmsg
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
,
4669 case VKI_SYS_SENDMMSG
:
4670 /* int sendmmsg(int s, struct mmsghdr *mmsg, int vlen, int flags); */
4671 PRE_MEM_READ_ef("socketcall.sendmmsg(args)", ARG2
, 4*sizeof(Addr
) );
4672 ML_(linux_PRE_sys_sendmmsg
)( tid
, ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
);
4676 VG_(message
)(Vg_DebugMsg
,"Warning: unhandled socketcall 0x%lx\n",ARG1
);
4677 SET_STATUS_Failure( VKI_EINVAL
);
4688 POST(sys_socketcall
)
4690 # define ARG2_0 (((UWord*)ARG2)[0])
4691 # define ARG2_1 (((UWord*)ARG2)[1])
4692 # define ARG2_2 (((UWord*)ARG2)[2])
4693 # define ARG2_3 (((UWord*)ARG2)[3])
4694 # define ARG2_4 (((UWord*)ARG2)[4])
4695 # define ARG2_5 (((UWord*)ARG2)[5])
4699 switch (ARG1
/* request */) {
4701 case VKI_SYS_SOCKETPAIR
:
4702 r
= ML_(generic_POST_sys_socketpair
)(
4703 tid
, VG_(mk_SysRes_Success
)(RES
),
4704 ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
4706 SET_STATUS_from_SysRes(r
);
4709 case VKI_SYS_SOCKET
:
4710 r
= ML_(generic_POST_sys_socket
)( tid
, VG_(mk_SysRes_Success
)(RES
) );
4711 SET_STATUS_from_SysRes(r
);
4715 /* int bind(int sockfd, struct sockaddr *my_addr,
4719 case VKI_SYS_LISTEN
:
4720 /* int listen(int s, int backlog); */
4723 case VKI_SYS_ACCEPT
:
4724 case VKI_SYS_ACCEPT4
:
4725 /* int accept(int s, struct sockaddr *addr, int *addrlen); */
4726 /* int accept4(int s, struct sockaddr *addr, int *addrlen, int flags); */
4727 r
= ML_(generic_POST_sys_accept
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4728 ARG2_0
, ARG2_1
, ARG2_2
);
4729 SET_STATUS_from_SysRes(r
);
4732 case VKI_SYS_SENDTO
:
4738 case VKI_SYS_RECVFROM
:
4739 ML_(generic_POST_sys_recvfrom
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4740 ARG2_0
, ARG2_1
, ARG2_2
,
4741 ARG2_3
, ARG2_4
, ARG2_5
);
4745 ML_(generic_POST_sys_recv
)( tid
, RES
, ARG2_0
, ARG2_1
, ARG2_2
);
4748 case VKI_SYS_CONNECT
:
4751 case VKI_SYS_SETSOCKOPT
:
4754 case VKI_SYS_GETSOCKOPT
:
4755 ML_(linux_POST_sys_getsockopt
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4757 ARG2_2
, ARG2_3
, ARG2_4
);
4760 case VKI_SYS_GETSOCKNAME
:
4761 ML_(generic_POST_sys_getsockname
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4762 ARG2_0
, ARG2_1
, ARG2_2
);
4765 case VKI_SYS_GETPEERNAME
:
4766 ML_(generic_POST_sys_getpeername
)( tid
, VG_(mk_SysRes_Success
)(RES
),
4767 ARG2_0
, ARG2_1
, ARG2_2
);
4770 case VKI_SYS_SHUTDOWN
:
4773 case VKI_SYS_SENDMSG
:
4776 case VKI_SYS_RECVMSG
:
4777 ML_(generic_POST_sys_recvmsg
)( tid
, "msg", (struct vki_msghdr
*)ARG2_1
, RES
);
4780 case VKI_SYS_RECVMMSG
:
4781 ML_(linux_POST_sys_recvmmsg
)( tid
, RES
,
4782 ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
, ARG2_4
);
4785 case VKI_SYS_SENDMMSG
:
4786 ML_(linux_POST_sys_sendmmsg
)( tid
, RES
, ARG2_0
, ARG2_1
, ARG2_2
, ARG2_3
);
4790 VG_(message
)(Vg_DebugMsg
,"FATAL: unhandled socketcall 0x%lx\n",ARG1
);
4791 VG_(core_panic
)("... bye!\n");
4792 break; /*NOTREACHED*/
4805 PRINT("sys_socket ( %ld, %ld, %ld )", SARG1
, SARG2
, SARG3
);
4806 PRE_REG_READ3(long, "socket", int, domain
, int, type
, int, protocol
);
4812 r
= ML_(generic_POST_sys_socket
)(tid
, VG_(mk_SysRes_Success
)(RES
));
4813 SET_STATUS_from_SysRes(r
);
4818 PRINT("sys_setsockopt ( %ld, %ld, %ld, %#lx, %lu )",
4819 SARG1
, SARG2
, SARG3
, ARG4
, ARG5
);
4820 PRE_REG_READ5(long, "setsockopt",
4821 int, s
, int, level
, int, optname
,
4822 const void *, optval
, unsigned, optlen
); // socklen_t
4823 ML_(linux_PRE_sys_setsockopt
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4828 PRINT("sys_getsockopt ( %ld, %ld, %ld, %#lx, %ld )",
4829 SARG1
, SARG2
, SARG3
, ARG4
, SARG5
);
4830 PRE_REG_READ5(long, "getsockopt",
4831 int, s
, int, level
, int, optname
,
4832 void *, optval
, int, *optlen
);
4833 ML_(linux_PRE_sys_getsockopt
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4835 POST(sys_getsockopt
)
4838 ML_(linux_POST_sys_getsockopt
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4839 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
4844 *flags
|= SfMayBlock
;
4845 PRINT("sys_connect ( %ld, %#lx, %ld )", SARG1
, ARG2
, SARG3
);
4846 PRE_REG_READ3(long, "connect",
4847 int, sockfd
, struct sockaddr
*, serv_addr
, int, addrlen
);
4848 ML_(generic_PRE_sys_connect
)(tid
, ARG1
,ARG2
,ARG3
);
4853 *flags
|= SfMayBlock
;
4854 PRINT("sys_accept ( %ld, %#lx, %#lx )", SARG1
, ARG2
, ARG3
);
4855 PRE_REG_READ3(long, "accept",
4856 int, s
, struct sockaddr
*, addr
, int *, addrlen
);
4857 ML_(generic_PRE_sys_accept
)(tid
, ARG1
,ARG2
,ARG3
);
4863 r
= ML_(generic_POST_sys_accept
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4865 SET_STATUS_from_SysRes(r
);
4870 *flags
|= SfMayBlock
;
4871 PRINT("sys_accept4 ( %ld, %#lx, %#lx, %ld )", SARG1
, ARG2
, ARG3
, SARG4
);
4872 PRE_REG_READ4(long, "accept4",
4873 int, s
, struct sockaddr
*, addr
, int *, addrlen
, int, flags
);
4874 ML_(generic_PRE_sys_accept
)(tid
, ARG1
,ARG2
,ARG3
);
4880 r
= ML_(generic_POST_sys_accept
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4882 SET_STATUS_from_SysRes(r
);
4887 *flags
|= SfMayBlock
;
4888 PRINT("sys_send ( %ld, %#lx, %lu, %#lx )", SARG1
, ARG2
, ARG3
, ARG4
);
4889 PRE_REG_READ4(long, "send",
4890 int, s
, const void *, msg
, vki_size_t
, len
,
4893 ML_(generic_PRE_sys_send
)( tid
, ARG1
, ARG2
, ARG3
);
4898 *flags
|= SfMayBlock
;
4899 PRINT("sys_sendto ( %ld, %#lx, %lu, %lu, %#lx, %ld )",
4900 SARG1
, ARG2
, ARG3
, ARG4
, ARG5
, SARG6
);
4901 PRE_REG_READ6(long, "sendto",
4902 int, s
, const void *, msg
, vki_size_t
, len
,
4903 unsigned int, flags
,
4904 const struct sockaddr
*, to
, int, tolen
);
4905 ML_(generic_PRE_sys_sendto
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
4910 *flags
|= SfMayBlock
;
4911 PRINT ("sys_recv ( %ld, %#lx, %lu, %lu )", SARG1
, ARG2
, ARG3
, ARG4
);
4912 PRE_REG_READ4 (long, "recv", int, s
, void *, buf
, vki_size_t
, len
,
4913 unsigned int, flags
);
4914 ML_ (generic_PRE_sys_recv
) (tid
, ARG1
, ARG2
, ARG3
);
4919 ML_ (generic_POST_sys_recv
) (tid
, RES
, ARG1
, ARG2
, ARG3
);
4924 *flags
|= SfMayBlock
;
4925 PRINT("sys_recvfrom ( %ld, %#lx, %lu, %lu, %#lx, %#lx )",
4926 SARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
4927 PRE_REG_READ6(long, "recvfrom",
4928 int, s
, void *, buf
, vki_size_t
, len
, unsigned int, flags
,
4929 struct sockaddr
*, from
, int *, fromlen
);
4930 ML_(generic_PRE_sys_recvfrom
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
4935 ML_(generic_POST_sys_recvfrom
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4936 ARG1
,ARG2
,ARG3
,ARG4
,ARG5
,ARG6
);
4941 *flags
|= SfMayBlock
;
4942 PRINT("sys_sendmsg ( %ld, %#lx, %lu )", SARG1
, ARG2
, ARG3
);
4943 PRE_REG_READ3(long, "sendmsg",
4944 int, s
, const struct msghdr
*, msg
, unsigned int, flags
);
4945 ML_(generic_PRE_sys_sendmsg
)(tid
, "msg", (struct vki_msghdr
*)ARG2
);
4950 *flags
|= SfMayBlock
;
4951 PRINT("sys_recvmsg ( %ld, %#lx, %lu )", SARG1
, ARG2
, ARG3
);
4952 PRE_REG_READ3(long, "recvmsg", int, s
, struct msghdr
*, msg
,
4953 unsigned int, flags
);
4954 ML_(generic_PRE_sys_recvmsg
)(tid
, "msg", (struct vki_msghdr
*)ARG2
);
4958 ML_(generic_POST_sys_recvmsg
)(tid
, "msg", (struct vki_msghdr
*)ARG2
, RES
);
4963 *flags
|= SfMayBlock
;
4964 PRINT("sys_shutdown ( %ld, %ld )", SARG1
, SARG2
);
4965 PRE_REG_READ2(int, "shutdown", int, s
, int, how
);
4970 PRINT("sys_bind ( %ld, %#lx, %ld )", SARG1
, ARG2
, SARG3
);
4971 PRE_REG_READ3(long, "bind",
4972 int, sockfd
, struct sockaddr
*, my_addr
, int, addrlen
);
4973 ML_(generic_PRE_sys_bind
)(tid
, ARG1
,ARG2
,ARG3
);
4978 PRINT("sys_listen ( %ld, %ld )", SARG1
, SARG2
);
4979 PRE_REG_READ2(long, "listen", int, s
, int, backlog
);
4982 PRE(sys_getsockname
)
4984 PRINT("sys_getsockname ( %ld, %#lx, %#lx )", SARG1
, ARG2
, ARG3
);
4985 PRE_REG_READ3(long, "getsockname",
4986 int, s
, struct sockaddr
*, name
, int *, namelen
);
4987 ML_(generic_PRE_sys_getsockname
)(tid
, ARG1
,ARG2
,ARG3
);
4989 POST(sys_getsockname
)
4992 ML_(generic_POST_sys_getsockname
)(tid
, VG_(mk_SysRes_Success
)(RES
),
4996 PRE(sys_getpeername
)
4998 PRINT("sys_getpeername ( %ld, %#lx, %#lx )", SARG1
, ARG2
, ARG3
);
4999 PRE_REG_READ3(long, "getpeername",
5000 int, s
, struct sockaddr
*, name
, int *, namelen
);
5001 ML_(generic_PRE_sys_getpeername
)(tid
, ARG1
,ARG2
,ARG3
);
5003 POST(sys_getpeername
)
5006 ML_(generic_POST_sys_getpeername
)(tid
, VG_(mk_SysRes_Success
)(RES
),
5012 PRINT("sys_socketpair ( %ld, %ld, %ld, %#lx )", SARG1
, SARG2
, SARG3
, ARG4
);
5013 PRE_REG_READ4(long, "socketpair",
5014 int, d
, int, type
, int, protocol
, int*, sv
);
5015 ML_(generic_PRE_sys_socketpair
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
5017 POST(sys_socketpair
)
5020 ML_(generic_POST_sys_socketpair
)(tid
, VG_(mk_SysRes_Success
)(RES
),
5021 ARG1
,ARG2
,ARG3
,ARG4
);
5025 /* ---------------------------------------------------------------------
5027 ------------------------------------------------------------------ */
5031 HChar name
[30]; // large enough
5034 if (ARG3
& VKI_O_CREAT
) {
5036 PRINT("sys_openat ( %ld, %#lx(%s), %ld, %ld )",
5037 SARG1
, ARG2
, (HChar
*)ARG2
, SARG3
, SARG4
);
5038 PRE_REG_READ4(long, "openat",
5039 int, dfd
, const char *, filename
, int, flags
, int, mode
);
5042 PRINT("sys_openat ( %ld, %#lx(%s), %ld )",
5043 SARG1
, ARG2
, (HChar
*)ARG2
, SARG3
);
5044 PRE_REG_READ3(long, "openat",
5045 int, dfd
, const char *, filename
, int, flags
);
5048 PRE_MEM_RASCIIZ( "openat(filename)", ARG2
);
5050 /* For absolute filenames, dfd is ignored. If dfd is AT_FDCWD,
5051 filename is relative to cwd. When comparing dfd against AT_FDCWD,
5052 be sure only to compare the bottom 32 bits. */
5053 if (ML_(safe_to_deref
)( (void*)ARG2
, 1 )
5054 && *(Char
*)ARG2
!= '/'
5055 && ((Int
)ARG1
) != ((Int
)VKI_AT_FDCWD
)
5056 && !ML_(fd_allowed
)(ARG1
, "openat", tid
, False
))
5057 SET_STATUS_Failure( VKI_EBADF
);
5059 /* Handle the case where the open is of /proc/self/cmdline or
5060 /proc/<pid>/cmdline, and just give it a copy of the fd for the
5061 fake file we cooked up at startup (in m_main). Also, seek the
5062 cloned fd back to the start. */
5064 VG_(sprintf
)(name
, "/proc/%d/cmdline", VG_(getpid
)());
5065 if (ML_(safe_to_deref
)( (void*)ARG2
, 1 )
5066 && (VG_(strcmp
)((HChar
*)ARG2
, name
) == 0
5067 || VG_(strcmp
)((HChar
*)ARG2
, "/proc/self/cmdline") == 0)) {
5068 sres
= VG_(dup
)( VG_(cl_cmdline_fd
) );
5069 SET_STATUS_from_SysRes( sres
);
5070 if (!sr_isError(sres
)) {
5071 OffT off
= VG_(lseek
)( sr_Res(sres
), 0, VKI_SEEK_SET
);
5073 SET_STATUS_Failure( VKI_EMFILE
);
5078 /* Do the same for /proc/self/auxv or /proc/<pid>/auxv case. */
5080 VG_(sprintf
)(name
, "/proc/%d/auxv", VG_(getpid
)());
5081 if (ML_(safe_to_deref
)( (void*)ARG2
, 1 )
5082 && (VG_(strcmp
)((HChar
*)ARG2
, name
) == 0
5083 || VG_(strcmp
)((HChar
*)ARG2
, "/proc/self/auxv") == 0)) {
5084 sres
= VG_(dup
)( VG_(cl_auxv_fd
) );
5085 SET_STATUS_from_SysRes( sres
);
5086 if (!sr_isError(sres
)) {
5087 OffT off
= VG_(lseek
)( sr_Res(sres
), 0, VKI_SEEK_SET
);
5089 SET_STATUS_Failure( VKI_EMFILE
);
5094 /* Otherwise handle normally */
5095 *flags
|= SfMayBlock
;
5101 if (!ML_(fd_allowed
)(RES
, "openat", tid
, True
)) {
5103 SET_STATUS_Failure( VKI_EMFILE
);
5105 if (VG_(clo_track_fds
))
5106 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG2
);
5112 *flags
|= SfMayBlock
;
5113 PRINT("sys_mkdirat ( %ld, %#lx(%s), %ld )",
5114 SARG1
, ARG2
, (HChar
*)ARG2
, SARG3
);
5115 PRE_REG_READ3(long, "mkdirat",
5116 int, dfd
, const char *, pathname
, int, mode
);
5117 PRE_MEM_RASCIIZ( "mkdirat(pathname)", ARG2
);
5122 PRINT("sys_mknodat ( %ld, %#lx(%s), 0x%lx, 0x%lx )",
5123 SARG1
, ARG2
, (HChar
*)ARG2
, ARG3
, ARG4
);
5124 PRE_REG_READ4(long, "mknodat",
5125 int, dfd
, const char *, pathname
, int, mode
, unsigned, dev
);
5126 PRE_MEM_RASCIIZ( "mknodat(pathname)", ARG2
);
5131 PRINT("sys_fchownat ( %ld, %#lx(%s), 0x%lx, 0x%lx )",
5132 SARG1
, ARG2
, (HChar
*)ARG2
, ARG3
, ARG4
);
5133 PRE_REG_READ4(long, "fchownat",
5134 int, dfd
, const char *, path
,
5135 vki_uid_t
, owner
, vki_gid_t
, group
);
5136 PRE_MEM_RASCIIZ( "fchownat(path)", ARG2
);
5141 PRINT("sys_futimesat ( %ld, %#lx(%s), %#lx )",
5142 SARG1
, ARG2
, (HChar
*)ARG2
, ARG3
);
5143 PRE_REG_READ3(long, "futimesat",
5144 int, dfd
, char *, filename
, struct timeval
*, tvp
);
5146 PRE_MEM_RASCIIZ( "futimesat(filename)", ARG2
);
5148 PRE_MEM_READ( "futimesat(tvp)", ARG3
, 2 * sizeof(struct vki_timeval
) );
5153 PRINT("sys_utimensat ( %ld, %#lx(%s), %#lx, 0x%lx )",
5154 SARG1
, ARG2
, (HChar
*)ARG2
, ARG3
, ARG4
);
5155 PRE_REG_READ4(long, "utimensat",
5156 int, dfd
, char *, filename
, struct timespec
*, utimes
, int, flags
);
5158 PRE_MEM_RASCIIZ( "utimensat(filename)", ARG2
);
5160 PRE_MEM_READ( "utimensat(tvp)", ARG3
, 2 * sizeof(struct vki_timespec
) );
5165 FUSE_COMPATIBLE_MAY_BLOCK();
5166 PRINT("sys_newfstatat ( %ld, %#lx(%s), %#lx )",
5167 SARG1
, ARG2
, (HChar
*)ARG2
, ARG3
);
5168 PRE_REG_READ3(long, "fstatat",
5169 int, dfd
, char *, file_name
, struct stat
*, buf
);
5170 PRE_MEM_RASCIIZ( "fstatat(file_name)", ARG2
);
5171 PRE_MEM_WRITE( "fstatat(buf)", ARG3
, sizeof(struct vki_stat
) );
5174 POST(sys_newfstatat
)
5176 POST_MEM_WRITE( ARG3
, sizeof(struct vki_stat
) );
5181 *flags
|= SfMayBlock
;
5182 PRINT("sys_unlinkat ( %ld, %#lx(%s) )", SARG1
, ARG2
, (HChar
*)ARG2
);
5183 PRE_REG_READ2(long, "unlinkat", int, dfd
, const char *, pathname
);
5184 PRE_MEM_RASCIIZ( "unlinkat(pathname)", ARG2
);
5189 PRINT("sys_renameat ( %ld, %#lx(%s), %ld, %#lx(%s) )",
5190 SARG1
, ARG2
, (HChar
*)ARG2
, SARG3
, ARG4
, (HChar
*)ARG4
);
5191 PRE_REG_READ4(long, "renameat",
5192 int, olddfd
, const char *, oldpath
,
5193 int, newdfd
, const char *, newpath
);
5194 PRE_MEM_RASCIIZ( "renameat(oldpath)", ARG2
);
5195 PRE_MEM_RASCIIZ( "renameat(newpath)", ARG4
);
5200 PRINT("sys_renameat2 ( %ld, %#lx(%s), %ld, %#lx(%s), %lu )",
5201 SARG1
, ARG2
, (HChar
*)ARG2
, SARG3
, ARG4
, (HChar
*)ARG4
, ARG5
);
5202 PRE_REG_READ5(long, "renameat2",
5203 int, olddfd
, const char *, oldpath
,
5204 int, newdfd
, const char *, newpath
,
5205 unsigned int, flags
);
5206 PRE_MEM_RASCIIZ( "renameat2(oldpath)", ARG2
);
5207 PRE_MEM_RASCIIZ( "renameat2(newpath)", ARG4
);
5212 *flags
|= SfMayBlock
;
5213 PRINT("sys_linkat ( %ld, %#lx(%s), %ld, %#lx(%s), %ld )",
5214 SARG1
, ARG2
, (HChar
*)ARG2
, SARG3
, ARG4
, (HChar
*)ARG4
, SARG5
);
5215 PRE_REG_READ5(long, "linkat",
5216 int, olddfd
, const char *, oldpath
,
5217 int, newdfd
, const char *, newpath
,
5219 PRE_MEM_RASCIIZ( "linkat(oldpath)", ARG2
);
5220 PRE_MEM_RASCIIZ( "linkat(newpath)", ARG4
);
5225 *flags
|= SfMayBlock
;
5226 PRINT("sys_symlinkat ( %#lx(%s), %ld, %#lx(%s) )",
5227 ARG1
, (HChar
*)ARG1
, SARG2
, ARG3
, (HChar
*)ARG3
);
5228 PRE_REG_READ3(long, "symlinkat",
5229 const char *, oldpath
, int, newdfd
, const char *, newpath
);
5230 PRE_MEM_RASCIIZ( "symlinkat(oldpath)", ARG1
);
5231 PRE_MEM_RASCIIZ( "symlinkat(newpath)", ARG3
);
5236 HChar name
[30]; // large enough
5239 PRINT("sys_readlinkat ( %ld, %#lx(%s), %#lx, %lu )",
5240 SARG1
, ARG2
, (HChar
*)ARG2
, ARG3
, ARG4
);
5241 PRE_REG_READ4(long, "readlinkat",
5242 int, dfd
, const char *, path
, char *, buf
, vki_size_t
, bufsiz
);
5243 PRE_MEM_RASCIIZ( "readlinkat(path)", ARG2
);
5244 PRE_MEM_WRITE( "readlinkat(buf)", ARG3
,ARG4
);
5247 * Handle the case where readlinkat is looking at /proc/self/exe or
5250 VG_(sprintf
)(name
, "/proc/%d/exe", VG_(getpid
)());
5251 if (ML_(safe_to_deref
)((void*)ARG2
, 1)
5252 && (VG_(strcmp
)((HChar
*)ARG2
, name
) == 0
5253 || VG_(strcmp
)((HChar
*)ARG2
, "/proc/self/exe") == 0)) {
5254 VG_(sprintf
)(name
, "/proc/self/fd/%d", VG_(cl_exec_fd
));
5255 SET_STATUS_from_SysRes( VG_(do_syscall4
)(saved
, ARG1
, (UWord
)name
,
5259 SET_STATUS_from_SysRes( VG_(do_syscall4
)(saved
, ARG1
, ARG2
, ARG3
, ARG4
));
5262 if (SUCCESS
&& RES
> 0)
5263 POST_MEM_WRITE( ARG3
, RES
);
5268 PRINT("sys_fchmodat ( %ld, %#lx(%s), %lu )",
5269 SARG1
, ARG2
, (HChar
*)ARG2
, ARG3
);
5270 PRE_REG_READ3(long, "fchmodat",
5271 int, dfd
, const char *, path
, vki_mode_t
, mode
);
5272 PRE_MEM_RASCIIZ( "fchmodat(path)", ARG2
);
5277 PRINT("sys_faccessat ( %ld, %#lx(%s), %ld )",
5278 SARG1
, ARG2
, (HChar
*)ARG2
, SARG3
);
5279 PRE_REG_READ3(long, "faccessat",
5280 int, dfd
, const char *, pathname
, int, mode
);
5281 PRE_MEM_RASCIIZ( "faccessat(pathname)", ARG2
);
5284 PRE(sys_name_to_handle_at
)
5286 PRINT("sys_name_to_handle_at ( %ld, %#lx(%s), %#lx, %#lx, %ld )",
5287 SARG1
, ARG2
, (HChar
*)ARG2
, ARG3
, ARG4
, SARG5
);
5288 PRE_REG_READ5(int, "name_to_handle_at",
5289 int, dfd
, const char *, name
,
5290 struct vki_file_handle
*, handle
,
5291 int *, mnt_id
, int, flag
);
5292 PRE_MEM_RASCIIZ( "name_to_handle_at(name)", ARG2
);
5293 if (ML_(safe_to_deref
)( (void*)ARG3
, sizeof(struct vki_file_handle
))) {
5294 struct vki_file_handle
*fh
= (struct vki_file_handle
*)ARG3
;
5295 PRE_MEM_READ( "name_to_handle_at(handle)", (Addr
)&fh
->handle_bytes
, sizeof(fh
->handle_bytes
) );
5296 PRE_MEM_WRITE( "name_to_handle_at(handle)", (Addr
)fh
, sizeof(struct vki_file_handle
) + fh
->handle_bytes
);
5298 PRE_MEM_WRITE( "name_to_handle_at(mnt_id)", ARG4
, sizeof(int) );
5301 POST(sys_name_to_handle_at
)
5303 struct vki_file_handle
*fh
= (struct vki_file_handle
*)ARG3
;
5304 POST_MEM_WRITE( ARG3
, sizeof(struct vki_file_handle
) + fh
->handle_bytes
);
5305 POST_MEM_WRITE( ARG4
, sizeof(int) );
5308 PRE(sys_open_by_handle_at
)
5310 *flags
|= SfMayBlock
;
5311 PRINT("sys_open_by_handle_at ( %ld, %#lx, %ld )", SARG1
, ARG2
, SARG3
);
5312 PRE_REG_READ3(int, "open_by_handle_at",
5314 struct vki_file_handle
*, handle
,
5316 PRE_MEM_READ( "open_by_handle_at(handle)", ARG2
, sizeof(struct vki_file_handle
) + ((struct vki_file_handle
*)ARG2
)->handle_bytes
);
5319 POST(sys_open_by_handle_at
)
5322 if (!ML_(fd_allowed
)(RES
, "open_by_handle_at", tid
, True
)) {
5324 SET_STATUS_Failure( VKI_EMFILE
);
5326 if (VG_(clo_track_fds
))
5327 ML_(record_fd_open_with_given_name
)(tid
, RES
, (HChar
*)ARG2
);
5331 /* ---------------------------------------------------------------------
5332 p{read,write}v wrappers
5333 ------------------------------------------------------------------ */
5338 struct vki_iovec
* vec
;
5339 *flags
|= SfMayBlock
;
5340 #if VG_WORDSIZE == 4
5341 /* Note that the offset argument here is in lo+hi order on both
5342 big and little endian platforms... */
5343 PRINT("sys_preadv ( %lu, %#lx, %lu, %lld )",
5344 ARG1
, ARG2
, ARG3
, (Long
)LOHI64(ARG4
,ARG5
));
5345 PRE_REG_READ5(ssize_t
, "preadv",
5346 unsigned long, fd
, const struct iovec
*, vector
,
5347 unsigned long, count
, vki_u32
, offset_low
,
5348 vki_u32
, offset_high
);
5349 #elif VG_WORDSIZE == 8
5350 PRINT("sys_preadv ( %lu, %#lx, %lu, %ld )", ARG1
, ARG2
, ARG3
, SARG4
);
5351 PRE_REG_READ4(ssize_t
, "preadv",
5352 unsigned long, fd
, const struct iovec
*, vector
,
5353 unsigned long, count
, Word
, offset
);
5355 # error Unexpected word size
5357 if (!ML_(fd_allowed
)(ARG1
, "preadv", tid
, False
)) {
5358 SET_STATUS_Failure( VKI_EBADF
);
5360 PRE_MEM_READ( "preadv(vector)", ARG2
, ARG3
* sizeof(struct vki_iovec
) );
5363 /* ToDo: don't do any of the following if the vector is invalid */
5364 vec
= (struct vki_iovec
*)ARG2
;
5365 for (i
= 0; i
< (Int
)ARG3
; i
++)
5366 PRE_MEM_WRITE( "preadv(vector[...])",
5367 (Addr
)vec
[i
].iov_base
, vec
[i
].iov_len
);
5377 struct vki_iovec
* vec
= (struct vki_iovec
*)ARG2
;
5380 /* RES holds the number of bytes read. */
5381 for (i
= 0; i
< (Int
)ARG3
; i
++) {
5382 Int nReadThisBuf
= vec
[i
].iov_len
;
5383 if (nReadThisBuf
> remains
) nReadThisBuf
= remains
;
5384 POST_MEM_WRITE( (Addr
)vec
[i
].iov_base
, nReadThisBuf
);
5385 remains
-= nReadThisBuf
;
5386 if (remains
< 0) VG_(core_panic
)("preadv: remains < 0");
5394 struct vki_iovec
* vec
;
5395 *flags
|= SfMayBlock
;
5396 #if VG_WORDSIZE == 4
5397 /* Note that the offset argument here is in lo+hi order on both
5398 big and little endian platforms... */
5399 PRINT("sys_pwritev ( %lu, %#lx, %lu, %lld )",
5400 ARG1
, ARG2
, ARG3
, (Long
)LOHI64(ARG4
,ARG5
));
5401 PRE_REG_READ5(ssize_t
, "pwritev",
5402 unsigned long, fd
, const struct iovec
*, vector
,
5403 unsigned long, count
, vki_u32
, offset_low
,
5404 vki_u32
, offset_high
);
5405 #elif VG_WORDSIZE == 8
5406 PRINT("sys_pwritev ( %lu, %#lx, %lu, %ld )", ARG1
, ARG2
, ARG3
, SARG4
);
5407 PRE_REG_READ4(ssize_t
, "pwritev",
5408 unsigned long, fd
, const struct iovec
*, vector
,
5409 unsigned long, count
, Word
, offset
);
5411 # error Unexpected word size
5413 if (!ML_(fd_allowed
)(ARG1
, "pwritev", tid
, False
)) {
5414 SET_STATUS_Failure( VKI_EBADF
);
5416 PRE_MEM_READ( "pwritev(vector)",
5417 ARG2
, ARG3
* sizeof(struct vki_iovec
) );
5419 /* ToDo: don't do any of the following if the vector is invalid */
5420 vec
= (struct vki_iovec
*)ARG2
;
5421 for (i
= 0; i
< (Int
)ARG3
; i
++)
5422 PRE_MEM_READ( "pwritev(vector[...])",
5423 (Addr
)vec
[i
].iov_base
, vec
[i
].iov_len
);
5428 /* ---------------------------------------------------------------------
5429 process_vm_{read,write}v wrappers
5430 ------------------------------------------------------------------ */
5432 PRE(sys_process_vm_readv
)
5434 PRINT("sys_process_vm_readv ( %ld, %#lx, %lu, %#lx, %lu, %lu )",
5435 SARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
5436 PRE_REG_READ6(ssize_t
, "process_vm_readv",
5438 const struct iovec
*, lvec
,
5439 unsigned long, liovcnt
,
5440 const struct iovec
*, rvec
,
5441 unsigned long, riovcnt
,
5442 unsigned long, flags
);
5443 PRE_MEM_READ( "process_vm_readv(lvec)",
5444 ARG2
, ARG3
* sizeof(struct vki_iovec
) );
5445 PRE_MEM_READ( "process_vm_readv(rvec)",
5446 ARG4
, ARG5
* sizeof(struct vki_iovec
) );
5448 && ML_(safe_to_deref
) ((void *)ARG2
, sizeof(struct vki_iovec
) * ARG3
)) {
5449 const struct vki_iovec
*vec
= (const struct vki_iovec
*)ARG2
;
5451 for (i
= 0; i
< ARG3
; i
++)
5452 PRE_MEM_WRITE( "process_vm_readv(lvec[...])",
5453 (Addr
)vec
[i
].iov_base
, vec
[i
].iov_len
);
5457 POST(sys_process_vm_readv
)
5459 const struct vki_iovec
*vec
= (const struct vki_iovec
*)ARG2
;
5462 for (i
= 0; i
< ARG3
; i
++) {
5463 UInt nReadThisBuf
= vec
[i
].iov_len
<= remains
?
5464 vec
[i
].iov_len
: remains
;
5465 POST_MEM_WRITE( (Addr
)vec
[i
].iov_base
, nReadThisBuf
);
5466 remains
-= nReadThisBuf
;
5470 PRE(sys_process_vm_writev
)
5472 PRINT("sys_process_vm_writev ( %ld, %#lx, %lu, %#lx, %lu, %lu )",
5473 SARG1
, ARG2
, ARG3
, ARG4
, ARG5
, ARG6
);
5474 PRE_REG_READ6(ssize_t
, "process_vm_writev",
5476 const struct iovec
*, lvec
,
5477 unsigned long, liovcnt
,
5478 const struct iovec
*, rvec
,
5479 unsigned long, riovcnt
,
5480 unsigned long, flags
);
5481 PRE_MEM_READ( "process_vm_writev(lvec)",
5482 ARG2
, ARG3
* sizeof(struct vki_iovec
) );
5483 PRE_MEM_READ( "process_vm_writev(rvec)",
5484 ARG4
, ARG5
* sizeof(struct vki_iovec
) );
5486 && ML_(safe_to_deref
) ((void *)ARG2
, sizeof(struct vki_iovec
) * ARG3
)) {
5487 const struct vki_iovec
*vec
= (const struct vki_iovec
*)ARG2
;
5489 for (i
= 0; i
< ARG3
; i
++)
5490 PRE_MEM_READ( "process_vm_writev(lvec[...])",
5491 (Addr
)vec
[i
].iov_base
, vec
[i
].iov_len
);
5495 /* ---------------------------------------------------------------------
5496 {send,recv}mmsg wrappers
5497 ------------------------------------------------------------------ */
5501 *flags
|= SfMayBlock
;
5502 PRINT("sys_sendmmsg ( %ld, %#lx, %ld, %ld )", SARG1
, ARG2
, SARG3
, SARG4
);
5503 PRE_REG_READ4(long, "sendmmsg",
5504 int, s
, const struct mmsghdr
*, mmsg
, int, vlen
, int, flags
);
5505 ML_(linux_PRE_sys_sendmmsg
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
);
5510 ML_(linux_POST_sys_sendmmsg
) (tid
, RES
, ARG1
,ARG2
,ARG3
,ARG4
);
5515 *flags
|= SfMayBlock
;
5516 PRINT("sys_recvmmsg ( %ld, %#lx, %ld, %ld, %#lx )",
5517 SARG1
, ARG2
, SARG3
, SARG4
, ARG5
);
5518 PRE_REG_READ5(long, "recvmmsg",
5519 int, s
, struct mmsghdr
*, mmsg
, int, vlen
,
5520 int, flags
, struct timespec
*, timeout
);
5521 ML_(linux_PRE_sys_recvmmsg
)(tid
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
5526 ML_(linux_POST_sys_recvmmsg
) (tid
, RES
, ARG1
,ARG2
,ARG3
,ARG4
,ARG5
);
5529 /* ---------------------------------------------------------------------
5530 key retention service wrappers
5531 ------------------------------------------------------------------ */
5533 PRE(sys_request_key
)
5535 PRINT("sys_request_key ( %#lx(%s), %#lx(%s), %#lx(%s), %ld )",
5536 ARG1
, (HChar
*)ARG1
, ARG2
, (HChar
*)ARG2
, ARG3
, (HChar
*)ARG3
, SARG4
);
5537 PRE_REG_READ4(long, "request_key",
5538 const char *, type
, const char *, description
,
5539 const char *, callout_info
, vki_key_serial_t
, keyring
);
5540 PRE_MEM_RASCIIZ( "request_key(type)", ARG1
);
5541 PRE_MEM_RASCIIZ( "request_key(description)", ARG2
);
5542 if (ARG3
!= (UWord
)NULL
)
5543 PRE_MEM_RASCIIZ( "request_key(callout_info)", ARG3
);
5548 PRINT("sys_add_key ( %#lx(%s), %#lx(%s), %#lx, %lu, %ld )",
5549 ARG1
, (HChar
*)ARG1
, ARG2
, (HChar
*)ARG2
, ARG3
, ARG4
, SARG5
);
5550 PRE_REG_READ5(long, "add_key",
5551 const char *, type
, const char *, description
,
5552 const void *, payload
, vki_size_t
, plen
,
5553 vki_key_serial_t
, keyring
);
5554 PRE_MEM_RASCIIZ( "add_key(type)", ARG1
);
5555 PRE_MEM_RASCIIZ( "add_key(description)", ARG2
);
5556 if (ARG3
!= (UWord
)NULL
)
5557 PRE_MEM_READ( "request_key(payload)", ARG3
, ARG4
);
5562 switch (ARG1
/* option */) {
5563 case VKI_KEYCTL_GET_KEYRING_ID
:
5564 PRINT("sys_keyctl ( KEYCTL_GET_KEYRING_ID, %ld, %ld )", SARG2
, SARG3
);
5565 PRE_REG_READ3(long, "keyctl(KEYCTL_GET_KEYRING_ID)",
5566 int, option
, vki_key_serial_t
, id
, int, create
);
5568 case VKI_KEYCTL_JOIN_SESSION_KEYRING
:
5569 PRINT("sys_keyctl ( KEYCTL_JOIN_SESSION_KEYRING, %#lx(%s) )", ARG2
,(char*)ARG2
);
5570 PRE_REG_READ2(long, "keyctl(KEYCTL_JOIN_SESSION_KEYRING)",
5571 int, option
, const char *, name
);
5572 if (ARG2
!= (UWord
)NULL
)
5573 PRE_MEM_RASCIIZ("keyctl(KEYCTL_JOIN_SESSION_KEYRING, name)", ARG2
);
5575 case VKI_KEYCTL_UPDATE
:
5576 PRINT("sys_keyctl ( KEYCTL_UPDATE, %ld, %#lx, %lu )", SARG2
, ARG3
, ARG4
);
5577 PRE_REG_READ4(long, "keyctl(KEYCTL_UPDATE)",
5578 int, option
, vki_key_serial_t
, key
,
5579 const void *, payload
, vki_size_t
, plen
);
5580 if (ARG3
!= (UWord
)NULL
)
5581 PRE_MEM_READ("keyctl(KEYCTL_UPDATE, payload)", ARG3
, ARG4
);
5583 case VKI_KEYCTL_REVOKE
:
5584 PRINT("sys_keyctl ( KEYCTL_REVOKE, %ld )", SARG2
);
5585 PRE_REG_READ2(long, "keyctl(KEYCTL_REVOKE)",
5586 int, option
, vki_key_serial_t
, id
);
5588 case VKI_KEYCTL_CHOWN
:
5589 PRINT("sys_keyctl ( KEYCTL_CHOWN, %ld, %lu, %lu )", SARG2
, ARG3
, ARG4
);
5590 PRE_REG_READ4(long, "keyctl(KEYCTL_CHOWN)",
5591 int, option
, vki_key_serial_t
, id
,
5592 vki_uid_t
, uid
, vki_gid_t
, gid
);
5594 case VKI_KEYCTL_SETPERM
:
5595 PRINT("sys_keyctl ( KEYCTL_SETPERM, %ld, %lu )", SARG2
, ARG3
);
5596 PRE_REG_READ3(long, "keyctl(KEYCTL_SETPERM)",
5597 int, option
, vki_key_serial_t
, id
, vki_key_perm_t
, perm
);
5599 case VKI_KEYCTL_DESCRIBE
:
5600 PRINT("sys_keyctl ( KEYCTL_DESCRIBE, %ld, %#lx, %lu )", SARG2
, ARG3
, ARG4
);
5601 PRE_REG_READ4(long, "keyctl(KEYCTL_DESCRIBE)",
5602 int, option
, vki_key_serial_t
, id
,
5603 char *, buffer
, vki_size_t
, buflen
);
5604 if (ARG3
!= (UWord
)NULL
)
5605 PRE_MEM_WRITE("keyctl(KEYCTL_DESCRIBE, buffer)", ARG3
, ARG4
);
5607 case VKI_KEYCTL_CLEAR
:
5608 PRINT("sys_keyctl ( KEYCTL_CLEAR, %ld )", SARG2
);
5609 PRE_REG_READ2(long, "keyctl(KEYCTL_CLEAR)",
5610 int, option
, vki_key_serial_t
, keyring
);
5612 case VKI_KEYCTL_LINK
:
5613 PRINT("sys_keyctl ( KEYCTL_LINK, %ld, %ld )", SARG2
, SARG3
);
5614 PRE_REG_READ3(long, "keyctl(KEYCTL_LINK)", int, option
,
5615 vki_key_serial_t
, keyring
, vki_key_serial_t
, key
);
5617 case VKI_KEYCTL_UNLINK
:
5618 PRINT("sys_keyctl ( KEYCTL_UNLINK, %ld, %ld )", SARG2
, SARG3
);
5619 PRE_REG_READ3(long, "keyctl(KEYCTL_UNLINK)", int, option
,
5620 vki_key_serial_t
, keyring
, vki_key_serial_t
, key
);
5622 case VKI_KEYCTL_SEARCH
:
5623 PRINT("sys_keyctl ( KEYCTL_SEARCH, %ld, %#lx(%s), %#lx(%s), %ld )",
5624 SARG2
, ARG3
, (HChar
*)ARG3
, ARG4
, (HChar
*)ARG4
, SARG5
);
5625 PRE_REG_READ5(long, "keyctl(KEYCTL_SEARCH)",
5626 int, option
, vki_key_serial_t
, keyring
,
5627 const char *, type
, const char *, description
,
5628 vki_key_serial_t
, destring
);
5629 PRE_MEM_RASCIIZ("sys_keyctl(KEYCTL_SEARCH, type)", ARG3
);
5630 PRE_MEM_RASCIIZ("sys_keyctl(KEYCTL_SEARCH, description)", ARG4
);
5632 case VKI_KEYCTL_READ
:
5633 PRINT("sys_keyctl ( KEYCTL_READ, %ld, %#lx, %lu )", SARG2
, ARG3
, ARG4
);
5634 PRE_REG_READ4(long, "keyctl(KEYCTL_READ)",
5635 int, option
, vki_key_serial_t
, keyring
,
5636 char *, buffer
, vki_size_t
, buflen
);
5637 if (ARG3
!= (UWord
)NULL
)
5638 PRE_MEM_WRITE("keyctl(KEYCTL_READ, buffer)", ARG3
, ARG4
);
5640 case VKI_KEYCTL_INSTANTIATE
:
5641 PRINT("sys_keyctl ( KEYCTL_INSTANTIATE, %ld, %#lx, %lu, %ld )",
5642 SARG2
, ARG3
, ARG4
, SARG5
);
5643 PRE_REG_READ5(long, "keyctl(KEYCTL_INSTANTIATE)",
5644 int, option
, vki_key_serial_t
, key
,
5645 char *, payload
, vki_size_t
, plen
,
5646 vki_key_serial_t
, keyring
);
5647 if (ARG3
!= (UWord
)NULL
)
5648 PRE_MEM_READ("keyctl(KEYCTL_INSTANTIATE, payload)", ARG3
, ARG4
);
5650 case VKI_KEYCTL_NEGATE
:
5651 PRINT("sys_keyctl ( KEYCTL_NEGATE, %ld, %lu, %ld )", SARG2
, ARG3
, SARG4
);
5652 PRE_REG_READ4(long, "keyctl(KEYCTL_NEGATE)",
5653 int, option
, vki_key_serial_t
, key
,
5654 unsigned, timeout
, vki_key_serial_t
, keyring
);
5656 case VKI_KEYCTL_SET_REQKEY_KEYRING
:
5657 PRINT("sys_keyctl ( KEYCTL_SET_REQKEY_KEYRING, %ld )", SARG2
);
5658 PRE_REG_READ2(long, "keyctl(KEYCTL_SET_REQKEY_KEYRING)",
5659 int, option
, int, reqkey_defl
);
5661 case VKI_KEYCTL_SET_TIMEOUT
:
5662 PRINT("sys_keyctl ( KEYCTL_SET_TIMEOUT, %ld, %lu )", SARG2
, ARG3
);
5663 PRE_REG_READ3(long, "keyctl(KEYCTL_SET_TIMEOUT)",
5664 int, option
, vki_key_serial_t
, key
, unsigned, timeout
);
5666 case VKI_KEYCTL_ASSUME_AUTHORITY
:
5667 PRINT("sys_keyctl ( KEYCTL_ASSUME_AUTHORITY, %ld )", SARG2
);
5668 PRE_REG_READ2(long, "keyctl(KEYCTL_ASSUME_AUTHORITY)",
5669 int, option
, vki_key_serial_t
, key
);
5672 PRINT("sys_keyctl ( %ld ) ", SARG1
);
5673 PRE_REG_READ1(long, "keyctl", int, option
);
5681 switch (ARG1
/* option */) {
5682 case VKI_KEYCTL_DESCRIBE
:
5683 case VKI_KEYCTL_READ
:
5685 POST_MEM_WRITE(ARG3
, ARG4
);
5687 POST_MEM_WRITE(ARG3
, RES
);
5694 /* ---------------------------------------------------------------------
5696 ------------------------------------------------------------------ */
5700 PRINT("sys_ioprio_set ( %ld, %ld, %ld )", SARG1
, SARG2
, SARG3
);
5701 PRE_REG_READ3(int, "ioprio_set", int, which
, int, who
, int, ioprio
);
5706 PRINT("sys_ioprio_get ( %ld, %ld )", SARG1
, SARG2
);
5707 PRE_REG_READ2(int, "ioprio_get", int, which
, int, who
);
5710 /* ---------------------------------------------------------------------
5712 ------------------------------------------------------------------ */
5714 PRE(sys_init_module
)
5716 *flags
|= SfMayBlock
;
5717 PRINT("sys_init_module ( %#lx, %lu, %#lx(\"%s\") )",
5718 ARG1
, ARG2
, ARG3
, (HChar
*)ARG3
);
5719 PRE_REG_READ3(long, "init_module",
5720 void *, umod
, unsigned long, len
, const char *, uargs
);
5721 PRE_MEM_READ( "init_module(umod)", ARG1
, ARG2
);
5722 PRE_MEM_RASCIIZ( "init_module(uargs)", ARG3
);
5725 PRE(sys_finit_module
)
5727 *flags
|= SfMayBlock
;
5729 PRINT("sys_finit_module ( %lx, %#lx(\"%s\"), %lx )",
5730 ARG1
, ARG2
, (HChar
*)ARG2
, ARG3
);
5731 PRE_REG_READ3(long, "finit_module",
5732 int, fd
, const char *, params
, int, flags
);
5733 PRE_MEM_RASCIIZ("finit_module(params)", ARG2
);
5736 PRE(sys_delete_module
)
5738 *flags
|= SfMayBlock
;
5739 PRINT("sys_delete_module ( %#lx(\"%s\"), 0x%lx )", ARG1
, (HChar
*)ARG1
, ARG2
);
5740 PRE_REG_READ2(long, "delete_module",
5741 const char *, name_user
, unsigned int, flags
);
5742 PRE_MEM_RASCIIZ("delete_module(name_user)", ARG1
);
5745 /* ---------------------------------------------------------------------
5747 ------------------------------------------------------------------ */
5751 *flags
|= SfMayBlock
;
5752 PRINT("sys_splice ( %ld, %#lx, %ld, %#lx, %lu, %#lx )",
5753 SARG1
, ARG2
, SARG3
, ARG4
, ARG5
, ARG6
);
5754 PRE_REG_READ6(vki_ssize_t
, "splice",
5755 int, fd_in
, vki_loff_t
*, off_in
,
5756 int, fd_out
, vki_loff_t
*, off_out
,
5757 vki_size_t
, len
, unsigned int, flags
);
5758 if (!ML_(fd_allowed
)(ARG1
, "splice(fd_in)", tid
, False
) ||
5759 !ML_(fd_allowed
)(ARG3
, "splice(fd_out)", tid
, False
)) {
5760 SET_STATUS_Failure( VKI_EBADF
);
5763 PRE_MEM_READ( "splice(off_in)", ARG2
, sizeof(vki_loff_t
));
5765 PRE_MEM_READ( "splice(off_out)", ARG4
, sizeof(vki_loff_t
));
5771 *flags
|= SfMayBlock
;
5772 PRINT("sys_tree ( %ld, %ld, %lu, %#lx )", SARG1
, SARG2
, ARG3
, ARG4
);
5773 PRE_REG_READ4(vki_ssize_t
, "tee",
5774 int, fd_in
, int, fd_out
,
5775 vki_size_t
, len
, unsigned int, flags
);
5776 if (!ML_(fd_allowed
)(ARG1
, "tee(fd_in)", tid
, False
) ||
5777 !ML_(fd_allowed
)(ARG2
, "tee(fd_out)", tid
, False
)) {
5778 SET_STATUS_Failure( VKI_EBADF
);
5785 *flags
|= SfMayBlock
;
5786 PRINT("sys_vmsplice ( %ld, %#lx, %lu, %lu )", SARG1
, ARG2
, ARG3
, ARG4
);
5787 PRE_REG_READ4(vki_ssize_t
, "splice",
5788 int, fd
, struct vki_iovec
*, iov
,
5789 unsigned long, nr_segs
, unsigned int, flags
);
5790 if (!ML_(fd_allowed
)(ARG1
, "vmsplice(fd)", tid
, False
)) {
5791 SET_STATUS_Failure( VKI_EBADF
);
5792 } else if ((fdfl
= VG_(fcntl
)(ARG1
, VKI_F_GETFL
, 0)) < 0) {
5793 SET_STATUS_Failure( VKI_EBADF
);
5795 const struct vki_iovec
*iov
;
5796 PRE_MEM_READ( "vmsplice(iov)", ARG2
, sizeof(struct vki_iovec
) * ARG3
);
5797 for (iov
= (struct vki_iovec
*)ARG2
;
5798 iov
< (struct vki_iovec
*)ARG2
+ ARG3
; iov
++)
5800 if (ML_(safe_to_deref
) (iov
, sizeof(struct vki_iovec
))) {
5801 if ((fdfl
& VKI_O_ACCMODE
) == VKI_O_RDONLY
)
5802 PRE_MEM_WRITE( "vmsplice(iov[...])",
5803 (Addr
)iov
->iov_base
, iov
->iov_len
);
5805 PRE_MEM_READ( "vmsplice(iov[...])",
5806 (Addr
)iov
->iov_base
, iov
->iov_len
);
5816 Int fdfl
= VG_(fcntl
)(ARG1
, VKI_F_GETFL
, 0);
5817 vg_assert(fdfl
>= 0);
5818 if ((fdfl
& VKI_O_ACCMODE
) == VKI_O_RDONLY
)
5820 const struct vki_iovec
*iov
;
5821 for (iov
= (struct vki_iovec
*)ARG2
;
5822 iov
< (struct vki_iovec
*)ARG2
+ ARG3
; iov
++)
5824 POST_MEM_WRITE( (Addr
)iov
->iov_base
, iov
->iov_len
);
5830 /* ---------------------------------------------------------------------
5831 oprofile-related wrappers
5832 ------------------------------------------------------------------ */
5834 #if defined(VGP_x86_linux)
5835 PRE(sys_lookup_dcookie
)
5837 PRINT("sys_lookup_dcookie (0x%llx, %#lx, %lu)",
5838 MERGE64(ARG1
,ARG2
), ARG3
, ARG4
);
5839 PRE_REG_READ4(long, "lookup_dcookie",
5840 vki_u32
, MERGE64_FIRST(cookie
), vki_u32
, MERGE64_SECOND(cookie
),
5841 char *, buf
, vki_size_t
, len
);
5842 PRE_MEM_WRITE( "lookup_dcookie(buf)", ARG3
, ARG4
);
5844 POST(sys_lookup_dcookie
)
5847 if (ARG3
!= (Addr
)NULL
)
5848 POST_MEM_WRITE( ARG3
, RES
);
5852 #if defined(VGP_amd64_linux) || defined(VGP_s390x_linux) \
5853 || defined(VGP_arm64_linux)
5854 PRE(sys_lookup_dcookie
)
5856 *flags
|= SfMayBlock
;
5857 PRINT("sys_lookup_dcookie ( %lu, %#lx, %lu )", ARG1
, ARG2
, ARG3
);
5858 PRE_REG_READ3(int, "lookup_dcookie",
5859 unsigned long long, cookie
, char *, buf
, vki_size_t
, len
);
5861 PRE_MEM_WRITE( "sys_lookup_dcookie(buf)", ARG2
, ARG3
);
5864 POST(sys_lookup_dcookie
)
5867 if (ARG2
!= (Addr
)NULL
)
5868 POST_MEM_WRITE( ARG2
, RES
);
5872 /* ---------------------------------------------------------------------
5874 ------------------------------------------------------------------ */
5879 // These ones ignore ARG3.
5884 case VKI_F_GETLEASE
:
5885 case VKI_F_GETPIPE_SZ
:
5886 PRINT("sys_fcntl ( %lu, %lu )", ARG1
, ARG2
);
5887 PRE_REG_READ2(long, "fcntl", unsigned int, fd
, unsigned int, cmd
);
5890 // These ones use ARG3 as "arg".
5892 case VKI_F_DUPFD_CLOEXEC
:
5895 case VKI_F_SETLEASE
:
5899 case VKI_F_SETPIPE_SZ
:
5900 PRINT("sys_fcntl[ARG3=='arg'] ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
5901 PRE_REG_READ3(long, "fcntl",
5902 unsigned int, fd
, unsigned int, cmd
, unsigned long, arg
);
5905 // These ones use ARG3 as "lock".
5909 case VKI_F_OFD_GETLK
:
5910 case VKI_F_OFD_SETLK
:
5911 case VKI_F_OFD_SETLKW
:
5912 PRINT("sys_fcntl[ARG3=='lock'] ( %lu, %lu, %#lx )", ARG1
, ARG2
, ARG3
);
5913 PRE_REG_READ3(long, "fcntl",
5914 unsigned int, fd
, unsigned int, cmd
,
5915 struct vki_flock
*, lock
);
5917 struct vki_flock
*lock
= (struct vki_flock
*) ARG3
;
5918 PRE_FIELD_READ("fcntl(lock->l_type)", lock
->l_type
);
5919 PRE_FIELD_READ("fcntl(lock->l_whence)", lock
->l_whence
);
5920 PRE_FIELD_READ("fcntl(lock->l_start)", lock
->l_start
);
5921 PRE_FIELD_READ("fcntl(lock->l_len)", lock
->l_len
);
5922 if (ARG2
== VKI_F_GETLK
|| ARG2
== VKI_F_OFD_GETLK
) {
5923 PRE_FIELD_WRITE("fcntl(lock->l_pid)", lock
->l_pid
);
5928 # if defined(VGP_x86_linux) || defined(VGP_mips64_linux)
5931 case VKI_F_SETLKW64
:
5932 PRINT("sys_fcntl[ARG3=='lock'] ( %lu, %lu, %#lx )", ARG1
, ARG2
, ARG3
);
5933 PRE_REG_READ3(long, "fcntl",
5934 unsigned int, fd
, unsigned int, cmd
,
5935 struct flock64
*, lock
);
5937 struct vki_flock64
*lock
= (struct vki_flock64
*) ARG3
;
5938 PRE_FIELD_READ("fcntl(lock->l_type)", lock
->l_type
);
5939 PRE_FIELD_READ("fcntl(lock->l_whence)", lock
->l_whence
);
5940 PRE_FIELD_READ("fcntl(lock->l_start)", lock
->l_start
);
5941 PRE_FIELD_READ("fcntl(lock->l_len)", lock
->l_len
);
5942 if (ARG2
== VKI_F_GETLK64
) {
5943 PRE_FIELD_WRITE("fcntl(lock->l_pid)", lock
->l_pid
);
5949 case VKI_F_SETOWN_EX
:
5950 PRINT("sys_fcntl[F_SETOWN_EX] ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
5951 PRE_REG_READ3(long, "fcntl",
5952 unsigned int, fd
, unsigned int, cmd
,
5953 struct vki_f_owner_ex
*, arg
);
5954 PRE_MEM_READ("fcntl(F_SETOWN_EX)", ARG3
, sizeof(struct vki_f_owner_ex
));
5957 case VKI_F_GETOWN_EX
:
5958 PRINT("sys_fcntl[F_GETOWN_EX] ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
5959 PRE_REG_READ3(long, "fcntl",
5960 unsigned int, fd
, unsigned int, cmd
,
5961 struct vki_f_owner_ex
*, arg
);
5962 PRE_MEM_WRITE("fcntl(F_GETOWN_EX)", ARG3
, sizeof(struct vki_f_owner_ex
));
5966 PRINT("sys_fcntl[UNKNOWN] ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
5967 VG_(umsg
)("Warning: unimplemented fcntl command: %lu\n", ARG2
);
5968 SET_STATUS_Failure( VKI_EINVAL
);
5972 # if defined(VGP_x86_linux)
5973 if (ARG2
== VKI_F_SETLKW
|| ARG2
== VKI_F_SETLKW64
)
5975 if (ARG2
== VKI_F_SETLKW
)
5977 *flags
|= SfMayBlock
;
5983 if (ARG2
== VKI_F_DUPFD
) {
5984 if (!ML_(fd_allowed
)(RES
, "fcntl(DUPFD)", tid
, True
)) {
5986 SET_STATUS_Failure( VKI_EMFILE
);
5988 if (VG_(clo_track_fds
))
5989 ML_(record_fd_open_named
)(tid
, RES
);
5992 else if (ARG2
== VKI_F_DUPFD_CLOEXEC
) {
5993 if (!ML_(fd_allowed
)(RES
, "fcntl(DUPFD_CLOEXEC)", tid
, True
)) {
5995 SET_STATUS_Failure( VKI_EMFILE
);
5997 if (VG_(clo_track_fds
))
5998 ML_(record_fd_open_named
)(tid
, RES
);
6000 } else if (ARG2
== VKI_F_GETOWN_EX
) {
6001 POST_MEM_WRITE(ARG3
, sizeof(struct vki_f_owner_ex
));
6002 } else if (ARG2
== VKI_F_GETLK
|| ARG2
== VKI_F_OFD_GETLK
) {
6003 struct vki_flock
*lock
= (struct vki_flock
*) ARG3
;
6004 POST_FIELD_WRITE(lock
->l_pid
);
6005 # if defined(VGP_x86_linux) || defined(VGP_mips64_linux)
6006 } else if (ARG2
== VKI_F_GETLK64
) {
6007 struct vki_flock64
*lock
= (struct vki_flock64
*) ARG3
;
6008 PRE_FIELD_WRITE("fcntl(lock->l_pid)", lock
->l_pid
);
6013 // XXX: wrapper only suitable for 32-bit systems
6017 // These ones ignore ARG3.
6024 case VKI_F_GETLEASE
:
6025 PRINT("sys_fcntl64 ( %lu, %lu )", ARG1
, ARG2
);
6026 PRE_REG_READ2(long, "fcntl64", unsigned int, fd
, unsigned int, cmd
);
6029 // These ones use ARG3 as "arg".
6031 case VKI_F_DUPFD_CLOEXEC
:
6034 case VKI_F_SETLEASE
:
6036 PRINT("sys_fcntl64[ARG3=='arg'] ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
6037 PRE_REG_READ3(long, "fcntl64",
6038 unsigned int, fd
, unsigned int, cmd
, unsigned long, arg
);
6041 // These ones use ARG3 as "lock".
6045 # if defined(VGP_x86_linux)
6048 case VKI_F_SETLKW64
:
6050 case VKI_F_OFD_GETLK
:
6051 case VKI_F_OFD_SETLK
:
6052 case VKI_F_OFD_SETLKW
:
6053 PRINT("sys_fcntl64[ARG3=='lock'] ( %lu, %lu, %#lx )", ARG1
, ARG2
, ARG3
);
6054 PRE_REG_READ3(long, "fcntl64",
6055 unsigned int, fd
, unsigned int, cmd
,
6056 struct flock64
*, lock
);
6059 case VKI_F_SETOWN_EX
:
6060 PRINT("sys_fcntl[F_SETOWN_EX] ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
6061 PRE_REG_READ3(long, "fcntl",
6062 unsigned int, fd
, unsigned int, cmd
,
6063 struct vki_f_owner_ex
*, arg
);
6064 PRE_MEM_READ("fcntl(F_SETOWN_EX)", ARG3
, sizeof(struct vki_f_owner_ex
));
6067 case VKI_F_GETOWN_EX
:
6068 PRINT("sys_fcntl[F_GETOWN_EX] ( %lu, %lu, %lu )", ARG1
, ARG2
, ARG3
);
6069 PRE_REG_READ3(long, "fcntl",
6070 unsigned int, fd
, unsigned int, cmd
,
6071 struct vki_f_owner_ex
*, arg
);
6072 PRE_MEM_WRITE("fcntl(F_GETOWN_EX)", ARG3
, sizeof(struct vki_f_owner_ex
));
6076 # if defined(VGP_x86_linux)
6077 if (ARG2
== VKI_F_SETLKW
|| ARG2
== VKI_F_SETLKW64
)
6079 if (ARG2
== VKI_F_SETLKW
)
6081 *flags
|= SfMayBlock
;
6087 if (ARG2
== VKI_F_DUPFD
) {
6088 if (!ML_(fd_allowed
)(RES
, "fcntl64(DUPFD)", tid
, True
)) {
6090 SET_STATUS_Failure( VKI_EMFILE
);
6092 if (VG_(clo_track_fds
))
6093 ML_(record_fd_open_named
)(tid
, RES
);
6096 else if (ARG2
== VKI_F_DUPFD_CLOEXEC
) {
6097 if (!ML_(fd_allowed
)(RES
, "fcntl64(DUPFD_CLOEXEC)", tid
, True
)) {
6099 SET_STATUS_Failure( VKI_EMFILE
);
6101 if (VG_(clo_track_fds
))
6102 ML_(record_fd_open_named
)(tid
, RES
);
6104 } else if (ARG2
== VKI_F_GETOWN_EX
) {
6105 POST_MEM_WRITE(ARG3
, sizeof(struct vki_f_owner_ex
));
6109 /* ---------------------------------------------------------------------
6111 ------------------------------------------------------------------ */
6113 struct vg_drm_version_info
{
6114 struct vki_drm_version data
;
6115 struct vki_drm_version
*orig
; // Original ARG3 pointer value at syscall entry.
6120 *flags
|= SfMayBlock
;
6124 // We first handle the ones that don't use ARG3 (even as a
6125 // scalar/non-pointer argument).
6126 switch (ARG2
/* request */) {
6128 /* asm-generic/ioctls.h */
6133 /* linux perf_event ioctls */
6134 case VKI_PERF_EVENT_IOC_ENABLE
:
6135 case VKI_PERF_EVENT_IOC_DISABLE
:
6137 /* linux/soundcard interface (ALSA) */
6138 case VKI_SNDRV_PCM_IOCTL_HW_FREE
:
6139 case VKI_SNDRV_PCM_IOCTL_HWSYNC
:
6140 case VKI_SNDRV_PCM_IOCTL_PREPARE
:
6141 case VKI_SNDRV_PCM_IOCTL_RESET
:
6142 case VKI_SNDRV_PCM_IOCTL_START
:
6143 case VKI_SNDRV_PCM_IOCTL_DROP
:
6144 case VKI_SNDRV_PCM_IOCTL_DRAIN
:
6145 case VKI_SNDRV_PCM_IOCTL_RESUME
:
6146 case VKI_SNDRV_PCM_IOCTL_XRUN
:
6147 case VKI_SNDRV_PCM_IOCTL_UNLINK
:
6148 case VKI_SNDRV_TIMER_IOCTL_START
:
6149 case VKI_SNDRV_TIMER_IOCTL_STOP
:
6150 case VKI_SNDRV_TIMER_IOCTL_CONTINUE
:
6151 case VKI_SNDRV_TIMER_IOCTL_PAUSE
:
6153 /* SCSI no operand */
6154 case VKI_SCSI_IOCTL_DOORLOCK
:
6155 case VKI_SCSI_IOCTL_DOORUNLOCK
:
6158 case VKI_CDROM_DISC_STATUS
:
6162 case VKI_DVD_READ_STRUCT
:
6164 /* KVM ioctls that don't check for a numeric value as parameter */
6165 case VKI_KVM_S390_ENABLE_SIE
:
6166 case VKI_KVM_CREATE_IRQCHIP
:
6167 case VKI_KVM_S390_INITIAL_RESET
:
6168 case VKI_KVM_KVMCLOCK_CTRL
:
6170 /* vhost without parameter */
6171 case VKI_VHOST_SET_OWNER
:
6172 case VKI_VHOST_RESET_OWNER
:
6174 /* User input device creation */
6175 case VKI_UI_DEV_CREATE
:
6176 case VKI_UI_DEV_DESTROY
:
6179 case VKI_IB_USER_MAD_ENABLE_PKEY
:
6182 case VKI_LL_IOC_GROUP_LOCK
:
6183 case VKI_LL_IOC_GROUP_UNLOCK
:
6186 case VKI_V4L2_LOG_STATUS
:
6190 PRINT("sys_ioctl ( %lu, 0x%lx )", ARG1
, ARG2
);
6191 PRE_REG_READ2(long, "ioctl",
6192 unsigned int, fd
, unsigned int, request
);
6196 PRINT("sys_ioctl ( %lu, 0x%lx, 0x%lx )", ARG1
, ARG2
, ARG3
);
6197 PRE_REG_READ3(long, "ioctl",
6198 unsigned int, fd
, unsigned int, request
, unsigned long, arg
);
6202 // We now handle those that do look at ARG3 (and unknown ones fall into
6203 // this category). Nb: some of these may well belong in the
6204 // doesn't-use-ARG3 switch above.
6205 switch (ARG2
/* request */) {
6207 case VKI_ION_IOC_ALLOC
: {
6208 struct vki_ion_allocation_data
* data
6209 = (struct vki_ion_allocation_data
*)ARG3
;
6210 PRE_FIELD_READ ("ioctl(ION_IOC_ALLOC).len", data
->len
);
6211 PRE_FIELD_READ ("ioctl(ION_IOC_ALLOC).align", data
->align
);
6212 PRE_FIELD_READ ("ioctl(ION_IOC_ALLOC).heap_id_mask", data
->heap_id_mask
);
6213 PRE_FIELD_READ ("ioctl(ION_IOC_ALLOC).flags", data
->flags
);
6214 PRE_FIELD_WRITE("ioctl(ION_IOC_ALLOC).handle", data
->handle
);
6217 case VKI_ION_IOC_MAP
: {
6218 struct vki_ion_fd_data
* data
= (struct vki_ion_fd_data
*)ARG3
;
6219 PRE_FIELD_READ ("ioctl(ION_IOC_MAP).handle", data
->handle
);
6220 PRE_FIELD_WRITE("ioctl(ION_IOC_MAP).fd", data
->fd
);
6223 case VKI_ION_IOC_IMPORT
: {
6224 struct vki_ion_fd_data
* data
= (struct vki_ion_fd_data
*)ARG3
;
6225 PRE_FIELD_READ ("ioctl(ION_IOC_IMPORT).fd", data
->fd
);
6226 PRE_FIELD_WRITE("ioctl(ION_IOC_IMPORT).handle", data
->handle
);
6230 case VKI_SYNC_IOC_MERGE
: {
6231 struct vki_sync_merge_data
* data
= (struct vki_sync_merge_data
*)ARG3
;
6232 PRE_FIELD_READ ("ioctl(SYNC_IOC_MERGE).fd2", data
->fd2
);
6233 PRE_MEM_RASCIIZ("ioctl(SYNC_IOC_MERGE).name", (Addr
)(&data
->name
[0]));
6234 PRE_FIELD_WRITE("ioctl(SYNC_IOC_MERGE).fence", data
->fence
);
6241 PRE_MEM_READ( "ioctl(TCSET{S,SW,SF})", ARG3
, sizeof(struct vki_termios
) );
6244 PRE_MEM_WRITE( "ioctl(TCGETS)", ARG3
, sizeof(struct vki_termios
) );
6249 PRE_MEM_READ( "ioctl(TCSET{A,AW,AF})", ARG3
, sizeof(struct vki_termio
) );
6252 PRE_MEM_WRITE( "ioctl(TCGETA)", ARG3
, sizeof(struct vki_termio
) );
6259 /* These just take an int by value */
6261 case VKI_TIOCGWINSZ
:
6262 PRE_MEM_WRITE( "ioctl(TIOCGWINSZ)", ARG3
, sizeof(struct vki_winsize
) );
6264 case VKI_TIOCSWINSZ
:
6265 PRE_MEM_READ( "ioctl(TIOCSWINSZ)", ARG3
, sizeof(struct vki_winsize
) );
6268 PRE_MEM_READ( "ioctl(TIOCMBIS)", ARG3
, sizeof(unsigned int) );
6271 PRE_MEM_READ( "ioctl(TIOCMBIC)", ARG3
, sizeof(unsigned int) );
6274 PRE_MEM_READ( "ioctl(TIOCMSET)", ARG3
, sizeof(unsigned int) );
6277 PRE_MEM_WRITE( "ioctl(TIOCMGET)", ARG3
, sizeof(unsigned int) );
6280 PRE_MEM_READ( "ioctl(TIOCLINUX)", ARG3
, sizeof(char *) );
6281 if (*(char *)ARG3
== 11) {
6282 PRE_MEM_READ( "ioctl(TIOCLINUX, 11)", ARG3
, 2 * sizeof(char *) );
6286 /* Get process group ID for foreground processing group. */
6287 PRE_MEM_WRITE( "ioctl(TIOCGPGRP)", ARG3
, sizeof(vki_pid_t
) );
6290 /* Set a process group ID? */
6291 PRE_MEM_WRITE( "ioctl(TIOCGPGRP)", ARG3
, sizeof(vki_pid_t
) );
6293 case VKI_TIOCGPTN
: /* Get Pty Number (of pty-mux device) */
6294 PRE_MEM_WRITE( "ioctl(TIOCGPTN)", ARG3
, sizeof(int) );
6297 /* Just takes an int value. */
6299 case VKI_TIOCSPTLCK
: /* Lock/unlock Pty */
6300 PRE_MEM_READ( "ioctl(TIOCSPTLCK)", ARG3
, sizeof(int) );
6303 PRE_MEM_READ( "ioctl(FIONBIO)", ARG3
, sizeof(int) );
6306 PRE_MEM_READ( "ioctl(FIOASYNC)", ARG3
, sizeof(int) );
6308 case VKI_FIONREAD
: /* identical to SIOCINQ */
6309 PRE_MEM_WRITE( "ioctl(FIONREAD)", ARG3
, sizeof(int) );
6312 PRE_MEM_WRITE( "ioctl(FIOQSIZE)", ARG3
, sizeof(vki_loff_t
) );
6315 case VKI_TIOCSERGETLSR
:
6316 PRE_MEM_WRITE( "ioctl(TIOCSERGETLSR)", ARG3
, sizeof(int) );
6318 case VKI_TIOCGICOUNT
:
6319 PRE_MEM_WRITE( "ioctl(TIOCGICOUNT)", ARG3
,
6320 sizeof(struct vki_serial_icounter_struct
) );
6323 case VKI_SG_SET_COMMAND_Q
:
6324 PRE_MEM_READ( "ioctl(SG_SET_COMMAND_Q)", ARG3
, sizeof(int) );
6327 PRE_MEM_READ( "ioctl(SG_IO)", ARG3
, sizeof(vki_sg_io_hdr_t
) );
6329 vki_sg_io_hdr_t
*sgio
= (vki_sg_io_hdr_t
*)ARG3
;
6330 PRE_MEM_READ( "ioctl(SG_IO)", (Addr
)sgio
->cmdp
, sgio
->cmd_len
);
6331 if ( sgio
->dxfer_direction
== VKI_SG_DXFER_TO_DEV
||
6332 sgio
->dxfer_direction
== VKI_SG_DXFER_TO_FROM_DEV
) {
6333 PRE_MEM_READ( "ioctl(SG_IO)", (Addr
)sgio
->dxferp
, sgio
->dxfer_len
);
6337 case VKI_SG_GET_SCSI_ID
:
6338 PRE_MEM_WRITE( "ioctl(SG_GET_SCSI_ID)", ARG3
, sizeof(vki_sg_scsi_id_t
) );
6340 case VKI_SG_SET_RESERVED_SIZE
:
6341 PRE_MEM_READ( "ioctl(SG_SET_RESERVED_SIZE)", ARG3
, sizeof(int) );
6343 case VKI_SG_SET_TIMEOUT
:
6344 PRE_MEM_READ( "ioctl(SG_SET_TIMEOUT)", ARG3
, sizeof(int) );
6346 case VKI_SG_GET_RESERVED_SIZE
:
6347 PRE_MEM_WRITE( "ioctl(SG_GET_RESERVED_SIZE)", ARG3
, sizeof(int) );
6349 case VKI_SG_GET_TIMEOUT
:
6351 case VKI_SG_GET_VERSION_NUM
:
6352 PRE_MEM_WRITE( "ioctl(SG_GET_VERSION_NUM)", ARG3
, sizeof(int) );
6354 case VKI_SG_EMULATED_HOST
: /* 0x2203 */
6355 PRE_MEM_WRITE( "ioctl(SG_EMULATED_HOST)", ARG3
, sizeof(int) );
6357 case VKI_SG_GET_SG_TABLESIZE
: /* 0x227f */
6358 PRE_MEM_WRITE( "ioctl(SG_GET_SG_TABLESIZE)", ARG3
, sizeof(int) );
6361 case VKI_IIOCGETCPS
:
6362 PRE_MEM_WRITE( "ioctl(IIOCGETCPS)", ARG3
,
6363 VKI_ISDN_MAX_CHANNELS
* 2 * sizeof(unsigned long) );
6365 case VKI_IIOCNETGPN
:
6366 PRE_MEM_READ( "ioctl(IIOCNETGPN)",
6367 (Addr
)&((vki_isdn_net_ioctl_phone
*)ARG3
)->name
,
6368 sizeof(((vki_isdn_net_ioctl_phone
*)ARG3
)->name
) );
6369 PRE_MEM_WRITE( "ioctl(IIOCNETGPN)", ARG3
,
6370 sizeof(vki_isdn_net_ioctl_phone
) );
6373 /* These all use struct ifreq AFAIK */
6374 case VKI_SIOCGIFINDEX
: /* get iface index */
6375 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFINDEX)",
6376 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6377 PRE_MEM_WRITE( "ioctl(SIOCGIFINDEX)", ARG3
, sizeof(struct vki_ifreq
));
6379 case VKI_SIOCGIFFLAGS
: /* get flags */
6380 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFFLAGS)",
6381 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6382 PRE_MEM_WRITE( "ioctl(SIOCGIFFLAGS)", ARG3
, sizeof(struct vki_ifreq
));
6384 case VKI_SIOCGIFHWADDR
: /* Get hardware address */
6385 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFHWADDR)",
6386 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6387 PRE_MEM_WRITE( "ioctl(SIOCGIFHWADDR)", ARG3
, sizeof(struct vki_ifreq
));
6389 case VKI_SIOCGIFMTU
: /* get MTU size */
6390 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMTU)",
6391 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6392 PRE_MEM_WRITE( "ioctl(SIOCGIFMTU)", ARG3
, sizeof(struct vki_ifreq
));
6394 case VKI_SIOCGIFADDR
: /* get PA address */
6395 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFADDR)",
6396 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6397 PRE_MEM_WRITE( "ioctl(SIOCGIFADDR)", ARG3
, sizeof(struct vki_ifreq
));
6399 case VKI_SIOCGIFNETMASK
: /* get network PA mask */
6400 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFNETMASK)",
6401 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6402 PRE_MEM_WRITE( "ioctl(SIOCGIFNETMASK)", ARG3
, sizeof(struct vki_ifreq
));
6404 case VKI_SIOCGIFMETRIC
: /* get metric */
6405 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMETRIC)",
6406 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6407 PRE_MEM_WRITE( "ioctl(SIOCGIFMETRIC)", ARG3
, sizeof(struct vki_ifreq
));
6409 case VKI_SIOCGIFMAP
: /* Get device parameters */
6410 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMAP)",
6411 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6412 PRE_MEM_WRITE( "ioctl(SIOCGIFMAP)", ARG3
, sizeof(struct vki_ifreq
));
6414 case VKI_SIOCGIFTXQLEN
: /* Get the tx queue length */
6415 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFTXQLEN)",
6416 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6417 PRE_MEM_WRITE( "ioctl(SIOCGIFTXQLEN)", ARG3
, sizeof(struct vki_ifreq
));
6419 case VKI_SIOCGIFDSTADDR
: /* get remote PA address */
6420 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFDSTADDR)",
6421 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6422 PRE_MEM_WRITE( "ioctl(SIOCGIFDSTADDR)", ARG3
, sizeof(struct vki_ifreq
));
6424 case VKI_SIOCGIFBRDADDR
: /* get broadcast PA address */
6425 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFBRDADDR)",
6426 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6427 PRE_MEM_WRITE( "ioctl(SIOCGIFBRDADDR)", ARG3
, sizeof(struct vki_ifreq
));
6429 case VKI_SIOCGIFNAME
: /* get iface name */
6430 PRE_MEM_READ( "ioctl(SIOCGIFNAME)",
6431 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_ifindex
,
6432 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_ifindex
) );
6433 PRE_MEM_WRITE( "ioctl(SIOCGIFNAME)", ARG3
, sizeof(struct vki_ifreq
));
6435 case VKI_SIOCETHTOOL
: { /* ethtool(8) interface */
6436 struct vki_ifreq
*ir
= (struct vki_ifreq
*)ARG3
;
6437 PRE_MEM_READ( "ioctl(SIOCETHTOOL)", (Addr
)ir
, sizeof(struct vki_ifreq
) );
6438 PRE_MEM_RASCIIZ( "ioctl(SIOCETHTOOL)", (Addr
)ir
->vki_ifr_name
);
6439 PRE_MEM_READ( "ioctl(SIOCETHTOOL)", (Addr
)ir
->vki_ifr_data
, sizeof(vki_u32
) );
6440 PRINT("SIOCETHTOOL( 0x%x )", *(vki_u32
*)ir
->vki_ifr_data
);
6441 switch ( *(vki_u32
*)ir
->vki_ifr_data
) {
6442 case VKI_ETHTOOL_GSET
:
6443 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GSET)",
6444 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_cmd
) );
6446 case VKI_ETHTOOL_SSET
:
6447 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SSET)",
6448 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_cmd
) );
6450 case VKI_ETHTOOL_GDRVINFO
:
6451 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GDRVINFO)",
6452 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_drvinfo
) );
6454 case VKI_ETHTOOL_GREGS
:
6455 PRE_MEM_READ( "ioctl(SIOCETHTOOL,GREGS)",
6456 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_regs
) );
6457 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GREGS)",
6458 (Addr
)((struct vki_ethtool_regs
*)ir
->vki_ifr_data
)->data
,
6459 ((struct vki_ethtool_regs
*)ir
->vki_ifr_data
)->len
);
6461 case VKI_ETHTOOL_GWOL
:
6462 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GWOL)",
6463 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_wolinfo
) );
6465 case VKI_ETHTOOL_SWOL
:
6466 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SWOL)",
6467 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_wolinfo
) );
6469 case VKI_ETHTOOL_GMSGLVL
:
6470 case VKI_ETHTOOL_GLINK
:
6471 case VKI_ETHTOOL_GRXCSUM
:
6472 case VKI_ETHTOOL_GSG
:
6473 case VKI_ETHTOOL_GTSO
:
6474 case VKI_ETHTOOL_GUFO
:
6475 case VKI_ETHTOOL_GGSO
:
6476 case VKI_ETHTOOL_GFLAGS
:
6477 case VKI_ETHTOOL_GGRO
:
6478 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,Gvalue)",
6479 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_value
) );
6481 case VKI_ETHTOOL_SMSGLVL
:
6482 case VKI_ETHTOOL_SRXCSUM
:
6483 case VKI_ETHTOOL_SSG
:
6484 case VKI_ETHTOOL_STSO
:
6485 case VKI_ETHTOOL_SUFO
:
6486 case VKI_ETHTOOL_SGSO
:
6487 case VKI_ETHTOOL_SFLAGS
:
6488 case VKI_ETHTOOL_SGRO
:
6489 PRE_MEM_READ( "ioctl(SIOCETHTOOL,Svalue)",
6490 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_value
) );
6492 case VKI_ETHTOOL_NWAY_RST
:
6494 case VKI_ETHTOOL_GRINGPARAM
:
6495 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GRINGPARAM)",
6496 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ringparam
) );
6498 case VKI_ETHTOOL_SRINGPARAM
:
6499 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SRINGPARAM)",
6500 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ringparam
) );
6502 case VKI_ETHTOOL_TEST
:
6503 PRE_MEM_READ( "ioctl(SIOCETHTOOL,TEST)",
6504 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_test
) );
6505 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,TEST)",
6506 (Addr
)((struct vki_ethtool_test
*)ir
->vki_ifr_data
)->data
,
6507 ((struct vki_ethtool_test
*)ir
->vki_ifr_data
)->len
* sizeof(__vki_u64
) );
6509 case VKI_ETHTOOL_PHYS_ID
:
6511 case VKI_ETHTOOL_GPERMADDR
:
6512 PRE_MEM_READ( "ioctl(SIOCETHTOOL,GPERMADDR)",
6513 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_perm_addr
) );
6514 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GPERMADDR)",
6515 (Addr
)((struct vki_ethtool_perm_addr
*)ir
->vki_ifr_data
)->data
,
6516 ((struct vki_ethtool_perm_addr
*)ir
->vki_ifr_data
)->size
);
6518 case VKI_ETHTOOL_RESET
:
6520 case VKI_ETHTOOL_GSSET_INFO
:
6521 PRE_MEM_READ( "ioctl(SIOCETHTOOL,GSSET_INFO)",
6522 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_sset_info
) );
6523 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GSSET_INFO)",
6524 (Addr
)((struct vki_ethtool_sset_info
*)ir
->vki_ifr_data
)->data
,
6525 __builtin_popcountll(((struct vki_ethtool_sset_info
*)ir
->vki_ifr_data
)->sset_mask
) * sizeof(__vki_u32
) );
6527 case VKI_ETHTOOL_GFEATURES
:
6528 PRE_MEM_READ( "ioctl(SIOCETHTOOL,GFEATURES)",
6529 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_gfeatures
) );
6530 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GFEATURES)",
6531 (Addr
)((struct vki_ethtool_gfeatures
*)ir
->vki_ifr_data
)->features
,
6532 ((struct vki_ethtool_gfeatures
*)ir
->vki_ifr_data
)->size
* sizeof(struct vki_ethtool_get_features_block
) );
6534 case VKI_ETHTOOL_SFEATURES
:
6535 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SFEATURES)",
6536 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_sfeatures
) );
6537 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SFEATURES)",
6538 (Addr
)((struct vki_ethtool_sfeatures
*)ir
->vki_ifr_data
)->features
,
6539 ((struct vki_ethtool_sfeatures
*)ir
->vki_ifr_data
)->size
* sizeof(struct vki_ethtool_set_features_block
) );
6541 case VKI_ETHTOOL_GCHANNELS
:
6542 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GCHANNELS)",
6543 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_channels
) );
6545 case VKI_ETHTOOL_SCHANNELS
:
6546 PRE_MEM_READ( "ioctl(SIOCETHTOOL,SCHANNELS)",
6547 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_channels
) );
6549 case VKI_ETHTOOL_GET_TS_INFO
:
6550 PRE_MEM_WRITE( "ioctl(SIOCETHTOOL,GET_TS_INFO)",
6551 (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ts_info
) );
6556 case VKI_SIOCGMIIPHY
: /* get hardware entry */
6557 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMIIPHY)",
6558 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6559 PRE_MEM_WRITE( "ioctl(SIOCGIFMIIPHY)", ARG3
, sizeof(struct vki_ifreq
));
6561 case VKI_SIOCGMIIREG
: /* get hardware entry registers */
6562 PRE_MEM_RASCIIZ( "ioctl(SIOCGIFMIIREG)",
6563 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6564 PRE_MEM_READ( "ioctl(SIOCGIFMIIREG)",
6565 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
,
6566 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
) );
6567 PRE_MEM_READ( "ioctl(SIOCGIFMIIREG)",
6568 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->reg_num
,
6569 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->reg_num
) );
6570 PRE_MEM_WRITE( "ioctl(SIOCGIFMIIREG)", ARG3
,
6571 sizeof(struct vki_ifreq
));
6573 case VKI_SIOCGIFCONF
: /* get iface list */
6575 PRE_MEM_WRITE( "ioctl(SIOCGIFCONF)", ARG3, sizeof(struct ifconf));
6576 KERNEL_DO_SYSCALL(tid,RES);
6577 if (!VG_(is_kerror)(RES) && RES == 0)
6578 POST_MEM_WRITE(ARG3, sizeof(struct ifconf));
6580 PRE_MEM_READ( "ioctl(SIOCGIFCONF)",
6581 (Addr
)&((struct vki_ifconf
*)ARG3
)->ifc_len
,
6582 sizeof(((struct vki_ifconf
*)ARG3
)->ifc_len
));
6583 PRE_MEM_READ( "ioctl(SIOCGIFCONF)",
6584 (Addr
)&((struct vki_ifconf
*)ARG3
)->vki_ifc_buf
,
6585 sizeof(((struct vki_ifconf
*)ARG3
)->vki_ifc_buf
));
6587 // TODO len must be readable and writable
6588 // buf pointer only needs to be readable
6589 struct vki_ifconf
*ifc
= (struct vki_ifconf
*) ARG3
;
6590 PRE_MEM_WRITE( "ioctl(SIOCGIFCONF).ifc_buf",
6591 (Addr
)(ifc
->vki_ifc_buf
), ifc
->ifc_len
);
6594 case VKI_SIOCGSTAMP
:
6595 PRE_MEM_WRITE( "ioctl(SIOCGSTAMP)", ARG3
, sizeof(struct vki_timeval
));
6597 case VKI_SIOCGSTAMPNS
:
6598 PRE_MEM_WRITE( "ioctl(SIOCGSTAMPNS)", ARG3
, sizeof(struct vki_timespec
));
6600 /* SIOCOUTQ is an ioctl that, when called on a socket, returns
6601 the number of bytes currently in that socket's send buffer.
6602 It writes this value as an int to the memory location
6603 indicated by the third argument of ioctl(2). */
6605 PRE_MEM_WRITE( "ioctl(SIOCOUTQ)", ARG3
, sizeof(int));
6607 case VKI_SIOCGRARP
: /* get RARP table entry */
6608 case VKI_SIOCGARP
: /* get ARP table entry */
6609 PRE_MEM_WRITE( "ioctl(SIOCGARP)", ARG3
, sizeof(struct vki_arpreq
));
6612 case VKI_SIOCSIFFLAGS
: /* set flags */
6613 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFFLAGS)",
6614 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6615 PRE_MEM_READ( "ioctl(SIOCSIFFLAGS)",
6616 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
6617 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
6619 case VKI_SIOCSIFMAP
: /* Set device parameters */
6620 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFMAP)",
6621 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6622 PRE_MEM_READ( "ioctl(SIOCSIFMAP)",
6623 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_map
,
6624 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_map
) );
6626 case VKI_SIOCSHWTSTAMP
: /* Set hardware time stamping */
6627 PRE_MEM_RASCIIZ( "ioctl(SIOCSHWTSTAMP)",
6628 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6629 PRE_MEM_READ( "ioctl(SIOCSHWTSTAMP)",
6630 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_data
,
6631 sizeof(struct vki_hwtstamp_config
) );
6633 case VKI_SIOCSIFTXQLEN
: /* Set the tx queue length */
6634 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFTXQLEN)",
6635 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6636 PRE_MEM_READ( "ioctl(SIOCSIFTXQLEN)",
6637 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_qlen
,
6638 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_qlen
) );
6640 case VKI_SIOCSIFADDR
: /* set PA address */
6641 case VKI_SIOCSIFDSTADDR
: /* set remote PA address */
6642 case VKI_SIOCSIFBRDADDR
: /* set broadcast PA address */
6643 case VKI_SIOCSIFNETMASK
: /* set network PA mask */
6644 PRE_MEM_RASCIIZ( "ioctl(SIOCSIF*ADDR)",
6645 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6646 PRE_MEM_READ( "ioctl(SIOCSIF*ADDR)",
6647 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_addr
,
6648 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_addr
) );
6650 case VKI_SIOCSIFMETRIC
: /* set metric */
6651 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFMETRIC)",
6652 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6653 PRE_MEM_READ( "ioctl(SIOCSIFMETRIC)",
6654 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_metric
,
6655 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_metric
) );
6657 case VKI_SIOCSIFMTU
: /* set MTU size */
6658 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFMTU)",
6659 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6660 PRE_MEM_READ( "ioctl(SIOCSIFMTU)",
6661 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_mtu
,
6662 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_mtu
) );
6664 case VKI_SIOCSIFHWADDR
: /* set hardware address */
6665 PRE_MEM_RASCIIZ( "ioctl(SIOCSIFHWADDR)",
6666 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6667 PRE_MEM_READ( "ioctl(SIOCSIFHWADDR)",
6668 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_hwaddr
,
6669 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_hwaddr
) );
6671 case VKI_SIOCSMIIREG
: /* set hardware entry registers */
6672 PRE_MEM_RASCIIZ( "ioctl(SIOCSMIIREG)",
6673 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6674 PRE_MEM_READ( "ioctl(SIOCSMIIREG)",
6675 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
,
6676 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
) );
6677 PRE_MEM_READ( "ioctl(SIOCSMIIREG)",
6678 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->reg_num
,
6679 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->reg_num
) );
6680 PRE_MEM_READ( "ioctl(SIOCSMIIREG)",
6681 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->val_in
,
6682 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->val_in
) );
6684 /* Routing table calls. */
6685 case VKI_SIOCADDRT
: /* add routing table entry */
6686 case VKI_SIOCDELRT
: /* delete routing table entry */
6687 PRE_MEM_READ( "ioctl(SIOCADDRT/DELRT)", ARG3
,
6688 sizeof(struct vki_rtentry
));
6691 /* tun/tap related ioctls */
6692 case VKI_TUNSETNOCSUM
:
6693 case VKI_TUNSETDEBUG
:
6696 PRE_MEM_RASCIIZ( "ioctl(TUNSETIFF)",
6697 (Addr
)((struct vki_ifreq
*)ARG3
)->vki_ifr_name
);
6698 PRE_MEM_READ( "ioctl(TUNSETIFF)",
6699 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
6700 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
6701 PRE_MEM_WRITE( "ioctl(TUNSETIFF)", ARG3
, sizeof(struct vki_ifreq
) );
6703 case VKI_TUNSETPERSIST
:
6704 case VKI_TUNSETOWNER
:
6705 case VKI_TUNSETLINK
:
6706 case VKI_TUNSETGROUP
:
6708 case VKI_TUNGETFEATURES
:
6709 PRE_MEM_WRITE( "ioctl(TUNGETFEATURES)", ARG3
, sizeof(unsigned int) );
6711 case VKI_TUNSETOFFLOAD
:
6714 PRE_MEM_WRITE( "ioctl(TUNGETIFF)", ARG3
, sizeof(struct vki_ifreq
) );
6716 case VKI_TUNGETSNDBUF
:
6717 PRE_MEM_WRITE( "ioctl(TUNGETSNDBUF)", ARG3
, sizeof(int) );
6719 case VKI_TUNSETSNDBUF
:
6720 PRE_MEM_READ( "ioctl(TUNSETSNDBUF)", ARG3
, sizeof(int) );
6722 case VKI_TUNGETVNETHDRSZ
:
6723 PRE_MEM_WRITE( "ioctl(TUNGETVNETHDRSZ)", ARG3
, sizeof(int) );
6725 case VKI_TUNSETVNETHDRSZ
:
6726 PRE_MEM_READ( "ioctl(TUNSETVNETHDRSZ)", ARG3
, sizeof(int) );
6728 case VKI_TUNSETQUEUE
:
6729 PRE_MEM_READ( "ioctl(TUNSETQUEUE)",
6730 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
6731 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
6733 case VKI_TUNSETIFINDEX
:
6734 PRE_MEM_READ( "ioctl(TUNSETIFINDEX)", ARG3
, sizeof(unsigned int));
6737 /* RARP cache control calls. */
6738 case VKI_SIOCDRARP
: /* delete RARP table entry */
6739 case VKI_SIOCSRARP
: /* set RARP table entry */
6740 /* ARP cache control calls. */
6741 case VKI_SIOCSARP
: /* set ARP table entry */
6742 case VKI_SIOCDARP
: /* delete ARP table entry */
6743 PRE_MEM_READ( "ioctl(SIOCSIFFLAGS)", ARG3
, sizeof(struct vki_ifreq
));
6747 PRE_MEM_WRITE( "ioctl(SIOCGPGRP)", ARG3
, sizeof(int) );
6750 PRE_MEM_READ( "ioctl(SIOCSPGRP)", ARG3
, sizeof(int) );
6751 //tst->sys_flags &= ~SfMayBlock;
6754 case VKI_SIOCATMARK
:
6755 PRE_MEM_READ( "ioctl(SIOCATMARK)", ARG3
, sizeof(int) );
6758 /* linux/soundcard interface (OSS) */
6759 case VKI_SNDCTL_SEQ_GETOUTCOUNT
:
6760 case VKI_SNDCTL_SEQ_GETINCOUNT
:
6761 case VKI_SNDCTL_SEQ_PERCMODE
:
6762 case VKI_SNDCTL_SEQ_TESTMIDI
:
6763 case VKI_SNDCTL_SEQ_RESETSAMPLES
:
6764 case VKI_SNDCTL_SEQ_NRSYNTHS
:
6765 case VKI_SNDCTL_SEQ_NRMIDIS
:
6766 case VKI_SNDCTL_SEQ_GETTIME
:
6767 case VKI_SNDCTL_DSP_GETBLKSIZE
:
6768 case VKI_SNDCTL_DSP_GETFMTS
:
6769 case VKI_SNDCTL_DSP_GETTRIGGER
:
6770 case VKI_SNDCTL_DSP_GETODELAY
:
6771 case VKI_SNDCTL_DSP_GETSPDIF
:
6772 case VKI_SNDCTL_DSP_GETCAPS
:
6773 case VKI_SOUND_PCM_READ_RATE
:
6774 case VKI_SOUND_PCM_READ_CHANNELS
:
6775 case VKI_SOUND_PCM_READ_BITS
:
6776 case VKI_SOUND_PCM_READ_FILTER
:
6777 PRE_MEM_WRITE( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOR, int))",
6780 case VKI_SNDCTL_SEQ_CTRLRATE
:
6781 case VKI_SNDCTL_DSP_SPEED
:
6782 case VKI_SNDCTL_DSP_STEREO
:
6783 case VKI_SNDCTL_DSP_CHANNELS
:
6784 case VKI_SOUND_PCM_WRITE_FILTER
:
6785 case VKI_SNDCTL_DSP_SUBDIVIDE
:
6786 case VKI_SNDCTL_DSP_SETFRAGMENT
:
6787 case VKI_SNDCTL_DSP_SETFMT
:
6788 case VKI_SNDCTL_DSP_GETCHANNELMASK
:
6789 case VKI_SNDCTL_DSP_BIND_CHANNEL
:
6790 case VKI_SNDCTL_TMR_TIMEBASE
:
6791 case VKI_SNDCTL_TMR_TEMPO
:
6792 case VKI_SNDCTL_TMR_SOURCE
:
6793 case VKI_SNDCTL_MIDI_PRETIME
:
6794 case VKI_SNDCTL_MIDI_MPUMODE
:
6795 PRE_MEM_READ( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOWR, int))",
6797 PRE_MEM_WRITE( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOWR, int))",
6800 case VKI_SNDCTL_DSP_GETOSPACE
:
6801 case VKI_SNDCTL_DSP_GETISPACE
:
6802 PRE_MEM_WRITE( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOR, audio_buf_info))",
6803 ARG3
, sizeof(vki_audio_buf_info
));
6805 case VKI_SNDCTL_DSP_NONBLOCK
:
6807 case VKI_SNDCTL_DSP_SETTRIGGER
:
6808 PRE_MEM_READ( "ioctl(SNDCTL_XXX|SOUND_XXX (SIOW, int))",
6812 case VKI_SNDCTL_DSP_POST
:
6813 case VKI_SNDCTL_DSP_RESET
:
6814 case VKI_SNDCTL_DSP_SYNC
:
6815 case VKI_SNDCTL_DSP_SETSYNCRO
:
6816 case VKI_SNDCTL_DSP_SETDUPLEX
:
6819 /* linux/soundcard interface (ALSA) */
6820 case VKI_SNDRV_PCM_IOCTL_PAUSE
:
6821 case VKI_SNDRV_PCM_IOCTL_LINK
:
6822 /* these just take an int by value */
6824 case VKI_SNDRV_CTL_IOCTL_PVERSION
:
6825 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_PVERSION)", (Addr
)ARG3
, sizeof(int) );
6827 case VKI_SNDRV_CTL_IOCTL_CARD_INFO
:
6828 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_CARD_INFO)", (Addr
)ARG3
, sizeof(struct vki_snd_ctl_card_info
) );
6830 case VKI_SNDRV_CTL_IOCTL_ELEM_LIST
: {
6831 struct vki_snd_ctl_elem_list
*data
= (struct vki_snd_ctl_elem_list
*)ARG3
;
6832 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->offset
, sizeof(data
->offset
) );
6833 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->space
, sizeof(data
->space
) );
6834 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->used
, sizeof(data
->used
) );
6835 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->count
, sizeof(data
->count
) );
6836 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)&data
->pids
, sizeof(data
->pids
) );
6838 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_ELEM_LIST)", (Addr
)data
->pids
, sizeof(struct vki_snd_ctl_elem_id
) * data
->space
);
6842 case VKI_SNDRV_CTL_IOCTL_TLV_READ
: {
6843 struct vki_snd_ctl_tlv
*data
= (struct vki_snd_ctl_tlv
*)ARG3
;
6844 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_READ)", (Addr
)&data
->numid
, sizeof(data
->numid
) );
6845 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_READ)", (Addr
)&data
->length
, sizeof(data
->length
) );
6846 PRE_MEM_WRITE( "ioctl(SNDRV_CTL_IOCTL_TLV_READ)", (Addr
)data
->tlv
, data
->length
);
6849 case VKI_SNDRV_CTL_IOCTL_TLV_WRITE
:
6850 case VKI_SNDRV_CTL_IOCTL_TLV_COMMAND
: {
6851 struct vki_snd_ctl_tlv
*data
= (struct vki_snd_ctl_tlv
*)ARG3
;
6852 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_WRITE)", (Addr
)&data
->numid
, sizeof(data
->numid
) );
6853 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_WRITE)", (Addr
)&data
->length
, sizeof(data
->length
) );
6854 PRE_MEM_READ( "ioctl(SNDRV_CTL_IOCTL_TLV_WRITE)", (Addr
)data
->tlv
, data
->length
);
6858 /* Real Time Clock (/dev/rtc) ioctls */
6859 case VKI_RTC_UIE_ON
:
6860 case VKI_RTC_UIE_OFF
:
6861 case VKI_RTC_AIE_ON
:
6862 case VKI_RTC_AIE_OFF
:
6863 case VKI_RTC_PIE_ON
:
6864 case VKI_RTC_PIE_OFF
:
6865 case VKI_RTC_IRQP_SET
:
6867 case VKI_RTC_RD_TIME
:
6868 case VKI_RTC_ALM_READ
:
6869 PRE_MEM_WRITE( "ioctl(RTC_RD_TIME/ALM_READ)",
6870 ARG3
, sizeof(struct vki_rtc_time
));
6872 case VKI_RTC_ALM_SET
:
6873 PRE_MEM_READ( "ioctl(RTC_ALM_SET)", ARG3
, sizeof(struct vki_rtc_time
));
6875 case VKI_RTC_IRQP_READ
:
6876 PRE_MEM_WRITE( "ioctl(RTC_IRQP_READ)", ARG3
, sizeof(unsigned long));
6881 PRE_MEM_READ( "ioctl(BLKROSET)", ARG3
, sizeof(int));
6884 PRE_MEM_WRITE( "ioctl(BLKROGET)", ARG3
, sizeof(int));
6886 case VKI_BLKGETSIZE
:
6887 PRE_MEM_WRITE( "ioctl(BLKGETSIZE)", ARG3
, sizeof(unsigned long));
6894 PRE_MEM_WRITE( "ioctl(BLKRAGET)", ARG3
, sizeof(long));
6899 PRE_MEM_WRITE( "ioctl(BLKFRAGET)", ARG3
, sizeof(long));
6901 case VKI_BLKSECTGET
:
6902 PRE_MEM_WRITE( "ioctl(BLKSECTGET)", ARG3
, sizeof(unsigned short));
6905 PRE_MEM_WRITE( "ioctl(BLKSSZGET)", ARG3
, sizeof(int));
6908 PRE_MEM_WRITE( "ioctl(BLKBSZGET)", ARG3
, sizeof(int));
6911 PRE_MEM_READ( "ioctl(BLKBSZSET)", ARG3
, sizeof(int));
6913 case VKI_BLKGETSIZE64
:
6914 PRE_MEM_WRITE( "ioctl(BLKGETSIZE64)", ARG3
, sizeof(unsigned long long));
6916 case VKI_BLKPBSZGET
:
6917 PRE_MEM_WRITE( "ioctl(BLKPBSZGET)", ARG3
, sizeof(int));
6919 case VKI_BLKDISCARDZEROES
:
6920 PRE_MEM_WRITE( "ioctl(BLKDISCARDZEROES)", ARG3
, sizeof(vki_uint
));
6922 case VKI_BLKREPORTZONE
:
6923 PRE_MEM_READ("ioctl(BLKREPORTZONE)", ARG3
,
6924 sizeof(struct vki_blk_zone_report
));
6926 case VKI_BLKRESETZONE
:
6927 PRE_MEM_READ("ioctl(BLKRESETZONE)", ARG3
,
6928 sizeof(struct vki_blk_zone_range
));
6932 case VKI_HDIO_GETGEO
: /* 0x0301 */
6933 PRE_MEM_WRITE( "ioctl(HDIO_GETGEO)", ARG3
, sizeof(struct vki_hd_geometry
));
6935 case VKI_HDIO_GET_DMA
: /* 0x030b */
6936 PRE_MEM_WRITE( "ioctl(HDIO_GET_DMA)", ARG3
, sizeof(long));
6938 case VKI_HDIO_GET_IDENTITY
: /* 0x030d */
6939 PRE_MEM_WRITE( "ioctl(HDIO_GET_IDENTITY)", ARG3
,
6940 VKI_SIZEOF_STRUCT_HD_DRIVEID
);
6944 case VKI_SCSI_IOCTL_GET_IDLUN
: /* 0x5382 */
6945 PRE_MEM_WRITE( "ioctl(SCSI_IOCTL_GET_IDLUN)", ARG3
, sizeof(struct vki_scsi_idlun
));
6947 case VKI_SCSI_IOCTL_GET_BUS_NUMBER
: /* 0x5386 */
6948 PRE_MEM_WRITE( "ioctl(SCSI_IOCTL_GET_BUS_NUMBER)", ARG3
, sizeof(int));
6951 /* CD ROM stuff (??) */
6952 case VKI_CDROM_GET_MCN
:
6953 PRE_MEM_READ( "ioctl(CDROM_GET_MCN)", ARG3
,
6954 sizeof(struct vki_cdrom_mcn
) );
6956 case VKI_CDROM_SEND_PACKET
:
6957 PRE_MEM_READ( "ioctl(CDROM_SEND_PACKET)", ARG3
,
6958 sizeof(struct vki_cdrom_generic_command
));
6960 case VKI_CDROMSUBCHNL
:
6961 PRE_MEM_READ( "ioctl(CDROMSUBCHNL (cdsc_format, char))",
6962 (Addr
) &(((struct vki_cdrom_subchnl
*) ARG3
)->cdsc_format
),
6963 sizeof(((struct vki_cdrom_subchnl
*) ARG3
)->cdsc_format
));
6964 PRE_MEM_WRITE( "ioctl(CDROMSUBCHNL)", ARG3
,
6965 sizeof(struct vki_cdrom_subchnl
));
6967 case VKI_CDROMREADMODE1
: /*0x530d*/
6968 PRE_MEM_READ("ioctl(CDROMREADMODE1)", ARG3
, VKI_CD_FRAMESIZE_RAW1
);
6969 PRE_MEM_WRITE("ioctl(CDROMREADMODE1)", ARG3
, VKI_CD_FRAMESIZE_RAW1
);
6971 case VKI_CDROMREADMODE2
: /*0x530c*/
6972 PRE_MEM_READ("ioctl(CDROMREADMODE2)", ARG3
, VKI_CD_FRAMESIZE_RAW0
);
6973 PRE_MEM_WRITE("ioctl(CDROMREADMODE2)", ARG3
, VKI_CD_FRAMESIZE_RAW0
);
6975 case VKI_CDROMREADTOCHDR
:
6976 PRE_MEM_WRITE( "ioctl(CDROMREADTOCHDR)", ARG3
,
6977 sizeof(struct vki_cdrom_tochdr
));
6979 case VKI_CDROMREADTOCENTRY
:
6980 PRE_MEM_READ( "ioctl(CDROMREADTOCENTRY (cdte_format, char))",
6981 (Addr
) &(((struct vki_cdrom_tocentry
*) ARG3
)->cdte_format
),
6982 sizeof(((struct vki_cdrom_tocentry
*) ARG3
)->cdte_format
));
6983 PRE_MEM_READ( "ioctl(CDROMREADTOCENTRY (cdte_track, char))",
6984 (Addr
) &(((struct vki_cdrom_tocentry
*) ARG3
)->cdte_track
),
6985 sizeof(((struct vki_cdrom_tocentry
*) ARG3
)->cdte_track
));
6986 PRE_MEM_WRITE( "ioctl(CDROMREADTOCENTRY)", ARG3
,
6987 sizeof(struct vki_cdrom_tocentry
));
6989 case VKI_CDROMMULTISESSION
: /* 0x5310 */
6990 PRE_MEM_WRITE( "ioctl(CDROMMULTISESSION)", ARG3
,
6991 sizeof(struct vki_cdrom_multisession
));
6993 case VKI_CDROMVOLREAD
: /* 0x5313 */
6994 PRE_MEM_WRITE( "ioctl(CDROMVOLREAD)", ARG3
,
6995 sizeof(struct vki_cdrom_volctrl
));
6997 case VKI_CDROMREADRAW
: /* 0x5314 */
6998 PRE_MEM_READ( "ioctl(CDROMREADRAW)", ARG3
, sizeof(struct vki_cdrom_msf
));
6999 PRE_MEM_WRITE( "ioctl(CDROMREADRAW)", ARG3
, VKI_CD_FRAMESIZE_RAW
);
7001 case VKI_CDROMREADAUDIO
: /* 0x530e */
7002 PRE_MEM_READ( "ioctl(CDROMREADAUDIO)", ARG3
,
7003 sizeof (struct vki_cdrom_read_audio
));
7005 /* ToDo: don't do any of the following if the structure is invalid */
7006 struct vki_cdrom_read_audio
*cra
= (struct vki_cdrom_read_audio
*) ARG3
;
7007 PRE_MEM_WRITE( "ioctl(CDROMREADAUDIO).buf",
7008 (Addr
)(cra
->buf
), cra
->nframes
* VKI_CD_FRAMESIZE_RAW
);
7011 case VKI_CDROMPLAYMSF
:
7012 PRE_MEM_READ( "ioctl(CDROMPLAYMSF)", ARG3
, sizeof(struct vki_cdrom_msf
));
7014 /* The following two are probably bogus (should check args
7015 for readability). JRS 20021117 */
7016 case VKI_CDROM_DRIVE_STATUS
: /* 0x5326 */
7017 case VKI_CDROM_CLEAR_OPTIONS
: /* 0x5321 */
7019 case VKI_CDROM_GET_CAPABILITY
: /* 0x5331 */
7023 PRE_MEM_WRITE( "ioctl(FIGETBSZ)", ARG3
, sizeof(unsigned long));
7026 PRE_MEM_READ( "ioctl(FIBMAP)", ARG3
, sizeof(int));
7029 case VKI_FBIOGET_VSCREENINFO
: /* 0x4600 */
7030 PRE_MEM_WRITE( "ioctl(FBIOGET_VSCREENINFO)", ARG3
,
7031 sizeof(struct vki_fb_var_screeninfo
));
7033 case VKI_FBIOPUT_VSCREENINFO
:
7034 PRE_MEM_READ( "ioctl(FBIOPUT_VSCREENINFO)", ARG3
,
7035 sizeof(struct vki_fb_var_screeninfo
));
7037 case VKI_FBIOGET_FSCREENINFO
: /* 0x4602 */
7038 PRE_MEM_WRITE( "ioctl(FBIOGET_FSCREENINFO)", ARG3
,
7039 sizeof(struct vki_fb_fix_screeninfo
));
7041 case VKI_FBIOPAN_DISPLAY
:
7042 PRE_MEM_READ( "ioctl(FBIOPAN_DISPLAY)", ARG3
,
7043 sizeof(struct vki_fb_var_screeninfo
));
7052 PRE_MEM_READ( "ioctl(PPSETMODE)", ARG3
, sizeof(int) );
7055 PRE_MEM_WRITE( "ioctl(PPGETMODE)", ARG3
, sizeof(int) );
7057 case VKI_PPSETPHASE
:
7058 PRE_MEM_READ( "ioctl(PPSETPHASE)", ARG3
, sizeof(int) );
7060 case VKI_PPGETPHASE
:
7061 PRE_MEM_WRITE( "ioctl(PPGETPHASE)", ARG3
, sizeof(int) );
7063 case VKI_PPGETMODES
:
7064 PRE_MEM_WRITE( "ioctl(PPGETMODES)", ARG3
, sizeof(unsigned int) );
7066 case VKI_PPSETFLAGS
:
7067 PRE_MEM_READ( "ioctl(PPSETFLAGS)", ARG3
, sizeof(int) );
7069 case VKI_PPGETFLAGS
:
7070 PRE_MEM_WRITE( "ioctl(PPGETFLAGS)", ARG3
, sizeof(int) );
7073 PRE_MEM_WRITE( "ioctl(PPRSTATUS)", ARG3
, sizeof(unsigned char) );
7076 PRE_MEM_WRITE( "ioctl(PPRDATA)", ARG3
, sizeof(unsigned char) );
7078 case VKI_PPRCONTROL
:
7079 PRE_MEM_WRITE( "ioctl(PPRCONTROL)", ARG3
, sizeof(unsigned char) );
7082 PRE_MEM_READ( "ioctl(PPWDATA)", ARG3
, sizeof(unsigned char) );
7084 case VKI_PPWCONTROL
:
7085 PRE_MEM_READ( "ioctl(PPWCONTROL)", ARG3
, sizeof(unsigned char) );
7087 case VKI_PPFCONTROL
:
7088 PRE_MEM_READ( "ioctl(PPFCONTROL)", ARG3
, 2 * sizeof(unsigned char) );
7091 PRE_MEM_READ( "ioctl(PPDATADIR)", ARG3
, sizeof(int) );
7094 PRE_MEM_READ( "ioctl(PPNEGOT)", ARG3
, sizeof(int) );
7096 case VKI_PPWCTLONIRQ
:
7097 PRE_MEM_READ( "ioctl(PPWCTLONIRQ)",ARG3
, sizeof(unsigned char) );
7100 PRE_MEM_WRITE( "ioctl(PPCLRIRQ)", ARG3
, sizeof(int) );
7103 PRE_MEM_READ( "ioctl(PPSETTIME)", ARG3
, sizeof(struct vki_timeval
) );
7106 PRE_MEM_WRITE( "ioctl(PPGETTIME)", ARG3
, sizeof(struct vki_timeval
) );
7110 PRE_MEM_WRITE( "ioctl(GIO_FONT)", ARG3
, 32 * 256 );
7113 PRE_MEM_READ( "ioctl(PIO_FONT)", ARG3
, 32 * 256 );
7117 PRE_MEM_READ( "ioctl(GIO_FONTX)", ARG3
, sizeof(struct vki_consolefontdesc
) );
7119 /* ToDo: don't do any of the following if the structure is invalid */
7120 struct vki_consolefontdesc
*cfd
= (struct vki_consolefontdesc
*)ARG3
;
7121 PRE_MEM_WRITE( "ioctl(GIO_FONTX).chardata", (Addr
)cfd
->chardata
,
7122 32 * cfd
->charcount
);
7126 PRE_MEM_READ( "ioctl(PIO_FONTX)", ARG3
, sizeof(struct vki_consolefontdesc
) );
7128 /* ToDo: don't do any of the following if the structure is invalid */
7129 struct vki_consolefontdesc
*cfd
= (struct vki_consolefontdesc
*)ARG3
;
7130 PRE_MEM_READ( "ioctl(PIO_FONTX).chardata", (Addr
)cfd
->chardata
,
7131 32 * cfd
->charcount
);
7135 case VKI_PIO_FONTRESET
:
7139 PRE_MEM_WRITE( "ioctl(GIO_CMAP)", ARG3
, 16 * 3 );
7142 PRE_MEM_READ( "ioctl(PIO_CMAP)", ARG3
, 16 * 3 );
7150 PRE_MEM_WRITE( "ioctl(KDGETLED)", ARG3
, sizeof(char) );
7156 PRE_MEM_WRITE( "ioctl(KDGKBTYPE)", ARG3
, sizeof(char) );
7168 PRE_MEM_WRITE( "ioctl(KDGETMODE)", ARG3
, sizeof(int) );
7172 case VKI_KDUNMAPDISP
:
7175 case VKI_GIO_SCRNMAP
:
7176 PRE_MEM_WRITE( "ioctl(GIO_SCRNMAP)", ARG3
, VKI_E_TABSZ
);
7178 case VKI_PIO_SCRNMAP
:
7179 PRE_MEM_READ( "ioctl(PIO_SCRNMAP)", ARG3
, VKI_E_TABSZ
);
7181 case VKI_GIO_UNISCRNMAP
:
7182 PRE_MEM_WRITE( "ioctl(GIO_UNISCRNMAP)", ARG3
,
7183 VKI_E_TABSZ
* sizeof(unsigned short) );
7185 case VKI_PIO_UNISCRNMAP
:
7186 PRE_MEM_READ( "ioctl(PIO_UNISCRNMAP)", ARG3
,
7187 VKI_E_TABSZ
* sizeof(unsigned short) );
7190 case VKI_GIO_UNIMAP
:
7192 struct vki_unimapdesc
*desc
= (struct vki_unimapdesc
*) ARG3
;
7193 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", (Addr
)&desc
->entry_ct
,
7194 sizeof(unsigned short));
7195 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", (Addr
)&desc
->entries
,
7196 sizeof(struct vki_unipair
*));
7197 PRE_MEM_WRITE( "ioctl(GIO_UNIMAP).entries", (Addr
)desc
->entries
,
7198 desc
->entry_ct
* sizeof(struct vki_unipair
));
7201 case VKI_PIO_UNIMAP
:
7203 struct vki_unimapdesc
*desc
= (struct vki_unimapdesc
*) ARG3
;
7204 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", (Addr
)&desc
->entry_ct
,
7205 sizeof(unsigned short) );
7206 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", (Addr
)&desc
->entries
,
7207 sizeof(struct vki_unipair
*) );
7208 PRE_MEM_READ( "ioctl(PIO_UNIMAP).entries", (Addr
)desc
->entries
,
7209 desc
->entry_ct
* sizeof(struct vki_unipair
) );
7212 case VKI_PIO_UNIMAPCLR
:
7213 PRE_MEM_READ( "ioctl(GIO_UNIMAP)", ARG3
, sizeof(struct vki_unimapinit
));
7217 PRE_MEM_WRITE( "ioctl(KDGKBMODE)", ARG3
, sizeof(int) );
7223 PRE_MEM_WRITE( "ioctl(KDGKBMETA)", ARG3
, sizeof(int) );
7229 PRE_MEM_WRITE( "ioctl(KDGKBLED)", ARG3
, sizeof(char) );
7235 PRE_MEM_READ( "ioctl(KDGKBENT).kb_table",
7236 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_table
,
7237 sizeof(((struct vki_kbentry
*)ARG3
)->kb_table
) );
7238 PRE_MEM_READ( "ioctl(KDGKBENT).kb_index",
7239 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_index
,
7240 sizeof(((struct vki_kbentry
*)ARG3
)->kb_index
) );
7241 PRE_MEM_WRITE( "ioctl(KDGKBENT).kb_value",
7242 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_value
,
7243 sizeof(((struct vki_kbentry
*)ARG3
)->kb_value
) );
7246 PRE_MEM_READ( "ioctl(KDSKBENT).kb_table",
7247 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_table
,
7248 sizeof(((struct vki_kbentry
*)ARG3
)->kb_table
) );
7249 PRE_MEM_READ( "ioctl(KDSKBENT).kb_index",
7250 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_index
,
7251 sizeof(((struct vki_kbentry
*)ARG3
)->kb_index
) );
7252 PRE_MEM_READ( "ioctl(KDSKBENT).kb_value",
7253 (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_value
,
7254 sizeof(((struct vki_kbentry
*)ARG3
)->kb_value
) );
7258 PRE_MEM_READ( "ioctl(KDGKBSENT).kb_func",
7259 (Addr
)&((struct vki_kbsentry
*)ARG3
)->kb_func
,
7260 sizeof(((struct vki_kbsentry
*)ARG3
)->kb_func
) );
7261 PRE_MEM_WRITE( "ioctl(KDGKSENT).kb_string",
7262 (Addr
)((struct vki_kbsentry
*)ARG3
)->kb_string
,
7263 sizeof(((struct vki_kbsentry
*)ARG3
)->kb_string
) );
7266 PRE_MEM_READ( "ioctl(KDSKBSENT).kb_func",
7267 (Addr
)&((struct vki_kbsentry
*)ARG3
)->kb_func
,
7268 sizeof(((struct vki_kbsentry
*)ARG3
)->kb_func
) );
7269 PRE_MEM_RASCIIZ( "ioctl(KDSKBSENT).kb_string",
7270 (Addr
)((struct vki_kbsentry
*)ARG3
)->kb_string
);
7273 case VKI_KDGKBDIACR
:
7274 PRE_MEM_WRITE( "ioctl(KDGKBDIACR)", ARG3
, sizeof(struct vki_kbdiacrs
) );
7276 case VKI_KDSKBDIACR
:
7277 PRE_MEM_READ( "ioctl(KDSKBDIACR)", ARG3
, sizeof(struct vki_kbdiacrs
) );
7280 case VKI_KDGETKEYCODE
:
7281 PRE_MEM_READ( "ioctl(KDGETKEYCODE).scancode",
7282 (Addr
)&((struct vki_kbkeycode
*)ARG3
)->scancode
,
7283 sizeof(((struct vki_kbkeycode
*)ARG3
)->scancode
) );
7284 PRE_MEM_WRITE( "ioctl(KDGETKEYCODE).keycode",
7285 (Addr
)((struct vki_kbkeycode
*)ARG3
)->keycode
,
7286 sizeof(((struct vki_kbkeycode
*)ARG3
)->keycode
) );
7288 case VKI_KDSETKEYCODE
:
7289 PRE_MEM_READ( "ioctl(KDSETKEYCODE).scancode",
7290 (Addr
)&((struct vki_kbkeycode
*)ARG3
)->scancode
,
7291 sizeof(((struct vki_kbkeycode
*)ARG3
)->scancode
) );
7292 PRE_MEM_READ( "ioctl(KDSETKEYCODE).keycode",
7293 (Addr
)((struct vki_kbkeycode
*)ARG3
)->keycode
,
7294 sizeof(((struct vki_kbkeycode
*)ARG3
)->keycode
) );
7297 case VKI_KDSIGACCEPT
:
7301 PRE_MEM_READ( "ioctl(KBKBDREP)", ARG3
, sizeof(struct vki_kbd_repeat
) );
7306 struct vki_console_font_op
*op
= (struct vki_console_font_op
*) ARG3
;
7307 PRE_MEM_READ( "ioctl(KDFONTOP)", (Addr
)op
,
7308 sizeof(struct vki_console_font_op
) );
7310 case VKI_KD_FONT_OP_SET
:
7311 PRE_MEM_READ( "ioctl(KDFONTOP,KD_FONT_OP_SET).data",
7313 (op
->width
+ 7) / 8 * 32 * op
->charcount
);
7315 case VKI_KD_FONT_OP_GET
:
7317 PRE_MEM_WRITE( "ioctl(KDFONTOP,KD_FONT_OP_GET).data",
7319 (op
->width
+ 7) / 8 * 32 * op
->charcount
);
7321 case VKI_KD_FONT_OP_SET_DEFAULT
:
7323 PRE_MEM_RASCIIZ( "ioctl(KDFONTOP,KD_FONT_OP_SET_DEFAULT).data",
7326 case VKI_KD_FONT_OP_COPY
:
7332 case VKI_VT_OPENQRY
:
7333 PRE_MEM_WRITE( "ioctl(VT_OPENQRY)", ARG3
, sizeof(int) );
7335 case VKI_VT_GETMODE
:
7336 PRE_MEM_WRITE( "ioctl(VT_GETMODE)", ARG3
, sizeof(struct vki_vt_mode
) );
7338 case VKI_VT_SETMODE
:
7339 PRE_MEM_READ( "ioctl(VT_SETMODE)", ARG3
, sizeof(struct vki_vt_mode
) );
7341 case VKI_VT_GETSTATE
:
7342 PRE_MEM_WRITE( "ioctl(VT_GETSTATE).v_active",
7343 (Addr
) &(((struct vki_vt_stat
*) ARG3
)->v_active
),
7344 sizeof(((struct vki_vt_stat
*) ARG3
)->v_active
));
7345 PRE_MEM_WRITE( "ioctl(VT_GETSTATE).v_state",
7346 (Addr
) &(((struct vki_vt_stat
*) ARG3
)->v_state
),
7347 sizeof(((struct vki_vt_stat
*) ARG3
)->v_state
));
7349 case VKI_VT_RELDISP
:
7350 case VKI_VT_ACTIVATE
:
7351 case VKI_VT_WAITACTIVE
:
7352 case VKI_VT_DISALLOCATE
:
7355 PRE_MEM_READ( "ioctl(VT_RESIZE)", ARG3
, sizeof(struct vki_vt_sizes
) );
7357 case VKI_VT_RESIZEX
:
7358 PRE_MEM_READ( "ioctl(VT_RESIZEX)", ARG3
, sizeof(struct vki_vt_consize
) );
7360 case VKI_VT_LOCKSWITCH
:
7361 case VKI_VT_UNLOCKSWITCH
:
7364 case VKI_USBDEVFS_CONTROL
:
7366 struct vki_usbdevfs_ctrltransfer
*vkuc
= (struct vki_usbdevfs_ctrltransfer
*)ARG3
;
7367 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).bRequestType", (Addr
)&vkuc
->bRequestType
, sizeof(vkuc
->bRequestType
));
7368 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).bRequest", (Addr
)&vkuc
->bRequest
, sizeof(vkuc
->bRequest
));
7369 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).wValue", (Addr
)&vkuc
->wValue
, sizeof(vkuc
->wValue
));
7370 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).wIndex", (Addr
)&vkuc
->wIndex
, sizeof(vkuc
->wIndex
));
7371 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).wLength", (Addr
)&vkuc
->wLength
, sizeof(vkuc
->wLength
));
7372 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).timeout", (Addr
)&vkuc
->timeout
, sizeof(vkuc
->timeout
));
7373 if (vkuc
->bRequestType
& 0x80)
7374 PRE_MEM_WRITE( "ioctl(USBDEVFS_CONTROL).data", (Addr
)vkuc
->data
, vkuc
->wLength
);
7376 PRE_MEM_READ( "ioctl(USBDEVFS_CONTROL).data", (Addr
)vkuc
->data
, vkuc
->wLength
);
7379 case VKI_USBDEVFS_BULK
:
7381 struct vki_usbdevfs_bulktransfer
*vkub
= (struct vki_usbdevfs_bulktransfer
*)ARG3
;
7382 PRE_MEM_READ( "ioctl(USBDEVFS_BULK)", ARG3
, sizeof(struct vki_usbdevfs_bulktransfer
));
7383 if (vkub
->ep
& 0x80)
7384 PRE_MEM_WRITE( "ioctl(USBDEVFS_BULK).data", (Addr
)vkub
->data
, vkub
->len
);
7386 PRE_MEM_READ( "ioctl(USBDEVFS_BULK).data", (Addr
)vkub
->data
, vkub
->len
);
7389 case VKI_USBDEVFS_GETDRIVER
:
7391 struct vki_usbdevfs_getdriver
*vkugd
= (struct vki_usbdevfs_getdriver
*) ARG3
;
7392 PRE_MEM_WRITE( "ioctl(USBDEVFS_GETDRIVER)", (Addr
)&vkugd
->driver
, sizeof(vkugd
->driver
));
7395 case VKI_USBDEVFS_SUBMITURB
:
7397 struct vki_usbdevfs_urb
*vkuu
= (struct vki_usbdevfs_urb
*)ARG3
;
7399 /* Not the whole struct needs to be initialized */
7400 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).endpoint", (Addr
)&vkuu
->endpoint
, sizeof(vkuu
->endpoint
));
7401 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).type", (Addr
)&vkuu
->type
, sizeof(vkuu
->type
));
7402 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).flags", (Addr
)&vkuu
->flags
, sizeof(vkuu
->flags
));
7403 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)&vkuu
->buffer
, sizeof(vkuu
->buffer
));
7404 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).signr", (Addr
)&vkuu
->signr
, sizeof(vkuu
->signr
));
7405 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).status", (Addr
)&vkuu
->status
, sizeof(vkuu
->status
));
7406 if (vkuu
->type
== VKI_USBDEVFS_URB_TYPE_CONTROL
) {
7407 struct vki_usbdevfs_setuppacket
*vkusp
= (struct vki_usbdevfs_setuppacket
*)vkuu
->buffer
;
7408 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer_length", (Addr
)&vkuu
->buffer_length
, sizeof(vkuu
->buffer_length
));
7409 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer.setup_packet", (Addr
)vkusp
, sizeof(*vkusp
));
7410 if (vkusp
->bRequestType
& 0x80)
7411 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).buffer.data", (Addr
)(vkusp
+1), vkuu
->buffer_length
- sizeof(*vkusp
));
7413 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer.data", (Addr
)(vkusp
+1), vkuu
->buffer_length
- sizeof(*vkusp
));
7414 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).actual_length", (Addr
)&vkuu
->actual_length
, sizeof(vkuu
->actual_length
));
7415 } else if (vkuu
->type
== VKI_USBDEVFS_URB_TYPE_ISO
) {
7416 int total_length
= 0;
7418 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).number_of_packets", (Addr
)&vkuu
->number_of_packets
, sizeof(vkuu
->number_of_packets
));
7419 for(i
=0; i
<vkuu
->number_of_packets
; i
++) {
7420 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).iso_frame_desc[].length", (Addr
)&vkuu
->iso_frame_desc
[i
].length
, sizeof(vkuu
->iso_frame_desc
[i
].length
));
7421 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
));
7422 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).iso_frame_desc[].status", (Addr
)&vkuu
->iso_frame_desc
[i
].status
, sizeof(vkuu
->iso_frame_desc
[i
].status
));
7423 total_length
+= vkuu
->iso_frame_desc
[i
].length
;
7425 if (vkuu
->endpoint
& 0x80)
7426 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)vkuu
->buffer
, total_length
);
7428 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)vkuu
->buffer
, total_length
);
7429 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).error_count", (Addr
)&vkuu
->error_count
, sizeof(vkuu
->error_count
));
7431 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer_length", (Addr
)&vkuu
->buffer_length
, sizeof(vkuu
->buffer_length
));
7432 if (vkuu
->endpoint
& 0x80)
7433 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)vkuu
->buffer
, vkuu
->buffer_length
);
7435 PRE_MEM_READ( "ioctl(USBDEVFS_SUBMITURB).buffer", (Addr
)vkuu
->buffer
, vkuu
->buffer_length
);
7436 PRE_MEM_WRITE( "ioctl(USBDEVFS_SUBMITURB).actual_length", (Addr
)&vkuu
->actual_length
, sizeof(vkuu
->actual_length
));
7440 case VKI_USBDEVFS_DISCARDURB
:
7442 case VKI_USBDEVFS_REAPURB
:
7444 PRE_MEM_WRITE( "ioctl(USBDEVFS_REAPURB)", ARG3
, sizeof(struct vki_usbdevfs_urb
**));
7447 case VKI_USBDEVFS_REAPURBNDELAY
:
7449 PRE_MEM_WRITE( "ioctl(USBDEVFS_REAPURBNDELAY)", ARG3
, sizeof(struct vki_usbdevfs_urb
**));
7452 case VKI_USBDEVFS_CONNECTINFO
:
7453 PRE_MEM_WRITE( "ioctl(USBDEVFS_CONNECTINFO)", ARG3
, sizeof(struct vki_usbdevfs_connectinfo
));
7455 case VKI_USBDEVFS_IOCTL
:
7457 struct vki_usbdevfs_ioctl
*vkui
= (struct vki_usbdevfs_ioctl
*)ARG3
;
7459 PRE_MEM_READ("ioctl(USBDEVFS_IOCTL)", (Addr
)vkui
, sizeof(struct vki_usbdevfs_ioctl
));
7460 dir2
= _VKI_IOC_DIR(vkui
->ioctl_code
);
7461 size2
= _VKI_IOC_SIZE(vkui
->ioctl_code
);
7463 if (dir2
& _VKI_IOC_WRITE
)
7464 PRE_MEM_READ("ioctl(USBDEVFS_IOCTL).dataWrite", (Addr
)vkui
->data
, size2
);
7465 else if (dir2
& _VKI_IOC_READ
)
7466 PRE_MEM_WRITE("ioctl(USBDEVFS_IOCTL).dataRead", (Addr
)vkui
->data
, size2
);
7470 case VKI_USBDEVFS_RESET
:
7473 /* I2C (/dev/i2c-*) ioctls */
7475 case VKI_I2C_SLAVE_FORCE
:
7476 case VKI_I2C_TENBIT
:
7480 PRE_MEM_WRITE( "ioctl(I2C_FUNCS)", ARG3
, sizeof(unsigned long) );
7484 struct vki_i2c_rdwr_ioctl_data
*vkui
= (struct vki_i2c_rdwr_ioctl_data
*)ARG3
;
7486 PRE_MEM_READ("ioctl(I2C_RDWR)", (Addr
)vkui
, sizeof(struct vki_i2c_rdwr_ioctl_data
));
7487 for (i
=0; i
< vkui
->nmsgs
; i
++) {
7488 struct vki_i2c_msg
*msg
= vkui
->msgs
+ i
;
7489 PRE_MEM_READ("ioctl(I2C_RDWR).msgs", (Addr
)msg
, sizeof(struct vki_i2c_msg
));
7490 if (msg
->flags
& VKI_I2C_M_RD
)
7491 PRE_MEM_WRITE("ioctl(I2C_RDWR).msgs.buf", (Addr
)msg
->buf
, msg
->len
);
7493 PRE_MEM_READ("ioctl(I2C_RDWR).msgs.buf", (Addr
)msg
->buf
, msg
->len
);
7499 struct vki_i2c_smbus_ioctl_data
*vkis
7500 = (struct vki_i2c_smbus_ioctl_data
*) ARG3
;
7501 PRE_MEM_READ("ioctl(VKI_I2C_SMBUS).i2c_smbus_ioctl_data.read_write",
7502 (Addr
)&vkis
->read_write
, sizeof(vkis
->read_write
));
7503 PRE_MEM_READ("ioctl(VKI_I2C_SMBUS).i2c_smbus_ioctl_data.size",
7504 (Addr
)&vkis
->size
, sizeof(vkis
->size
));
7505 PRE_MEM_READ("ioctl(VKI_I2C_SMBUS).i2c_smbus_ioctl_data.command",
7506 (Addr
)&vkis
->command
, sizeof(vkis
->command
));
7507 /* i2c_smbus_write_quick hides its value in read_write, so
7508 this variable can have a different meaning */
7509 /* to make matters worse i2c_smbus_write_byte stores its
7511 if ( ! ((vkis
->size
== VKI_I2C_SMBUS_QUICK
) ||
7512 ((vkis
->size
== VKI_I2C_SMBUS_BYTE
)
7513 && (vkis
->read_write
== VKI_I2C_SMBUS_WRITE
)))) {
7514 /* the rest uses the byte array to store the data,
7515 some the first byte for size */
7517 switch(vkis
->size
) {
7518 case VKI_I2C_SMBUS_BYTE_DATA
:
7521 case VKI_I2C_SMBUS_WORD_DATA
:
7522 case VKI_I2C_SMBUS_PROC_CALL
:
7525 case VKI_I2C_SMBUS_BLOCK_DATA
:
7526 case VKI_I2C_SMBUS_I2C_BLOCK_BROKEN
:
7527 case VKI_I2C_SMBUS_BLOCK_PROC_CALL
:
7528 case VKI_I2C_SMBUS_I2C_BLOCK_DATA
:
7529 size
= 1 + vkis
->data
->block
[0];
7535 if ((vkis
->read_write
== VKI_I2C_SMBUS_READ
)
7536 || (vkis
->size
== VKI_I2C_SMBUS_PROC_CALL
)
7537 || (vkis
->size
== VKI_I2C_SMBUS_BLOCK_PROC_CALL
))
7538 PRE_MEM_WRITE("ioctl(VKI_I2C_SMBUS)"
7539 ".i2c_smbus_ioctl_data.data",
7540 (Addr
)&vkis
->data
->block
[0], size
);
7542 PRE_MEM_READ("ioctl(VKI_I2C_SMBUS)."
7543 "i2c_smbus_ioctl_data.data",
7544 (Addr
)&vkis
->data
->block
[0], size
);
7549 /* Wireless extensions ioctls */
7550 case VKI_SIOCSIWCOMMIT
:
7551 case VKI_SIOCSIWNWID
:
7552 case VKI_SIOCSIWFREQ
:
7553 case VKI_SIOCSIWMODE
:
7554 case VKI_SIOCSIWSENS
:
7555 case VKI_SIOCSIWRANGE
:
7556 case VKI_SIOCSIWPRIV
:
7557 case VKI_SIOCSIWSTATS
:
7558 case VKI_SIOCSIWSPY
:
7559 case VKI_SIOCSIWTHRSPY
:
7561 case VKI_SIOCSIWSCAN
:
7562 case VKI_SIOCSIWESSID
:
7563 case VKI_SIOCSIWRATE
:
7564 case VKI_SIOCSIWNICKN
:
7565 case VKI_SIOCSIWRTS
:
7566 case VKI_SIOCSIWFRAG
:
7567 case VKI_SIOCSIWTXPOW
:
7568 case VKI_SIOCSIWRETRY
:
7569 case VKI_SIOCSIWENCODE
:
7570 case VKI_SIOCSIWPOWER
:
7571 case VKI_SIOCSIWGENIE
:
7572 case VKI_SIOCSIWMLME
:
7573 case VKI_SIOCSIWAUTH
:
7574 case VKI_SIOCSIWENCODEEXT
:
7575 case VKI_SIOCSIWPMKSA
:
7577 case VKI_SIOCGIWNAME
:
7579 PRE_MEM_WRITE("ioctl(SIOCGIWNAME)",
7580 (Addr
)((struct vki_iwreq
*)ARG3
)->u
.name
,
7581 sizeof(((struct vki_iwreq
*)ARG3
)->u
.name
));
7584 case VKI_SIOCGIWNWID
:
7585 case VKI_SIOCGIWSENS
:
7586 case VKI_SIOCGIWRATE
:
7587 case VKI_SIOCGIWRTS
:
7588 case VKI_SIOCGIWFRAG
:
7589 case VKI_SIOCGIWTXPOW
:
7590 case VKI_SIOCGIWRETRY
:
7591 case VKI_SIOCGIWPOWER
:
7592 case VKI_SIOCGIWAUTH
:
7594 PRE_MEM_WRITE("ioctl(SIOCGIW[NWID|SENS|RATE|RTS|FRAG|TXPOW|"
7595 "RETRY|PARAM|AUTH])",
7596 (Addr
)&((struct vki_iwreq
*)ARG3
)->u
.nwid
,
7597 sizeof(struct vki_iw_param
));
7600 case VKI_SIOCGIWFREQ
:
7602 PRE_MEM_WRITE("ioctl(SIOCGIWFREQ",
7603 (Addr
)&((struct vki_iwreq
*)ARG3
)->u
.freq
,
7604 sizeof(struct vki_iw_freq
));
7607 case VKI_SIOCGIWMODE
:
7609 PRE_MEM_WRITE("ioctl(SIOCGIWMODE",
7610 (Addr
)&((struct vki_iwreq
*)ARG3
)->u
.mode
,
7614 case VKI_SIOCGIWRANGE
:
7615 case VKI_SIOCGIWPRIV
:
7616 case VKI_SIOCGIWSTATS
:
7617 case VKI_SIOCGIWSPY
:
7618 case VKI_SIOCGIWTHRSPY
:
7619 case VKI_SIOCGIWAPLIST
:
7620 case VKI_SIOCGIWSCAN
:
7621 case VKI_SIOCGIWESSID
:
7622 case VKI_SIOCGIWNICKN
:
7623 case VKI_SIOCGIWENCODE
:
7624 case VKI_SIOCGIWGENIE
:
7625 case VKI_SIOCGIWENCODEEXT
:
7627 struct vki_iw_point
* point
;
7628 point
= &((struct vki_iwreq
*)ARG3
)->u
.data
;
7629 PRE_MEM_WRITE("ioctl(SIOCGIW[RANGE|PRIV|STATS|SPY|THRSPY|"
7630 "APLIST|SCAN|ESSID|NICKN|ENCODE|GENIE|ENCODEEXT])",
7631 (Addr
)point
->pointer
, point
->length
);
7636 PRE_MEM_WRITE("ioctl(SIOCGIWAP)",
7637 (Addr
)&((struct vki_iwreq
*)ARG3
)->u
.ap_addr
,
7638 sizeof(struct vki_sockaddr
));
7642 /* User input device creation */
7643 case VKI_UI_SET_EVBIT
:
7644 case VKI_UI_SET_KEYBIT
:
7645 case VKI_UI_SET_RELBIT
:
7646 case VKI_UI_SET_ABSBIT
:
7647 case VKI_UI_SET_MSCBIT
:
7648 case VKI_UI_SET_LEDBIT
:
7649 case VKI_UI_SET_SNDBIT
:
7650 case VKI_UI_SET_FFBIT
:
7651 case VKI_UI_SET_SWBIT
:
7652 case VKI_UI_SET_PROPBIT
:
7653 /* These just take an int by value */
7656 # if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
7657 || defined(VGPV_mips32_linux_android) \
7658 || defined(VGPV_arm64_linux_android)
7660 case VKI_ASHMEM_GET_SIZE
:
7661 case VKI_ASHMEM_SET_SIZE
:
7662 case VKI_ASHMEM_GET_PROT_MASK
:
7663 case VKI_ASHMEM_SET_PROT_MASK
:
7664 case VKI_ASHMEM_GET_PIN_STATUS
:
7665 case VKI_ASHMEM_PURGE_ALL_CACHES
:
7667 case VKI_ASHMEM_GET_NAME
:
7668 PRE_MEM_WRITE( "ioctl(ASHMEM_SET_NAME)", ARG3
, VKI_ASHMEM_NAME_LEN
);
7670 case VKI_ASHMEM_SET_NAME
:
7671 PRE_MEM_RASCIIZ( "ioctl(ASHMEM_SET_NAME)", ARG3
);
7673 case VKI_ASHMEM_PIN
:
7674 case VKI_ASHMEM_UNPIN
:
7675 PRE_MEM_READ( "ioctl(ASHMEM_PIN|ASHMEM_UNPIN)",
7676 ARG3
, sizeof(struct vki_ashmem_pin
) );
7680 case VKI_BINDER_WRITE_READ
:
7682 struct vki_binder_write_read
* bwr
7683 = (struct vki_binder_write_read
*)ARG3
;
7685 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).write_buffer",
7687 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).write_size",
7689 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).write_consumed",
7690 bwr
->write_consumed
);
7691 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).read_buffer",
7693 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).read_size",
7695 PRE_FIELD_READ("ioctl(BINDER_WRITE_READ).read_consumed",
7696 bwr
->read_consumed
);
7698 PRE_FIELD_WRITE("ioctl(BINDER_WRITE_READ).write_consumed",
7699 bwr
->write_consumed
);
7700 PRE_FIELD_WRITE("ioctl(BINDER_WRITE_READ).read_consumed",
7701 bwr
->read_consumed
);
7704 PRE_MEM_WRITE("ioctl(BINDER_WRITE_READ).read_buffer[]",
7705 (Addr
)bwr
->read_buffer
, bwr
->read_size
);
7706 if (bwr
->write_size
)
7707 PRE_MEM_READ("ioctl(BINDER_WRITE_READ).write_buffer[]",
7708 (Addr
)bwr
->write_buffer
, bwr
->write_size
);
7712 case VKI_BINDER_SET_IDLE_TIMEOUT
:
7713 case VKI_BINDER_SET_MAX_THREADS
:
7714 case VKI_BINDER_SET_IDLE_PRIORITY
:
7715 case VKI_BINDER_SET_CONTEXT_MGR
:
7716 case VKI_BINDER_THREAD_EXIT
:
7718 case VKI_BINDER_VERSION
:
7720 struct vki_binder_version
* bv
= (struct vki_binder_version
*)ARG3
;
7721 PRE_FIELD_WRITE("ioctl(BINDER_VERSION)", bv
->protocol_version
);
7724 # endif /* defined(VGPV_*_linux_android) */
7726 case VKI_HCIGETDEVLIST
:
7728 struct vki_hci_dev_list_req
* dlr
= (struct vki_hci_dev_list_req
*)ARG3
;
7729 PRE_MEM_READ("ioctl(HCIGETDEVLIST)",
7730 (Addr
)ARG3
, sizeof(struct vki_hci_dev_list_req
));
7731 PRE_MEM_WRITE("ioctl(HCIGETDEVLIST)",
7732 (Addr
)ARG3
+ sizeof(struct vki_hci_dev_list_req
),
7733 dlr
->dev_num
* sizeof(struct vki_hci_dev_req
));
7737 case VKI_HCIINQUIRY
:
7739 struct vki_hci_inquiry_req
* ir
= (struct vki_hci_inquiry_req
*)ARG3
;
7740 PRE_MEM_READ("ioctl(HCIINQUIRY)",
7741 (Addr
)ARG3
, sizeof(struct vki_hci_inquiry_req
));
7742 PRE_MEM_WRITE("ioctl(HCIINQUIRY)",
7743 (Addr
)ARG3
+ sizeof(struct vki_hci_inquiry_req
),
7744 ir
->num_rsp
* sizeof(struct vki_inquiry_info
));
7748 case VKI_DRM_IOCTL_VERSION
:
7750 struct vki_drm_version
* data
= (struct vki_drm_version
*)ARG3
;
7751 struct vg_drm_version_info
* info
;
7752 PRE_MEM_WRITE("ioctl(DRM_VERSION).version_major", (Addr
)&data
->version_major
, sizeof(data
->version_major
));
7753 PRE_MEM_WRITE("ioctl(DRM_VERSION).version_minor", (Addr
)&data
->version_minor
, sizeof(data
->version_minor
));
7754 PRE_MEM_WRITE("ioctl(DRM_VERSION).version_patchlevel", (Addr
)&data
->version_patchlevel
, sizeof(data
->version_patchlevel
));
7755 PRE_MEM_READ("ioctl(DRM_VERSION).name_len", (Addr
)&data
->name_len
, sizeof(data
->name_len
));
7756 PRE_MEM_READ("ioctl(DRM_VERSION).name", (Addr
)&data
->name
, sizeof(data
->name
));
7757 PRE_MEM_WRITE("ioctl(DRM_VERSION).name", (Addr
)data
->name
, data
->name_len
);
7758 PRE_MEM_READ("ioctl(DRM_VERSION).date_len", (Addr
)&data
->date_len
, sizeof(data
->date_len
));
7759 PRE_MEM_READ("ioctl(DRM_VERSION).date", (Addr
)&data
->date
, sizeof(data
->date
));
7760 PRE_MEM_WRITE("ioctl(DRM_VERSION).date", (Addr
)data
->date
, data
->date_len
);
7761 PRE_MEM_READ("ioctl(DRM_VERSION).desc_len", (Addr
)&data
->desc_len
, sizeof(data
->desc_len
));
7762 PRE_MEM_READ("ioctl(DRM_VERSION).desc", (Addr
)&data
->desc
, sizeof(data
->desc
));
7763 PRE_MEM_WRITE("ioctl(DRM_VERSION).desc", (Addr
)data
->desc
, data
->desc_len
);
7764 info
= VG_(malloc
)("syswrap.ioctl.1", sizeof(*info
));
7765 // To ensure we VG_(free) info even when syscall fails:
7766 *flags
|= SfPostOnFail
;
7769 ARG3
= (Addr
)&info
->data
;
7772 case VKI_DRM_IOCTL_GET_UNIQUE
:
7774 struct vki_drm_unique
*data
= (struct vki_drm_unique
*)ARG3
;
7775 PRE_MEM_READ("ioctl(DRM_GET_UNIQUE).unique_len", (Addr
)&data
->unique_len
, sizeof(data
->unique_len
));
7776 PRE_MEM_READ("ioctl(DRM_GET_UNIQUE).unique", (Addr
)&data
->unique
, sizeof(data
->unique
));
7777 PRE_MEM_WRITE("ioctl(DRM_GET_UNIQUE).unique", (Addr
)data
->unique
, data
->unique_len
);
7780 case VKI_DRM_IOCTL_GET_MAGIC
:
7782 struct vki_drm_auth
*data
= (struct vki_drm_auth
*)ARG3
;
7783 PRE_MEM_WRITE("ioctl(DRM_GET_MAGIC).magic", (Addr
)&data
->magic
, sizeof(data
->magic
));
7786 case VKI_DRM_IOCTL_WAIT_VBLANK
:
7788 union vki_drm_wait_vblank
*data
= (union vki_drm_wait_vblank
*)ARG3
;
7789 PRE_MEM_READ("ioctl(DRM_WAIT_VBLANK).request.type", (Addr
)&data
->request
.type
, sizeof(data
->request
.type
));
7790 PRE_MEM_READ("ioctl(DRM_WAIT_VBLANK).request.sequence", (Addr
)&data
->request
.sequence
, sizeof(data
->request
.sequence
));
7791 /* XXX: It seems request.signal isn't used */
7792 PRE_MEM_WRITE("ioctl(DRM_WAIT_VBLANK).reply", (Addr
)&data
->reply
, sizeof(data
->reply
));
7795 case VKI_DRM_IOCTL_GEM_CLOSE
:
7797 struct vki_drm_gem_close
*data
= (struct vki_drm_gem_close
*)ARG3
;
7798 PRE_MEM_READ("ioctl(DRM_GEM_CLOSE).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7801 case VKI_DRM_IOCTL_GEM_FLINK
:
7803 struct vki_drm_gem_flink
*data
= (struct vki_drm_gem_flink
*)ARG3
;
7804 PRE_MEM_READ("ioctl(DRM_GEM_FLINK).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7805 PRE_MEM_WRITE("ioctl(DRM_GEM_FLINK).name", (Addr
)&data
->name
, sizeof(data
->name
));
7808 case VKI_DRM_IOCTL_GEM_OPEN
:
7810 struct vki_drm_gem_open
*data
= (struct vki_drm_gem_open
*)ARG3
;
7811 PRE_MEM_READ("ioctl(DRM_GEM_OPEN).name", (Addr
)&data
->name
, sizeof(data
->name
));
7812 PRE_MEM_WRITE("ioctl(DRM_GEM_OPEN).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7813 PRE_MEM_WRITE("ioctl(DRM_GEM_OPEN).size", (Addr
)&data
->size
, sizeof(data
->size
));
7816 case VKI_DRM_IOCTL_I915_GETPARAM
:
7818 vki_drm_i915_getparam_t
*data
= (vki_drm_i915_getparam_t
*)ARG3
;
7819 PRE_MEM_READ("ioctl(DRM_I915_GETPARAM).param", (Addr
)&data
->param
, sizeof(data
->param
));
7820 PRE_MEM_WRITE("ioctl(DRM_I915_GETPARAM).value", (Addr
)data
->value
, sizeof(int));
7823 case VKI_DRM_IOCTL_I915_GEM_BUSY
:
7825 struct vki_drm_i915_gem_busy
*data
= (struct vki_drm_i915_gem_busy
*)ARG3
;
7826 PRE_MEM_READ("ioctl(DRM_I915_GEM_BUSY).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7827 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_BUSY).busy", (Addr
)&data
->busy
, sizeof(data
->busy
));
7830 case VKI_DRM_IOCTL_I915_GEM_CREATE
:
7832 struct vki_drm_i915_gem_create
*data
= (struct vki_drm_i915_gem_create
*)ARG3
;
7833 PRE_MEM_READ("ioctl(DRM_I915_GEM_CREATE).size", (Addr
)&data
->size
, sizeof(data
->size
));
7834 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_CREATE).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7837 case VKI_DRM_IOCTL_I915_GEM_PREAD
:
7839 struct vki_drm_i915_gem_pread
*data
= (struct vki_drm_i915_gem_pread
*)ARG3
;
7840 PRE_MEM_READ("ioctl(DRM_I915_GEM_PREAD).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7841 PRE_MEM_READ("ioctl(DRM_I915_GEM_PREAD).offset", (Addr
)&data
->offset
, sizeof(data
->offset
));
7842 PRE_MEM_READ("ioctl(DRM_I915_GEM_PREAD).size", (Addr
)&data
->size
, sizeof(data
->size
));
7843 PRE_MEM_READ("ioctl(DRM_I915_GEM_PREAD).data_ptr", (Addr
)&data
->data_ptr
, sizeof(data
->data_ptr
));
7844 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_PREAD).data_ptr", (Addr
)data
->data_ptr
, data
->size
);
7847 case VKI_DRM_IOCTL_I915_GEM_PWRITE
:
7849 struct vki_drm_i915_gem_pwrite
*data
= (struct vki_drm_i915_gem_pwrite
*)ARG3
;
7850 PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7851 PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).offset", (Addr
)&data
->offset
, sizeof(data
->offset
));
7852 PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).size", (Addr
)&data
->size
, sizeof(data
->size
));
7853 PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).data_ptr", (Addr
)&data
->data_ptr
, sizeof(data
->data_ptr
));
7854 /* PRE_MEM_READ("ioctl(DRM_I915_GEM_PWRITE).data_ptr", (Addr)data->data_ptr, data->size);
7855 * NB: the buffer is allowed to contain any amount of uninitialized data (e.g.
7856 * interleaved vertex attributes may have a wide stride with uninitialized data between
7857 * consecutive vertices) */
7860 case VKI_DRM_IOCTL_I915_GEM_MMAP_GTT
:
7862 struct vki_drm_i915_gem_mmap_gtt
*data
= (struct vki_drm_i915_gem_mmap_gtt
*)ARG3
;
7863 PRE_MEM_READ("ioctl(DRM_I915_GEM_MMAP_GTT).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7864 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_MMAP_GTT).offset", (Addr
)&data
->offset
, sizeof(data
->offset
));
7867 case VKI_DRM_IOCTL_I915_GEM_SET_DOMAIN
:
7869 struct vki_drm_i915_gem_set_domain
*data
= (struct vki_drm_i915_gem_set_domain
*)ARG3
;
7870 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_DOMAIN).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7871 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_DOMAIN).read_domains", (Addr
)&data
->read_domains
, sizeof(data
->read_domains
));
7872 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_DOMAIN).write_domain", (Addr
)&data
->write_domain
, sizeof(data
->write_domain
));
7875 case VKI_DRM_IOCTL_I915_GEM_SET_TILING
:
7877 struct vki_drm_i915_gem_set_tiling
*data
= (struct vki_drm_i915_gem_set_tiling
*)ARG3
;
7878 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_TILING).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7879 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_TILING).tiling_mode", (Addr
)&data
->tiling_mode
, sizeof(data
->tiling_mode
));
7880 PRE_MEM_READ("ioctl(DRM_I915_GEM_SET_TILING).stride", (Addr
)&data
->stride
, sizeof(data
->stride
));
7881 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_SET_TILING).swizzle_mode", (Addr
)&data
->swizzle_mode
, sizeof(data
->swizzle_mode
));
7884 case VKI_DRM_IOCTL_I915_GEM_GET_TILING
:
7886 struct vki_drm_i915_gem_get_tiling
*data
= (struct vki_drm_i915_gem_get_tiling
*)ARG3
;
7887 PRE_MEM_READ("ioctl(DRM_I915_GEM_GET_TILING).handle", (Addr
)&data
->handle
, sizeof(data
->handle
));
7888 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_GET_TILING).tiling_mode", (Addr
)&data
->tiling_mode
, sizeof(data
->tiling_mode
));
7889 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_GET_TILING).swizzle_mode", (Addr
)&data
->swizzle_mode
, sizeof(data
->swizzle_mode
));
7892 case VKI_DRM_IOCTL_I915_GEM_GET_APERTURE
:
7894 struct vki_drm_i915_gem_get_aperture
*data
= (struct vki_drm_i915_gem_get_aperture
*)ARG3
;
7895 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_GET_APERTURE).aper_size", (Addr
)&data
->aper_size
, sizeof(data
->aper_size
));
7896 PRE_MEM_WRITE("ioctl(DRM_I915_GEM_GET_APERTURE).aper_available_size", (Addr
)&data
->aper_available_size
, sizeof(data
->aper_available_size
));
7900 /* KVM ioctls that check for a numeric value as parameter */
7901 case VKI_KVM_GET_API_VERSION
:
7902 case VKI_KVM_CREATE_VM
:
7903 case VKI_KVM_GET_VCPU_MMAP_SIZE
:
7904 case VKI_KVM_CHECK_EXTENSION
:
7905 case VKI_KVM_SET_TSS_ADDR
:
7906 case VKI_KVM_CREATE_VCPU
:
7910 case VKI_KVM_S390_MEM_OP
: {
7911 struct vki_kvm_s390_mem_op
*args
=
7912 (struct vki_kvm_s390_mem_op
*)(ARG3
);
7913 PRE_MEM_READ("ioctl(KVM_S390_MEM_OP)", ARG3
,
7914 sizeof(struct vki_kvm_s390_mem_op
));
7915 if (args
->flags
& VKI_KVM_S390_MEMOP_F_CHECK_ONLY
)
7917 if (args
->op
== VKI_KVM_S390_MEMOP_LOGICAL_READ
)
7918 PRE_MEM_WRITE("ioctl(KVM_S390_MEM_OP).buf", (Addr
)args
->buf
, args
->size
);
7919 if (args
->op
== VKI_KVM_S390_MEMOP_LOGICAL_WRITE
)
7920 PRE_MEM_READ("ioctl(KVM_S390_MEM_OP).buf", (Addr
)args
->buf
, args
->size
);
7926 case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL
: {
7927 SyscallArgs harrghs
;
7928 struct vki_xen_privcmd_hypercall
*args
=
7929 (struct vki_xen_privcmd_hypercall
*)(ARG3
);
7934 VG_(memset
)(&harrghs
, 0, sizeof(harrghs
));
7935 harrghs
.sysno
= args
->op
;
7936 harrghs
.arg1
= args
->arg
[0];
7937 harrghs
.arg2
= args
->arg
[1];
7938 harrghs
.arg3
= args
->arg
[2];
7939 harrghs
.arg4
= args
->arg
[3];
7940 harrghs
.arg5
= args
->arg
[4];
7941 harrghs
.arg6
= harrghs
.arg7
= harrghs
.arg8
= 0;
7943 WRAPPER_PRE_NAME(xen
, hypercall
) (tid
, layout
, &harrghs
, status
, flags
);
7945 /* HACK. arg8 is used to return the number of hypercall
7946 * arguments actually consumed! */
7947 PRE_MEM_READ("hypercall", ARG3
, sizeof(args
->op
) +
7948 ( sizeof(args
->arg
[0]) * harrghs
.arg8
) );
7953 case VKI_XEN_IOCTL_PRIVCMD_MMAP
: {
7954 struct vki_xen_privcmd_mmap
*args
=
7955 (struct vki_xen_privcmd_mmap
*)(ARG3
);
7956 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP(num)",
7957 (Addr
)&args
->num
, sizeof(args
->num
));
7958 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP(dom)",
7959 (Addr
)&args
->dom
, sizeof(args
->dom
));
7960 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAP(entry)",
7961 (Addr
)args
->entry
, sizeof(*(args
->entry
)) * args
->num
);
7964 case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH
: {
7965 struct vki_xen_privcmd_mmapbatch
*args
=
7966 (struct vki_xen_privcmd_mmapbatch
*)(ARG3
);
7967 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH(num)",
7968 (Addr
)&args
->num
, sizeof(args
->num
));
7969 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH(dom)",
7970 (Addr
)&args
->dom
, sizeof(args
->dom
));
7971 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH(addr)",
7972 (Addr
)&args
->addr
, sizeof(args
->addr
));
7973 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH(arr)",
7974 (Addr
)args
->arr
, sizeof(*(args
->arr
)) * args
->num
);
7977 case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2
: {
7978 struct vki_xen_privcmd_mmapbatch_v2
*args
=
7979 (struct vki_xen_privcmd_mmapbatch_v2
*)(ARG3
);
7980 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2(num)",
7981 (Addr
)&args
->num
, sizeof(args
->num
));
7982 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2(dom)",
7983 (Addr
)&args
->dom
, sizeof(args
->dom
));
7984 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2(addr)",
7985 (Addr
)&args
->addr
, sizeof(args
->addr
));
7986 PRE_MEM_READ("VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2(arr)",
7987 (Addr
)args
->arr
, sizeof(*(args
->arr
)) * args
->num
);
7991 case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ
: {
7992 struct vki_xen_ioctl_evtchn_bind_virq
*args
=
7993 (struct vki_xen_ioctl_evtchn_bind_virq
*)(ARG3
);
7994 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ(virq)",
7995 (Addr
)&args
->virq
, sizeof(args
->virq
));
7998 case VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN
: {
7999 struct vki_xen_ioctl_evtchn_bind_interdomain
*args
=
8000 (struct vki_xen_ioctl_evtchn_bind_interdomain
*)(ARG3
);
8001 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN(remote_domain)",
8002 (Addr
)&args
->remote_domain
, sizeof(args
->remote_domain
));
8003 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN(remote_port)",
8004 (Addr
)&args
->remote_port
, sizeof(args
->remote_port
));
8007 case VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT
: {
8008 struct vki_xen_ioctl_evtchn_bind_unbound_port
*args
=
8009 (struct vki_xen_ioctl_evtchn_bind_unbound_port
*)(ARG3
);
8010 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT(remote_domain)",
8011 (Addr
)&args
->remote_domain
, sizeof(args
->remote_domain
));
8014 case VKI_XEN_IOCTL_EVTCHN_UNBIND
: {
8015 struct vki_xen_ioctl_evtchn_unbind
*args
=
8016 (struct vki_xen_ioctl_evtchn_unbind
*)(ARG3
);
8017 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_UNBIND(port)",
8018 (Addr
)&args
->port
, sizeof(args
->port
));
8021 case VKI_XEN_IOCTL_EVTCHN_NOTIFY
: {
8022 struct vki_xen_ioctl_evtchn_notify
*args
=
8023 (struct vki_xen_ioctl_evtchn_notify
*)(ARG3
);
8024 PRE_MEM_READ("VKI_XEN_IOCTL_EVTCHN_notify(port)",
8025 (Addr
)&args
->port
, sizeof(args
->port
));
8028 case VKI_XEN_IOCTL_EVTCHN_RESET
:
8034 case VKI_OBD_IOC_FID2PATH
: {
8035 struct vki_getinfo_fid2path
*gf
= (struct vki_getinfo_fid2path
*)ARG3
;
8036 PRE_MEM_READ("VKI_OBD_IOC_FID2PATH(args)", ARG3
, sizeof(struct vki_getinfo_fid2path
));
8037 PRE_FIELD_WRITE("VKI_OBD_IOC_FID2PATH(args).gf_recno", gf
->gf_recno
);
8038 PRE_FIELD_WRITE("VKI_OBD_IOC_FID2PATH(args).gf_linkno", gf
->gf_linkno
);
8039 PRE_MEM_WRITE("VKI_OBD_IOC_FID2PATH(args)", (Addr
)gf
->gf_path
, gf
->gf_pathlen
);
8043 case VKI_LL_IOC_PATH2FID
:
8044 PRE_MEM_WRITE("ioctl(VKI_LL_IOC_PATH2FID)", ARG3
, sizeof(struct vki_lu_fid
));
8047 case VKI_LL_IOC_GETPARENT
: {
8048 struct vki_getparent
*gp
= (struct vki_getparent
*)ARG3
;
8049 PRE_FIELD_READ("ioctl(VKI_LL_IOC_GETPARENT).gp_linkno", gp
->gp_linkno
);
8050 PRE_FIELD_READ("ioctl(VKI_LL_IOC_GETPARENT).gp_name_size", gp
->gp_name_size
);
8051 PRE_FIELD_WRITE("ioctl(VKI_LL_IOC_GETPARENT).gp_fid", gp
->gp_fid
);
8052 PRE_MEM_WRITE("ioctl(VKI_LL_IOC_GETPARENT).gp_name", (Addr
)gp
->gp_name
, gp
->gp_name_size
);
8057 case VKI_V4L2_QUERYCAP
: {
8058 struct vki_v4l2_capability
*data
= (struct vki_v4l2_capability
*)ARG3
;
8059 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERYCAP)", (Addr
)data
, sizeof(*data
));
8062 case VKI_V4L2_ENUM_FMT
: {
8063 struct vki_v4l2_fmtdesc
*data
= (struct vki_v4l2_fmtdesc
*)ARG3
;
8064 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FMT).index", data
->index
);
8065 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FMT).type", data
->type
);
8066 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FMT).flags", data
->flags
);
8067 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FMT).description", data
->description
);
8068 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FMT).pixelformat", data
->pixelformat
);
8069 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FMT).reserved", data
->reserved
);
8072 case VKI_V4L2_G_FMT
: {
8073 struct vki_v4l2_format
*data
= (struct vki_v4l2_format
*)ARG3
;
8074 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).type", data
->type
);
8075 switch (data
->type
) {
8076 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
8077 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
8078 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).fmt.pix.priv", data
->fmt
.pix
.priv
);
8079 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.pix", data
->fmt
.pix
);
8080 PRE_MEM_READ("ioctl(VKI_V4L2_G_FMT)",
8081 (Addr
)&data
->type
+ sizeof(data
->type
) + sizeof(data
->fmt
.pix
),
8082 sizeof(*data
) - sizeof(data
->type
) - sizeof(data
->fmt
.pix
));
8084 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
8085 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
8086 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.vbi", data
->fmt
.vbi
);
8088 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
8089 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
8090 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.sliced", data
->fmt
.sliced
);
8092 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
8093 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
8094 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).fmt.win.clips", data
->fmt
.win
.clips
);
8095 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).fmt.win.bitmap", data
->fmt
.win
.bitmap
);
8096 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FMT).fmt.win.clipcount", data
->fmt
.win
.clipcount
);
8097 if (data
->fmt
.win
.clipcount
&& data
->fmt
.win
.clips
)
8098 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.clips[]",
8099 (Addr
)data
->fmt
.win
.clips
,
8100 data
->fmt
.win
.clipcount
* sizeof(data
->fmt
.win
.clips
[0]));
8101 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.clipcount", data
->fmt
.win
.clipcount
);
8102 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.w", data
->fmt
.win
.w
);
8103 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.field", data
->fmt
.win
.field
);
8104 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.chromakey", data
->fmt
.win
.chromakey
);
8105 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.win.global_alpha", data
->fmt
.win
.global_alpha
);
8107 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
8108 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
8109 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.pix_mp", data
->fmt
.pix_mp
);
8111 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
8112 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FMT).fmt.sdr", data
->fmt
.sdr
);
8117 case VKI_V4L2_S_FMT
: {
8118 struct vki_v4l2_format
*data
= (struct vki_v4l2_format
*)ARG3
;
8119 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).type", data
->type
);
8120 switch (data
->type
) {
8121 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
8122 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
8123 PRE_MEM_READ("ioctl(VKI_V4L2_S_FMT)",
8124 (Addr
)&data
->type
+ sizeof(data
->type
),
8125 sizeof(*data
) - sizeof(data
->type
));
8127 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
8128 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
8129 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.vbi", data
->fmt
.vbi
);
8131 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
8132 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
8133 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.sliced", data
->fmt
.sliced
);
8135 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
8136 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
8137 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.win", data
->fmt
.win
);
8138 if (data
->fmt
.win
.clipcount
&& data
->fmt
.win
.clips
)
8139 PRE_MEM_READ("ioctl(VKI_V4L2_S_FMT).fmt.win.clips[]",
8140 (Addr
)data
->fmt
.win
.clips
,
8141 data
->fmt
.win
.clipcount
* sizeof(data
->fmt
.win
.clips
[0]));
8142 if (data
->fmt
.win
.bitmap
)
8143 PRE_MEM_READ("ioctl(VKI_V4L2_S_FMT).fmt.win.bitmap[]",
8144 (Addr
)data
->fmt
.win
.bitmap
,
8145 data
->fmt
.win
.w
.height
* ((data
->fmt
.win
.w
.width
+ 7) / 8));
8147 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
8148 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
8149 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.pix_mp", data
->fmt
.pix_mp
);
8151 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
8152 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FMT).fmt.sdr", data
->fmt
.sdr
);
8157 case VKI_V4L2_TRY_FMT
: {
8158 struct vki_v4l2_format
*data
= (struct vki_v4l2_format
*)ARG3
;
8159 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).type", data
->type
);
8160 switch (data
->type
) {
8161 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
8162 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
8163 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_FMT)",
8164 (Addr
)&data
->type
+ sizeof(data
->type
),
8165 sizeof(*data
) - sizeof(data
->type
));
8167 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
8168 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
8169 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.vbi", data
->fmt
.vbi
);
8171 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
8172 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
8173 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.sliced", data
->fmt
.sliced
);
8175 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
8176 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
8177 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.win", data
->fmt
.win
);
8178 if (data
->fmt
.win
.clipcount
&& data
->fmt
.win
.clips
)
8179 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.win.clips[]",
8180 (Addr
)data
->fmt
.win
.clips
,
8181 data
->fmt
.win
.clipcount
* sizeof(data
->fmt
.win
.clips
[0]));
8182 if (data
->fmt
.win
.bitmap
)
8183 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.win.bitmap[]",
8184 (Addr
)data
->fmt
.win
.bitmap
,
8185 data
->fmt
.win
.w
.height
* ((data
->fmt
.win
.w
.width
+ 7) / 8));
8187 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
8188 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
8189 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.pix_mp", data
->fmt
.pix_mp
);
8191 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
8192 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_FMT).fmt.sdr", data
->fmt
.sdr
);
8197 case VKI_V4L2_REQBUFS
: {
8198 struct vki_v4l2_requestbuffers
*data
= (struct vki_v4l2_requestbuffers
*)ARG3
;
8199 PRE_MEM_READ("ioctl(VKI_V4L2_REQBUFS)", (Addr
)data
, sizeof(*data
));
8202 case VKI_V4L2_QUERYBUF
: {
8203 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
8204 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).type", data
->type
);
8205 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).index", data
->index
);
8206 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).reserved", data
->reserved
);
8207 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).reserved2", data
->reserved2
);
8208 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
8209 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
8212 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).length", data
->length
);
8213 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYBUF).m.planes", data
->m
.planes
);
8214 for (i
= 0; i
< data
->length
; i
++) {
8215 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].bytesused", data
->m
.planes
[i
].bytesused
);
8216 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].length", data
->m
.planes
[i
].length
);
8217 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].m", data
->m
.planes
[i
].m
);
8218 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].data_offset", data
->m
.planes
[i
].data_offset
);
8219 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m.planes[].reserved", data
->m
.planes
[i
].reserved
);
8222 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).m", data
->m
);
8223 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).length", data
->length
);
8225 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).bytesused", data
->bytesused
);
8226 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).flags", data
->flags
);
8227 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).field", data
->field
);
8228 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).timestamp", data
->timestamp
);
8229 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).timecode", data
->timecode
);
8230 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).sequence", data
->sequence
);
8231 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).memory", data
->memory
);
8232 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QUERYBUF).sequence", data
->sequence
);
8235 case VKI_V4L2_G_FBUF
: {
8236 struct vki_v4l2_framebuffer
*data
= (struct vki_v4l2_framebuffer
*)ARG3
;
8237 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_FBUF)", (Addr
)data
, sizeof(*data
));
8240 case VKI_V4L2_S_FBUF
: {
8241 struct vki_v4l2_framebuffer
*data
= (struct vki_v4l2_framebuffer
*)ARG3
;
8242 PRE_FIELD_WRITE("ioctl(VKI_V4L2_S_FBUF).capability", data
->capability
);
8243 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FBUF).flags", data
->flags
);
8244 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FBUF).base", data
->base
);
8245 PRE_FIELD_READ("ioctl(VKI_V4L2_S_FBUF).fmt", data
->fmt
);
8248 case VKI_V4L2_OVERLAY
: {
8249 int *data
= (int *)ARG3
;
8250 PRE_MEM_READ("ioctl(VKI_V4L2_OVERLAY)", (Addr
)data
, sizeof(*data
));
8253 case VKI_V4L2_QBUF
: {
8254 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
8255 int is_output
= data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
||
8256 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
||
8257 data
->type
== VKI_V4L2_BUF_TYPE_VBI_OUTPUT
||
8258 data
->type
== VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
;
8260 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).type", data
->type
);
8261 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).index", data
->index
);
8262 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).flags", data
->flags
);
8263 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).memory", data
->memory
);
8264 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).reserved", data
->reserved
);
8265 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).reserved2", data
->reserved2
);
8267 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).bytesused", data
->bytesused
);
8268 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).field", data
->field
);
8270 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
8271 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
8274 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).length", data
->length
);
8275 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes", data
->m
.planes
);
8276 for (i
= 0; i
< data
->length
; i
++) {
8278 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].bytesused", data
->m
.planes
[i
].bytesused
);
8279 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].data_offset", data
->m
.planes
[i
].data_offset
);
8281 if (data
->memory
== VKI_V4L2_MEMORY_MMAP
)
8282 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QBUF).m.planes[].m", data
->m
.planes
[i
].m
);
8283 else if (data
->memory
== VKI_V4L2_MEMORY_DMABUF
)
8284 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].m.fd", data
->m
.planes
[i
].m
.fd
);
8286 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].m", data
->m
.planes
[i
].m
);
8287 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.planes[].reserved", data
->m
.planes
[i
].reserved
);
8290 if (data
->memory
== VKI_V4L2_MEMORY_MMAP
)
8291 PRE_FIELD_WRITE("ioctl(VKI_V4L2_QBUF).m", data
->m
);
8292 else if (data
->memory
== VKI_V4L2_MEMORY_DMABUF
)
8293 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m.fd", data
->m
.fd
);
8295 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).m", data
->m
);
8297 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).bytesused", data
->bytesused
);
8298 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).field", data
->field
);
8301 if (is_output
&& (data
->flags
& VKI_V4L2_BUF_FLAG_TIMESTAMP_MASK
) == VKI_V4L2_BUF_FLAG_TIMESTAMP_COPY
) {
8302 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).timestamp", data
->timestamp
);
8303 PRE_FIELD_READ("ioctl(VKI_V4L2_QBUF).timecode", data
->timecode
);
8307 case VKI_V4L2_EXPBUF
: {
8308 struct vki_v4l2_exportbuffer
*data
= (struct vki_v4l2_exportbuffer
*)ARG3
;
8309 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).type", data
->type
);
8310 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).index", data
->index
);
8311 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).plane", data
->plane
);
8312 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).flags", data
->flags
);
8313 PRE_FIELD_WRITE("ioctl(VKI_V4L2_EXPBUF).fd", data
->fd
);
8314 PRE_FIELD_READ("ioctl(VKI_V4L2_EXPBUF).reserved", data
->reserved
);
8317 case VKI_V4L2_DQBUF
: {
8318 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
8319 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).type", data
->type
);
8320 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).index", data
->index
);
8321 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).memory", data
->memory
);
8322 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).reserved", data
->reserved
);
8323 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).reserved2", data
->reserved2
);
8324 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).bytesused", data
->bytesused
);
8325 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).field", data
->field
);
8326 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
8327 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
8330 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).length", data
->length
);
8331 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).m.planes", data
->m
.planes
);
8332 for (i
= 0; i
< data
->length
; i
++) {
8333 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m.planes[].bytesused", data
->m
.planes
[i
].bytesused
);
8334 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m.planes[].data_offset", data
->m
.planes
[i
].data_offset
);
8335 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m.planes[].length", data
->m
.planes
[i
].length
);
8336 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m.planes[].m", data
->m
.planes
[i
].m
);
8337 PRE_FIELD_READ("ioctl(VKI_V4L2_DQBUF).m.planes[].reserved", data
->m
.planes
[i
].reserved
);
8340 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).m", data
->m
);
8341 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).length", data
->length
);
8342 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).bytesused", data
->bytesused
);
8343 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).field", data
->field
);
8345 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).timestamp", data
->timestamp
);
8346 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).timecode", data
->timecode
);
8347 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DQBUF).sequence", data
->sequence
);
8350 case VKI_V4L2_STREAMON
: {
8351 int *data
= (int *)ARG3
;
8352 PRE_MEM_READ("ioctl(VKI_V4L2_STREAMON)", (Addr
)data
, sizeof(*data
));
8355 case VKI_V4L2_STREAMOFF
: {
8356 int *data
= (int *)ARG3
;
8357 PRE_MEM_READ("ioctl(VKI_V4L2_STREAMOFF)", (Addr
)data
, sizeof(*data
));
8360 case VKI_V4L2_G_PARM
: {
8361 struct vki_v4l2_streamparm
*data
= (struct vki_v4l2_streamparm
*)ARG3
;
8362 int is_output
= data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
||
8363 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
||
8364 data
->type
== VKI_V4L2_BUF_TYPE_VBI_OUTPUT
||
8365 data
->type
== VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
;
8367 PRE_FIELD_READ("ioctl(VKI_V4L2_G_PARM).type", data
->type
);
8369 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_PARM)", (Addr
)&data
->parm
.output
,
8370 sizeof(data
->parm
.output
) - sizeof(data
->parm
.output
.reserved
));
8371 PRE_FIELD_READ("ioctl(VKI_V4L2_G_PARM).parm.output.reserved", data
->parm
.output
.reserved
);
8373 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_PARM)", (Addr
)&data
->parm
.capture
,
8374 sizeof(data
->parm
.capture
) - sizeof(data
->parm
.capture
.reserved
));
8375 PRE_FIELD_READ("ioctl(VKI_V4L2_G_PARM).parm.capture.reserved", data
->parm
.capture
.reserved
);
8379 case VKI_V4L2_S_PARM
: {
8380 struct vki_v4l2_streamparm
*data
= (struct vki_v4l2_streamparm
*)ARG3
;
8381 int is_output
= data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
||
8382 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
||
8383 data
->type
== VKI_V4L2_BUF_TYPE_VBI_OUTPUT
||
8384 data
->type
== VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
;
8386 PRE_FIELD_READ("ioctl(VKI_V4L2_S_PARM).type", data
->type
);
8388 PRE_FIELD_READ("ioctl(VKI_V4L2_S_PARM).parm.output", data
->parm
.output
);
8390 PRE_FIELD_READ("ioctl(VKI_V4L2_S_PARM).parm.capture", data
->parm
.capture
);
8393 case VKI_V4L2_G_STD
: {
8394 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
8395 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_STD)", (Addr
)data
, sizeof(*data
));
8398 case VKI_V4L2_S_STD
: {
8399 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
8400 PRE_MEM_READ("ioctl(VKI_V4L2_S_STD)", (Addr
)data
, sizeof(*data
));
8403 case VKI_V4L2_ENUMSTD
: {
8404 struct vki_v4l2_standard
*data
= (struct vki_v4l2_standard
*)ARG3
;
8405 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMSTD).index", data
->index
);
8406 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMSTD)", (Addr
)&data
->id
, sizeof(*data
) - sizeof(data
->index
));
8409 case VKI_V4L2_ENUMINPUT
: {
8410 struct vki_v4l2_input
*data
= (struct vki_v4l2_input
*)ARG3
;
8411 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMINPUT).index", data
->index
);
8412 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMINPUT)", (Addr
)data
->name
, sizeof(*data
) - sizeof(data
->index
));
8415 case VKI_V4L2_G_CTRL
: {
8416 struct vki_v4l2_control
*data
= (struct vki_v4l2_control
*)ARG3
;
8417 PRE_FIELD_READ("ioctl(VKI_V4L2_G_CTRL).id", data
->id
);
8418 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_CTRL).value", data
->value
);
8421 case VKI_V4L2_S_CTRL
: {
8422 struct vki_v4l2_control
*data
= (struct vki_v4l2_control
*)ARG3
;
8423 PRE_MEM_READ("ioctl(VKI_V4L2_S_CTRL)", (Addr
)data
, sizeof(*data
));
8426 case VKI_V4L2_G_TUNER
: {
8427 struct vki_v4l2_tuner
*data
= (struct vki_v4l2_tuner
*)ARG3
;
8428 PRE_FIELD_READ("ioctl(VKI_V4L2_G_TUNER).index", data
->index
);
8429 PRE_FIELD_READ("ioctl(VKI_V4L2_G_TUNER).reserved", data
->reserved
);
8430 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_TUNER)", (Addr
)data
->name
,
8431 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
8434 case VKI_V4L2_S_TUNER
: {
8435 struct vki_v4l2_tuner
*data
= (struct vki_v4l2_tuner
*)ARG3
;
8436 PRE_FIELD_READ("ioctl(VKI_V4L2_S_TUNER).index", data
->index
);
8437 PRE_FIELD_READ("ioctl(VKI_V4L2_S_TUNER).audmode", data
->audmode
);
8438 PRE_FIELD_READ("ioctl(VKI_V4L2_S_TUNER).reserved", data
->reserved
);
8441 case VKI_V4L2_G_AUDIO
: {
8442 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
8443 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_AUDIO)", (Addr
)data
,
8444 sizeof(*data
) - sizeof(data
->reserved
));
8445 PRE_FIELD_READ("ioctl(VKI_V4L2_G_AUDIO).reserved", data
->reserved
);
8448 case VKI_V4L2_S_AUDIO
: {
8449 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
8450 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDIO).index", data
->index
);
8451 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDIO).mode", data
->mode
);
8452 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDIO).reserved", data
->reserved
);
8455 case VKI_V4L2_QUERYCTRL
: {
8456 struct vki_v4l2_queryctrl
*data
= (struct vki_v4l2_queryctrl
*)ARG3
;
8457 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYCTRL).id", data
->id
);
8458 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERYCTRL)", (Addr
)&data
->type
,
8459 sizeof(*data
) - sizeof(data
->id
));
8462 case VKI_V4L2_QUERYMENU
: {
8463 struct vki_v4l2_querymenu
*data
= (struct vki_v4l2_querymenu
*)ARG3
;
8464 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYMENU).id", data
->id
);
8465 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERYMENU).index", data
->index
);
8466 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERYMENU)", (Addr
)data
->name
,
8467 sizeof(*data
) - sizeof(data
->id
) - sizeof(data
->index
));
8470 case VKI_V4L2_G_INPUT
: {
8471 int *data
= (int *)ARG3
;
8472 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_INPUT)", (Addr
)data
, sizeof(*data
));
8475 case VKI_V4L2_S_INPUT
: {
8476 int *data
= (int *)ARG3
;
8477 PRE_MEM_READ("ioctl(VKI_V4L2_S_INPUT)", (Addr
)data
, sizeof(*data
));
8480 case VKI_V4L2_G_EDID
: {
8481 struct vki_v4l2_edid
*data
= (struct vki_v4l2_edid
*)ARG3
;
8482 PRE_MEM_READ("ioctl(VKI_V4L2_G_EDID)", (Addr
)data
, sizeof(*data
));
8483 if (data
->blocks
&& data
->edid
)
8484 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_EDID)", (Addr
)data
->edid
, data
->blocks
* 128);
8487 case VKI_V4L2_S_EDID
: {
8488 struct vki_v4l2_edid
*data
= (struct vki_v4l2_edid
*)ARG3
;
8489 PRE_MEM_READ("ioctl(VKI_V4L2_S_EDID)", (Addr
)data
, sizeof(*data
));
8490 if (data
->blocks
&& data
->edid
)
8491 PRE_MEM_READ("ioctl(VKI_V4L2_S_EDID)", (Addr
)data
->edid
, data
->blocks
* 128);
8494 case VKI_V4L2_G_OUTPUT
: {
8495 int *data
= (int *)ARG3
;
8496 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_OUTPUT)", (Addr
)data
, sizeof(*data
));
8499 case VKI_V4L2_S_OUTPUT
: {
8500 int *data
= (int *)ARG3
;
8501 PRE_MEM_READ("ioctl(VKI_V4L2_S_OUTPUT)", (Addr
)data
, sizeof(*data
));
8504 case VKI_V4L2_ENUMOUTPUT
: {
8505 struct vki_v4l2_output
*data
= (struct vki_v4l2_output
*)ARG3
;
8506 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMOUTPUT).index", data
->index
);
8507 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMOUTPUT)", (Addr
)data
->name
, sizeof(*data
) - sizeof(data
->index
));
8510 case VKI_V4L2_G_AUDOUT
: {
8511 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
8512 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_AUDOUT)", (Addr
)data
,
8513 sizeof(*data
) - sizeof(data
->reserved
));
8514 PRE_FIELD_READ("ioctl(VKI_V4L2_G_AUDOUT).reserved", data
->reserved
);
8517 case VKI_V4L2_S_AUDOUT
: {
8518 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
8519 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDOUT).index", data
->index
);
8520 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDOUT).reserved", data
->reserved
);
8521 PRE_FIELD_READ("ioctl(VKI_V4L2_S_AUDOUT).mode", data
->mode
);
8524 case VKI_V4L2_G_MODULATOR
: {
8525 struct vki_v4l2_modulator
*data
= (struct vki_v4l2_modulator
*)ARG3
;
8526 PRE_FIELD_READ("ioctl(VKI_V4L2_G_MODULATOR).index", data
->index
);
8527 PRE_FIELD_READ("ioctl(VKI_V4L2_G_MODULATOR).reserved", data
->reserved
);
8528 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_MODULATOR)", (Addr
)data
->name
,
8529 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
8532 case VKI_V4L2_S_MODULATOR
: {
8533 struct vki_v4l2_modulator
*data
= (struct vki_v4l2_modulator
*)ARG3
;
8534 PRE_FIELD_READ("ioctl(VKI_V4L2_S_MODULATOR).index", data
->index
);
8535 PRE_FIELD_READ("ioctl(VKI_V4L2_S_MODULATOR).txsubchans", data
->txsubchans
);
8536 PRE_FIELD_READ("ioctl(VKI_V4L2_S_MODULATOR).reserved", data
->reserved
);
8539 case VKI_V4L2_G_FREQUENCY
: {
8540 struct vki_v4l2_frequency
*data
= (struct vki_v4l2_frequency
*)ARG3
;
8541 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FREQUENCY).tuner", data
->tuner
);
8542 PRE_FIELD_READ("ioctl(VKI_V4L2_G_FREQUENCY).reserved", data
->reserved
);
8543 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FREQUENCY).type", data
->type
);
8544 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_FREQUENCY).frequency", data
->frequency
);
8547 case VKI_V4L2_S_FREQUENCY
: {
8548 struct vki_v4l2_frequency
*data
= (struct vki_v4l2_frequency
*)ARG3
;
8549 PRE_MEM_READ("ioctl(VKI_V4L2_S_FREQUENCY)", (Addr
)data
, sizeof(*data
));
8552 case VKI_V4L2_CROPCAP
: {
8553 struct vki_v4l2_cropcap
*data
= (struct vki_v4l2_cropcap
*)ARG3
;
8554 PRE_FIELD_READ("ioctl(VKI_V4L2_CROPCAP)", data
->type
);
8555 PRE_MEM_WRITE("ioctl(VKI_V4L2_CROPCAP)", (Addr
)&data
->bounds
, sizeof(*data
) - sizeof(data
->type
));
8558 case VKI_V4L2_G_CROP
: {
8559 struct vki_v4l2_crop
*data
= (struct vki_v4l2_crop
*)ARG3
;
8560 PRE_FIELD_READ("ioctl(VKI_V4L2_G_CROP).type", data
->type
);
8561 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_CROP).c", data
->c
);
8564 case VKI_V4L2_S_CROP
: {
8565 struct vki_v4l2_crop
*data
= (struct vki_v4l2_crop
*)ARG3
;
8566 PRE_MEM_READ("ioctl(VKI_V4L2_S_CROP)", (Addr
)data
, sizeof(*data
));
8569 case VKI_V4L2_G_JPEGCOMP
: {
8570 struct vki_v4l2_jpegcompression
*data
= (struct vki_v4l2_jpegcompression
*)ARG3
;
8571 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_JPEGCOMP)", (Addr
)data
, sizeof(*data
));
8574 case VKI_V4L2_S_JPEGCOMP
: {
8575 struct vki_v4l2_jpegcompression
*data
= (struct vki_v4l2_jpegcompression
*)ARG3
;
8576 PRE_MEM_READ("ioctl(VKI_V4L2_S_JPEGCOMP)", (Addr
)data
, sizeof(*data
));
8579 case VKI_V4L2_QUERYSTD
: {
8580 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
8581 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERYSTD)", (Addr
)data
, sizeof(*data
));
8584 case VKI_V4L2_ENUMAUDIO
: {
8585 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
8586 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMAUDIO).index", data
->index
);
8587 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMAUDIO).reserved", data
->reserved
);
8588 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMAUDIO)", (Addr
)data
->name
,
8589 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
8592 case VKI_V4L2_ENUMAUDOUT
: {
8593 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
8594 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMAUDOUT).index", data
->index
);
8595 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUMAUDOUT).reserved", data
->reserved
);
8596 PRE_MEM_WRITE("ioctl(VKI_V4L2_ENUMAUDOUT)", (Addr
)data
->name
,
8597 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
8600 case VKI_V4L2_G_PRIORITY
: {
8601 __vki_u32
*data
= (__vki_u32
*)ARG3
;
8602 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_PRIORITY)", (Addr
)data
, sizeof(*data
));
8605 case VKI_V4L2_S_PRIORITY
: {
8606 __vki_u32
*data
= (__vki_u32
*)ARG3
;
8607 PRE_MEM_READ("ioctl(VKI_V4L2_S_PRIORITY)", (Addr
)data
, sizeof(*data
));
8610 case VKI_V4L2_G_SLICED_VBI_CAP
: {
8611 struct vki_v4l2_sliced_vbi_cap
*data
= (struct vki_v4l2_sliced_vbi_cap
*)ARG3
;
8612 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SLICED_VBI_CAP).type", data
->type
);
8613 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SLICED_VBI_CAP).reserved", data
->reserved
);
8614 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_SLICED_VBI_CAP)", (Addr
)data
,
8615 sizeof(*data
) - sizeof(data
->type
) - sizeof(data
->reserved
));
8618 case VKI_V4L2_G_EXT_CTRLS
: {
8619 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
8620 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).ctrl_class", data
->ctrl_class
);
8621 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).count", data
->count
);
8625 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls", data
->controls
);
8626 for (i
= 0; i
< data
->count
; i
++) {
8627 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].id", data
->controls
[i
].id
);
8628 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].size", data
->controls
[i
].size
);
8629 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].reserved2", data
->controls
[i
].reserved2
);
8630 if (data
->controls
[i
].size
) {
8631 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].ptr", data
->controls
[i
].ptr
);
8632 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].ptr[]",
8633 (Addr
)data
->controls
[i
].ptr
, data
->controls
[i
].size
);
8635 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_EXT_CTRLS).controls[].value64",
8636 data
->controls
[i
].value64
);
8640 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_EXT_CTRLS).error_idx", data
->error_idx
);
8641 PRE_FIELD_READ("ioctl(VKI_V4L2_G_EXT_CTRLS).reserved", data
->reserved
);
8644 case VKI_V4L2_S_EXT_CTRLS
: {
8645 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
8646 PRE_FIELD_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).ctrl_class", data
->ctrl_class
);
8647 PRE_FIELD_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).count", data
->count
);
8651 PRE_FIELD_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).controls", data
->controls
);
8652 PRE_MEM_READ("ioctl(VKI_V4L2_S_EXT_CTRLS)", (Addr
)data
->controls
,
8653 data
->count
* sizeof(data
->controls
[0]));
8654 for (i
= 0; i
< data
->count
; i
++) {
8655 if (data
->controls
[i
].size
) {
8656 PRE_MEM_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).controls[].ptr[]",
8657 (Addr
)data
->controls
[i
].ptr
, data
->controls
[i
].size
);
8661 PRE_FIELD_WRITE("ioctl(VKI_V4L2_S_EXT_CTRLS).error_idx", data
->error_idx
);
8662 PRE_FIELD_READ("ioctl(VKI_V4L2_S_EXT_CTRLS).reserved", data
->reserved
);
8665 case VKI_V4L2_TRY_EXT_CTRLS
: {
8666 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
8667 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).ctrl_class", data
->ctrl_class
);
8668 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).count", data
->count
);
8672 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).controls", data
->controls
);
8673 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS)", (Addr
)data
->controls
,
8674 data
->count
* sizeof(data
->controls
[0]));
8675 for (i
= 0; i
< data
->count
; i
++) {
8676 if (data
->controls
[i
].size
) {
8677 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).controls[].ptr[]",
8678 (Addr
)data
->controls
[i
].ptr
, data
->controls
[i
].size
);
8682 PRE_FIELD_WRITE("ioctl(VKI_V4L2_TRY_EXT_CTRLS).error_idx", data
->error_idx
);
8683 PRE_FIELD_READ("ioctl(VKI_V4L2_TRY_EXT_CTRLS).reserved", data
->reserved
);
8686 case VKI_V4L2_ENUM_FRAMESIZES
: {
8687 struct vki_v4l2_frmsizeenum
*data
= (struct vki_v4l2_frmsizeenum
*)ARG3
;
8688 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMESIZES).index", data
->index
);
8689 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMESIZES).pixel_format", data
->pixel_format
);
8690 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMESIZES).reserved", data
->reserved
);
8691 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FRAMESIZES).type", data
->type
);
8692 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FRAMESIZES).stepwise", data
->stepwise
);
8695 case VKI_V4L2_ENUM_FRAMEINTERVALS
: {
8696 struct vki_v4l2_frmivalenum
*data
= (struct vki_v4l2_frmivalenum
*)ARG3
;
8697 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).index", data
->index
);
8698 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).pixel_format", data
->pixel_format
);
8699 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).width", data
->width
);
8700 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).height", data
->height
);
8701 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).reserved", data
->reserved
);
8702 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).type", data
->type
);
8703 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FRAMEINTERVALS).stepwise", data
->stepwise
);
8706 case VKI_V4L2_G_ENC_INDEX
: {
8707 struct vki_v4l2_enc_idx
*data
= (struct vki_v4l2_enc_idx
*)ARG3
;
8708 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_ENC_INDEX)", (Addr
)data
, sizeof(*data
));
8711 case VKI_V4L2_ENCODER_CMD
: {
8712 struct vki_v4l2_encoder_cmd
*data
= (struct vki_v4l2_encoder_cmd
*)ARG3
;
8713 PRE_MEM_READ("ioctl(VKI_V4L2_ENCODER_CMD)", (Addr
)data
, sizeof(*data
));
8716 case VKI_V4L2_TRY_ENCODER_CMD
: {
8717 struct vki_v4l2_encoder_cmd
*data
= (struct vki_v4l2_encoder_cmd
*)ARG3
;
8718 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_ENCODER_CMD)", (Addr
)data
, sizeof(*data
));
8721 case VKI_V4L2_DBG_S_REGISTER
: {
8722 struct vki_v4l2_dbg_register
*data
= (struct vki_v4l2_dbg_register
*)ARG3
;
8723 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_S_REGISTER).match.type", data
->match
.type
);
8724 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_S_REGISTER).match.addr", data
->match
.addr
);
8725 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_S_REGISTER).reg", data
->reg
);
8726 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_S_REGISTER).val", data
->val
);
8727 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_S_REGISTER).size", data
->size
);
8730 case VKI_V4L2_DBG_G_REGISTER
: {
8731 struct vki_v4l2_dbg_register
*data
= (struct vki_v4l2_dbg_register
*)ARG3
;
8732 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_REGISTER).match.type", data
->match
.type
);
8733 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_REGISTER).match.addr", data
->match
.addr
);
8734 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_REGISTER).reg", data
->reg
);
8735 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_G_REGISTER).val", data
->val
);
8736 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_G_REGISTER).size", data
->size
);
8739 case VKI_V4L2_S_HW_FREQ_SEEK
: {
8740 struct vki_v4l2_hw_freq_seek
*data
= (struct vki_v4l2_hw_freq_seek
*)ARG3
;
8741 PRE_MEM_READ("ioctl(VKI_V4L2_S_HW_FREQ_SEEK)", (Addr
)data
, sizeof(*data
));
8744 case VKI_V4L2_S_DV_TIMINGS
: {
8745 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
8746 PRE_FIELD_READ("ioctl(VKI_V4L2_S_DV_TIMINGS).type", data
->type
);
8747 PRE_FIELD_READ("ioctl(VKI_V4L2_S_DV_TIMINGS).bt", data
->bt
);
8750 case VKI_V4L2_G_DV_TIMINGS
: {
8751 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
8752 PRE_MEM_WRITE("ioctl(VKI_V4L2_G_DV_TIMINGS)", (Addr
)data
, sizeof(*data
));
8755 case VKI_V4L2_DQEVENT
: {
8756 struct vki_v4l2_event
*data
= (struct vki_v4l2_event
*)ARG3
;
8757 PRE_MEM_WRITE("ioctl(VKI_V4L2_DQEVENT)", (Addr
)data
, sizeof(*data
));
8760 case VKI_V4L2_SUBSCRIBE_EVENT
: {
8761 struct vki_v4l2_event_subscription
*data
= (struct vki_v4l2_event_subscription
*)ARG3
;
8762 PRE_MEM_READ("ioctl(VKI_V4L2_SUBSCRIBE_EVENT)", (Addr
)data
, sizeof(*data
));
8765 case VKI_V4L2_UNSUBSCRIBE_EVENT
: {
8766 struct vki_v4l2_event_subscription
*data
= (struct vki_v4l2_event_subscription
*)ARG3
;
8767 PRE_MEM_READ("ioctl(VKI_V4L2_UNSUBSCRIBE_EVENT)", (Addr
)data
, sizeof(*data
));
8770 case VKI_V4L2_CREATE_BUFS
: {
8771 struct vki_v4l2_create_buffers
*data
= (struct vki_v4l2_create_buffers
*)ARG3
;
8772 struct vki_v4l2_format
*fmt
= &data
->format
;
8773 PRE_FIELD_WRITE("ioctl(VKI_V4L2_CREATE_BUFS).index", data
->index
);
8774 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).count", data
->count
);
8775 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).memory", data
->memory
);
8776 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).reserved", data
->reserved
);
8777 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.type", fmt
->type
);
8778 switch (fmt
->type
) {
8779 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
8780 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
8781 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.pix", fmt
->fmt
.raw_data
);
8783 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
8784 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
8785 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.vbi", fmt
->fmt
.vbi
);
8787 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
8788 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
8789 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.sliced", fmt
->fmt
.sliced
);
8791 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
8792 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
8793 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.win", fmt
->fmt
.win
);
8795 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
8796 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
8797 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.pix_mp", fmt
->fmt
.pix_mp
);
8799 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
8800 PRE_FIELD_READ("ioctl(VKI_V4L2_CREATE_BUFS).format.sdr", fmt
->fmt
.sdr
);
8805 case VKI_V4L2_PREPARE_BUF
: {
8806 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
8807 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).index", data
->index
);
8808 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).type", data
->type
);
8809 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).memory", data
->memory
);
8810 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).reserved", data
->reserved
);
8811 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).reserved2", data
->reserved2
);
8812 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
8813 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
8816 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).length", data
->length
);
8817 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).m.planes", data
->m
.planes
);
8818 for (i
= 0; i
< data
->length
; i
++) {
8819 PRE_FIELD_READ("ioctl(VKI_V4L2_PREPARE_BUF).m.planes[].reserved", data
->m
.planes
[i
].reserved
);
8824 case VKI_V4L2_G_SELECTION
: {
8825 struct vki_v4l2_selection
*data
= (struct vki_v4l2_selection
*)ARG3
;
8826 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SELECTION).type", data
->type
);
8827 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SELECTION).target", data
->target
);
8828 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SELECTION).flags", data
->flags
);
8829 PRE_FIELD_READ("ioctl(VKI_V4L2_G_SELECTION).reserved", data
->reserved
);
8830 PRE_FIELD_WRITE("ioctl(VKI_V4L2_G_SELECTION).r", data
->r
);
8833 case VKI_V4L2_S_SELECTION
: {
8834 struct vki_v4l2_selection
*data
= (struct vki_v4l2_selection
*)ARG3
;
8835 PRE_MEM_READ("ioctl(VKI_V4L2_S_SELECTION)", (Addr
)data
, sizeof(*data
));
8838 case VKI_V4L2_DECODER_CMD
: {
8839 struct vki_v4l2_decoder_cmd
*data
= (struct vki_v4l2_decoder_cmd
*)ARG3
;
8840 PRE_MEM_READ("ioctl(VKI_V4L2_DECODER_CMD)", (Addr
)data
, sizeof(*data
));
8843 case VKI_V4L2_TRY_DECODER_CMD
: {
8844 struct vki_v4l2_decoder_cmd
*data
= (struct vki_v4l2_decoder_cmd
*)ARG3
;
8845 PRE_MEM_READ("ioctl(VKI_V4L2_TRY_DECODER_CMD)", (Addr
)data
, sizeof(*data
));
8848 case VKI_V4L2_ENUM_DV_TIMINGS
: {
8849 struct vki_v4l2_enum_dv_timings
*data
= (struct vki_v4l2_enum_dv_timings
*)ARG3
;
8850 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_DV_TIMINGS).index", data
->index
);
8851 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_DV_TIMINGS).pad", data
->pad
);
8852 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_DV_TIMINGS).reserved", data
->reserved
);
8853 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_DV_TIMINGS).timings", data
->timings
);
8856 case VKI_V4L2_QUERY_DV_TIMINGS
: {
8857 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
8858 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERY_DV_TIMINGS)", (Addr
)data
, sizeof(*data
));
8861 case VKI_V4L2_DV_TIMINGS_CAP
: {
8862 struct vki_v4l2_dv_timings_cap
*data
= (struct vki_v4l2_dv_timings_cap
*)ARG3
;
8863 PRE_MEM_WRITE("ioctl(VKI_V4L2_DV_TIMINGS_CAP)", (Addr
)data
, sizeof(*data
));
8866 case VKI_V4L2_ENUM_FREQ_BANDS
: {
8867 struct vki_v4l2_frequency_band
*data
= (struct vki_v4l2_frequency_band
*)ARG3
;
8868 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).tuner", data
->tuner
);
8869 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).type", data
->type
);
8870 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).index", data
->index
);
8871 PRE_FIELD_READ("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).reserved", data
->reserved
);
8872 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).capability", data
->capability
);
8873 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).rangelow", data
->rangelow
);
8874 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).rangehigh", data
->rangehigh
);
8875 PRE_FIELD_WRITE("ioctl(VKI_V4L2_ENUM_FREQ_BANDS).modulation", data
->modulation
);
8878 case VKI_V4L2_DBG_G_CHIP_INFO
: {
8879 struct vki_v4l2_dbg_chip_info
*data
= (struct vki_v4l2_dbg_chip_info
*)ARG3
;
8880 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).match.type", data
->match
.type
);
8881 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).match.addr", data
->match
.addr
);
8882 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).name", data
->name
);
8883 PRE_FIELD_WRITE("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).flags", data
->flags
);
8884 PRE_FIELD_READ("ioctl(VKI_V4L2_DBG_G_CHIP_INFO).reserved", data
->reserved
);
8887 case VKI_V4L2_QUERY_EXT_CTRL
: {
8888 struct vki_v4l2_query_ext_ctrl
*data
= (struct vki_v4l2_query_ext_ctrl
*)ARG3
;
8889 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERY_EXT_CTRL).id", data
->id
);
8890 PRE_FIELD_READ("ioctl(VKI_V4L2_QUERY_EXT_CTRL).reserved", data
->reserved
);
8891 PRE_MEM_WRITE("ioctl(VKI_V4L2_QUERY_EXT_CTRL)", (Addr
)&data
->type
,
8892 sizeof(*data
) - sizeof(data
->id
) - sizeof(data
->reserved
));
8895 case VKI_V4L2_SUBDEV_G_FMT
: {
8896 struct vki_v4l2_subdev_format
*data
= (struct vki_v4l2_subdev_format
*)ARG3
;
8897 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FMT).pad", data
->pad
);
8898 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FMT).which", data
->which
);
8899 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FMT).reserved", data
->reserved
);
8900 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_G_FMT).format", data
->format
);
8903 case VKI_V4L2_SUBDEV_S_FMT
: {
8904 struct vki_v4l2_subdev_format
*data
= (struct vki_v4l2_subdev_format
*)ARG3
;
8905 PRE_MEM_READ("ioctl(VKI_V4L2_SUBDEV_S_FMT)", (Addr
)data
, sizeof(*data
));
8908 case VKI_V4L2_SUBDEV_G_FRAME_INTERVAL
: {
8909 struct vki_v4l2_subdev_frame_interval
*data
= (struct vki_v4l2_subdev_frame_interval
*)ARG3
;
8910 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FRAME_SIZE).pad", data
->pad
);
8911 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_FRAME_SIZE).reserved", data
->reserved
);
8912 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_G_FRAME_SIZE).interval", data
->interval
);
8915 case VKI_V4L2_SUBDEV_S_FRAME_INTERVAL
: {
8916 struct vki_v4l2_subdev_frame_interval
*data
= (struct vki_v4l2_subdev_frame_interval
*)ARG3
;
8917 PRE_MEM_READ("ioctl(VKI_V4L2_SUBDEV_S_FRAME_INTERVAL)", (Addr
)data
, sizeof(*data
));
8920 case VKI_V4L2_SUBDEV_ENUM_MBUS_CODE
: {
8921 struct vki_v4l2_subdev_mbus_code_enum
*data
= (struct vki_v4l2_subdev_mbus_code_enum
*)ARG3
;
8922 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).index", data
->index
);
8923 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).pad", data
->pad
);
8924 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).code", data
->code
);
8925 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).which", data
->which
);
8926 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_MBUS_CODE).reserved", data
->reserved
);
8929 case VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE
: {
8930 struct vki_v4l2_subdev_frame_size_enum
*data
= (struct vki_v4l2_subdev_frame_size_enum
*)ARG3
;
8931 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).index", data
->index
);
8932 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).pad", data
->pad
);
8933 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).code", data
->code
);
8934 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).which", data
->which
);
8935 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).reserved", data
->reserved
);
8936 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).min_width", data
->min_width
);
8937 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).min_height", data
->min_height
);
8938 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).max_width", data
->max_width
);
8939 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE).max_height", data
->max_height
);
8942 case VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL
: {
8943 struct vki_v4l2_subdev_frame_interval_enum
*data
= (struct vki_v4l2_subdev_frame_interval_enum
*)ARG3
;
8944 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).index", data
->index
);
8945 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).pad", data
->pad
);
8946 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).code", data
->code
);
8947 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).width", data
->width
);
8948 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).height", data
->height
);
8949 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).which", data
->which
);
8950 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).reserved", data
->reserved
);
8951 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL).interval", data
->interval
);
8954 case VKI_V4L2_SUBDEV_G_CROP
: {
8955 struct vki_v4l2_subdev_crop
*data
= (struct vki_v4l2_subdev_crop
*)ARG3
;
8956 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_CROP).pad", data
->pad
);
8957 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_CROP).which", data
->which
);
8958 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_CROP).reserved", data
->reserved
);
8959 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_G_CROP).rect", data
->rect
);
8962 case VKI_V4L2_SUBDEV_S_CROP
: {
8963 struct vki_v4l2_subdev_crop
*data
= (struct vki_v4l2_subdev_crop
*)ARG3
;
8964 PRE_MEM_READ("ioctl(VKI_V4L2_SUBDEV_S_CROP)", (Addr
)data
, sizeof(*data
));
8967 case VKI_V4L2_SUBDEV_G_SELECTION
: {
8968 struct vki_v4l2_subdev_selection
*data
= (struct vki_v4l2_subdev_selection
*)ARG3
;
8969 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).pad", data
->pad
);
8970 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).which", data
->which
);
8971 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).target", data
->target
);
8972 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).flags", data
->flags
);
8973 PRE_FIELD_READ("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).reserved", data
->reserved
);
8974 PRE_FIELD_WRITE("ioctl(VKI_V4L2_SUBDEV_G_SELECTION).r", data
->r
);
8977 case VKI_V4L2_SUBDEV_S_SELECTION
: {
8978 struct vki_v4l2_subdev_selection
*data
= (struct vki_v4l2_subdev_selection
*)ARG3
;
8979 PRE_MEM_READ("ioctl(VKI_V4L2_SUBDEV_S_SELECTION)", (Addr
)data
, sizeof(*data
));
8982 case VKI_MEDIA_IOC_DEVICE_INFO
: {
8983 struct vki_media_device_info
*data
= (struct vki_media_device_info
*)ARG3
;
8984 PRE_FIELD_READ("ioctl(VKI_MEDIA_IOC_DEVICE_INFO).reserved", data
->reserved
);
8985 PRE_MEM_WRITE("ioctl(VKI_MEDIA_IOC_DEVICE_INFO)",
8986 (Addr
)data
, sizeof(*data
) - sizeof(data
->reserved
));
8989 case VKI_MEDIA_IOC_ENUM_ENTITIES
: {
8990 struct vki_media_entity_desc
*data
= (struct vki_media_entity_desc
*)ARG3
;
8991 PRE_FIELD_READ("ioctl(VKI_MEDIA_IOC_ENUM_ENTITIES).id", data
->id
);
8992 PRE_MEM_WRITE("ioctl(VKI_MEDIA_IOC_ENUM_ENTITIES)",
8993 (Addr
)data
->name
, sizeof(*data
) - sizeof(data
->id
));
8996 case VKI_MEDIA_IOC_ENUM_LINKS
: {
8997 struct vki_media_links_enum
*data
= (struct vki_media_links_enum
*)ARG3
;
8998 PRE_MEM_READ("ioctl(VKI_MEDIA_IOC_ENUM_LINKS)", (Addr
)data
, sizeof(*data
));
9001 case VKI_MEDIA_IOC_SETUP_LINK
: {
9002 struct vki_media_link_desc
*data
= (struct vki_media_link_desc
*)ARG3
;
9003 PRE_MEM_READ("ioctl(VKI_MEDIA_IOC_SETUP_LINK)", (Addr
)data
, sizeof(*data
));
9008 case VKI_TIOCGSERIAL
: {
9009 struct vki_serial_struct
*data
= (struct vki_serial_struct
*)ARG3
;
9010 PRE_MEM_WRITE("ioctl(VKI_TIOCGSERIAL)", (Addr
)data
, sizeof(*data
));
9013 case VKI_TIOCSSERIAL
: {
9014 struct vki_serial_struct
*data
= (struct vki_serial_struct
*)ARG3
;
9015 PRE_MEM_READ("ioctl(VKI_TIOCSSERIAL)", (Addr
)data
, sizeof(*data
));
9019 case VKI_PERF_EVENT_IOC_RESET
:
9020 case VKI_PERF_EVENT_IOC_REFRESH
:
9021 case VKI_PERF_EVENT_IOC_SET_OUTPUT
:
9022 case VKI_PERF_EVENT_IOC_SET_BPF
:
9023 /* These take scalar arguments, so already handled above */
9026 case VKI_PERF_EVENT_IOC_PERIOD
:
9027 PRE_MEM_READ("ioctl(VKI_PERF_EVENT_IOC_PERIOD)", (Addr
)ARG3
, sizeof(__vki_u64
));
9030 case VKI_PERF_EVENT_IOC_SET_FILTER
:
9031 PRE_MEM_RASCIIZ("ioctl(VKI_PERF_EVENT_IOC_SET_FILTER).filter", ARG3
);
9034 case VKI_PERF_EVENT_IOC_ID
:
9035 PRE_MEM_WRITE("ioctl(VKI_PERF_EVENT_IOC_ID)", (Addr
)ARG3
, sizeof(__vki_u64
));
9039 /* EVIOC* are variable length and return size written on success */
9040 switch (ARG2
& ~(_VKI_IOC_SIZEMASK
<< _VKI_IOC_SIZESHIFT
)) {
9041 case VKI_EVIOCGNAME(0):
9042 case VKI_EVIOCGPHYS(0):
9043 case VKI_EVIOCGUNIQ(0):
9044 case VKI_EVIOCGKEY(0):
9045 case VKI_EVIOCGLED(0):
9046 case VKI_EVIOCGSND(0):
9047 case VKI_EVIOCGSW(0):
9048 case VKI_EVIOCGBIT(VKI_EV_SYN
,0):
9049 case VKI_EVIOCGBIT(VKI_EV_KEY
,0):
9050 case VKI_EVIOCGBIT(VKI_EV_REL
,0):
9051 case VKI_EVIOCGBIT(VKI_EV_ABS
,0):
9052 case VKI_EVIOCGBIT(VKI_EV_MSC
,0):
9053 case VKI_EVIOCGBIT(VKI_EV_SW
,0):
9054 case VKI_EVIOCGBIT(VKI_EV_LED
,0):
9055 case VKI_EVIOCGBIT(VKI_EV_SND
,0):
9056 case VKI_EVIOCGBIT(VKI_EV_REP
,0):
9057 case VKI_EVIOCGBIT(VKI_EV_FF
,0):
9058 case VKI_EVIOCGBIT(VKI_EV_PWR
,0):
9059 case VKI_EVIOCGBIT(VKI_EV_FF_STATUS
,0):
9060 PRE_MEM_WRITE("ioctl(EVIO*)", ARG3
, _VKI_IOC_SIZE(ARG2
));
9063 ML_(PRE_unknown_ioctl
)(tid
, ARG2
, ARG3
);
9074 vg_assert(SUCCESS
|| (FAILURE
&& VKI_DRM_IOCTL_VERSION
== ARG2
));
9076 /* --- BEGIN special IOCTL handlers for specific Android hardware --- */
9078 /* BEGIN undocumented ioctls for PowerVR SGX 540 (the GPU on Nexus S) */
9079 if (KernelVariantiS(KernelVariant_android_gpu_sgx5xx
,
9080 VG_(clo_kernel_variant
))) {
9082 if (ARG2
>= 0xC01C6700 && ARG2
<= 0xC01C67FF && ARG3
>= 0x1000) {
9083 /* What's going on here: there appear to be a bunch of ioctls
9084 of the form 0xC01C67xx which are undocumented, and if
9085 unhandled give rise to a vast number of false positives in
9088 The "normal" interpretation of an ioctl of this form would
9089 be that the 3rd arg is a pointer to an area of size 0x1C
9090 (28 bytes) which is filled in by the kernel. Hence you
9091 might think that "POST_MEM_WRITE(ARG3, 28)" would fix it.
9094 It requires POST_MEM_WRITE(ARG3, 256) to silence them.
9095 One interpretation of this is that ARG3 really does point
9096 to a 28 byte struct, but inside that are pointers to other
9097 areas also filled in by the kernel. If these happen to be
9098 allocated just back up the stack then the 256 byte paint
9099 might cover them too, somewhat indiscriminately.
9101 By printing out ARG3 and also the 28 bytes that it points
9102 at, it's possible to guess that the 7 word structure has
9106 ioctl-number 0x1C ptr1 ptr1size ptr2 ptr2size aBitMask
9108 Unfortunately that doesn't seem to work for some reason,
9109 so stay with the blunt-instrument approach for the time
9113 /* blunt-instrument approach */
9114 POST_MEM_WRITE(ARG3
, 256);
9116 /* be a bit more sophisticated */
9117 POST_MEM_WRITE(ARG3
, 28);
9118 UInt
* word
= (UInt
*)ARG3
;
9119 if (word
&& word
[2] && word
[3] < 0x200/*stay sane*/)
9120 POST_MEM_WRITE(word
[2], word
[3]); // "ptr1"
9121 if (word
&& word
[4] && word
[5] < 0x200/*stay sane*/)
9122 POST_MEM_WRITE(word
[4], word
[5]); // "ptr2"
9124 goto post_sys_ioctl__out
;
9127 /* END undocumented ioctls for PowerVR SGX 540 (the GPU on Nexus S) */
9129 /* BEGIN undocumented ioctls for Qualcomm Adreno 3xx */
9130 if (KernelVariantiS(KernelVariant_android_gpu_adreno3xx
,
9131 VG_(clo_kernel_variant
))) {
9132 if (ARG2
== 0xC00C0902) {
9133 POST_MEM_WRITE(ARG3
, 24); // 16 is not enough
9134 goto post_sys_ioctl__out
;
9137 /* END undocumented ioctls for Qualcomm Adreno 3xx */
9139 /* --- END special IOCTL handlers for specific Android hardware --- */
9141 /* --- normal handling --- */
9142 switch (ARG2
/* request */) {
9144 /* The Linux kernel "ion" memory allocator, used on Android. Note:
9145 this is pretty poor given that there's no pre-handling to check
9146 that writable areas are addressable. */
9147 case VKI_ION_IOC_ALLOC
: {
9148 struct vki_ion_allocation_data
* data
9149 = (struct vki_ion_allocation_data
*)ARG3
;
9150 POST_FIELD_WRITE(data
->handle
);
9153 case VKI_ION_IOC_MAP
: {
9154 struct vki_ion_fd_data
* data
= (struct vki_ion_fd_data
*)ARG3
;
9155 POST_FIELD_WRITE(data
->fd
);
9158 case VKI_ION_IOC_FREE
: // is this necessary?
9159 POST_MEM_WRITE(ARG3
, sizeof(struct vki_ion_handle_data
));
9161 case VKI_ION_IOC_SHARE
:
9163 case VKI_ION_IOC_IMPORT
: {
9164 struct vki_ion_fd_data
* data
= (struct vki_ion_fd_data
*)ARG3
;
9165 POST_FIELD_WRITE(data
->handle
);
9168 case VKI_ION_IOC_SYNC
:
9170 case VKI_ION_IOC_CUSTOM
: // is this necessary?
9171 POST_MEM_WRITE(ARG3
, sizeof(struct vki_ion_custom_data
));
9174 case VKI_SYNC_IOC_MERGE
: {
9175 struct vki_sync_merge_data
* data
= (struct vki_sync_merge_data
*)ARG3
;
9176 POST_FIELD_WRITE(data
->fence
);
9183 case VKI_IB_USER_MAD_ENABLE_PKEY
:
9186 POST_MEM_WRITE( ARG3
, sizeof(struct vki_termios
) );
9193 POST_MEM_WRITE( ARG3
, sizeof(struct vki_termio
) );
9201 case VKI_TIOCGWINSZ
:
9202 POST_MEM_WRITE( ARG3
, sizeof(struct vki_winsize
) );
9204 case VKI_TIOCSWINSZ
:
9210 POST_MEM_WRITE( ARG3
, sizeof(unsigned int) );
9213 POST_MEM_WRITE( ARG3
, sizeof(char *) );
9216 /* Get process group ID for foreground processing group. */
9217 POST_MEM_WRITE( ARG3
, sizeof(vki_pid_t
) );
9220 /* Set a process group ID? */
9221 POST_MEM_WRITE( ARG3
, sizeof(vki_pid_t
) );
9223 case VKI_TIOCGPTN
: /* Get Pty Number (of pty-mux device) */
9224 POST_MEM_WRITE( ARG3
, sizeof(int));
9228 case VKI_TIOCSPTLCK
: /* Lock/unlock Pty */
9240 case VKI_FIONREAD
: /* identical to SIOCINQ */
9241 POST_MEM_WRITE( ARG3
, sizeof(int) );
9244 POST_MEM_WRITE( ARG3
, sizeof(vki_loff_t
) );
9247 case VKI_TIOCSERGETLSR
:
9248 POST_MEM_WRITE( ARG3
, sizeof(int) );
9250 case VKI_TIOCGICOUNT
:
9251 POST_MEM_WRITE( ARG3
, sizeof(struct vki_serial_icounter_struct
) );
9254 case VKI_SG_SET_COMMAND_Q
:
9258 vki_sg_io_hdr_t
*sgio
= (vki_sg_io_hdr_t
*)ARG3
;
9260 POST_MEM_WRITE( (Addr
)sgio
->sbp
, sgio
->sb_len_wr
);
9262 if ( sgio
->dxfer_direction
== VKI_SG_DXFER_FROM_DEV
||
9263 sgio
->dxfer_direction
== VKI_SG_DXFER_TO_FROM_DEV
) {
9264 int transferred
= sgio
->dxfer_len
- sgio
->resid
;
9265 POST_MEM_WRITE( (Addr
)sgio
->dxferp
, transferred
);
9269 case VKI_SG_GET_SCSI_ID
:
9270 POST_MEM_WRITE(ARG3
, sizeof(vki_sg_scsi_id_t
));
9272 case VKI_SG_SET_RESERVED_SIZE
:
9274 case VKI_SG_SET_TIMEOUT
:
9276 case VKI_SG_GET_RESERVED_SIZE
:
9277 POST_MEM_WRITE(ARG3
, sizeof(int));
9279 case VKI_SG_GET_TIMEOUT
:
9281 case VKI_SG_GET_VERSION_NUM
:
9282 POST_MEM_WRITE(ARG3
, sizeof(int));
9284 case VKI_SG_EMULATED_HOST
:
9285 POST_MEM_WRITE(ARG3
, sizeof(int));
9287 case VKI_SG_GET_SG_TABLESIZE
:
9288 POST_MEM_WRITE(ARG3
, sizeof(int));
9291 case VKI_IIOCGETCPS
:
9292 POST_MEM_WRITE( ARG3
, VKI_ISDN_MAX_CHANNELS
* 2 * sizeof(unsigned long) );
9294 case VKI_IIOCNETGPN
:
9295 POST_MEM_WRITE( ARG3
, sizeof(vki_isdn_net_ioctl_phone
) );
9298 /* These all use struct ifreq AFAIK */
9299 case VKI_SIOCGIFINDEX
: /* get iface index */
9300 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_ifindex
,
9301 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_ifindex
) );
9303 case VKI_SIOCGIFFLAGS
: /* get flags */
9304 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
9305 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
9307 case VKI_SIOCGIFHWADDR
: /* Get hardware address */
9308 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_hwaddr
,
9309 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_hwaddr
) );
9311 case VKI_SIOCGIFMTU
: /* get MTU size */
9312 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_mtu
,
9313 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_mtu
) );
9315 case VKI_SIOCGIFADDR
: /* get PA address */
9316 case VKI_SIOCGIFDSTADDR
: /* get remote PA address */
9317 case VKI_SIOCGIFBRDADDR
: /* get broadcast PA address */
9318 case VKI_SIOCGIFNETMASK
: /* get network PA mask */
9320 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_addr
,
9321 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_addr
) );
9323 case VKI_SIOCGIFMETRIC
: /* get metric */
9325 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_metric
,
9326 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_metric
) );
9328 case VKI_SIOCGIFMAP
: /* Get device parameters */
9330 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_map
,
9331 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_map
) );
9334 case VKI_SIOCGIFTXQLEN
: /* Get the tx queue length */
9336 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_qlen
,
9337 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_qlen
) );
9339 case VKI_SIOCGIFNAME
: /* get iface name */
9341 (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_name
,
9342 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_name
) );
9344 case VKI_SIOCETHTOOL
: { /* ethtool(8) interface */
9345 struct vki_ifreq
*ir
= (struct vki_ifreq
*)ARG3
;
9346 switch ( *(vki_u32
*)ir
->vki_ifr_data
) {
9347 case VKI_ETHTOOL_GSET
:
9348 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_cmd
));
9350 case VKI_ETHTOOL_SSET
:
9352 case VKI_ETHTOOL_GDRVINFO
:
9353 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_drvinfo
) );
9355 case VKI_ETHTOOL_GREGS
:
9356 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_regs
*)ir
->vki_ifr_data
)->data
,
9357 ((struct vki_ethtool_regs
*)ir
->vki_ifr_data
)->len
);
9359 case VKI_ETHTOOL_GWOL
:
9360 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_wolinfo
) );
9362 case VKI_ETHTOOL_SWOL
:
9364 case VKI_ETHTOOL_GMSGLVL
:
9365 case VKI_ETHTOOL_GLINK
:
9366 case VKI_ETHTOOL_GRXCSUM
:
9367 case VKI_ETHTOOL_GSG
:
9368 case VKI_ETHTOOL_GTSO
:
9369 case VKI_ETHTOOL_GUFO
:
9370 case VKI_ETHTOOL_GGSO
:
9371 case VKI_ETHTOOL_GFLAGS
:
9372 case VKI_ETHTOOL_GGRO
:
9373 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_value
));
9375 case VKI_ETHTOOL_SMSGLVL
:
9376 case VKI_ETHTOOL_SRXCSUM
:
9377 case VKI_ETHTOOL_SSG
:
9378 case VKI_ETHTOOL_STSO
:
9379 case VKI_ETHTOOL_SUFO
:
9380 case VKI_ETHTOOL_SGSO
:
9381 case VKI_ETHTOOL_SFLAGS
:
9382 case VKI_ETHTOOL_SGRO
:
9384 case VKI_ETHTOOL_NWAY_RST
:
9386 case VKI_ETHTOOL_GRINGPARAM
:
9387 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ringparam
));
9389 case VKI_ETHTOOL_SRINGPARAM
:
9391 case VKI_ETHTOOL_TEST
:
9392 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_test
*)ir
->vki_ifr_data
)->data
,
9393 ((struct vki_ethtool_test
*)ir
->vki_ifr_data
)->len
* sizeof(__vki_u64
) );
9395 case VKI_ETHTOOL_PHYS_ID
:
9397 case VKI_ETHTOOL_GPERMADDR
:
9398 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_perm_addr
*)ir
->vki_ifr_data
)->data
,
9399 ((struct vki_ethtool_perm_addr
*)ir
->vki_ifr_data
)->size
);
9401 case VKI_ETHTOOL_RESET
:
9403 case VKI_ETHTOOL_GSSET_INFO
:
9404 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_sset_info
*)ir
->vki_ifr_data
)->data
,
9405 __builtin_popcountll(((struct vki_ethtool_sset_info
*)ir
->vki_ifr_data
)->sset_mask
) * sizeof(__vki_u32
) );
9407 case VKI_ETHTOOL_GFEATURES
:
9408 POST_MEM_WRITE( (Addr
)((struct vki_ethtool_gfeatures
*)ir
->vki_ifr_data
)->features
,
9409 ((struct vki_ethtool_gfeatures
*)ir
->vki_ifr_data
)->size
* sizeof(struct vki_ethtool_get_features_block
) );
9411 case VKI_ETHTOOL_SFEATURES
:
9413 case VKI_ETHTOOL_GCHANNELS
:
9414 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_channels
) );
9416 case VKI_ETHTOOL_SCHANNELS
:
9418 case VKI_ETHTOOL_GET_TS_INFO
:
9419 POST_MEM_WRITE( (Addr
)ir
->vki_ifr_data
, sizeof(struct vki_ethtool_ts_info
) );
9424 case VKI_SIOCGMIIPHY
: /* get hardware entry */
9426 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
,
9427 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->phy_id
) );
9429 case VKI_SIOCGMIIREG
: /* get hardware entry registers */
9431 (Addr
)&((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->val_out
,
9432 sizeof(((struct vki_mii_ioctl_data
*)&((struct vki_ifreq
*)ARG3
)->vki_ifr_data
)->val_out
) );
9435 /* tun/tap related ioctls */
9437 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_name
,
9438 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_name
) );
9440 case VKI_TUNGETFEATURES
:
9441 POST_MEM_WRITE( ARG3
, sizeof(unsigned int) );
9444 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_name
,
9445 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_name
) );
9446 POST_MEM_WRITE( (Addr
)&((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
,
9447 sizeof(((struct vki_ifreq
*)ARG3
)->vki_ifr_flags
) );
9449 case VKI_TUNGETSNDBUF
:
9450 POST_MEM_WRITE( ARG3
, sizeof(int) );
9452 case VKI_TUNGETVNETHDRSZ
:
9453 POST_MEM_WRITE( ARG3
, sizeof(int) );
9456 case VKI_SIOCGIFCONF
: /* get iface list */
9458 PRE_MEM_WRITE("ioctl(SIOCGIFCONF)", ARG3, sizeof(struct ifconf));
9459 KERNEL_DO_SYSCALL(tid,RES);
9460 if (!VG_(is_kerror)(RES) && RES == 0)
9461 POST_MEM_WRITE(ARG3, sizeof(struct ifconf));
9463 if (RES
== 0 && ARG3
) {
9464 struct vki_ifconf
*ifc
= (struct vki_ifconf
*) ARG3
;
9465 if (ifc
->vki_ifc_buf
!= NULL
)
9466 POST_MEM_WRITE( (Addr
)(ifc
->vki_ifc_buf
), ifc
->ifc_len
);
9469 case VKI_SIOCGSTAMP
:
9470 POST_MEM_WRITE( ARG3
, sizeof(struct vki_timeval
) );
9472 case VKI_SIOCGSTAMPNS
:
9473 POST_MEM_WRITE( ARG3
, sizeof(struct vki_timespec
) );
9475 /* SIOCOUTQ is an ioctl that, when called on a socket, returns
9476 the number of bytes currently in that socket's send buffer.
9477 It writes this value as an int to the memory location
9478 indicated by the third argument of ioctl(2). */
9480 POST_MEM_WRITE(ARG3
, sizeof(int));
9482 case VKI_SIOCGRARP
: /* get RARP table entry */
9483 case VKI_SIOCGARP
: /* get ARP table entry */
9484 POST_MEM_WRITE(ARG3
, sizeof(struct vki_arpreq
));
9487 case VKI_SIOCSIFFLAGS
: /* set flags */
9488 case VKI_SIOCSIFMAP
: /* Set device parameters */
9489 case VKI_SIOCSHWTSTAMP
: /* Set hardware time stamping */
9490 case VKI_SIOCSIFTXQLEN
: /* Set the tx queue length */
9491 case VKI_SIOCSIFDSTADDR
: /* set remote PA address */
9492 case VKI_SIOCSIFBRDADDR
: /* set broadcast PA address */
9493 case VKI_SIOCSIFNETMASK
: /* set network PA mask */
9494 case VKI_SIOCSIFMETRIC
: /* set metric */
9495 case VKI_SIOCSIFADDR
: /* set PA address */
9496 case VKI_SIOCSIFMTU
: /* set MTU size */
9497 case VKI_SIOCSIFHWADDR
: /* set hardware address */
9498 case VKI_SIOCSMIIREG
: /* set hardware entry registers */
9500 /* Routing table calls. */
9501 case VKI_SIOCADDRT
: /* add routing table entry */
9502 case VKI_SIOCDELRT
: /* delete routing table entry */
9505 /* RARP cache control calls. */
9506 case VKI_SIOCDRARP
: /* delete RARP table entry */
9507 case VKI_SIOCSRARP
: /* set RARP table entry */
9508 /* ARP cache control calls. */
9509 case VKI_SIOCSARP
: /* set ARP table entry */
9510 case VKI_SIOCDARP
: /* delete ARP table entry */
9514 POST_MEM_WRITE(ARG3
, sizeof(int));
9519 case VKI_SIOCATMARK
:
9520 POST_MEM_WRITE(ARG3
, sizeof(int));
9523 /* linux/soundcard interface (OSS) */
9524 case VKI_SNDCTL_SEQ_GETOUTCOUNT
:
9525 case VKI_SNDCTL_SEQ_GETINCOUNT
:
9526 case VKI_SNDCTL_SEQ_PERCMODE
:
9527 case VKI_SNDCTL_SEQ_TESTMIDI
:
9528 case VKI_SNDCTL_SEQ_RESETSAMPLES
:
9529 case VKI_SNDCTL_SEQ_NRSYNTHS
:
9530 case VKI_SNDCTL_SEQ_NRMIDIS
:
9531 case VKI_SNDCTL_SEQ_GETTIME
:
9532 case VKI_SNDCTL_DSP_GETBLKSIZE
:
9533 case VKI_SNDCTL_DSP_GETFMTS
:
9534 case VKI_SNDCTL_DSP_SETFMT
:
9535 case VKI_SNDCTL_DSP_GETTRIGGER
:
9536 case VKI_SNDCTL_DSP_GETODELAY
:
9537 case VKI_SNDCTL_DSP_GETSPDIF
:
9538 case VKI_SNDCTL_DSP_GETCAPS
:
9539 case VKI_SOUND_PCM_READ_RATE
:
9540 case VKI_SOUND_PCM_READ_CHANNELS
:
9541 case VKI_SOUND_PCM_READ_BITS
:
9542 case VKI_SOUND_PCM_READ_FILTER
:
9543 POST_MEM_WRITE(ARG3
, sizeof(int));
9545 case VKI_SNDCTL_SEQ_CTRLRATE
:
9546 case VKI_SNDCTL_DSP_SPEED
:
9547 case VKI_SNDCTL_DSP_STEREO
:
9548 case VKI_SNDCTL_DSP_CHANNELS
:
9549 case VKI_SOUND_PCM_WRITE_FILTER
:
9550 case VKI_SNDCTL_DSP_SUBDIVIDE
:
9551 case VKI_SNDCTL_DSP_SETFRAGMENT
:
9552 case VKI_SNDCTL_DSP_GETCHANNELMASK
:
9553 case VKI_SNDCTL_DSP_BIND_CHANNEL
:
9554 case VKI_SNDCTL_TMR_TIMEBASE
:
9555 case VKI_SNDCTL_TMR_TEMPO
:
9556 case VKI_SNDCTL_TMR_SOURCE
:
9557 case VKI_SNDCTL_MIDI_PRETIME
:
9558 case VKI_SNDCTL_MIDI_MPUMODE
:
9560 case VKI_SNDCTL_DSP_GETOSPACE
:
9561 case VKI_SNDCTL_DSP_GETISPACE
:
9562 POST_MEM_WRITE(ARG3
, sizeof(vki_audio_buf_info
));
9564 case VKI_SNDCTL_DSP_NONBLOCK
:
9566 case VKI_SNDCTL_DSP_SETTRIGGER
:
9569 case VKI_SNDCTL_DSP_POST
:
9570 case VKI_SNDCTL_DSP_RESET
:
9571 case VKI_SNDCTL_DSP_SYNC
:
9572 case VKI_SNDCTL_DSP_SETSYNCRO
:
9573 case VKI_SNDCTL_DSP_SETDUPLEX
:
9576 /* linux/soundcard interface (ALSA) */
9577 case VKI_SNDRV_PCM_IOCTL_HW_FREE
:
9578 case VKI_SNDRV_PCM_IOCTL_HWSYNC
:
9579 case VKI_SNDRV_PCM_IOCTL_PREPARE
:
9580 case VKI_SNDRV_PCM_IOCTL_RESET
:
9581 case VKI_SNDRV_PCM_IOCTL_START
:
9582 case VKI_SNDRV_PCM_IOCTL_DROP
:
9583 case VKI_SNDRV_PCM_IOCTL_DRAIN
:
9584 case VKI_SNDRV_PCM_IOCTL_RESUME
:
9585 case VKI_SNDRV_PCM_IOCTL_XRUN
:
9586 case VKI_SNDRV_PCM_IOCTL_UNLINK
:
9587 case VKI_SNDRV_TIMER_IOCTL_START
:
9588 case VKI_SNDRV_TIMER_IOCTL_STOP
:
9589 case VKI_SNDRV_TIMER_IOCTL_CONTINUE
:
9590 case VKI_SNDRV_TIMER_IOCTL_PAUSE
:
9593 case VKI_SNDRV_CTL_IOCTL_PVERSION
: {
9594 POST_MEM_WRITE( (Addr
)ARG3
, sizeof(int) );
9597 case VKI_SNDRV_CTL_IOCTL_CARD_INFO
:
9598 POST_MEM_WRITE( (Addr
)ARG3
, sizeof(struct vki_snd_ctl_card_info
) );
9600 case VKI_SNDRV_CTL_IOCTL_ELEM_LIST
: {
9601 struct vki_snd_ctl_elem_list
*data
= (struct vki_snd_ctl_elem_list
*)ARG3
;
9602 POST_MEM_WRITE( (Addr
)&data
->used
, sizeof(data
->used
) );
9603 POST_MEM_WRITE( (Addr
)&data
->count
, sizeof(data
->count
) );
9605 POST_MEM_WRITE( (Addr
)data
->pids
, sizeof(struct vki_snd_ctl_elem_id
) * data
->used
);
9609 case VKI_SNDRV_CTL_IOCTL_TLV_READ
: {
9610 struct vki_snd_ctl_tlv
*data
= (struct vki_snd_ctl_tlv
*)ARG3
;
9611 POST_MEM_WRITE( (Addr
)data
->tlv
, data
->length
);
9614 case VKI_SNDRV_CTL_IOCTL_TLV_WRITE
:
9615 case VKI_SNDRV_CTL_IOCTL_TLV_COMMAND
:
9618 /* SCSI no operand */
9619 case VKI_SCSI_IOCTL_DOORLOCK
:
9620 case VKI_SCSI_IOCTL_DOORUNLOCK
:
9623 /* Real Time Clock (/dev/rtc) ioctls */
9624 case VKI_RTC_UIE_ON
:
9625 case VKI_RTC_UIE_OFF
:
9626 case VKI_RTC_AIE_ON
:
9627 case VKI_RTC_AIE_OFF
:
9628 case VKI_RTC_PIE_ON
:
9629 case VKI_RTC_PIE_OFF
:
9630 case VKI_RTC_IRQP_SET
:
9632 case VKI_RTC_RD_TIME
:
9633 case VKI_RTC_ALM_READ
:
9634 POST_MEM_WRITE(ARG3
, sizeof(struct vki_rtc_time
));
9636 case VKI_RTC_ALM_SET
:
9638 case VKI_RTC_IRQP_READ
:
9639 POST_MEM_WRITE(ARG3
, sizeof(unsigned long));
9646 POST_MEM_WRITE(ARG3
, sizeof(int));
9648 case VKI_BLKGETSIZE
:
9649 POST_MEM_WRITE(ARG3
, sizeof(unsigned long));
9656 POST_MEM_WRITE(ARG3
, sizeof(long));
9661 POST_MEM_WRITE(ARG3
, sizeof(long));
9663 case VKI_BLKSECTGET
:
9664 POST_MEM_WRITE(ARG3
, sizeof(unsigned short));
9667 POST_MEM_WRITE(ARG3
, sizeof(int));
9670 POST_MEM_WRITE(ARG3
, sizeof(int));
9674 case VKI_BLKGETSIZE64
:
9675 POST_MEM_WRITE(ARG3
, sizeof(unsigned long long));
9677 case VKI_BLKPBSZGET
:
9678 POST_MEM_WRITE(ARG3
, sizeof(int));
9680 case VKI_BLKDISCARDZEROES
:
9681 POST_MEM_WRITE(ARG3
, sizeof(vki_uint
));
9683 case VKI_BLKREPORTZONE
: {
9684 const struct vki_blk_zone_report
*zr
= (void *)ARG3
;
9686 POST_MEM_WRITE(ARG3
, sizeof(*zr
) + zr
->nr_zones
* sizeof(zr
->zones
[0]));
9689 case VKI_BLKRESETZONE
:
9693 case VKI_HDIO_GETGEO
: /* 0x0301 */
9694 POST_MEM_WRITE(ARG3
, sizeof(struct vki_hd_geometry
));
9696 case VKI_HDIO_GET_DMA
: /* 0x030b */
9697 POST_MEM_WRITE(ARG3
, sizeof(long));
9699 case VKI_HDIO_GET_IDENTITY
: /* 0x030d */
9700 POST_MEM_WRITE(ARG3
, VKI_SIZEOF_STRUCT_HD_DRIVEID
);
9704 case VKI_SCSI_IOCTL_GET_IDLUN
: /* 0x5382 */
9705 POST_MEM_WRITE(ARG3
, sizeof(struct vki_scsi_idlun
));
9707 case VKI_SCSI_IOCTL_GET_BUS_NUMBER
: /* 0x5386 */
9708 POST_MEM_WRITE(ARG3
, sizeof(int));
9711 /* CD ROM stuff (??) */
9712 case VKI_CDROM_DISC_STATUS
:
9715 case VKI_CDROMSUBCHNL
:
9716 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_subchnl
));
9718 case VKI_CDROMREADTOCHDR
:
9719 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_tochdr
));
9721 case VKI_CDROMREADTOCENTRY
:
9722 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_tocentry
));
9724 case VKI_CDROMMULTISESSION
:
9725 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_multisession
));
9727 case VKI_CDROMVOLREAD
:
9728 POST_MEM_WRITE(ARG3
, sizeof(struct vki_cdrom_volctrl
));
9730 case VKI_CDROMREADMODE1
:
9731 POST_MEM_WRITE(ARG3
, VKI_CD_FRAMESIZE_RAW1
);
9733 case VKI_CDROMREADMODE2
:
9734 POST_MEM_WRITE(ARG3
, VKI_CD_FRAMESIZE_RAW0
);
9736 case VKI_CDROMREADRAW
:
9737 POST_MEM_WRITE(ARG3
, VKI_CD_FRAMESIZE_RAW
);
9739 case VKI_CDROMREADAUDIO
:
9741 struct vki_cdrom_read_audio
*cra
= (struct vki_cdrom_read_audio
*) ARG3
;
9742 POST_MEM_WRITE( (Addr
)(cra
->buf
), cra
->nframes
* VKI_CD_FRAMESIZE_RAW
);
9746 case VKI_CDROMPLAYMSF
:
9748 /* The following two are probably bogus (should check args
9749 for readability). JRS 20021117 */
9750 case VKI_CDROM_DRIVE_STATUS
: /* 0x5326 */
9751 case VKI_CDROM_CLEAR_OPTIONS
: /* 0x5321 */
9753 case VKI_CDROM_GET_CAPABILITY
: /* 0x5331 */
9757 case VKI_DVD_READ_STRUCT
:
9761 POST_MEM_WRITE(ARG3
, sizeof(unsigned long));
9764 POST_MEM_WRITE(ARG3
, sizeof(int));
9767 case VKI_FBIOGET_VSCREENINFO
: //0x4600
9768 POST_MEM_WRITE(ARG3
, sizeof(struct vki_fb_var_screeninfo
));
9770 case VKI_FBIOGET_FSCREENINFO
: //0x4602
9771 POST_MEM_WRITE(ARG3
, sizeof(struct vki_fb_fix_screeninfo
));
9779 case VKI_PPSETPHASE
:
9780 case VKI_PPSETFLAGS
:
9782 case VKI_PPWCONTROL
:
9783 case VKI_PPFCONTROL
:
9786 case VKI_PPWCTLONIRQ
:
9790 POST_MEM_WRITE( ARG3
, sizeof(int) );
9792 case VKI_PPGETPHASE
:
9793 POST_MEM_WRITE( ARG3
, sizeof(int) );
9795 case VKI_PPGETMODES
:
9796 POST_MEM_WRITE( ARG3
, sizeof(unsigned int) );
9798 case VKI_PPGETFLAGS
:
9799 POST_MEM_WRITE( ARG3
, sizeof(int) );
9802 POST_MEM_WRITE( ARG3
, sizeof(unsigned char) );
9805 POST_MEM_WRITE( ARG3
, sizeof(unsigned char) );
9807 case VKI_PPRCONTROL
:
9808 POST_MEM_WRITE( ARG3
, sizeof(unsigned char) );
9811 POST_MEM_WRITE( ARG3
, sizeof(int) );
9814 POST_MEM_WRITE( ARG3
, sizeof(struct vki_timeval
) );
9818 POST_MEM_WRITE( ARG3
, 32 * 256 );
9824 POST_MEM_WRITE( (Addr
)((struct vki_consolefontdesc
*)ARG3
)->chardata
,
9825 32 * ((struct vki_consolefontdesc
*)ARG3
)->charcount
);
9830 case VKI_PIO_FONTRESET
:
9834 POST_MEM_WRITE( ARG3
, 16 * 3 );
9844 POST_MEM_WRITE( ARG3
, sizeof(char) );
9850 POST_MEM_WRITE( ARG3
, sizeof(char) );
9862 POST_MEM_WRITE( ARG3
, sizeof(int) );
9866 case VKI_KDUNMAPDISP
:
9869 case VKI_GIO_SCRNMAP
:
9870 POST_MEM_WRITE( ARG3
, VKI_E_TABSZ
);
9872 case VKI_PIO_SCRNMAP
:
9874 case VKI_GIO_UNISCRNMAP
:
9875 POST_MEM_WRITE( ARG3
, VKI_E_TABSZ
* sizeof(unsigned short) );
9877 case VKI_PIO_UNISCRNMAP
:
9880 case VKI_GIO_UNIMAP
:
9882 struct vki_unimapdesc
*desc
= (struct vki_unimapdesc
*) ARG3
;
9883 POST_MEM_WRITE( (Addr
)&desc
->entry_ct
, sizeof(desc
->entry_ct
));
9884 POST_MEM_WRITE( (Addr
)desc
->entries
,
9885 desc
->entry_ct
* sizeof(struct vki_unipair
) );
9888 case VKI_PIO_UNIMAP
:
9890 case VKI_PIO_UNIMAPCLR
:
9894 POST_MEM_WRITE( ARG3
, sizeof(int) );
9900 POST_MEM_WRITE( ARG3
, sizeof(int) );
9906 POST_MEM_WRITE( ARG3
, sizeof(char) );
9912 POST_MEM_WRITE( (Addr
)&((struct vki_kbentry
*)ARG3
)->kb_value
,
9913 sizeof(((struct vki_kbentry
*)ARG3
)->kb_value
) );
9919 POST_MEM_WRITE( (Addr
)((struct vki_kbsentry
*)ARG3
)->kb_string
,
9920 sizeof(((struct vki_kbsentry
*)ARG3
)->kb_string
) );
9925 case VKI_KDGKBDIACR
:
9926 POST_MEM_WRITE( ARG3
, sizeof(struct vki_kbdiacrs
) );
9928 case VKI_KDSKBDIACR
:
9931 case VKI_KDGETKEYCODE
:
9932 POST_MEM_WRITE( (Addr
)((struct vki_kbkeycode
*)ARG3
)->keycode
,
9933 sizeof(((struct vki_kbkeycode
*)ARG3
)->keycode
) );
9935 case VKI_KDSETKEYCODE
:
9938 case VKI_KDSIGACCEPT
:
9946 struct vki_console_font_op
*op
= (struct vki_console_font_op
*) ARG3
;
9948 case VKI_KD_FONT_OP_SET
:
9950 case VKI_KD_FONT_OP_GET
:
9952 POST_MEM_WRITE( (Addr
) op
->data
,
9953 (op
->width
+ 7) / 8 * 32 * op
->charcount
);
9955 case VKI_KD_FONT_OP_SET_DEFAULT
:
9957 case VKI_KD_FONT_OP_COPY
:
9960 POST_MEM_WRITE( (Addr
) op
, sizeof(*op
));
9964 case VKI_VT_OPENQRY
:
9965 POST_MEM_WRITE( ARG3
, sizeof(int) );
9967 case VKI_VT_GETMODE
:
9968 POST_MEM_WRITE( ARG3
, sizeof(struct vki_vt_mode
) );
9970 case VKI_VT_SETMODE
:
9972 case VKI_VT_GETSTATE
:
9973 POST_MEM_WRITE( (Addr
) &(((struct vki_vt_stat
*) ARG3
)->v_active
),
9974 sizeof(((struct vki_vt_stat
*) ARG3
)->v_active
) );
9975 POST_MEM_WRITE( (Addr
) &(((struct vki_vt_stat
*) ARG3
)->v_state
),
9976 sizeof(((struct vki_vt_stat
*) ARG3
)->v_state
) );
9978 case VKI_VT_RELDISP
:
9979 case VKI_VT_ACTIVATE
:
9980 case VKI_VT_WAITACTIVE
:
9981 case VKI_VT_DISALLOCATE
:
9985 case VKI_VT_RESIZEX
:
9987 case VKI_VT_LOCKSWITCH
:
9988 case VKI_VT_UNLOCKSWITCH
:
9991 case VKI_USBDEVFS_CONTROL
:
9993 struct vki_usbdevfs_ctrltransfer
*vkuc
= (struct vki_usbdevfs_ctrltransfer
*)ARG3
;
9994 if (vkuc
->bRequestType
& 0x80)
9995 POST_MEM_WRITE((Addr
)vkuc
->data
, RES
);
9998 case VKI_USBDEVFS_BULK
:
10000 struct vki_usbdevfs_bulktransfer
*vkub
= (struct vki_usbdevfs_bulktransfer
*)ARG3
;
10001 if (vkub
->ep
& 0x80)
10002 POST_MEM_WRITE((Addr
)vkub
->data
, RES
);
10005 case VKI_USBDEVFS_GETDRIVER
:
10007 struct vki_usbdevfs_getdriver
*vkugd
= (struct vki_usbdevfs_getdriver
*)ARG3
;
10008 POST_MEM_WRITE((Addr
)&vkugd
->driver
, sizeof(vkugd
->driver
));
10011 case VKI_USBDEVFS_REAPURB
:
10012 case VKI_USBDEVFS_REAPURBNDELAY
:
10014 struct vki_usbdevfs_urb
**vkuu
= (struct vki_usbdevfs_urb
**)ARG3
;
10015 POST_MEM_WRITE((Addr
)vkuu
, sizeof(*vkuu
));
10018 POST_MEM_WRITE((Addr
) &((*vkuu
)->status
),sizeof((*vkuu
)->status
));
10019 if ((*vkuu
)->type
== VKI_USBDEVFS_URB_TYPE_CONTROL
) {
10020 struct vki_usbdevfs_setuppacket
*vkusp
= (struct vki_usbdevfs_setuppacket
*)(*vkuu
)->buffer
;
10021 if (vkusp
->bRequestType
& 0x80)
10022 POST_MEM_WRITE((Addr
)(vkusp
+1), (*vkuu
)->buffer_length
- sizeof(*vkusp
));
10023 POST_MEM_WRITE((Addr
)&(*vkuu
)->actual_length
, sizeof((*vkuu
)->actual_length
));
10024 } else if ((*vkuu
)->type
== VKI_USBDEVFS_URB_TYPE_ISO
) {
10025 char *bp
= (*vkuu
)->buffer
;
10027 for(i
=0; i
<(*vkuu
)->number_of_packets
; i
++) {
10028 POST_MEM_WRITE((Addr
)&(*vkuu
)->iso_frame_desc
[i
].actual_length
, sizeof((*vkuu
)->iso_frame_desc
[i
].actual_length
));
10029 POST_MEM_WRITE((Addr
)&(*vkuu
)->iso_frame_desc
[i
].status
, sizeof((*vkuu
)->iso_frame_desc
[i
].status
));
10030 if ((*vkuu
)->endpoint
& 0x80)
10031 POST_MEM_WRITE((Addr
)bp
, (*vkuu
)->iso_frame_desc
[i
].actual_length
);
10032 bp
+= (*vkuu
)->iso_frame_desc
[i
].length
; // FIXME: or actual_length??
10034 POST_MEM_WRITE((Addr
)&(*vkuu
)->error_count
, sizeof((*vkuu
)->error_count
));
10036 if ((*vkuu
)->endpoint
& 0x80)
10037 POST_MEM_WRITE((Addr
)(*vkuu
)->buffer
, (*vkuu
)->actual_length
);
10038 POST_MEM_WRITE((Addr
)&(*vkuu
)->actual_length
, sizeof((*vkuu
)->actual_length
));
10042 case VKI_USBDEVFS_CONNECTINFO
:
10043 POST_MEM_WRITE(ARG3
, sizeof(struct vki_usbdevfs_connectinfo
));
10045 case VKI_USBDEVFS_IOCTL
:
10047 struct vki_usbdevfs_ioctl
*vkui
= (struct vki_usbdevfs_ioctl
*)ARG3
;
10049 dir2
= _VKI_IOC_DIR(vkui
->ioctl_code
);
10050 size2
= _VKI_IOC_SIZE(vkui
->ioctl_code
);
10052 if (dir2
& _VKI_IOC_READ
)
10053 POST_MEM_WRITE((Addr
)vkui
->data
, size2
);
10058 /* I2C (/dev/i2c-*) ioctls */
10059 case VKI_I2C_SLAVE
:
10060 case VKI_I2C_SLAVE_FORCE
:
10061 case VKI_I2C_TENBIT
:
10064 case VKI_I2C_FUNCS
:
10065 POST_MEM_WRITE( ARG3
, sizeof(unsigned long) );
10069 struct vki_i2c_rdwr_ioctl_data
*vkui
= (struct vki_i2c_rdwr_ioctl_data
*)ARG3
;
10071 for (i
=0; i
< vkui
->nmsgs
; i
++) {
10072 struct vki_i2c_msg
*msg
= vkui
->msgs
+ i
;
10073 if (msg
->flags
& VKI_I2C_M_RD
)
10074 POST_MEM_WRITE((Addr
)msg
->buf
, msg
->len
);
10078 case VKI_I2C_SMBUS
:
10080 struct vki_i2c_smbus_ioctl_data
*vkis
10081 = (struct vki_i2c_smbus_ioctl_data
*) ARG3
;
10082 /* i2c_smbus_write_quick hides its value in read_write, so
10083 this variable can have a different meaning */
10084 if ((vkis
->read_write
== VKI_I2C_SMBUS_READ
)
10085 || (vkis
->size
== VKI_I2C_SMBUS_PROC_CALL
)
10086 || (vkis
->size
== VKI_I2C_SMBUS_BLOCK_PROC_CALL
)) {
10087 if ( ! (vkis
->size
== VKI_I2C_SMBUS_QUICK
)) {
10089 switch(vkis
->size
) {
10090 case VKI_I2C_SMBUS_BYTE
:
10091 case VKI_I2C_SMBUS_BYTE_DATA
:
10094 case VKI_I2C_SMBUS_WORD_DATA
:
10095 case VKI_I2C_SMBUS_PROC_CALL
:
10098 case VKI_I2C_SMBUS_BLOCK_DATA
:
10099 case VKI_I2C_SMBUS_I2C_BLOCK_BROKEN
:
10100 case VKI_I2C_SMBUS_BLOCK_PROC_CALL
:
10101 case VKI_I2C_SMBUS_I2C_BLOCK_DATA
:
10102 size
= 1 + vkis
->data
->block
[0];
10107 POST_MEM_WRITE((Addr
)&vkis
->data
->block
[0], size
);
10113 /* Wireless extensions ioctls */
10114 case VKI_SIOCSIWCOMMIT
:
10115 case VKI_SIOCSIWNWID
:
10116 case VKI_SIOCSIWFREQ
:
10117 case VKI_SIOCSIWMODE
:
10118 case VKI_SIOCSIWSENS
:
10119 case VKI_SIOCSIWRANGE
:
10120 case VKI_SIOCSIWPRIV
:
10121 case VKI_SIOCSIWSTATS
:
10122 case VKI_SIOCSIWSPY
:
10123 case VKI_SIOCSIWTHRSPY
:
10124 case VKI_SIOCSIWAP
:
10125 case VKI_SIOCSIWSCAN
:
10126 case VKI_SIOCSIWESSID
:
10127 case VKI_SIOCSIWRATE
:
10128 case VKI_SIOCSIWNICKN
:
10129 case VKI_SIOCSIWRTS
:
10130 case VKI_SIOCSIWFRAG
:
10131 case VKI_SIOCSIWTXPOW
:
10132 case VKI_SIOCSIWRETRY
:
10133 case VKI_SIOCSIWENCODE
:
10134 case VKI_SIOCSIWPOWER
:
10135 case VKI_SIOCSIWGENIE
:
10136 case VKI_SIOCSIWMLME
:
10137 case VKI_SIOCSIWAUTH
:
10138 case VKI_SIOCSIWENCODEEXT
:
10139 case VKI_SIOCSIWPMKSA
:
10141 case VKI_SIOCGIWNAME
:
10143 POST_MEM_WRITE((Addr
)((struct vki_iwreq
*)ARG3
)->u
.name
,
10144 sizeof(((struct vki_iwreq
*)ARG3
)->u
.name
));
10147 case VKI_SIOCGIWNWID
:
10148 case VKI_SIOCGIWSENS
:
10149 case VKI_SIOCGIWRATE
:
10150 case VKI_SIOCGIWRTS
:
10151 case VKI_SIOCGIWFRAG
:
10152 case VKI_SIOCGIWTXPOW
:
10153 case VKI_SIOCGIWRETRY
:
10154 case VKI_SIOCGIWPOWER
:
10155 case VKI_SIOCGIWAUTH
:
10157 POST_MEM_WRITE((Addr
)&((struct vki_iwreq
*)ARG3
)->u
.param
,
10158 sizeof(struct vki_iw_param
));
10161 case VKI_SIOCGIWFREQ
:
10163 POST_MEM_WRITE((Addr
)&((struct vki_iwreq
*)ARG3
)->u
.freq
,
10164 sizeof(struct vki_iw_freq
));
10167 case VKI_SIOCGIWMODE
:
10169 POST_MEM_WRITE((Addr
)&((struct vki_iwreq
*)ARG3
)->u
.mode
,
10170 sizeof(__vki_u32
));
10173 case VKI_SIOCGIWRANGE
:
10174 case VKI_SIOCGIWPRIV
:
10175 case VKI_SIOCGIWSTATS
:
10176 case VKI_SIOCGIWSPY
:
10177 case VKI_SIOCGIWTHRSPY
:
10178 case VKI_SIOCGIWAPLIST
:
10179 case VKI_SIOCGIWSCAN
:
10180 case VKI_SIOCGIWESSID
:
10181 case VKI_SIOCGIWNICKN
:
10182 case VKI_SIOCGIWENCODE
:
10183 case VKI_SIOCGIWGENIE
:
10184 case VKI_SIOCGIWENCODEEXT
:
10186 struct vki_iw_point
* point
;
10187 point
= &((struct vki_iwreq
*)ARG3
)->u
.data
;
10188 POST_MEM_WRITE((Addr
)point
->pointer
, point
->length
);
10191 case VKI_SIOCGIWAP
:
10193 POST_MEM_WRITE((Addr
)&((struct vki_iwreq
*)ARG3
)->u
.ap_addr
,
10194 sizeof(struct vki_sockaddr
));
10198 # if defined(VGPV_arm_linux_android) || defined(VGPV_x86_linux_android) \
10199 || defined(VGPV_mips32_linux_android) \
10200 || defined(VGPV_arm64_linux_android)
10202 case VKI_ASHMEM_GET_SIZE
:
10203 case VKI_ASHMEM_SET_SIZE
:
10204 case VKI_ASHMEM_GET_PROT_MASK
:
10205 case VKI_ASHMEM_SET_PROT_MASK
:
10206 case VKI_ASHMEM_GET_PIN_STATUS
:
10207 case VKI_ASHMEM_PURGE_ALL_CACHES
:
10208 case VKI_ASHMEM_SET_NAME
:
10209 case VKI_ASHMEM_PIN
:
10210 case VKI_ASHMEM_UNPIN
:
10212 case VKI_ASHMEM_GET_NAME
:
10213 POST_MEM_WRITE( ARG3
, VKI_ASHMEM_NAME_LEN
);
10217 case VKI_BINDER_WRITE_READ
:
10219 struct vki_binder_write_read
* bwr
10220 = (struct vki_binder_write_read
*)ARG3
;
10221 POST_FIELD_WRITE(bwr
->write_consumed
);
10222 POST_FIELD_WRITE(bwr
->read_consumed
);
10224 if (bwr
->read_size
)
10225 POST_MEM_WRITE((Addr
)bwr
->read_buffer
, bwr
->read_consumed
);
10229 case VKI_BINDER_SET_IDLE_TIMEOUT
:
10230 case VKI_BINDER_SET_MAX_THREADS
:
10231 case VKI_BINDER_SET_IDLE_PRIORITY
:
10232 case VKI_BINDER_SET_CONTEXT_MGR
:
10233 case VKI_BINDER_THREAD_EXIT
:
10235 case VKI_BINDER_VERSION
:
10237 struct vki_binder_version
* bv
= (struct vki_binder_version
*)ARG3
;
10238 POST_FIELD_WRITE(bv
->protocol_version
);
10241 # endif /* defined(VGPV_*_linux_android) */
10243 case VKI_HCIGETDEVLIST
:
10245 struct vki_hci_dev_list_req
* dlr
= (struct vki_hci_dev_list_req
*)ARG3
;
10246 POST_MEM_WRITE((Addr
)ARG3
+ sizeof(struct vki_hci_dev_list_req
),
10247 dlr
->dev_num
* sizeof(struct vki_hci_dev_req
));
10251 case VKI_HCIINQUIRY
:
10253 struct vki_hci_inquiry_req
* ir
= (struct vki_hci_inquiry_req
*)ARG3
;
10254 POST_MEM_WRITE((Addr
)ARG3
+ sizeof(struct vki_hci_inquiry_req
),
10255 ir
->num_rsp
* sizeof(struct vki_inquiry_info
));
10259 case VKI_DRM_IOCTL_VERSION
:
10261 struct vki_drm_version
* data
= (struct vki_drm_version
*)ARG3
;
10262 struct vg_drm_version_info
* info
= container_of(data
, struct vg_drm_version_info
, data
);
10263 const vki_size_t orig_name_len
= info
->orig
->name_len
;
10264 const vki_size_t orig_date_len
= info
->orig
->date_len
;
10265 const vki_size_t orig_desc_len
= info
->orig
->desc_len
;
10266 *info
->orig
= info
->data
;
10267 ARG3
= (Addr
)info
->orig
;
10271 POST_MEM_WRITE((Addr
)&data
->version_major
, sizeof(data
->version_major
));
10272 POST_MEM_WRITE((Addr
)&data
->version_minor
, sizeof(data
->version_minor
));
10273 POST_MEM_WRITE((Addr
)&data
->version_patchlevel
, sizeof(data
->version_patchlevel
));
10274 POST_MEM_WRITE((Addr
)&data
->name_len
, sizeof(data
->name_len
));
10275 POST_MEM_WRITE((Addr
)data
->name
, VG_MIN(data
->name_len
, orig_name_len
));
10276 POST_MEM_WRITE((Addr
)&data
->date_len
, sizeof(data
->date_len
));
10277 POST_MEM_WRITE((Addr
)data
->date
, VG_MIN(data
->date_len
, orig_date_len
));
10278 POST_MEM_WRITE((Addr
)&data
->desc_len
, sizeof(data
->desc_len
));
10279 POST_MEM_WRITE((Addr
)data
->desc
, VG_MIN(data
->desc_len
, orig_desc_len
));
10283 case VKI_DRM_IOCTL_GET_UNIQUE
:
10285 struct vki_drm_unique
*data
= (struct vki_drm_unique
*)ARG3
;
10286 POST_MEM_WRITE((Addr
)data
->unique
, sizeof(data
->unique_len
));
10289 case VKI_DRM_IOCTL_GET_MAGIC
:
10291 struct vki_drm_auth
*data
= (struct vki_drm_auth
*)ARG3
;
10292 POST_MEM_WRITE((Addr
)&data
->magic
, sizeof(data
->magic
));
10295 case VKI_DRM_IOCTL_WAIT_VBLANK
:
10297 union vki_drm_wait_vblank
*data
= (union vki_drm_wait_vblank
*)ARG3
;
10298 POST_MEM_WRITE((Addr
)&data
->reply
, sizeof(data
->reply
));
10301 case VKI_DRM_IOCTL_GEM_FLINK
:
10303 struct vki_drm_gem_flink
*data
= (struct vki_drm_gem_flink
*)ARG3
;
10304 POST_MEM_WRITE((Addr
)&data
->name
, sizeof(data
->name
));
10307 case VKI_DRM_IOCTL_GEM_OPEN
:
10309 struct vki_drm_gem_open
*data
= (struct vki_drm_gem_open
*)ARG3
;
10310 POST_MEM_WRITE((Addr
)&data
->handle
, sizeof(data
->handle
));
10311 POST_MEM_WRITE((Addr
)&data
->size
, sizeof(data
->size
));
10314 case VKI_DRM_IOCTL_I915_GETPARAM
:
10316 vki_drm_i915_getparam_t
*data
= (vki_drm_i915_getparam_t
*)ARG3
;
10317 POST_MEM_WRITE((Addr
)data
->value
, sizeof(int));
10320 case VKI_DRM_IOCTL_I915_GEM_BUSY
:
10322 struct vki_drm_i915_gem_busy
*data
= (struct vki_drm_i915_gem_busy
*)ARG3
;
10323 POST_MEM_WRITE((Addr
)&data
->busy
, sizeof(data
->busy
));
10326 case VKI_DRM_IOCTL_I915_GEM_CREATE
:
10328 struct vki_drm_i915_gem_create
*data
= (struct vki_drm_i915_gem_create
*)ARG3
;
10329 POST_MEM_WRITE((Addr
)&data
->handle
, sizeof(data
->handle
));
10332 case VKI_DRM_IOCTL_I915_GEM_PREAD
:
10334 struct vki_drm_i915_gem_pread
*data
= (struct vki_drm_i915_gem_pread
*)ARG3
;
10335 POST_MEM_WRITE((Addr
)data
->data_ptr
, data
->size
);
10338 case VKI_DRM_IOCTL_I915_GEM_MMAP_GTT
:
10340 struct vki_drm_i915_gem_mmap_gtt
*data
= (struct vki_drm_i915_gem_mmap_gtt
*)ARG3
;
10341 POST_MEM_WRITE((Addr
)&data
->offset
, sizeof(data
->offset
));
10344 case VKI_DRM_IOCTL_I915_GEM_SET_TILING
:
10346 struct vki_drm_i915_gem_set_tiling
*data
= (struct vki_drm_i915_gem_set_tiling
*)ARG3
;
10347 POST_MEM_WRITE((Addr
)&data
->tiling_mode
, sizeof(data
->tiling_mode
));
10348 POST_MEM_WRITE((Addr
)&data
->stride
, sizeof(data
->stride
));
10349 POST_MEM_WRITE((Addr
)&data
->swizzle_mode
, sizeof(data
->swizzle_mode
));
10352 case VKI_DRM_IOCTL_I915_GEM_GET_TILING
:
10354 struct vki_drm_i915_gem_get_tiling
*data
= (struct vki_drm_i915_gem_get_tiling
*)ARG3
;
10355 POST_MEM_WRITE((Addr
)&data
->tiling_mode
, sizeof(data
->tiling_mode
));
10356 POST_MEM_WRITE((Addr
)&data
->swizzle_mode
, sizeof(data
->swizzle_mode
));
10359 case VKI_DRM_IOCTL_I915_GEM_GET_APERTURE
:
10361 struct vki_drm_i915_gem_get_aperture
*data
= (struct vki_drm_i915_gem_get_aperture
*)ARG3
;
10362 POST_MEM_WRITE((Addr
)&data
->aper_size
, sizeof(data
->aper_size
));
10363 POST_MEM_WRITE((Addr
)&data
->aper_available_size
, sizeof(data
->aper_available_size
));
10367 /* KVM ioctls that only write the system call return value */
10368 case VKI_KVM_GET_API_VERSION
:
10369 case VKI_KVM_CREATE_VM
:
10370 case VKI_KVM_CHECK_EXTENSION
:
10371 case VKI_KVM_GET_VCPU_MMAP_SIZE
:
10372 case VKI_KVM_S390_ENABLE_SIE
:
10373 case VKI_KVM_CREATE_VCPU
:
10374 case VKI_KVM_SET_TSS_ADDR
:
10375 case VKI_KVM_CREATE_IRQCHIP
:
10377 case VKI_KVM_S390_INITIAL_RESET
:
10378 case VKI_KVM_KVMCLOCK_CTRL
:
10381 case VKI_KVM_S390_MEM_OP
: {
10382 struct vki_kvm_s390_mem_op
*args
=
10383 (struct vki_kvm_s390_mem_op
*)(ARG3
);
10384 if (args
->flags
& VKI_KVM_S390_MEMOP_F_CHECK_ONLY
)
10386 if (args
->op
== VKI_KVM_S390_MEMOP_LOGICAL_READ
)
10387 POST_MEM_WRITE((Addr
)args
->buf
, args
->size
);
10392 case VKI_XEN_IOCTL_PRIVCMD_HYPERCALL
: {
10393 SyscallArgs harrghs
;
10394 struct vki_xen_privcmd_hypercall
*args
=
10395 (struct vki_xen_privcmd_hypercall
*)(ARG3
);
10400 VG_(memset
)(&harrghs
, 0, sizeof(harrghs
));
10401 harrghs
.sysno
= args
->op
;
10402 harrghs
.arg1
= args
->arg
[0];
10403 harrghs
.arg2
= args
->arg
[1];
10404 harrghs
.arg3
= args
->arg
[2];
10405 harrghs
.arg4
= args
->arg
[3];
10406 harrghs
.arg5
= args
->arg
[4];
10407 harrghs
.arg6
= harrghs
.arg7
= harrghs
.arg8
= 0;
10409 WRAPPER_POST_NAME(xen
, hypercall
) (tid
, &harrghs
, status
);
10413 case VKI_XEN_IOCTL_PRIVCMD_MMAP
:
10415 case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH
: {
10416 struct vki_xen_privcmd_mmapbatch
*args
=
10417 (struct vki_xen_privcmd_mmapbatch
*)(ARG3
);
10418 POST_MEM_WRITE((Addr
)args
->arr
, sizeof(*(args
->arr
)) * args
->num
);
10421 case VKI_XEN_IOCTL_PRIVCMD_MMAPBATCH_V2
: {
10422 struct vki_xen_privcmd_mmapbatch_v2
*args
=
10423 (struct vki_xen_privcmd_mmapbatch_v2
*)(ARG3
);
10424 POST_MEM_WRITE((Addr
)args
->err
, sizeof(*(args
->err
)) * args
->num
);
10428 case VKI_XEN_IOCTL_EVTCHN_BIND_VIRQ
:
10429 case VKI_XEN_IOCTL_EVTCHN_BIND_INTERDOMAIN
:
10430 case VKI_XEN_IOCTL_EVTCHN_BIND_UNBOUND_PORT
:
10431 case VKI_XEN_IOCTL_EVTCHN_UNBIND
:
10432 case VKI_XEN_IOCTL_EVTCHN_NOTIFY
:
10433 case VKI_XEN_IOCTL_EVTCHN_RESET
:
10439 case VKI_OBD_IOC_FID2PATH
: {
10440 struct vki_getinfo_fid2path
*args
= (void *)(ARG3
);
10441 POST_FIELD_WRITE(args
->gf_recno
);
10442 POST_FIELD_WRITE(args
->gf_linkno
);
10443 POST_MEM_WRITE((Addr
)args
->gf_path
, VG_(strlen
)(args
->gf_path
)+1);
10447 case VKI_LL_IOC_PATH2FID
:
10448 POST_MEM_WRITE(ARG3
, sizeof(struct vki_lu_fid
));
10451 case VKI_LL_IOC_GETPARENT
: {
10452 struct vki_getparent
*gp
= (struct vki_getparent
*)ARG3
;
10453 POST_FIELD_WRITE(gp
->gp_fid
);
10454 POST_MEM_WRITE((Addr
)gp
->gp_name
, VG_(strlen
)(gp
->gp_name
)+1);
10459 case VKI_V4L2_S_FMT
:
10460 case VKI_V4L2_TRY_FMT
:
10461 case VKI_V4L2_REQBUFS
:
10462 case VKI_V4L2_OVERLAY
:
10463 case VKI_V4L2_STREAMON
:
10464 case VKI_V4L2_STREAMOFF
:
10465 case VKI_V4L2_S_PARM
:
10466 case VKI_V4L2_S_STD
:
10467 case VKI_V4L2_S_FREQUENCY
:
10468 case VKI_V4L2_S_CTRL
:
10469 case VKI_V4L2_S_TUNER
:
10470 case VKI_V4L2_S_AUDIO
:
10471 case VKI_V4L2_S_INPUT
:
10472 case VKI_V4L2_S_EDID
:
10473 case VKI_V4L2_S_OUTPUT
:
10474 case VKI_V4L2_S_AUDOUT
:
10475 case VKI_V4L2_S_MODULATOR
:
10476 case VKI_V4L2_S_JPEGCOMP
:
10477 case VKI_V4L2_S_CROP
:
10478 case VKI_V4L2_S_PRIORITY
:
10479 case VKI_V4L2_S_HW_FREQ_SEEK
:
10480 case VKI_V4L2_S_DV_TIMINGS
:
10481 case VKI_V4L2_SUBSCRIBE_EVENT
:
10482 case VKI_V4L2_UNSUBSCRIBE_EVENT
:
10483 case VKI_V4L2_PREPARE_BUF
:
10485 case VKI_V4L2_QUERYCAP
: {
10486 struct vki_v4l2_capability
*data
= (struct vki_v4l2_capability
*)ARG3
;
10487 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10490 case VKI_V4L2_ENUM_FMT
: {
10491 struct vki_v4l2_fmtdesc
*data
= (struct vki_v4l2_fmtdesc
*)ARG3
;
10492 POST_FIELD_WRITE(data
->flags
);
10493 POST_FIELD_WRITE(data
->description
);
10494 POST_FIELD_WRITE(data
->pixelformat
);
10495 POST_FIELD_WRITE(data
->reserved
);
10498 case VKI_V4L2_G_FMT
: {
10499 struct vki_v4l2_format
*data
= (struct vki_v4l2_format
*)ARG3
;
10500 switch (data
->type
) {
10501 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE
:
10502 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
:
10503 POST_FIELD_WRITE(data
->fmt
.pix
);
10505 case VKI_V4L2_BUF_TYPE_VBI_CAPTURE
:
10506 case VKI_V4L2_BUF_TYPE_VBI_OUTPUT
:
10507 POST_FIELD_WRITE(data
->fmt
.vbi
);
10509 case VKI_V4L2_BUF_TYPE_SLICED_VBI_CAPTURE
:
10510 case VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
:
10511 POST_FIELD_WRITE(data
->fmt
.sliced
);
10513 case VKI_V4L2_BUF_TYPE_VIDEO_OVERLAY
:
10514 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY
:
10515 POST_FIELD_WRITE(data
->fmt
.win
);
10517 case VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
10518 case VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
10519 POST_FIELD_WRITE(data
->fmt
.pix_mp
);
10521 case VKI_V4L2_BUF_TYPE_SDR_CAPTURE
:
10522 POST_FIELD_WRITE(data
->fmt
.sdr
);
10527 case VKI_V4L2_QUERYBUF
: {
10528 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
10529 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
10530 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
10533 for (i
= 0; i
< data
->length
; i
++) {
10534 POST_FIELD_WRITE(data
->m
.planes
[i
].bytesused
);
10535 POST_FIELD_WRITE(data
->m
.planes
[i
].length
);
10536 POST_FIELD_WRITE(data
->m
.planes
[i
].m
);
10537 POST_FIELD_WRITE(data
->m
.planes
[i
].data_offset
);
10538 POST_FIELD_WRITE(data
->m
.planes
[i
].reserved
);
10541 POST_FIELD_WRITE(data
->m
);
10542 POST_FIELD_WRITE(data
->length
);
10544 POST_FIELD_WRITE(data
->bytesused
);
10545 POST_FIELD_WRITE(data
->flags
);
10546 POST_FIELD_WRITE(data
->field
);
10547 POST_FIELD_WRITE(data
->timestamp
);
10548 POST_FIELD_WRITE(data
->timecode
);
10549 POST_FIELD_WRITE(data
->sequence
);
10550 POST_FIELD_WRITE(data
->memory
);
10551 POST_FIELD_WRITE(data
->sequence
);
10554 case VKI_V4L2_G_FBUF
: {
10555 struct vki_v4l2_framebuffer
*data
= (struct vki_v4l2_framebuffer
*)ARG3
;
10556 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10559 case VKI_V4L2_S_FBUF
: {
10560 struct vki_v4l2_framebuffer
*data
= (struct vki_v4l2_framebuffer
*)ARG3
;
10561 POST_FIELD_WRITE(data
->capability
);
10562 POST_FIELD_WRITE(data
->flags
);
10563 POST_FIELD_WRITE(data
->fmt
);
10566 case VKI_V4L2_QBUF
: {
10567 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
10569 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
10570 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
10573 for (i
= 0; i
< data
->length
; i
++) {
10574 POST_FIELD_WRITE(data
->m
.planes
[i
].length
);
10575 if (data
->memory
== VKI_V4L2_MEMORY_MMAP
)
10576 POST_FIELD_WRITE(data
->m
.planes
[i
].m
);
10579 if (data
->memory
== VKI_V4L2_MEMORY_MMAP
)
10580 POST_FIELD_WRITE(data
->m
);
10581 POST_FIELD_WRITE(data
->length
);
10585 case VKI_V4L2_EXPBUF
: {
10586 struct vki_v4l2_exportbuffer
*data
= (struct vki_v4l2_exportbuffer
*)ARG3
;
10587 POST_FIELD_WRITE(data
->fd
);
10590 case VKI_V4L2_DQBUF
: {
10591 struct vki_v4l2_buffer
*data
= (struct vki_v4l2_buffer
*)ARG3
;
10592 POST_FIELD_WRITE(data
->index
);
10593 POST_FIELD_WRITE(data
->bytesused
);
10594 POST_FIELD_WRITE(data
->field
);
10595 if (data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
||
10596 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
10599 for (i
= 0; i
< data
->length
; i
++) {
10600 POST_FIELD_WRITE(data
->m
.planes
[i
].bytesused
);
10601 POST_FIELD_WRITE(data
->m
.planes
[i
].data_offset
);
10602 POST_FIELD_WRITE(data
->m
.planes
[i
].length
);
10603 POST_FIELD_WRITE(data
->m
.planes
[i
].m
);
10606 POST_FIELD_WRITE(data
->m
);
10607 POST_FIELD_WRITE(data
->length
);
10608 POST_FIELD_WRITE(data
->bytesused
);
10609 POST_FIELD_WRITE(data
->field
);
10611 POST_FIELD_WRITE(data
->timestamp
);
10612 POST_FIELD_WRITE(data
->timecode
);
10613 POST_FIELD_WRITE(data
->sequence
);
10616 case VKI_V4L2_G_PARM
: {
10617 struct vki_v4l2_streamparm
*data
= (struct vki_v4l2_streamparm
*)ARG3
;
10618 int is_output
= data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT
||
10619 data
->type
== VKI_V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
||
10620 data
->type
== VKI_V4L2_BUF_TYPE_VBI_OUTPUT
||
10621 data
->type
== VKI_V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
;
10624 POST_MEM_WRITE((Addr
)&data
->parm
.output
,
10625 sizeof(data
->parm
.output
) - sizeof(data
->parm
.output
.reserved
));
10627 POST_MEM_WRITE((Addr
)&data
->parm
.capture
,
10628 sizeof(data
->parm
.capture
) - sizeof(data
->parm
.capture
.reserved
));
10631 case VKI_V4L2_G_STD
: {
10632 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
10633 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10636 case VKI_V4L2_ENUMSTD
: {
10637 struct vki_v4l2_standard
*data
= (struct vki_v4l2_standard
*)ARG3
;
10638 POST_MEM_WRITE((Addr
)&data
->id
, sizeof(*data
) - sizeof(data
->index
));
10641 case VKI_V4L2_ENUMINPUT
: {
10642 struct vki_v4l2_input
*data
= (struct vki_v4l2_input
*)ARG3
;
10643 POST_MEM_WRITE((Addr
)data
->name
, sizeof(*data
) - sizeof(data
->index
));
10646 case VKI_V4L2_G_CTRL
: {
10647 struct vki_v4l2_control
*data
= (struct vki_v4l2_control
*)ARG3
;
10648 POST_FIELD_WRITE(data
->value
);
10651 case VKI_V4L2_G_TUNER
: {
10652 struct vki_v4l2_tuner
*data
= (struct vki_v4l2_tuner
*)ARG3
;
10653 POST_MEM_WRITE((Addr
)data
->name
,
10654 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
10657 case VKI_V4L2_G_AUDIO
: {
10658 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
10659 POST_MEM_WRITE((Addr
)data
,
10660 sizeof(*data
) - sizeof(data
->reserved
));
10663 case VKI_V4L2_QUERYCTRL
: {
10664 struct vki_v4l2_queryctrl
*data
= (struct vki_v4l2_queryctrl
*)ARG3
;
10665 POST_MEM_WRITE((Addr
)&data
->type
,
10666 sizeof(*data
) - sizeof(data
->id
));
10669 case VKI_V4L2_QUERYMENU
: {
10670 struct vki_v4l2_querymenu
*data
= (struct vki_v4l2_querymenu
*)ARG3
;
10671 POST_MEM_WRITE((Addr
)data
->name
,
10672 sizeof(*data
) - sizeof(data
->id
) - sizeof(data
->index
));
10675 case VKI_V4L2_G_INPUT
: {
10676 int *data
= (int *)ARG3
;
10677 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10680 case VKI_V4L2_G_EDID
: {
10681 struct vki_v4l2_edid
*data
= (struct vki_v4l2_edid
*)ARG3
;
10682 if (data
->blocks
&& data
->edid
)
10683 POST_MEM_WRITE((Addr
)data
->edid
, data
->blocks
* 128);
10686 case VKI_V4L2_G_OUTPUT
: {
10687 int *data
= (int *)ARG3
;
10688 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10691 case VKI_V4L2_ENUMOUTPUT
: {
10692 struct vki_v4l2_output
*data
= (struct vki_v4l2_output
*)ARG3
;
10693 POST_MEM_WRITE((Addr
)data
->name
, sizeof(*data
) - sizeof(data
->index
));
10696 case VKI_V4L2_G_AUDOUT
: {
10697 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
10698 POST_MEM_WRITE((Addr
)data
,
10699 sizeof(*data
) - sizeof(data
->reserved
));
10702 case VKI_V4L2_G_MODULATOR
: {
10703 struct vki_v4l2_modulator
*data
= (struct vki_v4l2_modulator
*)ARG3
;
10704 POST_MEM_WRITE((Addr
)data
->name
,
10705 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
10708 case VKI_V4L2_G_FREQUENCY
: {
10709 struct vki_v4l2_frequency
*data
= (struct vki_v4l2_frequency
*)ARG3
;
10710 POST_FIELD_WRITE(data
->type
);
10711 POST_FIELD_WRITE(data
->frequency
);
10714 case VKI_V4L2_CROPCAP
: {
10715 struct vki_v4l2_cropcap
*data
= (struct vki_v4l2_cropcap
*)ARG3
;
10716 POST_MEM_WRITE((Addr
)&data
->bounds
, sizeof(*data
) - sizeof(data
->type
));
10719 case VKI_V4L2_G_CROP
: {
10720 struct vki_v4l2_crop
*data
= (struct vki_v4l2_crop
*)ARG3
;
10721 POST_FIELD_WRITE(data
->c
);
10724 case VKI_V4L2_G_JPEGCOMP
: {
10725 struct vki_v4l2_jpegcompression
*data
= (struct vki_v4l2_jpegcompression
*)ARG3
;
10726 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10729 case VKI_V4L2_QUERYSTD
: {
10730 vki_v4l2_std_id
*data
= (vki_v4l2_std_id
*)ARG3
;
10731 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10734 case VKI_V4L2_ENUMAUDIO
: {
10735 struct vki_v4l2_audio
*data
= (struct vki_v4l2_audio
*)ARG3
;
10736 POST_MEM_WRITE((Addr
)data
->name
,
10737 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
10740 case VKI_V4L2_ENUMAUDOUT
: {
10741 struct vki_v4l2_audioout
*data
= (struct vki_v4l2_audioout
*)ARG3
;
10742 POST_MEM_WRITE((Addr
)data
->name
,
10743 sizeof(*data
) - sizeof(data
->index
) - sizeof(data
->reserved
));
10746 case VKI_V4L2_G_PRIORITY
: {
10747 __vki_u32
*data
= (__vki_u32
*)ARG3
;
10748 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10751 case VKI_V4L2_G_SLICED_VBI_CAP
: {
10752 struct vki_v4l2_sliced_vbi_cap
*data
= (struct vki_v4l2_sliced_vbi_cap
*)ARG3
;
10753 POST_MEM_WRITE((Addr
)data
,
10754 sizeof(*data
) - sizeof(data
->type
) - sizeof(data
->reserved
));
10757 case VKI_V4L2_G_EXT_CTRLS
: {
10758 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
10762 for (i
= 0; i
< data
->count
; i
++) {
10763 if (data
->controls
[i
].size
)
10764 POST_MEM_WRITE((Addr
)data
->controls
[i
].ptr
, data
->controls
[i
].size
);
10766 POST_FIELD_WRITE(data
->controls
[i
].value64
);
10769 POST_FIELD_WRITE(data
->error_idx
);
10772 case VKI_V4L2_S_EXT_CTRLS
: {
10773 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
10774 POST_FIELD_WRITE(data
->error_idx
);
10777 case VKI_V4L2_TRY_EXT_CTRLS
: {
10778 struct vki_v4l2_ext_controls
*data
= (struct vki_v4l2_ext_controls
*)ARG3
;
10779 POST_FIELD_WRITE(data
->error_idx
);
10782 case VKI_V4L2_ENUM_FRAMESIZES
: {
10783 struct vki_v4l2_frmsizeenum
*data
= (struct vki_v4l2_frmsizeenum
*)ARG3
;
10784 POST_FIELD_WRITE(data
->type
);
10785 POST_FIELD_WRITE(data
->stepwise
);
10788 case VKI_V4L2_ENUM_FRAMEINTERVALS
: {
10789 struct vki_v4l2_frmivalenum
*data
= (struct vki_v4l2_frmivalenum
*)ARG3
;
10790 POST_FIELD_WRITE(data
->type
);
10791 POST_FIELD_WRITE(data
->stepwise
);
10794 case VKI_V4L2_G_ENC_INDEX
: {
10795 struct vki_v4l2_enc_idx
*data
= (struct vki_v4l2_enc_idx
*)ARG3
;
10796 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10799 case VKI_V4L2_ENCODER_CMD
: {
10800 struct vki_v4l2_encoder_cmd
*data
= (struct vki_v4l2_encoder_cmd
*)ARG3
;
10801 POST_FIELD_WRITE(data
->flags
);
10804 case VKI_V4L2_TRY_ENCODER_CMD
: {
10805 struct vki_v4l2_encoder_cmd
*data
= (struct vki_v4l2_encoder_cmd
*)ARG3
;
10806 POST_FIELD_WRITE(data
->flags
);
10809 case VKI_V4L2_DBG_S_REGISTER
: {
10810 struct vki_v4l2_dbg_register
*data
= (struct vki_v4l2_dbg_register
*)ARG3
;
10811 POST_FIELD_WRITE(data
->size
);
10814 case VKI_V4L2_DBG_G_REGISTER
: {
10815 struct vki_v4l2_dbg_register
*data
= (struct vki_v4l2_dbg_register
*)ARG3
;
10816 POST_FIELD_WRITE(data
->val
);
10817 POST_FIELD_WRITE(data
->size
);
10820 case VKI_V4L2_G_DV_TIMINGS
: {
10821 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
10822 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10825 case VKI_V4L2_DQEVENT
: {
10826 struct vki_v4l2_event
*data
= (struct vki_v4l2_event
*)ARG3
;
10827 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10830 case VKI_V4L2_CREATE_BUFS
: {
10831 struct vki_v4l2_create_buffers
*data
= (struct vki_v4l2_create_buffers
*)ARG3
;
10832 POST_FIELD_WRITE(data
->index
);
10835 case VKI_V4L2_G_SELECTION
: {
10836 struct vki_v4l2_selection
*data
= (struct vki_v4l2_selection
*)ARG3
;
10837 POST_FIELD_WRITE(data
->r
);
10840 case VKI_V4L2_S_SELECTION
: {
10841 struct vki_v4l2_selection
*data
= (struct vki_v4l2_selection
*)ARG3
;
10842 POST_FIELD_WRITE(data
->r
);
10845 case VKI_V4L2_DECODER_CMD
: {
10846 struct vki_v4l2_decoder_cmd
*data
= (struct vki_v4l2_decoder_cmd
*)ARG3
;
10847 POST_FIELD_WRITE(data
->flags
);
10850 case VKI_V4L2_TRY_DECODER_CMD
: {
10851 struct vki_v4l2_decoder_cmd
*data
= (struct vki_v4l2_decoder_cmd
*)ARG3
;
10852 POST_FIELD_WRITE(data
->flags
);
10855 case VKI_V4L2_ENUM_DV_TIMINGS
: {
10856 struct vki_v4l2_enum_dv_timings
*data
= (struct vki_v4l2_enum_dv_timings
*)ARG3
;
10857 POST_FIELD_WRITE(data
->timings
);
10860 case VKI_V4L2_QUERY_DV_TIMINGS
: {
10861 struct vki_v4l2_dv_timings
*data
= (struct vki_v4l2_dv_timings
*)ARG3
;
10862 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10865 case VKI_V4L2_DV_TIMINGS_CAP
: {
10866 struct vki_v4l2_dv_timings_cap
*data
= (struct vki_v4l2_dv_timings_cap
*)ARG3
;
10867 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10870 case VKI_V4L2_ENUM_FREQ_BANDS
: {
10871 struct vki_v4l2_frequency_band
*data
= (struct vki_v4l2_frequency_band
*)ARG3
;
10872 POST_FIELD_WRITE(data
->capability
);
10873 POST_FIELD_WRITE(data
->rangelow
);
10874 POST_FIELD_WRITE(data
->rangehigh
);
10875 POST_FIELD_WRITE(data
->modulation
);
10878 case VKI_V4L2_DBG_G_CHIP_INFO
: {
10879 struct vki_v4l2_dbg_chip_info
*data
= (struct vki_v4l2_dbg_chip_info
*)ARG3
;
10880 POST_FIELD_WRITE(data
->name
);
10881 POST_FIELD_WRITE(data
->flags
);
10884 case VKI_V4L2_QUERY_EXT_CTRL
: {
10885 struct vki_v4l2_query_ext_ctrl
*data
= (struct vki_v4l2_query_ext_ctrl
*)ARG3
;
10886 POST_MEM_WRITE((Addr
)&data
->type
,
10887 sizeof(*data
) - sizeof(data
->id
) - sizeof(data
->reserved
));
10891 case VKI_V4L2_SUBDEV_S_FMT
:
10892 case VKI_V4L2_SUBDEV_S_FRAME_INTERVAL
:
10893 case VKI_V4L2_SUBDEV_S_CROP
:
10894 case VKI_V4L2_SUBDEV_S_SELECTION
:
10897 case VKI_V4L2_SUBDEV_G_FMT
: {
10898 struct vki_v4l2_subdev_format
*data
= (struct vki_v4l2_subdev_format
*)ARG3
;
10899 POST_FIELD_WRITE(data
->format
);
10902 case VKI_V4L2_SUBDEV_G_FRAME_INTERVAL
: {
10903 struct vki_v4l2_subdev_frame_interval
*data
= (struct vki_v4l2_subdev_frame_interval
*)ARG3
;
10904 POST_FIELD_WRITE(data
->interval
);
10907 case VKI_V4L2_SUBDEV_ENUM_MBUS_CODE
: {
10908 struct vki_v4l2_subdev_mbus_code_enum
*data
= (struct vki_v4l2_subdev_mbus_code_enum
*)ARG3
;
10909 POST_FIELD_WRITE(data
->code
);
10912 case VKI_V4L2_SUBDEV_ENUM_FRAME_SIZE
: {
10913 struct vki_v4l2_subdev_frame_size_enum
*data
= (struct vki_v4l2_subdev_frame_size_enum
*)ARG3
;
10914 POST_FIELD_WRITE(data
->min_width
);
10915 POST_FIELD_WRITE(data
->min_height
);
10916 POST_FIELD_WRITE(data
->max_width
);
10917 POST_FIELD_WRITE(data
->max_height
);
10920 case VKI_V4L2_SUBDEV_ENUM_FRAME_INTERVAL
: {
10921 struct vki_v4l2_subdev_frame_interval_enum
*data
= (struct vki_v4l2_subdev_frame_interval_enum
*)ARG3
;
10922 POST_FIELD_WRITE(data
->interval
);
10925 case VKI_V4L2_SUBDEV_G_CROP
: {
10926 struct vki_v4l2_subdev_crop
*data
= (struct vki_v4l2_subdev_crop
*)ARG3
;
10927 POST_FIELD_WRITE(data
->rect
);
10930 case VKI_V4L2_SUBDEV_G_SELECTION
: {
10931 struct vki_v4l2_subdev_selection
*data
= (struct vki_v4l2_subdev_selection
*)ARG3
;
10932 POST_FIELD_WRITE(data
->r
);
10935 case VKI_MEDIA_IOC_DEVICE_INFO
: {
10936 struct vki_media_device_info
*data
= (struct vki_media_device_info
*)ARG3
;
10937 POST_MEM_WRITE((Addr
)data
, sizeof(*data
) - sizeof(data
->reserved
));
10940 case VKI_MEDIA_IOC_ENUM_ENTITIES
: {
10941 struct vki_media_entity_desc
*data
= (struct vki_media_entity_desc
*)ARG3
;
10942 POST_MEM_WRITE((Addr
)data
->name
, sizeof(*data
) - sizeof(data
->id
));
10945 case VKI_MEDIA_IOC_ENUM_LINKS
:
10947 * This ioctl does write to the provided pointers, but it's not
10948 * possible to deduce the size of the array those pointers point to.
10951 case VKI_MEDIA_IOC_SETUP_LINK
:
10955 case VKI_TIOCGSERIAL
: {
10956 struct vki_serial_struct
*data
= (struct vki_serial_struct
*)ARG3
;
10957 POST_MEM_WRITE((Addr
)data
, sizeof(*data
));
10960 case VKI_TIOCSSERIAL
:
10963 case VKI_PERF_EVENT_IOC_ENABLE
:
10964 case VKI_PERF_EVENT_IOC_DISABLE
:
10965 case VKI_PERF_EVENT_IOC_REFRESH
:
10966 case VKI_PERF_EVENT_IOC_RESET
:
10967 case VKI_PERF_EVENT_IOC_PERIOD
:
10968 case VKI_PERF_EVENT_IOC_SET_OUTPUT
:
10969 case VKI_PERF_EVENT_IOC_SET_FILTER
:
10970 case VKI_PERF_EVENT_IOC_SET_BPF
:
10973 case VKI_PERF_EVENT_IOC_ID
:
10974 POST_MEM_WRITE((Addr
)ARG3
, sizeof(__vki_u64
));
10978 /* EVIOC* are variable length and return size written on success */
10979 switch (ARG2
& ~(_VKI_IOC_SIZEMASK
<< _VKI_IOC_SIZESHIFT
)) {
10980 case VKI_EVIOCGNAME(0):
10981 case VKI_EVIOCGPHYS(0):
10982 case VKI_EVIOCGUNIQ(0):
10983 case VKI_EVIOCGKEY(0):
10984 case VKI_EVIOCGLED(0):
10985 case VKI_EVIOCGSND(0):
10986 case VKI_EVIOCGSW(0):
10987 case VKI_EVIOCGBIT(VKI_EV_SYN
,0):
10988 case VKI_EVIOCGBIT(VKI_EV_KEY
,0):
10989 case VKI_EVIOCGBIT(VKI_EV_REL
,0):
10990 case VKI_EVIOCGBIT(VKI_EV_ABS
,0):
10991 case VKI_EVIOCGBIT(VKI_EV_MSC
,0):
10992 case VKI_EVIOCGBIT(VKI_EV_SW
,0):
10993 case VKI_EVIOCGBIT(VKI_EV_LED
,0):
10994 case VKI_EVIOCGBIT(VKI_EV_SND
,0):
10995 case VKI_EVIOCGBIT(VKI_EV_REP
,0):
10996 case VKI_EVIOCGBIT(VKI_EV_FF
,0):
10997 case VKI_EVIOCGBIT(VKI_EV_PWR
,0):
10998 case VKI_EVIOCGBIT(VKI_EV_FF_STATUS
,0):
11000 POST_MEM_WRITE(ARG3
, RES
);
11003 ML_(POST_unknown_ioctl
)(tid
, RES
, ARG2
, ARG3
);
11009 post_sys_ioctl__out
:
11010 {} /* keep C compilers happy */
11013 /* ---------------------------------------------------------------------
11014 socketcall wrapper helpers
11015 ------------------------------------------------------------------ */
11018 ML_(linux_PRE_sys_getsockopt
) ( ThreadId tid
,
11019 UWord arg0
, UWord arg1
, UWord arg2
,
11020 UWord arg3
, UWord arg4
)
11022 /* int getsockopt(int s, int level, int optname,
11023 void *optval, socklen_t *optlen); */
11024 Addr optval_p
= arg3
;
11025 Addr optlen_p
= arg4
;
11026 /* vg_assert(sizeof(socklen_t) == sizeof(UInt)); */
11027 if (optval_p
!= (Addr
)NULL
) {
11028 ML_(buf_and_len_pre_check
) ( tid
, optval_p
, optlen_p
,
11029 "socketcall.getsockopt(optval)",
11030 "socketcall.getsockopt(optlen)" );
11031 if (arg1
== VKI_SOL_SCTP
&&
11032 (arg2
== VKI_SCTP_GET_PEER_ADDRS
||
11033 arg2
== VKI_SCTP_GET_LOCAL_ADDRS
))
11035 struct vki_sctp_getaddrs
*ga
= (struct vki_sctp_getaddrs
*)arg3
;
11036 int address_bytes
= sizeof(struct vki_sockaddr_in6
) * ga
->addr_num
;
11037 PRE_MEM_WRITE( "socketcall.getsockopt(optval.addrs)",
11038 (Addr
)ga
->addrs
, address_bytes
);
11044 ML_(linux_POST_sys_getsockopt
) ( ThreadId tid
,
11046 UWord arg0
, UWord arg1
, UWord arg2
,
11047 UWord arg3
, UWord arg4
)
11049 Addr optval_p
= arg3
;
11050 Addr optlen_p
= arg4
;
11051 vg_assert(!sr_isError(res
)); /* guaranteed by caller */
11052 if (optval_p
!= (Addr
)NULL
) {
11053 ML_(buf_and_len_post_check
) ( tid
, res
, optval_p
, optlen_p
,
11054 "socketcall.getsockopt(optlen_out)" );
11055 if (arg1
== VKI_SOL_SCTP
&&
11056 (arg2
== VKI_SCTP_GET_PEER_ADDRS
||
11057 arg2
== VKI_SCTP_GET_LOCAL_ADDRS
))
11059 struct vki_sctp_getaddrs
*ga
= (struct vki_sctp_getaddrs
*)arg3
;
11060 struct vki_sockaddr
*a
= ga
->addrs
;
11062 for (i
= 0; i
< ga
->addr_num
; i
++) {
11064 if (a
->sa_family
== VKI_AF_INET
)
11065 sl
= sizeof(struct vki_sockaddr_in
);
11066 else if (a
->sa_family
== VKI_AF_INET6
)
11067 sl
= sizeof(struct vki_sockaddr_in6
);
11069 VG_(message
)(Vg_UserMsg
, "Warning: getsockopt: unhandled "
11070 "address type %d\n", a
->sa_family
);
11072 a
= (struct vki_sockaddr
*)((char*)a
+ sl
);
11074 POST_MEM_WRITE( (Addr
)ga
->addrs
, (char*)a
- (char*)ga
->addrs
);
11080 ML_(linux_PRE_sys_setsockopt
) ( ThreadId tid
,
11081 UWord arg0
, UWord arg1
, UWord arg2
,
11082 UWord arg3
, UWord arg4
)
11084 /* int setsockopt(int s, int level, int optname,
11085 const void *optval, socklen_t optlen); */
11086 Addr optval_p
= arg3
;
11087 if (optval_p
!= (Addr
)NULL
) {
11089 * OK, let's handle at least some setsockopt levels and options
11090 * ourselves, so we don't get false claims of references to
11091 * uninitialized memory (such as padding in structures) and *do*
11092 * check what pointers in the argument point to.
11094 if (arg1
== VKI_SOL_SOCKET
&& arg2
== VKI_SO_ATTACH_FILTER
)
11096 struct vki_sock_fprog
*fp
= (struct vki_sock_fprog
*)optval_p
;
11099 * struct sock_fprog has a 16-bit count of instructions,
11100 * followed by a pointer to an array of those instructions.
11101 * There's padding between those two elements.
11103 * So that we don't bogusly complain about the padding bytes,
11104 * we just report that we read len and and filter.
11106 * We then make sure that what filter points to is valid.
11108 PRE_MEM_READ( "setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, &optval.len)",
11109 (Addr
)&fp
->len
, sizeof(fp
->len
) );
11110 PRE_MEM_READ( "setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, &optval.filter)",
11111 (Addr
)&fp
->filter
, sizeof(fp
->filter
) );
11113 /* len * sizeof (*filter) */
11114 if (fp
->filter
!= NULL
)
11116 PRE_MEM_READ( "setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, optval.filter)",
11117 (Addr
)(fp
->filter
),
11118 fp
->len
* sizeof(*fp
->filter
) );
11123 PRE_MEM_READ( "socketcall.setsockopt(optval)",
11125 arg4
/* optlen */ );
11131 ML_(linux_PRE_sys_recvmmsg
) ( ThreadId tid
,
11132 UWord arg1
, UWord arg2
, UWord arg3
,
11133 UWord arg4
, UWord arg5
)
11135 struct vki_mmsghdr
*mmsg
= (struct vki_mmsghdr
*)arg2
;
11136 HChar name
[40]; // large enough
11138 for (i
= 0; i
< arg3
; i
++) {
11139 VG_(sprintf
)(name
, "mmsg[%u].msg_hdr", i
);
11140 ML_(generic_PRE_sys_recvmsg
)(tid
, name
, &mmsg
[i
].msg_hdr
);
11141 VG_(sprintf
)(name
, "recvmmsg(mmsg[%u].msg_len)", i
);
11142 PRE_MEM_WRITE( name
, (Addr
)&mmsg
[i
].msg_len
, sizeof(mmsg
[i
].msg_len
) );
11145 PRE_MEM_READ( "recvmmsg(timeout)", arg5
, sizeof(struct vki_timespec
) );
11149 ML_(linux_POST_sys_recvmmsg
) (ThreadId tid
, UWord res
,
11150 UWord arg1
, UWord arg2
, UWord arg3
,
11151 UWord arg4
, UWord arg5
)
11154 struct vki_mmsghdr
*mmsg
= (struct vki_mmsghdr
*)arg2
;
11155 HChar name
[32]; // large enough
11157 for (i
= 0; i
< res
; i
++) {
11158 VG_(sprintf
)(name
, "mmsg[%u].msg_hdr", i
);
11159 ML_(generic_POST_sys_recvmsg
)(tid
, name
, &mmsg
[i
].msg_hdr
, mmsg
[i
].msg_len
);
11160 POST_MEM_WRITE( (Addr
)&mmsg
[i
].msg_len
, sizeof(mmsg
[i
].msg_len
) );
11166 ML_(linux_PRE_sys_sendmmsg
) ( ThreadId tid
,
11167 UWord arg1
, UWord arg2
, UWord arg3
, UWord arg4
)
11169 struct vki_mmsghdr
*mmsg
= (struct vki_mmsghdr
*)arg2
;
11170 HChar name
[40]; // large enough
11172 for (i
= 0; i
< arg3
; i
++) {
11173 VG_(sprintf
)(name
, "mmsg[%u].msg_hdr", i
);
11174 ML_(generic_PRE_sys_sendmsg
)(tid
, name
, &mmsg
[i
].msg_hdr
);
11175 VG_(sprintf
)(name
, "sendmmsg(mmsg[%u].msg_len)", i
);
11176 PRE_MEM_WRITE( name
, (Addr
)&mmsg
[i
].msg_len
, sizeof(mmsg
[i
].msg_len
) );
11181 ML_(linux_POST_sys_sendmmsg
) (ThreadId tid
, UWord res
,
11182 UWord arg1
, UWord arg2
, UWord arg3
, UWord arg4
)
11185 struct vki_mmsghdr
*mmsg
= (struct vki_mmsghdr
*)arg2
;
11187 for (i
= 0; i
< res
; i
++) {
11188 POST_MEM_WRITE( (Addr
)&mmsg
[i
].msg_len
, sizeof(mmsg
[i
].msg_len
) );
11193 /* ---------------------------------------------------------------------
11194 ptrace wrapper helpers
11195 ------------------------------------------------------------------ */
11198 ML_(linux_POST_traceme
) ( ThreadId tid
)
11200 ThreadState
*tst
= VG_(get_ThreadState
)(tid
);
11201 tst
->ptrace
= VKI_PT_PTRACED
;
11205 ML_(linux_PRE_getregset
) ( ThreadId tid
, long arg3
, long arg4
)
11207 struct vki_iovec
*iov
= (struct vki_iovec
*) arg4
;
11209 PRE_FIELD_READ("ptrace(getregset iovec->iov_base)", iov
->iov_base
);
11210 PRE_FIELD_READ("ptrace(getregset iovec->iov_len)", iov
->iov_len
);
11211 if (ML_(safe_to_deref
)(iov
, sizeof(struct vki_iovec
))) {
11212 PRE_MEM_WRITE("ptrace(getregset *(iovec->iov_base))",
11213 (Addr
) iov
->iov_base
, iov
->iov_len
);
11218 ML_(linux_PRE_setregset
) ( ThreadId tid
, long arg3
, long arg4
)
11220 struct vki_iovec
*iov
= (struct vki_iovec
*) arg4
;
11222 PRE_FIELD_READ("ptrace(setregset iovec->iov_base)", iov
->iov_base
);
11223 PRE_FIELD_READ("ptrace(setregset iovec->iov_len)", iov
->iov_len
);
11224 if (ML_(safe_to_deref
)(iov
, sizeof(struct vki_iovec
))) {
11225 PRE_MEM_READ("ptrace(setregset *(iovec->iov_base))",
11226 (Addr
) iov
->iov_base
, iov
->iov_len
);
11231 ML_(linux_POST_getregset
) ( ThreadId tid
, long arg3
, long arg4
)
11233 struct vki_iovec
*iov
= (struct vki_iovec
*) arg4
;
11235 /* XXX: The actual amount of data written by the kernel might be
11236 less than iov_len, depending on the regset (arg3). */
11237 POST_MEM_WRITE((unsigned long) iov
->iov_base
, iov
->iov_len
);
11242 PRINT("kcmp ( %ld, %ld, %ld, %lu, %lu )", SARG1
, SARG2
, SARG3
, ARG4
, ARG5
);
11244 case VKI_KCMP_VM
: case VKI_KCMP_FILES
: case VKI_KCMP_FS
:
11245 case VKI_KCMP_SIGHAND
: case VKI_KCMP_IO
: case VKI_KCMP_SYSVSEM
:
11246 /* Most of the comparison types don't look at |idx1| or
11248 PRE_REG_READ3(long, "kcmp",
11249 vki_pid_t
, pid1
, vki_pid_t
, pid2
, int, type
);
11251 case VKI_KCMP_FILE
:
11253 PRE_REG_READ5(long, "kcmp",
11254 vki_pid_t
, pid1
, vki_pid_t
, pid2
, int, type
,
11255 unsigned long, idx1
, unsigned long, idx2
);
11263 #endif // defined(VGO_linux)
11265 /*--------------------------------------------------------------------*/
11267 /*--------------------------------------------------------------------*/