1 #include "qemu/osdep.h" 2 3 #include <sys/ipc.h> 4 #include <sys/msg.h> 5 #include <sys/sem.h> 6 #include <sys/shm.h> 7 #include <sys/select.h> 8 #include <sys/mount.h> 9 #include <arpa/inet.h> 10 #include <netinet/in.h> 11 #include <netinet/tcp.h> 12 #include <netinet/udp.h> 13 #include <linux/if_packet.h> 14 #include <linux/in6.h> 15 #include <linux/netlink.h> 16 #include <sched.h> 17 #include "qemu.h" 18 #include "user-internals.h" 19 #include "strace.h" 20 #include "signal-common.h" 21 #include "target_mman.h" 22 23 struct syscallname { 24 int nr; 25 const char *name; 26 const char *format; 27 void (*call)(CPUArchState *, const struct syscallname *, 28 abi_long, abi_long, abi_long, 29 abi_long, abi_long, abi_long); 30 void (*result)(CPUArchState *, const struct syscallname *, abi_long, 31 abi_long, abi_long, abi_long, 32 abi_long, abi_long, abi_long); 33 }; 34 35 /* 36 * It is possible that target doesn't have syscall that uses 37 * following flags but we don't want the compiler to warn 38 * us about them being unused. Same applies to utility print 39 * functions. It is ok to keep them while not used. 40 */ 41 #define UNUSED __attribute__ ((unused)) 42 43 /* 44 * Structure used to translate flag values into strings. This is 45 * similar that is in the actual strace tool. 46 */ 47 struct flags { 48 abi_long f_value; /* flag */ 49 abi_long f_mask; /* mask */ 50 const char *f_string; /* stringified flag */ 51 }; 52 53 /* No 'struct flags' element should have a zero mask. */ 54 #define FLAG_BASIC(V, M, N) { V, M | QEMU_BUILD_BUG_ON_ZERO(!(M)), N } 55 56 /* common flags for all architectures */ 57 #define FLAG_GENERIC_MASK(V, M) FLAG_BASIC(V, M, #V) 58 #define FLAG_GENERIC(V) FLAG_BASIC(V, V, #V) 59 /* target specific flags (syscall_defs.h has TARGET_<flag>) */ 60 #define FLAG_TARGET_MASK(V, M) FLAG_BASIC(TARGET_##V, TARGET_##M, #V) 61 #define FLAG_TARGET(V) FLAG_BASIC(TARGET_##V, TARGET_##V, #V) 62 /* end of flags array */ 63 #define FLAG_END { 0, 0, NULL } 64 65 /* Structure used to translate enumerated values into strings */ 66 struct enums { 67 abi_long e_value; /* enum value */ 68 const char *e_string; /* stringified enum */ 69 }; 70 71 /* common enums for all architectures */ 72 #define ENUM_GENERIC(name) { name, #name } 73 /* target specific enums */ 74 #define ENUM_TARGET(name) { TARGET_ ## name, #name } 75 /* end of enums array */ 76 #define ENUM_END { 0, NULL } 77 78 UNUSED static const char *get_comma(int); 79 UNUSED static void print_pointer(abi_long, int); 80 UNUSED static void print_flags(const struct flags *, abi_long, int); 81 UNUSED static void print_enums(const struct enums *, abi_long, int); 82 UNUSED static void print_at_dirfd(abi_long, int); 83 UNUSED static void print_file_mode(abi_long, int); 84 UNUSED static void print_open_flags(abi_long, int); 85 UNUSED static void print_syscall_prologue(const struct syscallname *); 86 UNUSED static void print_syscall_epilogue(const struct syscallname *); 87 UNUSED static void print_string(abi_long, int); 88 UNUSED static void print_buf(abi_long addr, abi_long len, int last); 89 UNUSED static void print_raw_param(const char *, abi_long, int); 90 UNUSED static void print_raw_param64(const char *, long long, int last); 91 UNUSED static void print_timeval(abi_ulong, int); 92 UNUSED static void print_timespec(abi_ulong, int); 93 UNUSED static void print_timespec64(abi_ulong, int); 94 UNUSED static void print_timezone(abi_ulong, int); 95 UNUSED static void print_itimerval(abi_ulong, int); 96 UNUSED static void print_number(abi_long, int); 97 UNUSED static void print_signal(abi_ulong, int); 98 UNUSED static void print_sockaddr(abi_ulong, abi_long, int); 99 UNUSED static void print_socket_domain(int domain); 100 UNUSED static void print_socket_type(int type); 101 UNUSED static void print_socket_protocol(int domain, int type, int protocol); 102 103 /* 104 * Utility functions 105 */ 106 static void 107 print_ipc_cmd(int cmd) 108 { 109 #define output_cmd(val) \ 110 if( cmd == val ) { \ 111 qemu_log(#val); \ 112 return; \ 113 } 114 115 cmd &= 0xff; 116 117 /* General IPC commands */ 118 output_cmd( IPC_RMID ); 119 output_cmd( IPC_SET ); 120 output_cmd( IPC_STAT ); 121 output_cmd( IPC_INFO ); 122 /* msgctl() commands */ 123 output_cmd( MSG_STAT ); 124 output_cmd( MSG_INFO ); 125 /* shmctl() commands */ 126 output_cmd( SHM_LOCK ); 127 output_cmd( SHM_UNLOCK ); 128 output_cmd( SHM_STAT ); 129 output_cmd( SHM_INFO ); 130 /* semctl() commands */ 131 output_cmd( GETPID ); 132 output_cmd( GETVAL ); 133 output_cmd( GETALL ); 134 output_cmd( GETNCNT ); 135 output_cmd( GETZCNT ); 136 output_cmd( SETVAL ); 137 output_cmd( SETALL ); 138 output_cmd( SEM_STAT ); 139 output_cmd( SEM_INFO ); 140 output_cmd( IPC_RMID ); 141 output_cmd( IPC_RMID ); 142 output_cmd( IPC_RMID ); 143 output_cmd( IPC_RMID ); 144 output_cmd( IPC_RMID ); 145 output_cmd( IPC_RMID ); 146 output_cmd( IPC_RMID ); 147 output_cmd( IPC_RMID ); 148 output_cmd( IPC_RMID ); 149 150 /* Some value we don't recognize */ 151 qemu_log("%d", cmd); 152 } 153 154 static const char * const target_signal_name[] = { 155 #define MAKE_SIG_ENTRY(sig) [TARGET_##sig] = #sig, 156 MAKE_SIGNAL_LIST 157 #undef MAKE_SIG_ENTRY 158 }; 159 160 static void 161 print_signal(abi_ulong arg, int last) 162 { 163 const char *signal_name = NULL; 164 165 if (arg < ARRAY_SIZE(target_signal_name)) { 166 signal_name = target_signal_name[arg]; 167 } 168 169 if (signal_name == NULL) { 170 print_raw_param("%ld", arg, last); 171 return; 172 } 173 qemu_log("%s%s", signal_name, get_comma(last)); 174 } 175 176 static void print_si_code(int arg) 177 { 178 const char *codename = NULL; 179 180 switch (arg) { 181 case SI_USER: 182 codename = "SI_USER"; 183 break; 184 case SI_KERNEL: 185 codename = "SI_KERNEL"; 186 break; 187 case SI_QUEUE: 188 codename = "SI_QUEUE"; 189 break; 190 case SI_TIMER: 191 codename = "SI_TIMER"; 192 break; 193 case SI_MESGQ: 194 codename = "SI_MESGQ"; 195 break; 196 case SI_ASYNCIO: 197 codename = "SI_ASYNCIO"; 198 break; 199 case SI_SIGIO: 200 codename = "SI_SIGIO"; 201 break; 202 case SI_TKILL: 203 codename = "SI_TKILL"; 204 break; 205 default: 206 qemu_log("%d", arg); 207 return; 208 } 209 qemu_log("%s", codename); 210 } 211 212 static void get_target_siginfo(target_siginfo_t *tinfo, 213 const target_siginfo_t *info) 214 { 215 abi_ulong sival_ptr; 216 217 int sig; 218 int si_errno; 219 int si_code; 220 int si_type; 221 222 __get_user(sig, &info->si_signo); 223 __get_user(si_errno, &tinfo->si_errno); 224 __get_user(si_code, &info->si_code); 225 226 tinfo->si_signo = sig; 227 tinfo->si_errno = si_errno; 228 tinfo->si_code = si_code; 229 230 /* Ensure we don't leak random junk to the guest later */ 231 memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad)); 232 233 /* This is awkward, because we have to use a combination of 234 * the si_code and si_signo to figure out which of the union's 235 * members are valid. (Within the host kernel it is always possible 236 * to tell, but the kernel carefully avoids giving userspace the 237 * high 16 bits of si_code, so we don't have the information to 238 * do this the easy way...) We therefore make our best guess, 239 * bearing in mind that a guest can spoof most of the si_codes 240 * via rt_sigqueueinfo() if it likes. 241 * 242 * Once we have made our guess, we record it in the top 16 bits of 243 * the si_code, so that print_siginfo() later can use it. 244 * print_siginfo() will strip these top bits out before printing 245 * the si_code. 246 */ 247 248 switch (si_code) { 249 case SI_USER: 250 case SI_TKILL: 251 case SI_KERNEL: 252 /* Sent via kill(), tkill() or tgkill(), or direct from the kernel. 253 * These are the only unspoofable si_code values. 254 */ 255 __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid); 256 __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid); 257 si_type = QEMU_SI_KILL; 258 break; 259 default: 260 /* Everything else is spoofable. Make best guess based on signal */ 261 switch (sig) { 262 case TARGET_SIGCHLD: 263 __get_user(tinfo->_sifields._sigchld._pid, 264 &info->_sifields._sigchld._pid); 265 __get_user(tinfo->_sifields._sigchld._uid, 266 &info->_sifields._sigchld._uid); 267 __get_user(tinfo->_sifields._sigchld._status, 268 &info->_sifields._sigchld._status); 269 __get_user(tinfo->_sifields._sigchld._utime, 270 &info->_sifields._sigchld._utime); 271 __get_user(tinfo->_sifields._sigchld._stime, 272 &info->_sifields._sigchld._stime); 273 si_type = QEMU_SI_CHLD; 274 break; 275 case TARGET_SIGIO: 276 __get_user(tinfo->_sifields._sigpoll._band, 277 &info->_sifields._sigpoll._band); 278 __get_user(tinfo->_sifields._sigpoll._fd, 279 &info->_sifields._sigpoll._fd); 280 si_type = QEMU_SI_POLL; 281 break; 282 default: 283 /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */ 284 __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid); 285 __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid); 286 /* XXX: potential problem if 64 bit */ 287 __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr); 288 tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr; 289 290 si_type = QEMU_SI_RT; 291 break; 292 } 293 break; 294 } 295 296 tinfo->si_code = deposit32(si_code, 16, 16, si_type); 297 } 298 299 static void print_siginfo(const target_siginfo_t *tinfo) 300 { 301 /* Print a target_siginfo_t in the format desired for printing 302 * signals being taken. We assume the target_siginfo_t is in the 303 * internal form where the top 16 bits of si_code indicate which 304 * part of the union is valid, rather than in the guest-visible 305 * form where the bottom 16 bits are sign-extended into the top 16. 306 */ 307 int si_type = extract32(tinfo->si_code, 16, 16); 308 int si_code = sextract32(tinfo->si_code, 0, 16); 309 310 qemu_log("{si_signo="); 311 print_signal(tinfo->si_signo, 1); 312 qemu_log(", si_code="); 313 print_si_code(si_code); 314 315 switch (si_type) { 316 case QEMU_SI_KILL: 317 qemu_log(", si_pid=%u, si_uid=%u", 318 (unsigned int)tinfo->_sifields._kill._pid, 319 (unsigned int)tinfo->_sifields._kill._uid); 320 break; 321 case QEMU_SI_TIMER: 322 qemu_log(", si_timer1=%u, si_timer2=%u", 323 tinfo->_sifields._timer._timer1, 324 tinfo->_sifields._timer._timer2); 325 break; 326 case QEMU_SI_POLL: 327 qemu_log(", si_band=%d, si_fd=%d", 328 tinfo->_sifields._sigpoll._band, 329 tinfo->_sifields._sigpoll._fd); 330 break; 331 case QEMU_SI_FAULT: 332 qemu_log(", si_addr="); 333 print_pointer(tinfo->_sifields._sigfault._addr, 1); 334 break; 335 case QEMU_SI_CHLD: 336 qemu_log(", si_pid=%u, si_uid=%u, si_status=%d" 337 ", si_utime=" TARGET_ABI_FMT_ld 338 ", si_stime=" TARGET_ABI_FMT_ld, 339 (unsigned int)(tinfo->_sifields._sigchld._pid), 340 (unsigned int)(tinfo->_sifields._sigchld._uid), 341 tinfo->_sifields._sigchld._status, 342 tinfo->_sifields._sigchld._utime, 343 tinfo->_sifields._sigchld._stime); 344 break; 345 case QEMU_SI_RT: 346 qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld, 347 (unsigned int)tinfo->_sifields._rt._pid, 348 (unsigned int)tinfo->_sifields._rt._uid, 349 tinfo->_sifields._rt._sigval.sival_ptr); 350 break; 351 default: 352 g_assert_not_reached(); 353 } 354 qemu_log("}"); 355 } 356 357 static void 358 print_sockaddr(abi_ulong addr, abi_long addrlen, int last) 359 { 360 struct target_sockaddr *sa; 361 int i; 362 int sa_family; 363 364 sa = lock_user(VERIFY_READ, addr, addrlen, 1); 365 if (sa) { 366 sa_family = tswap16(sa->sa_family); 367 switch (sa_family) { 368 case AF_UNIX: { 369 struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa; 370 int i; 371 qemu_log("{sun_family=AF_UNIX,sun_path=\""); 372 for (i = 0; i < addrlen - 373 offsetof(struct target_sockaddr_un, sun_path) && 374 un->sun_path[i]; i++) { 375 qemu_log("%c", un->sun_path[i]); 376 } 377 qemu_log("\"}"); 378 break; 379 } 380 case AF_INET: { 381 struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa; 382 uint8_t *c = (uint8_t *)&in->sin_addr.s_addr; 383 qemu_log("{sin_family=AF_INET,sin_port=htons(%d),", 384 ntohs(in->sin_port)); 385 qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")", 386 c[0], c[1], c[2], c[3]); 387 qemu_log("}"); 388 break; 389 } 390 case AF_PACKET: { 391 struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa; 392 uint8_t *c = (uint8_t *)&ll->sll_addr; 393 qemu_log("{sll_family=AF_PACKET," 394 "sll_protocol=htons(0x%04x),if%d,pkttype=", 395 ntohs(ll->sll_protocol), ll->sll_ifindex); 396 switch (ll->sll_pkttype) { 397 case PACKET_HOST: 398 qemu_log("PACKET_HOST"); 399 break; 400 case PACKET_BROADCAST: 401 qemu_log("PACKET_BROADCAST"); 402 break; 403 case PACKET_MULTICAST: 404 qemu_log("PACKET_MULTICAST"); 405 break; 406 case PACKET_OTHERHOST: 407 qemu_log("PACKET_OTHERHOST"); 408 break; 409 case PACKET_OUTGOING: 410 qemu_log("PACKET_OUTGOING"); 411 break; 412 default: 413 qemu_log("%d", ll->sll_pkttype); 414 break; 415 } 416 qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", 417 c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); 418 qemu_log("}"); 419 break; 420 } 421 case AF_NETLINK: { 422 struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa; 423 qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}", 424 tswap32(nl->nl_pid), tswap32(nl->nl_groups)); 425 break; 426 } 427 default: 428 qemu_log("{sa_family=%d, sa_data={", sa->sa_family); 429 for (i = 0; i < 13; i++) { 430 qemu_log("%02x, ", sa->sa_data[i]); 431 } 432 qemu_log("%02x}", sa->sa_data[i]); 433 qemu_log("}"); 434 break; 435 } 436 unlock_user(sa, addr, 0); 437 } else { 438 print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0); 439 } 440 qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); 441 } 442 443 static void 444 print_socket_domain(int domain) 445 { 446 switch (domain) { 447 case PF_UNIX: 448 qemu_log("PF_UNIX"); 449 break; 450 case PF_INET: 451 qemu_log("PF_INET"); 452 break; 453 case PF_NETLINK: 454 qemu_log("PF_NETLINK"); 455 break; 456 case PF_PACKET: 457 qemu_log("PF_PACKET"); 458 break; 459 default: 460 qemu_log("%d", domain); 461 break; 462 } 463 } 464 465 static void 466 print_socket_type(int type) 467 { 468 switch (type & TARGET_SOCK_TYPE_MASK) { 469 case TARGET_SOCK_DGRAM: 470 qemu_log("SOCK_DGRAM"); 471 break; 472 case TARGET_SOCK_STREAM: 473 qemu_log("SOCK_STREAM"); 474 break; 475 case TARGET_SOCK_RAW: 476 qemu_log("SOCK_RAW"); 477 break; 478 case TARGET_SOCK_RDM: 479 qemu_log("SOCK_RDM"); 480 break; 481 case TARGET_SOCK_SEQPACKET: 482 qemu_log("SOCK_SEQPACKET"); 483 break; 484 case TARGET_SOCK_PACKET: 485 qemu_log("SOCK_PACKET"); 486 break; 487 } 488 if (type & TARGET_SOCK_CLOEXEC) { 489 qemu_log("|SOCK_CLOEXEC"); 490 } 491 if (type & TARGET_SOCK_NONBLOCK) { 492 qemu_log("|SOCK_NONBLOCK"); 493 } 494 } 495 496 static void 497 print_socket_protocol(int domain, int type, int protocol) 498 { 499 if (domain == AF_PACKET || 500 (domain == AF_INET && type == TARGET_SOCK_PACKET)) { 501 switch (protocol) { 502 case 0x0003: 503 qemu_log("ETH_P_ALL"); 504 break; 505 default: 506 qemu_log("%d", protocol); 507 } 508 return; 509 } 510 511 if (domain == PF_NETLINK) { 512 switch (protocol) { 513 case NETLINK_ROUTE: 514 qemu_log("NETLINK_ROUTE"); 515 break; 516 case NETLINK_UNUSED: 517 qemu_log("NETLINK_UNUSED"); 518 break; 519 case NETLINK_USERSOCK: 520 qemu_log("NETLINK_USERSOCK"); 521 break; 522 case NETLINK_FIREWALL: 523 qemu_log("NETLINK_FIREWALL"); 524 break; 525 case NETLINK_SOCK_DIAG: 526 qemu_log("NETLINK_SOCK_DIAG"); 527 break; 528 case NETLINK_NFLOG: 529 qemu_log("NETLINK_NFLOG"); 530 break; 531 case NETLINK_XFRM: 532 qemu_log("NETLINK_XFRM"); 533 break; 534 case NETLINK_SELINUX: 535 qemu_log("NETLINK_SELINUX"); 536 break; 537 case NETLINK_ISCSI: 538 qemu_log("NETLINK_ISCSI"); 539 break; 540 case NETLINK_AUDIT: 541 qemu_log("NETLINK_AUDIT"); 542 break; 543 case NETLINK_FIB_LOOKUP: 544 qemu_log("NETLINK_FIB_LOOKUP"); 545 break; 546 case NETLINK_CONNECTOR: 547 qemu_log("NETLINK_CONNECTOR"); 548 break; 549 case NETLINK_NETFILTER: 550 qemu_log("NETLINK_NETFILTER"); 551 break; 552 case NETLINK_IP6_FW: 553 qemu_log("NETLINK_IP6_FW"); 554 break; 555 case NETLINK_DNRTMSG: 556 qemu_log("NETLINK_DNRTMSG"); 557 break; 558 case NETLINK_KOBJECT_UEVENT: 559 qemu_log("NETLINK_KOBJECT_UEVENT"); 560 break; 561 case NETLINK_GENERIC: 562 qemu_log("NETLINK_GENERIC"); 563 break; 564 case NETLINK_SCSITRANSPORT: 565 qemu_log("NETLINK_SCSITRANSPORT"); 566 break; 567 case NETLINK_ECRYPTFS: 568 qemu_log("NETLINK_ECRYPTFS"); 569 break; 570 case NETLINK_RDMA: 571 qemu_log("NETLINK_RDMA"); 572 break; 573 case NETLINK_CRYPTO: 574 qemu_log("NETLINK_CRYPTO"); 575 break; 576 case NETLINK_SMC: 577 qemu_log("NETLINK_SMC"); 578 break; 579 default: 580 qemu_log("%d", protocol); 581 break; 582 } 583 return; 584 } 585 586 switch (protocol) { 587 case IPPROTO_IP: 588 qemu_log("IPPROTO_IP"); 589 break; 590 case IPPROTO_TCP: 591 qemu_log("IPPROTO_TCP"); 592 break; 593 case IPPROTO_UDP: 594 qemu_log("IPPROTO_UDP"); 595 break; 596 case IPPROTO_RAW: 597 qemu_log("IPPROTO_RAW"); 598 break; 599 default: 600 qemu_log("%d", protocol); 601 break; 602 } 603 } 604 605 606 #ifdef TARGET_NR__newselect 607 static void 608 print_fdset(int n, abi_ulong target_fds_addr) 609 { 610 int i; 611 int first = 1; 612 613 qemu_log("["); 614 if( target_fds_addr ) { 615 abi_long *target_fds; 616 617 target_fds = lock_user(VERIFY_READ, 618 target_fds_addr, 619 sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1), 620 1); 621 622 if (!target_fds) 623 return; 624 625 for (i=n; i>=0; i--) { 626 if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> 627 (i & (TARGET_ABI_BITS - 1))) & 1) { 628 qemu_log("%s%d", get_comma(first), i); 629 first = 0; 630 } 631 } 632 unlock_user(target_fds, target_fds_addr, 0); 633 } 634 qemu_log("]"); 635 } 636 #endif 637 638 /* 639 * Sysycall specific output functions 640 */ 641 642 /* select */ 643 #ifdef TARGET_NR__newselect 644 static void 645 print_newselect(CPUArchState *cpu_env, const struct syscallname *name, 646 abi_long arg1, abi_long arg2, abi_long arg3, 647 abi_long arg4, abi_long arg5, abi_long arg6) 648 { 649 print_syscall_prologue(name); 650 print_fdset(arg1, arg2); 651 qemu_log(","); 652 print_fdset(arg1, arg3); 653 qemu_log(","); 654 print_fdset(arg1, arg4); 655 qemu_log(","); 656 print_timeval(arg5, 1); 657 print_syscall_epilogue(name); 658 } 659 #endif 660 661 #ifdef TARGET_NR_semctl 662 static void 663 print_semctl(CPUArchState *cpu_env, const struct syscallname *name, 664 abi_long arg1, abi_long arg2, abi_long arg3, 665 abi_long arg4, abi_long arg5, abi_long arg6) 666 { 667 qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", 668 name->name, arg1, arg2); 669 print_ipc_cmd(arg3); 670 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 671 } 672 #endif 673 674 #ifdef TARGET_NR_ipc 675 static void 676 print_ipc(CPUArchState *cpu_env, const struct syscallname *name, 677 abi_long arg1, abi_long arg2, abi_long arg3, 678 abi_long arg4, abi_long arg5, abi_long arg6) 679 { 680 switch(arg1) { 681 case IPCOP_semctl: 682 qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", 683 arg1, arg2); 684 print_ipc_cmd(arg3); 685 qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); 686 break; 687 default: 688 qemu_log(("%s(" 689 TARGET_ABI_FMT_ld "," 690 TARGET_ABI_FMT_ld "," 691 TARGET_ABI_FMT_ld "," 692 TARGET_ABI_FMT_ld 693 ")"), 694 name->name, arg1, arg2, arg3, arg4); 695 } 696 } 697 #endif 698 699 /* 700 * Variants for the return value output function 701 */ 702 703 static bool 704 print_syscall_err(abi_long ret) 705 { 706 const char *errstr; 707 708 qemu_log(" = "); 709 if (is_error(ret)) { 710 errstr = target_strerror(-ret); 711 if (errstr) { 712 qemu_log("-1 errno=%d (%s)", (int)-ret, errstr); 713 return true; 714 } 715 } 716 return false; 717 } 718 719 static void 720 print_syscall_ret_addr(CPUArchState *cpu_env, const struct syscallname *name, 721 abi_long ret, abi_long arg0, abi_long arg1, 722 abi_long arg2, abi_long arg3, abi_long arg4, 723 abi_long arg5) 724 { 725 if (!print_syscall_err(ret)) { 726 qemu_log("0x" TARGET_ABI_FMT_lx, ret); 727 } 728 qemu_log("\n"); 729 } 730 731 #if 0 /* currently unused */ 732 static void 733 print_syscall_ret_raw(struct syscallname *name, abi_long ret) 734 { 735 qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); 736 } 737 #endif 738 739 #ifdef TARGET_NR__newselect 740 static void 741 print_syscall_ret_newselect(CPUArchState *cpu_env, const struct syscallname *name, 742 abi_long ret, abi_long arg0, abi_long arg1, 743 abi_long arg2, abi_long arg3, abi_long arg4, 744 abi_long arg5) 745 { 746 if (!print_syscall_err(ret)) { 747 qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); 748 print_fdset(arg0, arg1); 749 qemu_log(","); 750 print_fdset(arg0, arg2); 751 qemu_log(","); 752 print_fdset(arg0, arg3); 753 qemu_log(","); 754 print_timeval(arg4, 1); 755 qemu_log(")"); 756 } 757 758 qemu_log("\n"); 759 } 760 #endif 761 762 /* special meanings of adjtimex()' non-negative return values */ 763 #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */ 764 #define TARGET_TIME_INS 1 /* insert leap second */ 765 #define TARGET_TIME_DEL 2 /* delete leap second */ 766 #define TARGET_TIME_OOP 3 /* leap second in progress */ 767 #define TARGET_TIME_WAIT 4 /* leap second has occurred */ 768 #define TARGET_TIME_ERROR 5 /* clock not synchronized */ 769 #ifdef TARGET_NR_adjtimex 770 static void 771 print_syscall_ret_adjtimex(CPUArchState *cpu_env, const struct syscallname *name, 772 abi_long ret, abi_long arg0, abi_long arg1, 773 abi_long arg2, abi_long arg3, abi_long arg4, 774 abi_long arg5) 775 { 776 if (!print_syscall_err(ret)) { 777 qemu_log(TARGET_ABI_FMT_ld, ret); 778 switch (ret) { 779 case TARGET_TIME_OK: 780 qemu_log(" TIME_OK (clock synchronized, no leap second)"); 781 break; 782 case TARGET_TIME_INS: 783 qemu_log(" TIME_INS (insert leap second)"); 784 break; 785 case TARGET_TIME_DEL: 786 qemu_log(" TIME_DEL (delete leap second)"); 787 break; 788 case TARGET_TIME_OOP: 789 qemu_log(" TIME_OOP (leap second in progress)"); 790 break; 791 case TARGET_TIME_WAIT: 792 qemu_log(" TIME_WAIT (leap second has occurred)"); 793 break; 794 case TARGET_TIME_ERROR: 795 qemu_log(" TIME_ERROR (clock not synchronized)"); 796 break; 797 } 798 } 799 800 qemu_log("\n"); 801 } 802 #endif 803 804 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) 805 static void 806 print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name, 807 abi_long ret, abi_long arg0, abi_long arg1, 808 abi_long arg2, abi_long arg3, abi_long arg4, 809 abi_long arg5) 810 { 811 if (!print_syscall_err(ret)) { 812 qemu_log(TARGET_ABI_FMT_ld, ret); 813 qemu_log(" ("); 814 print_timespec(arg1, 1); 815 qemu_log(")"); 816 } 817 818 qemu_log("\n"); 819 } 820 #define print_syscall_ret_clock_getres print_syscall_ret_clock_gettime 821 #endif 822 823 #if defined(TARGET_NR_clock_gettime64) 824 static void 825 print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name, 826 abi_long ret, abi_long arg0, abi_long arg1, 827 abi_long arg2, abi_long arg3, abi_long arg4, 828 abi_long arg5) 829 { 830 if (!print_syscall_err(ret)) { 831 qemu_log(TARGET_ABI_FMT_ld, ret); 832 qemu_log(" ("); 833 print_timespec64(arg1, 1); 834 qemu_log(")"); 835 } 836 837 qemu_log("\n"); 838 } 839 #endif 840 841 #ifdef TARGET_NR_gettimeofday 842 static void 843 print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name, 844 abi_long ret, abi_long arg0, abi_long arg1, 845 abi_long arg2, abi_long arg3, abi_long arg4, 846 abi_long arg5) 847 { 848 if (!print_syscall_err(ret)) { 849 qemu_log(TARGET_ABI_FMT_ld, ret); 850 qemu_log(" ("); 851 print_timeval(arg0, 0); 852 print_timezone(arg1, 1); 853 qemu_log(")"); 854 } 855 856 qemu_log("\n"); 857 } 858 #endif 859 860 #ifdef TARGET_NR_getitimer 861 static void 862 print_syscall_ret_getitimer(CPUArchState *cpu_env, const struct syscallname *name, 863 abi_long ret, abi_long arg0, abi_long arg1, 864 abi_long arg2, abi_long arg3, abi_long arg4, 865 abi_long arg5) 866 { 867 if (!print_syscall_err(ret)) { 868 qemu_log(TARGET_ABI_FMT_ld, ret); 869 qemu_log(" ("); 870 print_itimerval(arg1, 1); 871 qemu_log(")"); 872 } 873 874 qemu_log("\n"); 875 } 876 #endif 877 878 879 #ifdef TARGET_NR_getitimer 880 static void 881 print_syscall_ret_setitimer(CPUArchState *cpu_env, const struct syscallname *name, 882 abi_long ret, abi_long arg0, abi_long arg1, 883 abi_long arg2, abi_long arg3, abi_long arg4, 884 abi_long arg5) 885 { 886 if (!print_syscall_err(ret)) { 887 qemu_log(TARGET_ABI_FMT_ld, ret); 888 qemu_log(" (old_value = "); 889 print_itimerval(arg2, 1); 890 qemu_log(")"); 891 } 892 893 qemu_log("\n"); 894 } 895 #endif 896 897 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \ 898 || defined(TARGGET_NR_flistxattr) 899 static void 900 print_syscall_ret_listxattr(CPUArchState *cpu_env, const struct syscallname *name, 901 abi_long ret, abi_long arg0, abi_long arg1, 902 abi_long arg2, abi_long arg3, abi_long arg4, 903 abi_long arg5) 904 { 905 if (!print_syscall_err(ret)) { 906 qemu_log(TARGET_ABI_FMT_ld, ret); 907 qemu_log(" (list = "); 908 if (arg1 != 0) { 909 abi_long attr = arg1; 910 while (ret) { 911 if (attr != arg1) { 912 qemu_log(","); 913 } 914 print_string(attr, 1); 915 ret -= target_strlen(attr) + 1; 916 attr += target_strlen(attr) + 1; 917 } 918 } else { 919 qemu_log("NULL"); 920 } 921 qemu_log(")"); 922 } 923 924 qemu_log("\n"); 925 } 926 #define print_syscall_ret_llistxattr print_syscall_ret_listxattr 927 #define print_syscall_ret_flistxattr print_syscall_ret_listxattr 928 #endif 929 930 #ifdef TARGET_NR_ioctl 931 static void 932 print_syscall_ret_ioctl(CPUArchState *cpu_env, const struct syscallname *name, 933 abi_long ret, abi_long arg0, abi_long arg1, 934 abi_long arg2, abi_long arg3, abi_long arg4, 935 abi_long arg5) 936 { 937 if (!print_syscall_err(ret)) { 938 qemu_log(TARGET_ABI_FMT_ld, ret); 939 940 const IOCTLEntry *ie; 941 const argtype *arg_type; 942 void *argptr; 943 int target_size; 944 945 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { 946 if (ie->target_cmd == arg1) { 947 break; 948 } 949 } 950 951 if (ie->target_cmd == arg1 && 952 (ie->access == IOC_R || ie->access == IOC_RW)) { 953 arg_type = ie->arg_type; 954 qemu_log(" ("); 955 arg_type++; 956 target_size = thunk_type_size(arg_type, 0); 957 argptr = lock_user(VERIFY_READ, arg2, target_size, 1); 958 if (argptr) { 959 thunk_print(argptr, arg_type); 960 unlock_user(argptr, arg2, target_size); 961 } else { 962 print_pointer(arg2, 1); 963 } 964 qemu_log(")"); 965 } 966 } 967 qemu_log("\n"); 968 } 969 #endif 970 971 UNUSED static const struct flags access_flags[] = { 972 FLAG_GENERIC_MASK(F_OK, R_OK | W_OK | X_OK), 973 FLAG_GENERIC(R_OK), 974 FLAG_GENERIC(W_OK), 975 FLAG_GENERIC(X_OK), 976 FLAG_END, 977 }; 978 979 UNUSED static const struct flags at_file_flags[] = { 980 #ifdef AT_EACCESS 981 FLAG_GENERIC(AT_EACCESS), 982 #endif 983 #ifdef AT_SYMLINK_NOFOLLOW 984 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), 985 #endif 986 FLAG_END, 987 }; 988 989 UNUSED static const struct flags unlinkat_flags[] = { 990 #ifdef AT_REMOVEDIR 991 FLAG_GENERIC(AT_REMOVEDIR), 992 #endif 993 FLAG_END, 994 }; 995 996 UNUSED static const struct flags mode_flags[] = { 997 FLAG_GENERIC(S_IFSOCK), 998 FLAG_GENERIC(S_IFLNK), 999 FLAG_GENERIC(S_IFREG), 1000 FLAG_GENERIC(S_IFBLK), 1001 FLAG_GENERIC(S_IFDIR), 1002 FLAG_GENERIC(S_IFCHR), 1003 FLAG_GENERIC(S_IFIFO), 1004 FLAG_END, 1005 }; 1006 1007 UNUSED static const struct flags open_access_flags[] = { 1008 FLAG_TARGET_MASK(O_RDONLY, O_ACCMODE), 1009 FLAG_TARGET_MASK(O_WRONLY, O_ACCMODE), 1010 FLAG_TARGET_MASK(O_RDWR, O_ACCMODE), 1011 FLAG_END, 1012 }; 1013 1014 UNUSED static const struct flags open_flags[] = { 1015 FLAG_TARGET(O_APPEND), 1016 FLAG_TARGET(O_CREAT), 1017 FLAG_TARGET(O_DIRECTORY), 1018 FLAG_TARGET(O_EXCL), 1019 #if TARGET_O_LARGEFILE != 0 1020 FLAG_TARGET(O_LARGEFILE), 1021 #endif 1022 FLAG_TARGET(O_NOCTTY), 1023 FLAG_TARGET(O_NOFOLLOW), 1024 FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */ 1025 FLAG_TARGET(O_DSYNC), 1026 FLAG_TARGET(__O_SYNC), 1027 FLAG_TARGET(O_TRUNC), 1028 #ifdef O_DIRECT 1029 FLAG_TARGET(O_DIRECT), 1030 #endif 1031 #ifdef O_NOATIME 1032 FLAG_TARGET(O_NOATIME), 1033 #endif 1034 #ifdef O_CLOEXEC 1035 FLAG_TARGET(O_CLOEXEC), 1036 #endif 1037 #ifdef O_PATH 1038 FLAG_TARGET(O_PATH), 1039 #endif 1040 #ifdef O_TMPFILE 1041 FLAG_TARGET(O_TMPFILE), 1042 FLAG_TARGET(__O_TMPFILE), 1043 #endif 1044 FLAG_END, 1045 }; 1046 1047 UNUSED static const struct flags mount_flags[] = { 1048 #ifdef MS_BIND 1049 FLAG_GENERIC(MS_BIND), 1050 #endif 1051 #ifdef MS_DIRSYNC 1052 FLAG_GENERIC(MS_DIRSYNC), 1053 #endif 1054 FLAG_GENERIC(MS_MANDLOCK), 1055 #ifdef MS_MOVE 1056 FLAG_GENERIC(MS_MOVE), 1057 #endif 1058 FLAG_GENERIC(MS_NOATIME), 1059 FLAG_GENERIC(MS_NODEV), 1060 FLAG_GENERIC(MS_NODIRATIME), 1061 FLAG_GENERIC(MS_NOEXEC), 1062 FLAG_GENERIC(MS_NOSUID), 1063 FLAG_GENERIC(MS_RDONLY), 1064 #ifdef MS_RELATIME 1065 FLAG_GENERIC(MS_RELATIME), 1066 #endif 1067 FLAG_GENERIC(MS_REMOUNT), 1068 FLAG_GENERIC(MS_SYNCHRONOUS), 1069 FLAG_END, 1070 }; 1071 1072 UNUSED static const struct flags umount2_flags[] = { 1073 #ifdef MNT_FORCE 1074 FLAG_GENERIC(MNT_FORCE), 1075 #endif 1076 #ifdef MNT_DETACH 1077 FLAG_GENERIC(MNT_DETACH), 1078 #endif 1079 #ifdef MNT_EXPIRE 1080 FLAG_GENERIC(MNT_EXPIRE), 1081 #endif 1082 FLAG_END, 1083 }; 1084 1085 UNUSED static const struct flags mmap_prot_flags[] = { 1086 FLAG_GENERIC_MASK(PROT_NONE, PROT_READ | PROT_WRITE | PROT_EXEC), 1087 FLAG_GENERIC(PROT_EXEC), 1088 FLAG_GENERIC(PROT_READ), 1089 FLAG_GENERIC(PROT_WRITE), 1090 FLAG_TARGET(PROT_SEM), 1091 FLAG_GENERIC(PROT_GROWSDOWN), 1092 FLAG_GENERIC(PROT_GROWSUP), 1093 FLAG_END, 1094 }; 1095 1096 UNUSED static const struct flags mmap_flags[] = { 1097 FLAG_TARGET(MAP_SHARED), 1098 FLAG_TARGET(MAP_PRIVATE), 1099 FLAG_TARGET(MAP_ANONYMOUS), 1100 FLAG_TARGET(MAP_DENYWRITE), 1101 FLAG_TARGET(MAP_FIXED), 1102 FLAG_TARGET(MAP_GROWSDOWN), 1103 FLAG_TARGET(MAP_EXECUTABLE), 1104 #ifdef MAP_LOCKED 1105 FLAG_TARGET(MAP_LOCKED), 1106 #endif 1107 #ifdef MAP_NONBLOCK 1108 FLAG_TARGET(MAP_NONBLOCK), 1109 #endif 1110 FLAG_TARGET(MAP_NORESERVE), 1111 #ifdef MAP_POPULATE 1112 FLAG_TARGET(MAP_POPULATE), 1113 #endif 1114 #if defined(TARGET_MAP_UNINITIALIZED) && TARGET_MAP_UNINITIALIZED != 0 1115 FLAG_TARGET(MAP_UNINITIALIZED), 1116 #endif 1117 FLAG_TARGET(MAP_HUGETLB), 1118 FLAG_TARGET(MAP_STACK), 1119 FLAG_END, 1120 }; 1121 1122 #ifndef CLONE_PIDFD 1123 # define CLONE_PIDFD 0x00001000 1124 #endif 1125 1126 UNUSED static const struct flags clone_flags[] = { 1127 FLAG_GENERIC(CLONE_VM), 1128 FLAG_GENERIC(CLONE_FS), 1129 FLAG_GENERIC(CLONE_FILES), 1130 FLAG_GENERIC(CLONE_SIGHAND), 1131 FLAG_GENERIC(CLONE_PIDFD), 1132 FLAG_GENERIC(CLONE_PTRACE), 1133 FLAG_GENERIC(CLONE_VFORK), 1134 FLAG_GENERIC(CLONE_PARENT), 1135 FLAG_GENERIC(CLONE_THREAD), 1136 FLAG_GENERIC(CLONE_NEWNS), 1137 FLAG_GENERIC(CLONE_SYSVSEM), 1138 FLAG_GENERIC(CLONE_SETTLS), 1139 FLAG_GENERIC(CLONE_PARENT_SETTID), 1140 FLAG_GENERIC(CLONE_CHILD_CLEARTID), 1141 FLAG_GENERIC(CLONE_DETACHED), 1142 FLAG_GENERIC(CLONE_UNTRACED), 1143 FLAG_GENERIC(CLONE_CHILD_SETTID), 1144 #if defined(CLONE_NEWUTS) 1145 FLAG_GENERIC(CLONE_NEWUTS), 1146 #endif 1147 #if defined(CLONE_NEWIPC) 1148 FLAG_GENERIC(CLONE_NEWIPC), 1149 #endif 1150 #if defined(CLONE_NEWUSER) 1151 FLAG_GENERIC(CLONE_NEWUSER), 1152 #endif 1153 #if defined(CLONE_NEWPID) 1154 FLAG_GENERIC(CLONE_NEWPID), 1155 #endif 1156 #if defined(CLONE_NEWNET) 1157 FLAG_GENERIC(CLONE_NEWNET), 1158 #endif 1159 #if defined(CLONE_NEWCGROUP) 1160 FLAG_GENERIC(CLONE_NEWCGROUP), 1161 #endif 1162 #if defined(CLONE_NEWTIME) 1163 FLAG_GENERIC(CLONE_NEWTIME), 1164 #endif 1165 #if defined(CLONE_IO) 1166 FLAG_GENERIC(CLONE_IO), 1167 #endif 1168 FLAG_END, 1169 }; 1170 1171 UNUSED static const struct flags execveat_flags[] = { 1172 #ifdef AT_EMPTY_PATH 1173 FLAG_GENERIC(AT_EMPTY_PATH), 1174 #endif 1175 #ifdef AT_SYMLINK_NOFOLLOW 1176 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), 1177 #endif 1178 FLAG_END, 1179 }; 1180 1181 UNUSED static const struct flags msg_flags[] = { 1182 /* send */ 1183 FLAG_GENERIC(MSG_CONFIRM), 1184 FLAG_GENERIC(MSG_DONTROUTE), 1185 FLAG_GENERIC(MSG_DONTWAIT), 1186 FLAG_GENERIC(MSG_EOR), 1187 FLAG_GENERIC(MSG_MORE), 1188 FLAG_GENERIC(MSG_NOSIGNAL), 1189 FLAG_GENERIC(MSG_OOB), 1190 /* recv */ 1191 FLAG_GENERIC(MSG_CMSG_CLOEXEC), 1192 FLAG_GENERIC(MSG_ERRQUEUE), 1193 FLAG_GENERIC(MSG_PEEK), 1194 FLAG_GENERIC(MSG_TRUNC), 1195 FLAG_GENERIC(MSG_WAITALL), 1196 /* recvmsg */ 1197 FLAG_GENERIC(MSG_CTRUNC), 1198 FLAG_END, 1199 }; 1200 1201 UNUSED static const struct flags statx_flags[] = { 1202 #ifdef AT_EMPTY_PATH 1203 FLAG_GENERIC(AT_EMPTY_PATH), 1204 #endif 1205 #ifdef AT_NO_AUTOMOUNT 1206 FLAG_GENERIC(AT_NO_AUTOMOUNT), 1207 #endif 1208 #ifdef AT_SYMLINK_NOFOLLOW 1209 FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), 1210 #endif 1211 #ifdef AT_STATX_SYNC_AS_STAT 1212 FLAG_GENERIC_MASK(AT_STATX_SYNC_AS_STAT, AT_STATX_SYNC_TYPE), 1213 #endif 1214 #ifdef AT_STATX_FORCE_SYNC 1215 FLAG_GENERIC_MASK(AT_STATX_FORCE_SYNC, AT_STATX_SYNC_TYPE), 1216 #endif 1217 #ifdef AT_STATX_DONT_SYNC 1218 FLAG_GENERIC_MASK(AT_STATX_DONT_SYNC, AT_STATX_SYNC_TYPE), 1219 #endif 1220 FLAG_END, 1221 }; 1222 1223 UNUSED static const struct flags statx_mask[] = { 1224 /* This must come first, because it includes everything. */ 1225 #ifdef STATX_ALL 1226 FLAG_GENERIC(STATX_ALL), 1227 #endif 1228 /* This must come second; it includes everything except STATX_BTIME. */ 1229 #ifdef STATX_BASIC_STATS 1230 FLAG_GENERIC(STATX_BASIC_STATS), 1231 #endif 1232 #ifdef STATX_TYPE 1233 FLAG_GENERIC(STATX_TYPE), 1234 #endif 1235 #ifdef STATX_MODE 1236 FLAG_GENERIC(STATX_MODE), 1237 #endif 1238 #ifdef STATX_NLINK 1239 FLAG_GENERIC(STATX_NLINK), 1240 #endif 1241 #ifdef STATX_UID 1242 FLAG_GENERIC(STATX_UID), 1243 #endif 1244 #ifdef STATX_GID 1245 FLAG_GENERIC(STATX_GID), 1246 #endif 1247 #ifdef STATX_ATIME 1248 FLAG_GENERIC(STATX_ATIME), 1249 #endif 1250 #ifdef STATX_MTIME 1251 FLAG_GENERIC(STATX_MTIME), 1252 #endif 1253 #ifdef STATX_CTIME 1254 FLAG_GENERIC(STATX_CTIME), 1255 #endif 1256 #ifdef STATX_INO 1257 FLAG_GENERIC(STATX_INO), 1258 #endif 1259 #ifdef STATX_SIZE 1260 FLAG_GENERIC(STATX_SIZE), 1261 #endif 1262 #ifdef STATX_BLOCKS 1263 FLAG_GENERIC(STATX_BLOCKS), 1264 #endif 1265 #ifdef STATX_BTIME 1266 FLAG_GENERIC(STATX_BTIME), 1267 #endif 1268 FLAG_END, 1269 }; 1270 1271 UNUSED static const struct flags falloc_flags[] = { 1272 FLAG_GENERIC(FALLOC_FL_KEEP_SIZE), 1273 FLAG_GENERIC(FALLOC_FL_PUNCH_HOLE), 1274 #ifdef FALLOC_FL_NO_HIDE_STALE 1275 FLAG_GENERIC(FALLOC_FL_NO_HIDE_STALE), 1276 #endif 1277 #ifdef FALLOC_FL_COLLAPSE_RANGE 1278 FLAG_GENERIC(FALLOC_FL_COLLAPSE_RANGE), 1279 #endif 1280 #ifdef FALLOC_FL_ZERO_RANGE 1281 FLAG_GENERIC(FALLOC_FL_ZERO_RANGE), 1282 #endif 1283 #ifdef FALLOC_FL_INSERT_RANGE 1284 FLAG_GENERIC(FALLOC_FL_INSERT_RANGE), 1285 #endif 1286 #ifdef FALLOC_FL_UNSHARE_RANGE 1287 FLAG_GENERIC(FALLOC_FL_UNSHARE_RANGE), 1288 #endif 1289 }; 1290 1291 UNUSED static const struct flags termios_iflags[] = { 1292 FLAG_TARGET(IGNBRK), 1293 FLAG_TARGET(BRKINT), 1294 FLAG_TARGET(IGNPAR), 1295 FLAG_TARGET(PARMRK), 1296 FLAG_TARGET(INPCK), 1297 FLAG_TARGET(ISTRIP), 1298 FLAG_TARGET(INLCR), 1299 FLAG_TARGET(IGNCR), 1300 FLAG_TARGET(ICRNL), 1301 FLAG_TARGET(IUCLC), 1302 FLAG_TARGET(IXON), 1303 FLAG_TARGET(IXANY), 1304 FLAG_TARGET(IXOFF), 1305 FLAG_TARGET(IMAXBEL), 1306 FLAG_TARGET(IUTF8), 1307 FLAG_END, 1308 }; 1309 1310 UNUSED static const struct flags termios_oflags[] = { 1311 FLAG_TARGET(OPOST), 1312 FLAG_TARGET(OLCUC), 1313 FLAG_TARGET(ONLCR), 1314 FLAG_TARGET(OCRNL), 1315 FLAG_TARGET(ONOCR), 1316 FLAG_TARGET(ONLRET), 1317 FLAG_TARGET(OFILL), 1318 FLAG_TARGET(OFDEL), 1319 FLAG_END, 1320 }; 1321 1322 UNUSED static struct enums termios_oflags_NLDLY[] = { 1323 ENUM_TARGET(NL0), 1324 ENUM_TARGET(NL1), 1325 ENUM_END, 1326 }; 1327 1328 UNUSED static struct enums termios_oflags_CRDLY[] = { 1329 ENUM_TARGET(CR0), 1330 ENUM_TARGET(CR1), 1331 ENUM_TARGET(CR2), 1332 ENUM_TARGET(CR3), 1333 ENUM_END, 1334 }; 1335 1336 UNUSED static struct enums termios_oflags_TABDLY[] = { 1337 ENUM_TARGET(TAB0), 1338 ENUM_TARGET(TAB1), 1339 ENUM_TARGET(TAB2), 1340 ENUM_TARGET(TAB3), 1341 ENUM_END, 1342 }; 1343 1344 UNUSED static struct enums termios_oflags_VTDLY[] = { 1345 ENUM_TARGET(VT0), 1346 ENUM_TARGET(VT1), 1347 ENUM_END, 1348 }; 1349 1350 UNUSED static struct enums termios_oflags_FFDLY[] = { 1351 ENUM_TARGET(FF0), 1352 ENUM_TARGET(FF1), 1353 ENUM_END, 1354 }; 1355 1356 UNUSED static struct enums termios_oflags_BSDLY[] = { 1357 ENUM_TARGET(BS0), 1358 ENUM_TARGET(BS1), 1359 ENUM_END, 1360 }; 1361 1362 UNUSED static struct enums termios_cflags_CBAUD[] = { 1363 ENUM_TARGET(B0), 1364 ENUM_TARGET(B50), 1365 ENUM_TARGET(B75), 1366 ENUM_TARGET(B110), 1367 ENUM_TARGET(B134), 1368 ENUM_TARGET(B150), 1369 ENUM_TARGET(B200), 1370 ENUM_TARGET(B300), 1371 ENUM_TARGET(B600), 1372 ENUM_TARGET(B1200), 1373 ENUM_TARGET(B1800), 1374 ENUM_TARGET(B2400), 1375 ENUM_TARGET(B4800), 1376 ENUM_TARGET(B9600), 1377 ENUM_TARGET(B19200), 1378 ENUM_TARGET(B38400), 1379 ENUM_TARGET(B57600), 1380 ENUM_TARGET(B115200), 1381 ENUM_TARGET(B230400), 1382 ENUM_TARGET(B460800), 1383 ENUM_END, 1384 }; 1385 1386 UNUSED static struct enums termios_cflags_CSIZE[] = { 1387 ENUM_TARGET(CS5), 1388 ENUM_TARGET(CS6), 1389 ENUM_TARGET(CS7), 1390 ENUM_TARGET(CS8), 1391 ENUM_END, 1392 }; 1393 1394 UNUSED static const struct flags termios_cflags[] = { 1395 FLAG_TARGET(CSTOPB), 1396 FLAG_TARGET(CREAD), 1397 FLAG_TARGET(PARENB), 1398 FLAG_TARGET(PARODD), 1399 FLAG_TARGET(HUPCL), 1400 FLAG_TARGET(CLOCAL), 1401 FLAG_TARGET(CRTSCTS), 1402 FLAG_END, 1403 }; 1404 1405 UNUSED static const struct flags termios_lflags[] = { 1406 FLAG_TARGET(ISIG), 1407 FLAG_TARGET(ICANON), 1408 FLAG_TARGET(XCASE), 1409 FLAG_TARGET(ECHO), 1410 FLAG_TARGET(ECHOE), 1411 FLAG_TARGET(ECHOK), 1412 FLAG_TARGET(ECHONL), 1413 FLAG_TARGET(NOFLSH), 1414 FLAG_TARGET(TOSTOP), 1415 FLAG_TARGET(ECHOCTL), 1416 FLAG_TARGET(ECHOPRT), 1417 FLAG_TARGET(ECHOKE), 1418 FLAG_TARGET(FLUSHO), 1419 FLAG_TARGET(PENDIN), 1420 FLAG_TARGET(IEXTEN), 1421 FLAG_TARGET(EXTPROC), 1422 FLAG_END, 1423 }; 1424 1425 #ifdef TARGET_NR_mlockall 1426 static const struct flags mlockall_flags[] = { 1427 FLAG_TARGET(MCL_CURRENT), 1428 FLAG_TARGET(MCL_FUTURE), 1429 #ifdef MCL_ONFAULT 1430 FLAG_TARGET(MCL_ONFAULT), 1431 #endif 1432 FLAG_END, 1433 }; 1434 #endif 1435 1436 /* IDs of the various system clocks */ 1437 #define TARGET_CLOCK_REALTIME 0 1438 #define TARGET_CLOCK_MONOTONIC 1 1439 #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 1440 #define TARGET_CLOCK_THREAD_CPUTIME_ID 3 1441 #define TARGET_CLOCK_MONOTONIC_RAW 4 1442 #define TARGET_CLOCK_REALTIME_COARSE 5 1443 #define TARGET_CLOCK_MONOTONIC_COARSE 6 1444 #define TARGET_CLOCK_BOOTTIME 7 1445 #define TARGET_CLOCK_REALTIME_ALARM 8 1446 #define TARGET_CLOCK_BOOTTIME_ALARM 9 1447 #define TARGET_CLOCK_SGI_CYCLE 10 1448 #define TARGET_CLOCK_TAI 11 1449 1450 UNUSED static struct enums clockids[] = { 1451 ENUM_TARGET(CLOCK_REALTIME), 1452 ENUM_TARGET(CLOCK_MONOTONIC), 1453 ENUM_TARGET(CLOCK_PROCESS_CPUTIME_ID), 1454 ENUM_TARGET(CLOCK_THREAD_CPUTIME_ID), 1455 ENUM_TARGET(CLOCK_MONOTONIC_RAW), 1456 ENUM_TARGET(CLOCK_REALTIME_COARSE), 1457 ENUM_TARGET(CLOCK_MONOTONIC_COARSE), 1458 ENUM_TARGET(CLOCK_BOOTTIME), 1459 ENUM_TARGET(CLOCK_REALTIME_ALARM), 1460 ENUM_TARGET(CLOCK_BOOTTIME_ALARM), 1461 ENUM_TARGET(CLOCK_SGI_CYCLE), 1462 ENUM_TARGET(CLOCK_TAI), 1463 ENUM_END, 1464 }; 1465 1466 UNUSED static struct enums itimer_types[] = { 1467 ENUM_GENERIC(ITIMER_REAL), 1468 ENUM_GENERIC(ITIMER_VIRTUAL), 1469 ENUM_GENERIC(ITIMER_PROF), 1470 ENUM_END, 1471 }; 1472 1473 /* 1474 * print_xxx utility functions. These are used to print syscall 1475 * parameters in certain format. All of these have parameter 1476 * named 'last'. This parameter is used to add comma to output 1477 * when last == 0. 1478 */ 1479 1480 static const char * 1481 get_comma(int last) 1482 { 1483 return ((last) ? "" : ","); 1484 } 1485 1486 static void 1487 print_flags(const struct flags *f, abi_long flags, int last) 1488 { 1489 const char *sep = ""; 1490 int n; 1491 1492 for (n = 0; f->f_string != NULL; f++) { 1493 if ((flags & f->f_mask) == f->f_value) { 1494 qemu_log("%s%s", sep, f->f_string); 1495 flags &= ~f->f_mask; 1496 sep = "|"; 1497 n++; 1498 } 1499 } 1500 1501 if (n > 0) { 1502 /* print rest of the flags as numeric */ 1503 if (flags != 0) { 1504 qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); 1505 } else { 1506 qemu_log("%s", get_comma(last)); 1507 } 1508 } else { 1509 /* no string version of flags found, print them in hex then */ 1510 qemu_log("%#x%s", (unsigned int)flags, get_comma(last)); 1511 } 1512 } 1513 1514 static void 1515 print_enums(const struct enums *e, abi_long enum_arg, int last) 1516 { 1517 for (; e->e_string != NULL; e++) { 1518 if (e->e_value == enum_arg) { 1519 qemu_log("%s", e->e_string); 1520 break; 1521 } 1522 } 1523 1524 if (e->e_string == NULL) { 1525 qemu_log("%#x", (unsigned int)enum_arg); 1526 } 1527 1528 qemu_log("%s", get_comma(last)); 1529 } 1530 1531 static void 1532 print_at_dirfd(abi_long dirfd, int last) 1533 { 1534 #ifdef AT_FDCWD 1535 if (dirfd == AT_FDCWD) { 1536 qemu_log("AT_FDCWD%s", get_comma(last)); 1537 return; 1538 } 1539 #endif 1540 qemu_log("%d%s", (int)dirfd, get_comma(last)); 1541 } 1542 1543 static void 1544 print_file_mode(abi_long mode, int last) 1545 { 1546 const char *sep = ""; 1547 const struct flags *m; 1548 1549 if (mode == 0) { 1550 qemu_log("000%s", get_comma(last)); 1551 return; 1552 } 1553 1554 for (m = &mode_flags[0]; m->f_string != NULL; m++) { 1555 if ((m->f_value & mode) == m->f_value) { 1556 qemu_log("%s%s", m->f_string, sep); 1557 sep = "|"; 1558 mode &= ~m->f_value; 1559 break; 1560 } 1561 } 1562 1563 mode &= ~S_IFMT; 1564 /* print rest of the mode as octal */ 1565 if (mode != 0) 1566 qemu_log("%s%#o", sep, (unsigned int)mode); 1567 1568 qemu_log("%s", get_comma(last)); 1569 } 1570 1571 static void 1572 print_open_flags(abi_long flags, int last) 1573 { 1574 print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); 1575 flags &= ~TARGET_O_ACCMODE; 1576 if (flags == 0) { 1577 qemu_log("%s", get_comma(last)); 1578 return; 1579 } 1580 qemu_log("|"); 1581 print_flags(open_flags, flags, last); 1582 } 1583 1584 static void 1585 print_syscall_prologue(const struct syscallname *sc) 1586 { 1587 qemu_log("%s(", sc->name); 1588 } 1589 1590 /*ARGSUSED*/ 1591 static void 1592 print_syscall_epilogue(const struct syscallname *sc) 1593 { 1594 (void)sc; 1595 qemu_log(")"); 1596 } 1597 1598 static void 1599 print_string(abi_long addr, int last) 1600 { 1601 char *s; 1602 1603 if ((s = lock_user_string(addr)) != NULL) { 1604 qemu_log("\"%s\"%s", s, get_comma(last)); 1605 unlock_user(s, addr, 0); 1606 } else { 1607 /* can't get string out of it, so print it as pointer */ 1608 print_pointer(addr, last); 1609 } 1610 } 1611 1612 #define MAX_PRINT_BUF 40 1613 static void 1614 print_buf(abi_long addr, abi_long len, int last) 1615 { 1616 uint8_t *s; 1617 int i; 1618 1619 s = lock_user(VERIFY_READ, addr, len, 1); 1620 if (s) { 1621 qemu_log("\""); 1622 for (i = 0; i < MAX_PRINT_BUF && i < len; i++) { 1623 if (isprint(s[i])) { 1624 qemu_log("%c", s[i]); 1625 } else { 1626 qemu_log("\\%o", s[i]); 1627 } 1628 } 1629 qemu_log("\""); 1630 if (i != len) { 1631 qemu_log("..."); 1632 } 1633 if (!last) { 1634 qemu_log(","); 1635 } 1636 unlock_user(s, addr, 0); 1637 } else { 1638 print_pointer(addr, last); 1639 } 1640 } 1641 1642 /* 1643 * Prints out raw parameter using given format. Caller needs 1644 * to do byte swapping if needed. 1645 */ 1646 static void 1647 print_raw_param(const char *fmt, abi_long param, int last) 1648 { 1649 char format[64]; 1650 1651 (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); 1652 qemu_log(format, param); 1653 } 1654 1655 /* 1656 * Same as print_raw_param() but prints out raw 64-bit parameter. 1657 */ 1658 static void 1659 print_raw_param64(const char *fmt, long long param, int last) 1660 { 1661 char format[64]; 1662 1663 (void)snprintf(format, sizeof(format), "%s%s", fmt, get_comma(last)); 1664 qemu_log(format, param); 1665 } 1666 1667 1668 static void 1669 print_pointer(abi_long p, int last) 1670 { 1671 if (p == 0) 1672 qemu_log("NULL%s", get_comma(last)); 1673 else 1674 qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); 1675 } 1676 1677 /* 1678 * Reads 32-bit (int) number from guest address space from 1679 * address 'addr' and prints it. 1680 */ 1681 static void 1682 print_number(abi_long addr, int last) 1683 { 1684 if (addr == 0) { 1685 qemu_log("NULL%s", get_comma(last)); 1686 } else { 1687 int num; 1688 1689 get_user_s32(num, addr); 1690 qemu_log("[%d]%s", num, get_comma(last)); 1691 } 1692 } 1693 1694 static void 1695 print_timeval(abi_ulong tv_addr, int last) 1696 { 1697 if( tv_addr ) { 1698 struct target_timeval *tv; 1699 1700 tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1); 1701 if (!tv) { 1702 print_pointer(tv_addr, last); 1703 return; 1704 } 1705 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld 1706 ",tv_usec = " TARGET_ABI_FMT_ld "}%s", 1707 tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); 1708 unlock_user(tv, tv_addr, 0); 1709 } else 1710 qemu_log("NULL%s", get_comma(last)); 1711 } 1712 1713 static void 1714 print_timespec(abi_ulong ts_addr, int last) 1715 { 1716 if (ts_addr) { 1717 struct target_timespec *ts; 1718 1719 ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1); 1720 if (!ts) { 1721 print_pointer(ts_addr, last); 1722 return; 1723 } 1724 qemu_log("{tv_sec = " TARGET_ABI_FMT_ld 1725 ",tv_nsec = " TARGET_ABI_FMT_ld "}%s", 1726 tswapal(ts->tv_sec), tswapal(ts->tv_nsec), get_comma(last)); 1727 unlock_user(ts, ts_addr, 0); 1728 } else { 1729 qemu_log("NULL%s", get_comma(last)); 1730 } 1731 } 1732 1733 static void 1734 print_timespec64(abi_ulong ts_addr, int last) 1735 { 1736 if (ts_addr) { 1737 struct target__kernel_timespec *ts; 1738 1739 ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1); 1740 if (!ts) { 1741 print_pointer(ts_addr, last); 1742 return; 1743 } 1744 print_raw_param64("{tv_sec=%" PRId64, tswap64(ts->tv_sec), 0); 1745 print_raw_param64("tv_nsec=%" PRId64 "}", tswap64(ts->tv_nsec), last); 1746 unlock_user(ts, ts_addr, 0); 1747 } else { 1748 qemu_log("NULL%s", get_comma(last)); 1749 } 1750 } 1751 1752 static void 1753 print_timezone(abi_ulong tz_addr, int last) 1754 { 1755 if (tz_addr) { 1756 struct target_timezone *tz; 1757 1758 tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1); 1759 if (!tz) { 1760 print_pointer(tz_addr, last); 1761 return; 1762 } 1763 qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest), 1764 tswap32(tz->tz_dsttime), get_comma(last)); 1765 unlock_user(tz, tz_addr, 0); 1766 } else { 1767 qemu_log("NULL%s", get_comma(last)); 1768 } 1769 } 1770 1771 static void 1772 print_itimerval(abi_ulong it_addr, int last) 1773 { 1774 if (it_addr) { 1775 qemu_log("{it_interval="); 1776 print_timeval(it_addr + 1777 offsetof(struct target_itimerval, it_interval), 0); 1778 qemu_log("it_value="); 1779 print_timeval(it_addr + 1780 offsetof(struct target_itimerval, it_value), 0); 1781 qemu_log("}%s", get_comma(last)); 1782 } else { 1783 qemu_log("NULL%s", get_comma(last)); 1784 } 1785 } 1786 1787 void 1788 print_termios(void *arg) 1789 { 1790 const struct target_termios *target = arg; 1791 1792 target_tcflag_t iflags = tswap32(target->c_iflag); 1793 target_tcflag_t oflags = tswap32(target->c_oflag); 1794 target_tcflag_t cflags = tswap32(target->c_cflag); 1795 target_tcflag_t lflags = tswap32(target->c_lflag); 1796 1797 qemu_log("{"); 1798 1799 qemu_log("c_iflag = "); 1800 print_flags(termios_iflags, iflags, 0); 1801 1802 qemu_log("c_oflag = "); 1803 target_tcflag_t oflags_clean = oflags & ~(TARGET_NLDLY | TARGET_CRDLY | 1804 TARGET_TABDLY | TARGET_BSDLY | 1805 TARGET_VTDLY | TARGET_FFDLY); 1806 print_flags(termios_oflags, oflags_clean, 0); 1807 if (oflags & TARGET_NLDLY) { 1808 print_enums(termios_oflags_NLDLY, oflags & TARGET_NLDLY, 0); 1809 } 1810 if (oflags & TARGET_CRDLY) { 1811 print_enums(termios_oflags_CRDLY, oflags & TARGET_CRDLY, 0); 1812 } 1813 if (oflags & TARGET_TABDLY) { 1814 print_enums(termios_oflags_TABDLY, oflags & TARGET_TABDLY, 0); 1815 } 1816 if (oflags & TARGET_BSDLY) { 1817 print_enums(termios_oflags_BSDLY, oflags & TARGET_BSDLY, 0); 1818 } 1819 if (oflags & TARGET_VTDLY) { 1820 print_enums(termios_oflags_VTDLY, oflags & TARGET_VTDLY, 0); 1821 } 1822 if (oflags & TARGET_FFDLY) { 1823 print_enums(termios_oflags_FFDLY, oflags & TARGET_FFDLY, 0); 1824 } 1825 1826 qemu_log("c_cflag = "); 1827 if (cflags & TARGET_CBAUD) { 1828 print_enums(termios_cflags_CBAUD, cflags & TARGET_CBAUD, 0); 1829 } 1830 if (cflags & TARGET_CSIZE) { 1831 print_enums(termios_cflags_CSIZE, cflags & TARGET_CSIZE, 0); 1832 } 1833 target_tcflag_t cflags_clean = cflags & ~(TARGET_CBAUD | TARGET_CSIZE); 1834 print_flags(termios_cflags, cflags_clean, 0); 1835 1836 qemu_log("c_lflag = "); 1837 print_flags(termios_lflags, lflags, 0); 1838 1839 qemu_log("c_cc = "); 1840 qemu_log("\"%s\",", target->c_cc); 1841 1842 qemu_log("c_line = "); 1843 print_raw_param("\'%c\'", target->c_line, 1); 1844 1845 qemu_log("}"); 1846 } 1847 1848 #undef UNUSED 1849 1850 #ifdef TARGET_NR_accept 1851 static void 1852 print_accept(CPUArchState *cpu_env, const struct syscallname *name, 1853 abi_long arg0, abi_long arg1, abi_long arg2, 1854 abi_long arg3, abi_long arg4, abi_long arg5) 1855 { 1856 print_syscall_prologue(name); 1857 print_raw_param("%d", arg0, 0); 1858 print_pointer(arg1, 0); 1859 print_number(arg2, 1); 1860 print_syscall_epilogue(name); 1861 } 1862 #endif 1863 1864 #ifdef TARGET_NR_access 1865 static void 1866 print_access(CPUArchState *cpu_env, const struct syscallname *name, 1867 abi_long arg0, abi_long arg1, abi_long arg2, 1868 abi_long arg3, abi_long arg4, abi_long arg5) 1869 { 1870 print_syscall_prologue(name); 1871 print_string(arg0, 0); 1872 print_flags(access_flags, arg1, 1); 1873 print_syscall_epilogue(name); 1874 } 1875 #endif 1876 1877 #ifdef TARGET_NR_acct 1878 static void 1879 print_acct(CPUArchState *cpu_env, const struct syscallname *name, 1880 abi_long arg0, abi_long arg1, abi_long arg2, 1881 abi_long arg3, abi_long arg4, abi_long arg5) 1882 { 1883 print_syscall_prologue(name); 1884 print_string(arg0, 1); 1885 print_syscall_epilogue(name); 1886 } 1887 #endif 1888 1889 #ifdef TARGET_NR_brk 1890 static void 1891 print_brk(CPUArchState *cpu_env, const struct syscallname *name, 1892 abi_long arg0, abi_long arg1, abi_long arg2, 1893 abi_long arg3, abi_long arg4, abi_long arg5) 1894 { 1895 print_syscall_prologue(name); 1896 print_pointer(arg0, 1); 1897 print_syscall_epilogue(name); 1898 } 1899 #endif 1900 1901 #ifdef TARGET_NR_chdir 1902 static void 1903 print_chdir(CPUArchState *cpu_env, const struct syscallname *name, 1904 abi_long arg0, abi_long arg1, abi_long arg2, 1905 abi_long arg3, abi_long arg4, abi_long arg5) 1906 { 1907 print_syscall_prologue(name); 1908 print_string(arg0, 1); 1909 print_syscall_epilogue(name); 1910 } 1911 #endif 1912 1913 #ifdef TARGET_NR_chroot 1914 static void 1915 print_chroot(CPUArchState *cpu_env, const struct syscallname *name, 1916 abi_long arg0, abi_long arg1, abi_long arg2, 1917 abi_long arg3, abi_long arg4, abi_long arg5) 1918 { 1919 print_syscall_prologue(name); 1920 print_string(arg0, 1); 1921 print_syscall_epilogue(name); 1922 } 1923 #endif 1924 1925 #ifdef TARGET_NR_chmod 1926 static void 1927 print_chmod(CPUArchState *cpu_env, const struct syscallname *name, 1928 abi_long arg0, abi_long arg1, abi_long arg2, 1929 abi_long arg3, abi_long arg4, abi_long arg5) 1930 { 1931 print_syscall_prologue(name); 1932 print_string(arg0, 0); 1933 print_file_mode(arg1, 1); 1934 print_syscall_epilogue(name); 1935 } 1936 #endif 1937 1938 #if defined(TARGET_NR_chown) || defined(TARGET_NR_lchown) 1939 static void 1940 print_chown(CPUArchState *cpu_env, const struct syscallname *name, 1941 abi_long arg0, abi_long arg1, abi_long arg2, 1942 abi_long arg3, abi_long arg4, abi_long arg5) 1943 { 1944 print_syscall_prologue(name); 1945 print_string(arg0, 0); 1946 print_raw_param("%d", arg1, 0); 1947 print_raw_param("%d", arg2, 1); 1948 print_syscall_epilogue(name); 1949 } 1950 #define print_lchown print_chown 1951 #endif 1952 1953 #ifdef TARGET_NR_clock_adjtime 1954 static void 1955 print_clock_adjtime(CPUArchState *cpu_env, const struct syscallname *name, 1956 abi_long arg0, abi_long arg1, abi_long arg2, 1957 abi_long arg3, abi_long arg4, abi_long arg5) 1958 { 1959 print_syscall_prologue(name); 1960 print_enums(clockids, arg0, 0); 1961 print_pointer(arg1, 1); 1962 print_syscall_epilogue(name); 1963 } 1964 #endif 1965 1966 #ifdef TARGET_NR_clone 1967 static void do_print_clone(unsigned int flags, abi_ulong newsp, 1968 abi_ulong parent_tidptr, target_ulong newtls, 1969 abi_ulong child_tidptr) 1970 { 1971 print_flags(clone_flags, flags, 0); 1972 print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0); 1973 print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0); 1974 print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0); 1975 print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1); 1976 } 1977 1978 static void 1979 print_clone(CPUArchState *cpu_env, const struct syscallname *name, 1980 abi_long arg1, abi_long arg2, abi_long arg3, 1981 abi_long arg4, abi_long arg5, abi_long arg6) 1982 { 1983 print_syscall_prologue(name); 1984 #if defined(TARGET_MICROBLAZE) 1985 do_print_clone(arg1, arg2, arg4, arg6, arg5); 1986 #elif defined(TARGET_CLONE_BACKWARDS) 1987 do_print_clone(arg1, arg2, arg3, arg4, arg5); 1988 #elif defined(TARGET_CLONE_BACKWARDS2) 1989 do_print_clone(arg2, arg1, arg3, arg5, arg4); 1990 #else 1991 do_print_clone(arg1, arg2, arg3, arg5, arg4); 1992 #endif 1993 print_syscall_epilogue(name); 1994 } 1995 #endif 1996 1997 #ifdef TARGET_NR_creat 1998 static void 1999 print_creat(CPUArchState *cpu_env, const struct syscallname *name, 2000 abi_long arg0, abi_long arg1, abi_long arg2, 2001 abi_long arg3, abi_long arg4, abi_long arg5) 2002 { 2003 print_syscall_prologue(name); 2004 print_string(arg0, 0); 2005 print_file_mode(arg1, 1); 2006 print_syscall_epilogue(name); 2007 } 2008 #endif 2009 2010 #ifdef TARGET_NR_execv 2011 static void 2012 print_execv(CPUArchState *cpu_env, const struct syscallname *name, 2013 abi_long arg0, abi_long arg1, abi_long arg2, 2014 abi_long arg3, abi_long arg4, abi_long arg5) 2015 { 2016 print_syscall_prologue(name); 2017 print_string(arg0, 0); 2018 print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1); 2019 print_syscall_epilogue(name); 2020 } 2021 #endif 2022 2023 static void 2024 print_execve_argv(abi_long argv, int last) 2025 { 2026 abi_ulong arg_ptr_addr; 2027 char *s; 2028 2029 qemu_log("{"); 2030 for (arg_ptr_addr = argv; ; arg_ptr_addr += sizeof(abi_ulong)) { 2031 abi_ulong *arg_ptr, arg_addr; 2032 2033 arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); 2034 if (!arg_ptr) { 2035 return; 2036 } 2037 arg_addr = tswapal(*arg_ptr); 2038 unlock_user(arg_ptr, arg_ptr_addr, 0); 2039 if (!arg_addr) { 2040 break; 2041 } 2042 s = lock_user_string(arg_addr); 2043 if (s) { 2044 qemu_log("\"%s\",", s); 2045 unlock_user(s, arg_addr, 0); 2046 } 2047 } 2048 qemu_log("NULL}%s", get_comma(last)); 2049 } 2050 2051 static void 2052 print_execve(CPUArchState *cpu_env, const struct syscallname *name, 2053 abi_long arg1, abi_long arg2, abi_long arg3, 2054 abi_long arg4, abi_long arg5, abi_long arg6) 2055 { 2056 print_syscall_prologue(name); 2057 print_string(arg1, 0); 2058 print_execve_argv(arg2, 1); 2059 print_syscall_epilogue(name); 2060 } 2061 2062 static void 2063 print_execveat(CPUArchState *cpu_env, const struct syscallname *name, 2064 abi_long arg1, abi_long arg2, abi_long arg3, 2065 abi_long arg4, abi_long arg5, abi_long arg6) 2066 { 2067 print_syscall_prologue(name); 2068 print_at_dirfd(arg1, 0); 2069 print_string(arg2, 0); 2070 print_execve_argv(arg3, 0); 2071 print_flags(execveat_flags, arg5, 1); 2072 print_syscall_epilogue(name); 2073 } 2074 2075 #if defined(TARGET_NR_faccessat) || defined(TARGET_NR_faccessat2) 2076 static void 2077 print_faccessat(CPUArchState *cpu_env, const struct syscallname *name, 2078 abi_long arg0, abi_long arg1, abi_long arg2, 2079 abi_long arg3, abi_long arg4, abi_long arg5) 2080 { 2081 print_syscall_prologue(name); 2082 print_at_dirfd(arg0, 0); 2083 print_string(arg1, 0); 2084 print_flags(access_flags, arg2, 0); 2085 print_flags(at_file_flags, arg3, 1); 2086 print_syscall_epilogue(name); 2087 } 2088 #endif 2089 2090 #ifdef TARGET_NR_fallocate 2091 static void 2092 print_fallocate(CPUArchState *cpu_env, const struct syscallname *name, 2093 abi_long arg0, abi_long arg1, abi_long arg2, 2094 abi_long arg3, abi_long arg4, abi_long arg5) 2095 { 2096 print_syscall_prologue(name); 2097 print_raw_param("%d", arg0, 0); 2098 print_flags(falloc_flags, arg1, 0); 2099 #if TARGET_ABI_BITS == 32 2100 print_raw_param("%" PRIu64, target_offset64(arg2, arg3), 0); 2101 print_raw_param("%" PRIu64, target_offset64(arg4, arg5), 1); 2102 #else 2103 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 2104 print_raw_param(TARGET_ABI_FMT_ld, arg3, 1); 2105 #endif 2106 print_syscall_epilogue(name); 2107 } 2108 #endif 2109 2110 #ifdef TARGET_NR_fchmodat 2111 static void 2112 print_fchmodat(CPUArchState *cpu_env, const struct syscallname *name, 2113 abi_long arg0, abi_long arg1, abi_long arg2, 2114 abi_long arg3, abi_long arg4, abi_long arg5) 2115 { 2116 print_syscall_prologue(name); 2117 print_at_dirfd(arg0, 0); 2118 print_string(arg1, 0); 2119 print_file_mode(arg2, 0); 2120 print_flags(at_file_flags, arg3, 1); 2121 print_syscall_epilogue(name); 2122 } 2123 #endif 2124 2125 #ifdef TARGET_NR_fchownat 2126 static void 2127 print_fchownat(CPUArchState *cpu_env, const struct syscallname *name, 2128 abi_long arg0, abi_long arg1, abi_long arg2, 2129 abi_long arg3, abi_long arg4, abi_long arg5) 2130 { 2131 print_syscall_prologue(name); 2132 print_at_dirfd(arg0, 0); 2133 print_string(arg1, 0); 2134 print_raw_param("%d", arg2, 0); 2135 print_raw_param("%d", arg3, 0); 2136 print_flags(at_file_flags, arg4, 1); 2137 print_syscall_epilogue(name); 2138 } 2139 #endif 2140 2141 #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) 2142 static void 2143 print_fcntl(CPUArchState *cpu_env, const struct syscallname *name, 2144 abi_long arg0, abi_long arg1, abi_long arg2, 2145 abi_long arg3, abi_long arg4, abi_long arg5) 2146 { 2147 print_syscall_prologue(name); 2148 print_raw_param("%d", arg0, 0); 2149 switch(arg1) { 2150 case TARGET_F_DUPFD: 2151 qemu_log("F_DUPFD,"); 2152 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 2153 break; 2154 case TARGET_F_GETFD: 2155 qemu_log("F_GETFD"); 2156 break; 2157 case TARGET_F_SETFD: 2158 qemu_log("F_SETFD,"); 2159 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 2160 break; 2161 case TARGET_F_GETFL: 2162 qemu_log("F_GETFL"); 2163 break; 2164 case TARGET_F_SETFL: 2165 qemu_log("F_SETFL,"); 2166 print_open_flags(arg2, 1); 2167 break; 2168 case TARGET_F_GETLK: 2169 qemu_log("F_GETLK,"); 2170 print_pointer(arg2, 1); 2171 break; 2172 case TARGET_F_SETLK: 2173 qemu_log("F_SETLK,"); 2174 print_pointer(arg2, 1); 2175 break; 2176 case TARGET_F_SETLKW: 2177 qemu_log("F_SETLKW,"); 2178 print_pointer(arg2, 1); 2179 break; 2180 case TARGET_F_GETOWN: 2181 qemu_log("F_GETOWN"); 2182 break; 2183 case TARGET_F_SETOWN: 2184 qemu_log("F_SETOWN,"); 2185 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 2186 break; 2187 case TARGET_F_GETSIG: 2188 qemu_log("F_GETSIG"); 2189 break; 2190 case TARGET_F_SETSIG: 2191 qemu_log("F_SETSIG,"); 2192 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 2193 break; 2194 #if TARGET_ABI_BITS == 32 2195 case TARGET_F_GETLK64: 2196 qemu_log("F_GETLK64,"); 2197 print_pointer(arg2, 1); 2198 break; 2199 case TARGET_F_SETLK64: 2200 qemu_log("F_SETLK64,"); 2201 print_pointer(arg2, 1); 2202 break; 2203 case TARGET_F_SETLKW64: 2204 qemu_log("F_SETLKW64,"); 2205 print_pointer(arg2, 1); 2206 break; 2207 #endif 2208 case TARGET_F_OFD_GETLK: 2209 qemu_log("F_OFD_GETLK,"); 2210 print_pointer(arg2, 1); 2211 break; 2212 case TARGET_F_OFD_SETLK: 2213 qemu_log("F_OFD_SETLK,"); 2214 print_pointer(arg2, 1); 2215 break; 2216 case TARGET_F_OFD_SETLKW: 2217 qemu_log("F_OFD_SETLKW,"); 2218 print_pointer(arg2, 1); 2219 break; 2220 case TARGET_F_SETLEASE: 2221 qemu_log("F_SETLEASE,"); 2222 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 2223 break; 2224 case TARGET_F_GETLEASE: 2225 qemu_log("F_GETLEASE"); 2226 break; 2227 #ifdef F_DUPFD_CLOEXEC 2228 case TARGET_F_DUPFD_CLOEXEC: 2229 qemu_log("F_DUPFD_CLOEXEC,"); 2230 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 2231 break; 2232 #endif 2233 case TARGET_F_NOTIFY: 2234 qemu_log("F_NOTIFY,"); 2235 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 2236 break; 2237 #ifdef F_GETOWN_EX 2238 case TARGET_F_GETOWN_EX: 2239 qemu_log("F_GETOWN_EX,"); 2240 print_pointer(arg2, 1); 2241 break; 2242 #endif 2243 #ifdef F_SETOWN_EX 2244 case TARGET_F_SETOWN_EX: 2245 qemu_log("F_SETOWN_EX,"); 2246 print_pointer(arg2, 1); 2247 break; 2248 #endif 2249 #ifdef F_SETPIPE_SZ 2250 case TARGET_F_SETPIPE_SZ: 2251 qemu_log("F_SETPIPE_SZ,"); 2252 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 2253 break; 2254 case TARGET_F_GETPIPE_SZ: 2255 qemu_log("F_GETPIPE_SZ"); 2256 break; 2257 #endif 2258 #ifdef F_ADD_SEALS 2259 case TARGET_F_ADD_SEALS: 2260 qemu_log("F_ADD_SEALS,"); 2261 print_raw_param("0x"TARGET_ABI_FMT_lx, arg2, 1); 2262 break; 2263 case TARGET_F_GET_SEALS: 2264 qemu_log("F_GET_SEALS"); 2265 break; 2266 #endif 2267 default: 2268 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); 2269 print_pointer(arg2, 1); 2270 break; 2271 } 2272 print_syscall_epilogue(name); 2273 } 2274 #define print_fcntl64 print_fcntl 2275 #endif 2276 2277 #ifdef TARGET_NR_fgetxattr 2278 static void 2279 print_fgetxattr(CPUArchState *cpu_env, const struct syscallname *name, 2280 abi_long arg0, abi_long arg1, abi_long arg2, 2281 abi_long arg3, abi_long arg4, abi_long arg5) 2282 { 2283 print_syscall_prologue(name); 2284 print_raw_param("%d", arg0, 0); 2285 print_string(arg1, 0); 2286 print_pointer(arg2, 0); 2287 print_raw_param(TARGET_FMT_lu, arg3, 1); 2288 print_syscall_epilogue(name); 2289 } 2290 #endif 2291 2292 #ifdef TARGET_NR_flistxattr 2293 static void 2294 print_flistxattr(CPUArchState *cpu_env, const struct syscallname *name, 2295 abi_long arg0, abi_long arg1, abi_long arg2, 2296 abi_long arg3, abi_long arg4, abi_long arg5) 2297 { 2298 print_syscall_prologue(name); 2299 print_raw_param("%d", arg0, 0); 2300 print_pointer(arg1, 0); 2301 print_raw_param(TARGET_FMT_lu, arg2, 1); 2302 print_syscall_epilogue(name); 2303 } 2304 #endif 2305 2306 #if defined(TARGET_NR_getxattr) || defined(TARGET_NR_lgetxattr) 2307 static void 2308 print_getxattr(CPUArchState *cpu_env, const struct syscallname *name, 2309 abi_long arg0, abi_long arg1, abi_long arg2, 2310 abi_long arg3, abi_long arg4, abi_long arg5) 2311 { 2312 print_syscall_prologue(name); 2313 print_string(arg0, 0); 2314 print_string(arg1, 0); 2315 print_pointer(arg2, 0); 2316 print_raw_param(TARGET_FMT_lu, arg3, 1); 2317 print_syscall_epilogue(name); 2318 } 2319 #define print_lgetxattr print_getxattr 2320 #endif 2321 2322 #if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) 2323 static void 2324 print_listxattr(CPUArchState *cpu_env, const struct syscallname *name, 2325 abi_long arg0, abi_long arg1, abi_long arg2, 2326 abi_long arg3, abi_long arg4, abi_long arg5) 2327 { 2328 print_syscall_prologue(name); 2329 print_string(arg0, 0); 2330 print_pointer(arg1, 0); 2331 print_raw_param(TARGET_FMT_lu, arg2, 1); 2332 print_syscall_epilogue(name); 2333 } 2334 #define print_llistxattr print_listxattr 2335 #endif 2336 2337 #if defined(TARGET_NR_fremovexattr) 2338 static void 2339 print_fremovexattr(CPUArchState *cpu_env, const struct syscallname *name, 2340 abi_long arg0, abi_long arg1, abi_long arg2, 2341 abi_long arg3, abi_long arg4, abi_long arg5) 2342 { 2343 print_syscall_prologue(name); 2344 print_raw_param("%d", arg0, 0); 2345 print_string(arg1, 1); 2346 print_syscall_epilogue(name); 2347 } 2348 #endif 2349 2350 #if defined(TARGET_NR_removexattr) || defined(TARGET_NR_lremovexattr) 2351 static void 2352 print_removexattr(CPUArchState *cpu_env, const struct syscallname *name, 2353 abi_long arg0, abi_long arg1, abi_long arg2, 2354 abi_long arg3, abi_long arg4, abi_long arg5) 2355 { 2356 print_syscall_prologue(name); 2357 print_string(arg0, 0); 2358 print_string(arg1, 1); 2359 print_syscall_epilogue(name); 2360 } 2361 #define print_lremovexattr print_removexattr 2362 #endif 2363 2364 #ifdef TARGET_NR_futimesat 2365 static void 2366 print_futimesat(CPUArchState *cpu_env, const struct syscallname *name, 2367 abi_long arg0, abi_long arg1, abi_long arg2, 2368 abi_long arg3, abi_long arg4, abi_long arg5) 2369 { 2370 print_syscall_prologue(name); 2371 print_at_dirfd(arg0, 0); 2372 print_string(arg1, 0); 2373 print_timeval(arg2, 0); 2374 print_timeval(arg2 + sizeof (struct target_timeval), 1); 2375 print_syscall_epilogue(name); 2376 } 2377 #endif 2378 2379 #ifdef TARGET_NR_gettimeofday 2380 static void 2381 print_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name, 2382 abi_long arg0, abi_long arg1, abi_long arg2, 2383 abi_long arg3, abi_long arg4, abi_long arg5) 2384 { 2385 print_syscall_prologue(name); 2386 print_pointer(arg0, 0); 2387 print_pointer(arg1, 1); 2388 print_syscall_epilogue(name); 2389 } 2390 #endif 2391 2392 #ifdef TARGET_NR_settimeofday 2393 static void 2394 print_settimeofday(CPUArchState *cpu_env, const struct syscallname *name, 2395 abi_long arg0, abi_long arg1, abi_long arg2, 2396 abi_long arg3, abi_long arg4, abi_long arg5) 2397 { 2398 print_syscall_prologue(name); 2399 print_timeval(arg0, 0); 2400 print_timezone(arg1, 1); 2401 print_syscall_epilogue(name); 2402 } 2403 #endif 2404 2405 #if defined(TARGET_NR_clock_gettime) || defined(TARGET_NR_clock_getres) 2406 static void 2407 print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name, 2408 abi_long arg0, abi_long arg1, abi_long arg2, 2409 abi_long arg3, abi_long arg4, abi_long arg5) 2410 { 2411 print_syscall_prologue(name); 2412 print_enums(clockids, arg0, 0); 2413 print_pointer(arg1, 1); 2414 print_syscall_epilogue(name); 2415 } 2416 #define print_clock_getres print_clock_gettime 2417 #endif 2418 2419 #if defined(TARGET_NR_clock_gettime64) 2420 static void 2421 print_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name, 2422 abi_long arg0, abi_long arg1, abi_long arg2, 2423 abi_long arg3, abi_long arg4, abi_long arg5) 2424 { 2425 print_syscall_prologue(name); 2426 print_enums(clockids, arg0, 0); 2427 print_pointer(arg1, 1); 2428 print_syscall_epilogue(name); 2429 } 2430 #endif 2431 2432 #ifdef TARGET_NR_clock_settime 2433 static void 2434 print_clock_settime(CPUArchState *cpu_env, const struct syscallname *name, 2435 abi_long arg0, abi_long arg1, abi_long arg2, 2436 abi_long arg3, abi_long arg4, abi_long arg5) 2437 { 2438 print_syscall_prologue(name); 2439 print_enums(clockids, arg0, 0); 2440 print_timespec(arg1, 1); 2441 print_syscall_epilogue(name); 2442 } 2443 #endif 2444 2445 #ifdef TARGET_NR_getitimer 2446 static void 2447 print_getitimer(CPUArchState *cpu_env, const struct syscallname *name, 2448 abi_long arg0, abi_long arg1, abi_long arg2, 2449 abi_long arg3, abi_long arg4, abi_long arg5) 2450 { 2451 print_syscall_prologue(name); 2452 print_enums(itimer_types, arg0, 0); 2453 print_pointer(arg1, 1); 2454 print_syscall_epilogue(name); 2455 } 2456 #endif 2457 2458 #ifdef TARGET_NR_setitimer 2459 static void 2460 print_setitimer(CPUArchState *cpu_env, const struct syscallname *name, 2461 abi_long arg0, abi_long arg1, abi_long arg2, 2462 abi_long arg3, abi_long arg4, abi_long arg5) 2463 { 2464 print_syscall_prologue(name); 2465 print_enums(itimer_types, arg0, 0); 2466 print_itimerval(arg1, 0); 2467 print_pointer(arg2, 1); 2468 print_syscall_epilogue(name); 2469 } 2470 #endif 2471 2472 #ifdef TARGET_NR_link 2473 static void 2474 print_link(CPUArchState *cpu_env, const struct syscallname *name, 2475 abi_long arg0, abi_long arg1, abi_long arg2, 2476 abi_long arg3, abi_long arg4, abi_long arg5) 2477 { 2478 print_syscall_prologue(name); 2479 print_string(arg0, 0); 2480 print_string(arg1, 1); 2481 print_syscall_epilogue(name); 2482 } 2483 #endif 2484 2485 #ifdef TARGET_NR_linkat 2486 static void 2487 print_linkat(CPUArchState *cpu_env, const struct syscallname *name, 2488 abi_long arg0, abi_long arg1, abi_long arg2, 2489 abi_long arg3, abi_long arg4, abi_long arg5) 2490 { 2491 print_syscall_prologue(name); 2492 print_at_dirfd(arg0, 0); 2493 print_string(arg1, 0); 2494 print_at_dirfd(arg2, 0); 2495 print_string(arg3, 0); 2496 print_flags(at_file_flags, arg4, 1); 2497 print_syscall_epilogue(name); 2498 } 2499 #endif 2500 2501 #if defined(TARGET_NR__llseek) || defined(TARGET_NR_llseek) 2502 static void 2503 print__llseek(CPUArchState *cpu_env, const struct syscallname *name, 2504 abi_long arg0, abi_long arg1, abi_long arg2, 2505 abi_long arg3, abi_long arg4, abi_long arg5) 2506 { 2507 const char *whence = "UNKNOWN"; 2508 print_syscall_prologue(name); 2509 print_raw_param("%d", arg0, 0); 2510 print_raw_param("%ld", arg1, 0); 2511 print_raw_param("%ld", arg2, 0); 2512 print_pointer(arg3, 0); 2513 switch(arg4) { 2514 case SEEK_SET: whence = "SEEK_SET"; break; 2515 case SEEK_CUR: whence = "SEEK_CUR"; break; 2516 case SEEK_END: whence = "SEEK_END"; break; 2517 } 2518 qemu_log("%s", whence); 2519 print_syscall_epilogue(name); 2520 } 2521 #define print_llseek print__llseek 2522 #endif 2523 2524 #ifdef TARGET_NR_lseek 2525 static void 2526 print_lseek(CPUArchState *cpu_env, const struct syscallname *name, 2527 abi_long arg0, abi_long arg1, abi_long arg2, 2528 abi_long arg3, abi_long arg4, abi_long arg5) 2529 { 2530 print_syscall_prologue(name); 2531 print_raw_param("%d", arg0, 0); 2532 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); 2533 switch (arg2) { 2534 case SEEK_SET: 2535 qemu_log("SEEK_SET"); break; 2536 case SEEK_CUR: 2537 qemu_log("SEEK_CUR"); break; 2538 case SEEK_END: 2539 qemu_log("SEEK_END"); break; 2540 #ifdef SEEK_DATA 2541 case SEEK_DATA: 2542 qemu_log("SEEK_DATA"); break; 2543 #endif 2544 #ifdef SEEK_HOLE 2545 case SEEK_HOLE: 2546 qemu_log("SEEK_HOLE"); break; 2547 #endif 2548 default: 2549 print_raw_param("%#x", arg2, 1); 2550 } 2551 print_syscall_epilogue(name); 2552 } 2553 #endif 2554 2555 #ifdef TARGET_NR_truncate 2556 static void 2557 print_truncate(CPUArchState *cpu_env, const struct syscallname *name, 2558 abi_long arg0, abi_long arg1, abi_long arg2, 2559 abi_long arg3, abi_long arg4, abi_long arg5) 2560 { 2561 print_syscall_prologue(name); 2562 print_string(arg0, 0); 2563 print_raw_param(TARGET_ABI_FMT_ld, arg1, 1); 2564 print_syscall_epilogue(name); 2565 } 2566 #endif 2567 2568 #ifdef TARGET_NR_truncate64 2569 static void 2570 print_truncate64(CPUArchState *cpu_env, const struct syscallname *name, 2571 abi_long arg0, abi_long arg1, abi_long arg2, 2572 abi_long arg3, abi_long arg4, abi_long arg5) 2573 { 2574 print_syscall_prologue(name); 2575 print_string(arg0, 0); 2576 if (regpairs_aligned(cpu_env, TARGET_NR_truncate64)) { 2577 arg1 = arg2; 2578 arg2 = arg3; 2579 } 2580 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); 2581 print_syscall_epilogue(name); 2582 } 2583 #endif 2584 2585 #ifdef TARGET_NR_ftruncate64 2586 static void 2587 print_ftruncate64(CPUArchState *cpu_env, const struct syscallname *name, 2588 abi_long arg0, abi_long arg1, abi_long arg2, 2589 abi_long arg3, abi_long arg4, abi_long arg5) 2590 { 2591 print_syscall_prologue(name); 2592 print_raw_param("%d", arg0, 0); 2593 if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { 2594 arg1 = arg2; 2595 arg2 = arg3; 2596 } 2597 print_raw_param("%" PRIu64, target_offset64(arg1, arg2), 1); 2598 print_syscall_epilogue(name); 2599 } 2600 #endif 2601 2602 #ifdef TARGET_NR_mlockall 2603 static void 2604 print_mlockall(CPUArchState *cpu_env, const struct syscallname *name, 2605 abi_long arg0, abi_long arg1, abi_long arg2, 2606 abi_long arg3, abi_long arg4, abi_long arg5) 2607 { 2608 print_syscall_prologue(name); 2609 print_flags(mlockall_flags, arg0, 1); 2610 print_syscall_epilogue(name); 2611 } 2612 #endif 2613 2614 #if defined(TARGET_NR_socket) 2615 static void 2616 print_socket(CPUArchState *cpu_env, const struct syscallname *name, 2617 abi_long arg0, abi_long arg1, abi_long arg2, 2618 abi_long arg3, abi_long arg4, abi_long arg5) 2619 { 2620 abi_ulong domain = arg0, type = arg1, protocol = arg2; 2621 2622 print_syscall_prologue(name); 2623 print_socket_domain(domain); 2624 qemu_log(","); 2625 print_socket_type(type); 2626 qemu_log(","); 2627 if (domain == AF_PACKET || 2628 (domain == AF_INET && type == TARGET_SOCK_PACKET)) { 2629 protocol = tswap16(protocol); 2630 } 2631 print_socket_protocol(domain, type, protocol); 2632 print_syscall_epilogue(name); 2633 } 2634 2635 #endif 2636 2637 #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind) 2638 2639 static void print_sockfd(abi_long sockfd, int last) 2640 { 2641 print_raw_param(TARGET_ABI_FMT_ld, sockfd, last); 2642 } 2643 2644 #endif 2645 2646 #if defined(TARGET_NR_socketcall) 2647 2648 #define get_user_ualx(x, gaddr, idx) \ 2649 get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long)) 2650 2651 static void do_print_socket(const char *name, abi_long arg1) 2652 { 2653 abi_ulong domain, type, protocol; 2654 2655 get_user_ualx(domain, arg1, 0); 2656 get_user_ualx(type, arg1, 1); 2657 get_user_ualx(protocol, arg1, 2); 2658 qemu_log("%s(", name); 2659 print_socket_domain(domain); 2660 qemu_log(","); 2661 print_socket_type(type); 2662 qemu_log(","); 2663 if (domain == AF_PACKET || 2664 (domain == AF_INET && type == TARGET_SOCK_PACKET)) { 2665 protocol = tswap16(protocol); 2666 } 2667 print_socket_protocol(domain, type, protocol); 2668 qemu_log(")"); 2669 } 2670 2671 static void do_print_sockaddr(const char *name, abi_long arg1) 2672 { 2673 abi_ulong sockfd, addr, addrlen; 2674 2675 get_user_ualx(sockfd, arg1, 0); 2676 get_user_ualx(addr, arg1, 1); 2677 get_user_ualx(addrlen, arg1, 2); 2678 2679 qemu_log("%s(", name); 2680 print_sockfd(sockfd, 0); 2681 print_sockaddr(addr, addrlen, 0); 2682 qemu_log(")"); 2683 } 2684 2685 static void do_print_listen(const char *name, abi_long arg1) 2686 { 2687 abi_ulong sockfd, backlog; 2688 2689 get_user_ualx(sockfd, arg1, 0); 2690 get_user_ualx(backlog, arg1, 1); 2691 2692 qemu_log("%s(", name); 2693 print_sockfd(sockfd, 0); 2694 print_raw_param(TARGET_ABI_FMT_ld, backlog, 1); 2695 qemu_log(")"); 2696 } 2697 2698 static void do_print_socketpair(const char *name, abi_long arg1) 2699 { 2700 abi_ulong domain, type, protocol, tab; 2701 2702 get_user_ualx(domain, arg1, 0); 2703 get_user_ualx(type, arg1, 1); 2704 get_user_ualx(protocol, arg1, 2); 2705 get_user_ualx(tab, arg1, 3); 2706 2707 qemu_log("%s(", name); 2708 print_socket_domain(domain); 2709 qemu_log(","); 2710 print_socket_type(type); 2711 qemu_log(","); 2712 print_socket_protocol(domain, type, protocol); 2713 qemu_log(","); 2714 print_raw_param(TARGET_ABI_FMT_lx, tab, 1); 2715 qemu_log(")"); 2716 } 2717 2718 static void do_print_sendrecv(const char *name, abi_long arg1) 2719 { 2720 abi_ulong sockfd, msg, len, flags; 2721 2722 get_user_ualx(sockfd, arg1, 0); 2723 get_user_ualx(msg, arg1, 1); 2724 get_user_ualx(len, arg1, 2); 2725 get_user_ualx(flags, arg1, 3); 2726 2727 qemu_log("%s(", name); 2728 print_sockfd(sockfd, 0); 2729 print_buf(msg, len, 0); 2730 print_raw_param(TARGET_ABI_FMT_ld, len, 0); 2731 print_flags(msg_flags, flags, 1); 2732 qemu_log(")"); 2733 } 2734 2735 static void do_print_msgaddr(const char *name, abi_long arg1) 2736 { 2737 abi_ulong sockfd, msg, len, flags, addr, addrlen; 2738 2739 get_user_ualx(sockfd, arg1, 0); 2740 get_user_ualx(msg, arg1, 1); 2741 get_user_ualx(len, arg1, 2); 2742 get_user_ualx(flags, arg1, 3); 2743 get_user_ualx(addr, arg1, 4); 2744 get_user_ualx(addrlen, arg1, 5); 2745 2746 qemu_log("%s(", name); 2747 print_sockfd(sockfd, 0); 2748 print_buf(msg, len, 0); 2749 print_raw_param(TARGET_ABI_FMT_ld, len, 0); 2750 print_flags(msg_flags, flags, 0); 2751 print_sockaddr(addr, addrlen, 0); 2752 qemu_log(")"); 2753 } 2754 2755 static void do_print_shutdown(const char *name, abi_long arg1) 2756 { 2757 abi_ulong sockfd, how; 2758 2759 get_user_ualx(sockfd, arg1, 0); 2760 get_user_ualx(how, arg1, 1); 2761 2762 qemu_log("shutdown("); 2763 print_sockfd(sockfd, 0); 2764 switch (how) { 2765 case SHUT_RD: 2766 qemu_log("SHUT_RD"); 2767 break; 2768 case SHUT_WR: 2769 qemu_log("SHUT_WR"); 2770 break; 2771 case SHUT_RDWR: 2772 qemu_log("SHUT_RDWR"); 2773 break; 2774 default: 2775 print_raw_param(TARGET_ABI_FMT_ld, how, 1); 2776 break; 2777 } 2778 qemu_log(")"); 2779 } 2780 2781 static void do_print_msg(const char *name, abi_long arg1) 2782 { 2783 abi_ulong sockfd, msg, flags; 2784 2785 get_user_ualx(sockfd, arg1, 0); 2786 get_user_ualx(msg, arg1, 1); 2787 get_user_ualx(flags, arg1, 2); 2788 2789 qemu_log("%s(", name); 2790 print_sockfd(sockfd, 0); 2791 print_pointer(msg, 0); 2792 print_flags(msg_flags, flags, 1); 2793 qemu_log(")"); 2794 } 2795 2796 static void do_print_sockopt(const char *name, abi_long arg1) 2797 { 2798 abi_ulong sockfd, level, optname, optval, optlen; 2799 2800 get_user_ualx(sockfd, arg1, 0); 2801 get_user_ualx(level, arg1, 1); 2802 get_user_ualx(optname, arg1, 2); 2803 get_user_ualx(optval, arg1, 3); 2804 get_user_ualx(optlen, arg1, 4); 2805 2806 qemu_log("%s(", name); 2807 print_sockfd(sockfd, 0); 2808 switch (level) { 2809 case SOL_TCP: 2810 qemu_log("SOL_TCP,"); 2811 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 2812 print_pointer(optval, 0); 2813 break; 2814 case SOL_UDP: 2815 qemu_log("SOL_UDP,"); 2816 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 2817 print_pointer(optval, 0); 2818 break; 2819 case SOL_IP: 2820 qemu_log("SOL_IP,"); 2821 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 2822 print_pointer(optval, 0); 2823 break; 2824 case SOL_RAW: 2825 qemu_log("SOL_RAW,"); 2826 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 2827 print_pointer(optval, 0); 2828 break; 2829 case TARGET_SOL_SOCKET: 2830 qemu_log("SOL_SOCKET,"); 2831 switch (optname) { 2832 case TARGET_SO_DEBUG: 2833 qemu_log("SO_DEBUG,"); 2834 print_optint: 2835 print_number(optval, 0); 2836 break; 2837 case TARGET_SO_REUSEADDR: 2838 qemu_log("SO_REUSEADDR,"); 2839 goto print_optint; 2840 case TARGET_SO_REUSEPORT: 2841 qemu_log("SO_REUSEPORT,"); 2842 goto print_optint; 2843 case TARGET_SO_TYPE: 2844 qemu_log("SO_TYPE,"); 2845 goto print_optint; 2846 case TARGET_SO_ERROR: 2847 qemu_log("SO_ERROR,"); 2848 goto print_optint; 2849 case TARGET_SO_DONTROUTE: 2850 qemu_log("SO_DONTROUTE,"); 2851 goto print_optint; 2852 case TARGET_SO_BROADCAST: 2853 qemu_log("SO_BROADCAST,"); 2854 goto print_optint; 2855 case TARGET_SO_SNDBUF: 2856 qemu_log("SO_SNDBUF,"); 2857 goto print_optint; 2858 case TARGET_SO_RCVBUF: 2859 qemu_log("SO_RCVBUF,"); 2860 goto print_optint; 2861 case TARGET_SO_KEEPALIVE: 2862 qemu_log("SO_KEEPALIVE,"); 2863 goto print_optint; 2864 case TARGET_SO_OOBINLINE: 2865 qemu_log("SO_OOBINLINE,"); 2866 goto print_optint; 2867 case TARGET_SO_NO_CHECK: 2868 qemu_log("SO_NO_CHECK,"); 2869 goto print_optint; 2870 case TARGET_SO_PRIORITY: 2871 qemu_log("SO_PRIORITY,"); 2872 goto print_optint; 2873 case TARGET_SO_BSDCOMPAT: 2874 qemu_log("SO_BSDCOMPAT,"); 2875 goto print_optint; 2876 case TARGET_SO_PASSCRED: 2877 qemu_log("SO_PASSCRED,"); 2878 goto print_optint; 2879 case TARGET_SO_TIMESTAMP: 2880 qemu_log("SO_TIMESTAMP,"); 2881 goto print_optint; 2882 case TARGET_SO_RCVLOWAT: 2883 qemu_log("SO_RCVLOWAT,"); 2884 goto print_optint; 2885 case TARGET_SO_RCVTIMEO: 2886 qemu_log("SO_RCVTIMEO,"); 2887 print_timeval(optval, 0); 2888 break; 2889 case TARGET_SO_SNDTIMEO: 2890 qemu_log("SO_SNDTIMEO,"); 2891 print_timeval(optval, 0); 2892 break; 2893 case TARGET_SO_ATTACH_FILTER: { 2894 struct target_sock_fprog *fprog; 2895 2896 qemu_log("SO_ATTACH_FILTER,"); 2897 2898 if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) { 2899 struct target_sock_filter *filter; 2900 qemu_log("{"); 2901 if (lock_user_struct(VERIFY_READ, filter, 2902 tswapal(fprog->filter), 0)) { 2903 int i; 2904 for (i = 0; i < tswap16(fprog->len) - 1; i++) { 2905 qemu_log("[%d]{0x%x,%d,%d,0x%x},", 2906 i, tswap16(filter[i].code), 2907 filter[i].jt, filter[i].jf, 2908 tswap32(filter[i].k)); 2909 } 2910 qemu_log("[%d]{0x%x,%d,%d,0x%x}", 2911 i, tswap16(filter[i].code), 2912 filter[i].jt, filter[i].jf, 2913 tswap32(filter[i].k)); 2914 } else { 2915 qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter)); 2916 } 2917 qemu_log(",%d},", tswap16(fprog->len)); 2918 unlock_user(fprog, optval, 0); 2919 } else { 2920 print_pointer(optval, 0); 2921 } 2922 break; 2923 } 2924 default: 2925 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 2926 print_pointer(optval, 0); 2927 break; 2928 } 2929 break; 2930 case SOL_IPV6: 2931 qemu_log("SOL_IPV6,"); 2932 switch (optname) { 2933 case IPV6_MTU_DISCOVER: 2934 qemu_log("IPV6_MTU_DISCOVER,"); 2935 goto print_optint; 2936 case IPV6_MTU: 2937 qemu_log("IPV6_MTU,"); 2938 goto print_optint; 2939 case IPV6_V6ONLY: 2940 qemu_log("IPV6_V6ONLY,"); 2941 goto print_optint; 2942 case IPV6_RECVPKTINFO: 2943 qemu_log("IPV6_RECVPKTINFO,"); 2944 goto print_optint; 2945 case IPV6_UNICAST_HOPS: 2946 qemu_log("IPV6_UNICAST_HOPS,"); 2947 goto print_optint; 2948 case IPV6_MULTICAST_HOPS: 2949 qemu_log("IPV6_MULTICAST_HOPS,"); 2950 goto print_optint; 2951 case IPV6_MULTICAST_LOOP: 2952 qemu_log("IPV6_MULTICAST_LOOP,"); 2953 goto print_optint; 2954 case IPV6_RECVERR: 2955 qemu_log("IPV6_RECVERR,"); 2956 goto print_optint; 2957 case IPV6_RECVHOPLIMIT: 2958 qemu_log("IPV6_RECVHOPLIMIT,"); 2959 goto print_optint; 2960 case IPV6_2292HOPLIMIT: 2961 qemu_log("IPV6_2292HOPLIMIT,"); 2962 goto print_optint; 2963 case IPV6_CHECKSUM: 2964 qemu_log("IPV6_CHECKSUM,"); 2965 goto print_optint; 2966 case IPV6_ADDRFORM: 2967 qemu_log("IPV6_ADDRFORM,"); 2968 goto print_optint; 2969 case IPV6_2292PKTINFO: 2970 qemu_log("IPV6_2292PKTINFO,"); 2971 goto print_optint; 2972 case IPV6_RECVTCLASS: 2973 qemu_log("IPV6_RECVTCLASS,"); 2974 goto print_optint; 2975 case IPV6_RECVRTHDR: 2976 qemu_log("IPV6_RECVRTHDR,"); 2977 goto print_optint; 2978 case IPV6_2292RTHDR: 2979 qemu_log("IPV6_2292RTHDR,"); 2980 goto print_optint; 2981 case IPV6_RECVHOPOPTS: 2982 qemu_log("IPV6_RECVHOPOPTS,"); 2983 goto print_optint; 2984 case IPV6_2292HOPOPTS: 2985 qemu_log("IPV6_2292HOPOPTS,"); 2986 goto print_optint; 2987 case IPV6_RECVDSTOPTS: 2988 qemu_log("IPV6_RECVDSTOPTS,"); 2989 goto print_optint; 2990 case IPV6_2292DSTOPTS: 2991 qemu_log("IPV6_2292DSTOPTS,"); 2992 goto print_optint; 2993 case IPV6_TCLASS: 2994 qemu_log("IPV6_TCLASS,"); 2995 goto print_optint; 2996 case IPV6_ADDR_PREFERENCES: 2997 qemu_log("IPV6_ADDR_PREFERENCES,"); 2998 goto print_optint; 2999 #ifdef IPV6_RECVPATHMTU 3000 case IPV6_RECVPATHMTU: 3001 qemu_log("IPV6_RECVPATHMTU,"); 3002 goto print_optint; 3003 #endif 3004 #ifdef IPV6_TRANSPARENT 3005 case IPV6_TRANSPARENT: 3006 qemu_log("IPV6_TRANSPARENT,"); 3007 goto print_optint; 3008 #endif 3009 #ifdef IPV6_FREEBIND 3010 case IPV6_FREEBIND: 3011 qemu_log("IPV6_FREEBIND,"); 3012 goto print_optint; 3013 #endif 3014 #ifdef IPV6_RECVORIGDSTADDR 3015 case IPV6_RECVORIGDSTADDR: 3016 qemu_log("IPV6_RECVORIGDSTADDR,"); 3017 goto print_optint; 3018 #endif 3019 case IPV6_PKTINFO: 3020 qemu_log("IPV6_PKTINFO,"); 3021 print_pointer(optval, 0); 3022 break; 3023 case IPV6_ADD_MEMBERSHIP: 3024 qemu_log("IPV6_ADD_MEMBERSHIP,"); 3025 print_pointer(optval, 0); 3026 break; 3027 case IPV6_DROP_MEMBERSHIP: 3028 qemu_log("IPV6_DROP_MEMBERSHIP,"); 3029 print_pointer(optval, 0); 3030 break; 3031 default: 3032 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 3033 print_pointer(optval, 0); 3034 break; 3035 } 3036 break; 3037 default: 3038 print_raw_param(TARGET_ABI_FMT_ld, level, 0); 3039 print_raw_param(TARGET_ABI_FMT_ld, optname, 0); 3040 print_pointer(optval, 0); 3041 break; 3042 } 3043 print_raw_param(TARGET_ABI_FMT_ld, optlen, 1); 3044 qemu_log(")"); 3045 } 3046 3047 #define PRINT_SOCKOP(name, func) \ 3048 [TARGET_SYS_##name] = { #name, func } 3049 3050 static struct { 3051 const char *name; 3052 void (*print)(const char *, abi_long); 3053 } scall[] = { 3054 PRINT_SOCKOP(SOCKET, do_print_socket), 3055 PRINT_SOCKOP(BIND, do_print_sockaddr), 3056 PRINT_SOCKOP(CONNECT, do_print_sockaddr), 3057 PRINT_SOCKOP(LISTEN, do_print_listen), 3058 PRINT_SOCKOP(ACCEPT, do_print_sockaddr), 3059 PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr), 3060 PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr), 3061 PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair), 3062 PRINT_SOCKOP(SEND, do_print_sendrecv), 3063 PRINT_SOCKOP(RECV, do_print_sendrecv), 3064 PRINT_SOCKOP(SENDTO, do_print_msgaddr), 3065 PRINT_SOCKOP(RECVFROM, do_print_msgaddr), 3066 PRINT_SOCKOP(SHUTDOWN, do_print_shutdown), 3067 PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt), 3068 PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt), 3069 PRINT_SOCKOP(SENDMSG, do_print_msg), 3070 PRINT_SOCKOP(RECVMSG, do_print_msg), 3071 PRINT_SOCKOP(ACCEPT4, NULL), 3072 PRINT_SOCKOP(RECVMMSG, NULL), 3073 PRINT_SOCKOP(SENDMMSG, NULL), 3074 }; 3075 3076 static void 3077 print_socketcall(CPUArchState *cpu_env, const struct syscallname *name, 3078 abi_long arg0, abi_long arg1, abi_long arg2, 3079 abi_long arg3, abi_long arg4, abi_long arg5) 3080 { 3081 if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) { 3082 scall[arg0].print(scall[arg0].name, arg1); 3083 return; 3084 } 3085 print_syscall_prologue(name); 3086 print_raw_param(TARGET_ABI_FMT_ld, arg0, 0); 3087 print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); 3088 print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); 3089 print_raw_param(TARGET_ABI_FMT_ld, arg3, 0); 3090 print_raw_param(TARGET_ABI_FMT_ld, arg4, 0); 3091 print_raw_param(TARGET_ABI_FMT_ld, arg5, 0); 3092 print_syscall_epilogue(name); 3093 } 3094 #endif 3095 3096 #if defined(TARGET_NR_bind) 3097 static void 3098 print_bind(CPUArchState *cpu_env, const struct syscallname *name, 3099 abi_long arg0, abi_long arg1, abi_long arg2, 3100 abi_long arg3, abi_long arg4, abi_long arg5) 3101 { 3102 print_syscall_prologue(name); 3103 print_sockfd(arg0, 0); 3104 print_sockaddr(arg1, arg2, 1); 3105 print_syscall_epilogue(name); 3106 } 3107 #endif 3108 3109 #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ 3110 defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) 3111 static void 3112 print_stat(CPUArchState *cpu_env, const struct syscallname *name, 3113 abi_long arg0, abi_long arg1, abi_long arg2, 3114 abi_long arg3, abi_long arg4, abi_long arg5) 3115 { 3116 print_syscall_prologue(name); 3117 print_string(arg0, 0); 3118 print_pointer(arg1, 1); 3119 print_syscall_epilogue(name); 3120 } 3121 #define print_lstat print_stat 3122 #define print_stat64 print_stat 3123 #define print_lstat64 print_stat 3124 #endif 3125 3126 #if defined(TARGET_NR_madvise) 3127 static struct enums madvise_advice[] = { 3128 ENUM_TARGET(MADV_NORMAL), 3129 ENUM_TARGET(MADV_RANDOM), 3130 ENUM_TARGET(MADV_SEQUENTIAL), 3131 ENUM_TARGET(MADV_WILLNEED), 3132 ENUM_TARGET(MADV_DONTNEED), 3133 ENUM_TARGET(MADV_FREE), 3134 ENUM_TARGET(MADV_REMOVE), 3135 ENUM_TARGET(MADV_DONTFORK), 3136 ENUM_TARGET(MADV_DOFORK), 3137 ENUM_TARGET(MADV_MERGEABLE), 3138 ENUM_TARGET(MADV_UNMERGEABLE), 3139 ENUM_TARGET(MADV_HUGEPAGE), 3140 ENUM_TARGET(MADV_NOHUGEPAGE), 3141 ENUM_TARGET(MADV_DONTDUMP), 3142 ENUM_TARGET(MADV_DODUMP), 3143 ENUM_TARGET(MADV_WIPEONFORK), 3144 ENUM_TARGET(MADV_KEEPONFORK), 3145 ENUM_TARGET(MADV_COLD), 3146 ENUM_TARGET(MADV_PAGEOUT), 3147 ENUM_TARGET(MADV_POPULATE_READ), 3148 ENUM_TARGET(MADV_POPULATE_WRITE), 3149 ENUM_TARGET(MADV_DONTNEED_LOCKED), 3150 ENUM_END, 3151 }; 3152 3153 static void 3154 print_madvise(CPUArchState *cpu_env, const struct syscallname *name, 3155 abi_long arg0, abi_long arg1, abi_long arg2, 3156 abi_long arg3, abi_long arg4, abi_long arg5) 3157 { 3158 print_syscall_prologue(name); 3159 print_pointer(arg0, 0); 3160 print_raw_param("%d", arg1, 0); 3161 print_enums(madvise_advice, arg2, 1); 3162 print_syscall_epilogue(name); 3163 } 3164 #endif 3165 3166 #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) 3167 static void 3168 print_fstat(CPUArchState *cpu_env, const struct syscallname *name, 3169 abi_long arg0, abi_long arg1, abi_long arg2, 3170 abi_long arg3, abi_long arg4, abi_long arg5) 3171 { 3172 print_syscall_prologue(name); 3173 print_raw_param("%d", arg0, 0); 3174 print_pointer(arg1, 1); 3175 print_syscall_epilogue(name); 3176 } 3177 #define print_fstat64 print_fstat 3178 #endif 3179 3180 #ifdef TARGET_NR_mkdir 3181 static void 3182 print_mkdir(CPUArchState *cpu_env, const struct syscallname *name, 3183 abi_long arg0, abi_long arg1, abi_long arg2, 3184 abi_long arg3, abi_long arg4, abi_long arg5) 3185 { 3186 print_syscall_prologue(name); 3187 print_string(arg0, 0); 3188 print_file_mode(arg1, 1); 3189 print_syscall_epilogue(name); 3190 } 3191 #endif 3192 3193 #ifdef TARGET_NR_mkdirat 3194 static void 3195 print_mkdirat(CPUArchState *cpu_env, const struct syscallname *name, 3196 abi_long arg0, abi_long arg1, abi_long arg2, 3197 abi_long arg3, abi_long arg4, abi_long arg5) 3198 { 3199 print_syscall_prologue(name); 3200 print_at_dirfd(arg0, 0); 3201 print_string(arg1, 0); 3202 print_file_mode(arg2, 1); 3203 print_syscall_epilogue(name); 3204 } 3205 #endif 3206 3207 #ifdef TARGET_NR_rmdir 3208 static void 3209 print_rmdir(CPUArchState *cpu_env, const struct syscallname *name, 3210 abi_long arg0, abi_long arg1, abi_long arg2, 3211 abi_long arg3, abi_long arg4, abi_long arg5) 3212 { 3213 print_syscall_prologue(name); 3214 print_string(arg0, 0); 3215 print_syscall_epilogue(name); 3216 } 3217 #endif 3218 3219 #ifdef TARGET_NR_rt_sigaction 3220 static void 3221 print_rt_sigaction(CPUArchState *cpu_env, const struct syscallname *name, 3222 abi_long arg0, abi_long arg1, abi_long arg2, 3223 abi_long arg3, abi_long arg4, abi_long arg5) 3224 { 3225 print_syscall_prologue(name); 3226 print_signal(arg0, 0); 3227 print_pointer(arg1, 0); 3228 print_pointer(arg2, 1); 3229 print_syscall_epilogue(name); 3230 } 3231 #endif 3232 3233 #ifdef TARGET_NR_rt_sigprocmask 3234 static void 3235 print_rt_sigprocmask(CPUArchState *cpu_env, const struct syscallname *name, 3236 abi_long arg0, abi_long arg1, abi_long arg2, 3237 abi_long arg3, abi_long arg4, abi_long arg5) 3238 { 3239 const char *how = "UNKNOWN"; 3240 print_syscall_prologue(name); 3241 switch(arg0) { 3242 case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break; 3243 case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; 3244 case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; 3245 } 3246 qemu_log("%s,", how); 3247 print_pointer(arg1, 0); 3248 print_pointer(arg2, 0); 3249 print_raw_param("%u", arg3, 1); 3250 print_syscall_epilogue(name); 3251 } 3252 #endif 3253 3254 #ifdef TARGET_NR_rt_sigqueueinfo 3255 static void 3256 print_rt_sigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name, 3257 abi_long arg0, abi_long arg1, abi_long arg2, 3258 abi_long arg3, abi_long arg4, abi_long arg5) 3259 { 3260 void *p; 3261 target_siginfo_t uinfo; 3262 3263 print_syscall_prologue(name); 3264 print_raw_param("%d", arg0, 0); 3265 print_signal(arg1, 0); 3266 p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1); 3267 if (p) { 3268 get_target_siginfo(&uinfo, p); 3269 print_siginfo(&uinfo); 3270 3271 unlock_user(p, arg2, 0); 3272 } else { 3273 print_pointer(arg2, 1); 3274 } 3275 print_syscall_epilogue(name); 3276 } 3277 #endif 3278 3279 #ifdef TARGET_NR_rt_tgsigqueueinfo 3280 static void 3281 print_rt_tgsigqueueinfo(CPUArchState *cpu_env, const struct syscallname *name, 3282 abi_long arg0, abi_long arg1, abi_long arg2, 3283 abi_long arg3, abi_long arg4, abi_long arg5) 3284 { 3285 void *p; 3286 target_siginfo_t uinfo; 3287 3288 print_syscall_prologue(name); 3289 print_raw_param("%d", arg0, 0); 3290 print_raw_param("%d", arg1, 0); 3291 print_signal(arg2, 0); 3292 p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); 3293 if (p) { 3294 get_target_siginfo(&uinfo, p); 3295 print_siginfo(&uinfo); 3296 3297 unlock_user(p, arg3, 0); 3298 } else { 3299 print_pointer(arg3, 1); 3300 } 3301 print_syscall_epilogue(name); 3302 } 3303 #endif 3304 3305 #ifdef TARGET_NR_syslog 3306 static void 3307 print_syslog_action(abi_ulong arg, int last) 3308 { 3309 const char *type; 3310 3311 switch (arg) { 3312 case TARGET_SYSLOG_ACTION_CLOSE: { 3313 type = "SYSLOG_ACTION_CLOSE"; 3314 break; 3315 } 3316 case TARGET_SYSLOG_ACTION_OPEN: { 3317 type = "SYSLOG_ACTION_OPEN"; 3318 break; 3319 } 3320 case TARGET_SYSLOG_ACTION_READ: { 3321 type = "SYSLOG_ACTION_READ"; 3322 break; 3323 } 3324 case TARGET_SYSLOG_ACTION_READ_ALL: { 3325 type = "SYSLOG_ACTION_READ_ALL"; 3326 break; 3327 } 3328 case TARGET_SYSLOG_ACTION_READ_CLEAR: { 3329 type = "SYSLOG_ACTION_READ_CLEAR"; 3330 break; 3331 } 3332 case TARGET_SYSLOG_ACTION_CLEAR: { 3333 type = "SYSLOG_ACTION_CLEAR"; 3334 break; 3335 } 3336 case TARGET_SYSLOG_ACTION_CONSOLE_OFF: { 3337 type = "SYSLOG_ACTION_CONSOLE_OFF"; 3338 break; 3339 } 3340 case TARGET_SYSLOG_ACTION_CONSOLE_ON: { 3341 type = "SYSLOG_ACTION_CONSOLE_ON"; 3342 break; 3343 } 3344 case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: { 3345 type = "SYSLOG_ACTION_CONSOLE_LEVEL"; 3346 break; 3347 } 3348 case TARGET_SYSLOG_ACTION_SIZE_UNREAD: { 3349 type = "SYSLOG_ACTION_SIZE_UNREAD"; 3350 break; 3351 } 3352 case TARGET_SYSLOG_ACTION_SIZE_BUFFER: { 3353 type = "SYSLOG_ACTION_SIZE_BUFFER"; 3354 break; 3355 } 3356 default: { 3357 print_raw_param("%ld", arg, last); 3358 return; 3359 } 3360 } 3361 qemu_log("%s%s", type, get_comma(last)); 3362 } 3363 3364 static void 3365 print_syslog(CPUArchState *cpu_env, const struct syscallname *name, 3366 abi_long arg0, abi_long arg1, abi_long arg2, 3367 abi_long arg3, abi_long arg4, abi_long arg5) 3368 { 3369 print_syscall_prologue(name); 3370 print_syslog_action(arg0, 0); 3371 print_pointer(arg1, 0); 3372 print_raw_param("%d", arg2, 1); 3373 print_syscall_epilogue(name); 3374 } 3375 #endif 3376 3377 #ifdef TARGET_NR_mknod 3378 static void 3379 print_mknod(CPUArchState *cpu_env, const struct syscallname *name, 3380 abi_long arg0, abi_long arg1, abi_long arg2, 3381 abi_long arg3, abi_long arg4, abi_long arg5) 3382 { 3383 int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); 3384 3385 print_syscall_prologue(name); 3386 print_string(arg0, 0); 3387 print_file_mode(arg1, (hasdev == 0)); 3388 if (hasdev) { 3389 print_raw_param("makedev(%d", major(arg2), 0); 3390 print_raw_param("%d)", minor(arg2), 1); 3391 } 3392 print_syscall_epilogue(name); 3393 } 3394 #endif 3395 3396 #ifdef TARGET_NR_mknodat 3397 static void 3398 print_mknodat(CPUArchState *cpu_env, const struct syscallname *name, 3399 abi_long arg0, abi_long arg1, abi_long arg2, 3400 abi_long arg3, abi_long arg4, abi_long arg5) 3401 { 3402 int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); 3403 3404 print_syscall_prologue(name); 3405 print_at_dirfd(arg0, 0); 3406 print_string(arg1, 0); 3407 print_file_mode(arg2, (hasdev == 0)); 3408 if (hasdev) { 3409 print_raw_param("makedev(%d", major(arg3), 0); 3410 print_raw_param("%d)", minor(arg3), 1); 3411 } 3412 print_syscall_epilogue(name); 3413 } 3414 #endif 3415 3416 #ifdef TARGET_NR_mq_open 3417 static void 3418 print_mq_open(CPUArchState *cpu_env, const struct syscallname *name, 3419 abi_long arg0, abi_long arg1, abi_long arg2, 3420 abi_long arg3, abi_long arg4, abi_long arg5) 3421 { 3422 int is_creat = (arg1 & TARGET_O_CREAT); 3423 3424 print_syscall_prologue(name); 3425 print_string(arg0, 0); 3426 print_open_flags(arg1, (is_creat == 0)); 3427 if (is_creat) { 3428 print_file_mode(arg2, 0); 3429 print_pointer(arg3, 1); 3430 } 3431 print_syscall_epilogue(name); 3432 } 3433 #endif 3434 3435 #ifdef TARGET_NR_open 3436 static void 3437 print_open(CPUArchState *cpu_env, const struct syscallname *name, 3438 abi_long arg0, abi_long arg1, abi_long arg2, 3439 abi_long arg3, abi_long arg4, abi_long arg5) 3440 { 3441 int is_creat = (arg1 & TARGET_O_CREAT); 3442 3443 print_syscall_prologue(name); 3444 print_string(arg0, 0); 3445 print_open_flags(arg1, (is_creat == 0)); 3446 if (is_creat) 3447 print_file_mode(arg2, 1); 3448 print_syscall_epilogue(name); 3449 } 3450 #endif 3451 3452 #ifdef TARGET_NR_openat 3453 static void 3454 print_openat(CPUArchState *cpu_env, const struct syscallname *name, 3455 abi_long arg0, abi_long arg1, abi_long arg2, 3456 abi_long arg3, abi_long arg4, abi_long arg5) 3457 { 3458 int is_creat = (arg2 & TARGET_O_CREAT); 3459 3460 print_syscall_prologue(name); 3461 print_at_dirfd(arg0, 0); 3462 print_string(arg1, 0); 3463 print_open_flags(arg2, (is_creat == 0)); 3464 if (is_creat) 3465 print_file_mode(arg3, 1); 3466 print_syscall_epilogue(name); 3467 } 3468 #endif 3469 3470 #ifdef TARGET_NR_pidfd_send_signal 3471 static void 3472 print_pidfd_send_signal(CPUArchState *cpu_env, const struct syscallname *name, 3473 abi_long arg0, abi_long arg1, abi_long arg2, 3474 abi_long arg3, abi_long arg4, abi_long arg5) 3475 { 3476 void *p; 3477 target_siginfo_t uinfo; 3478 3479 print_syscall_prologue(name); 3480 print_raw_param("%d", arg0, 0); 3481 print_signal(arg1, 0); 3482 3483 p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1); 3484 if (p) { 3485 get_target_siginfo(&uinfo, p); 3486 print_siginfo(&uinfo); 3487 3488 unlock_user(p, arg2, 0); 3489 } else { 3490 print_pointer(arg2, 0); 3491 } 3492 3493 print_raw_param("%u", arg3, 1); 3494 print_syscall_epilogue(name); 3495 } 3496 #endif 3497 3498 #ifdef TARGET_NR_mq_unlink 3499 static void 3500 print_mq_unlink(CPUArchState *cpu_env, const struct syscallname *name, 3501 abi_long arg0, abi_long arg1, abi_long arg2, 3502 abi_long arg3, abi_long arg4, abi_long arg5) 3503 { 3504 print_syscall_prologue(name); 3505 print_string(arg0, 1); 3506 print_syscall_epilogue(name); 3507 } 3508 #endif 3509 3510 #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) 3511 static void 3512 print_fstatat64(CPUArchState *cpu_env, const struct syscallname *name, 3513 abi_long arg0, abi_long arg1, abi_long arg2, 3514 abi_long arg3, abi_long arg4, abi_long arg5) 3515 { 3516 print_syscall_prologue(name); 3517 print_at_dirfd(arg0, 0); 3518 print_string(arg1, 0); 3519 print_pointer(arg2, 0); 3520 print_flags(at_file_flags, arg3, 1); 3521 print_syscall_epilogue(name); 3522 } 3523 #define print_newfstatat print_fstatat64 3524 #endif 3525 3526 #ifdef TARGET_NR_readlink 3527 static void 3528 print_readlink(CPUArchState *cpu_env, const struct syscallname *name, 3529 abi_long arg0, abi_long arg1, abi_long arg2, 3530 abi_long arg3, abi_long arg4, abi_long arg5) 3531 { 3532 print_syscall_prologue(name); 3533 print_string(arg0, 0); 3534 print_pointer(arg1, 0); 3535 print_raw_param("%u", arg2, 1); 3536 print_syscall_epilogue(name); 3537 } 3538 #endif 3539 3540 #ifdef TARGET_NR_readlinkat 3541 static void 3542 print_readlinkat(CPUArchState *cpu_env, const struct syscallname *name, 3543 abi_long arg0, abi_long arg1, abi_long arg2, 3544 abi_long arg3, abi_long arg4, abi_long arg5) 3545 { 3546 print_syscall_prologue(name); 3547 print_at_dirfd(arg0, 0); 3548 print_string(arg1, 0); 3549 print_pointer(arg2, 0); 3550 print_raw_param("%u", arg3, 1); 3551 print_syscall_epilogue(name); 3552 } 3553 #endif 3554 3555 #ifdef TARGET_NR_rename 3556 static void 3557 print_rename(CPUArchState *cpu_env, const struct syscallname *name, 3558 abi_long arg0, abi_long arg1, abi_long arg2, 3559 abi_long arg3, abi_long arg4, abi_long arg5) 3560 { 3561 print_syscall_prologue(name); 3562 print_string(arg0, 0); 3563 print_string(arg1, 1); 3564 print_syscall_epilogue(name); 3565 } 3566 #endif 3567 3568 #ifdef TARGET_NR_renameat 3569 static void 3570 print_renameat(CPUArchState *cpu_env, const struct syscallname *name, 3571 abi_long arg0, abi_long arg1, abi_long arg2, 3572 abi_long arg3, abi_long arg4, abi_long arg5) 3573 { 3574 print_syscall_prologue(name); 3575 print_at_dirfd(arg0, 0); 3576 print_string(arg1, 0); 3577 print_at_dirfd(arg2, 0); 3578 print_string(arg3, 1); 3579 print_syscall_epilogue(name); 3580 } 3581 #endif 3582 3583 #ifdef TARGET_NR_statfs 3584 static void 3585 print_statfs(CPUArchState *cpu_env, const struct syscallname *name, 3586 abi_long arg0, abi_long arg1, abi_long arg2, 3587 abi_long arg3, abi_long arg4, abi_long arg5) 3588 { 3589 print_syscall_prologue(name); 3590 print_string(arg0, 0); 3591 print_pointer(arg1, 1); 3592 print_syscall_epilogue(name); 3593 } 3594 #endif 3595 3596 #ifdef TARGET_NR_statfs64 3597 static void 3598 print_statfs64(CPUArchState *cpu_env, const struct syscallname *name, 3599 abi_long arg0, abi_long arg1, abi_long arg2, 3600 abi_long arg3, abi_long arg4, abi_long arg5) 3601 { 3602 print_syscall_prologue(name); 3603 print_string(arg0, 0); 3604 print_pointer(arg1, 1); 3605 print_syscall_epilogue(name); 3606 } 3607 #endif 3608 3609 #ifdef TARGET_NR_symlink 3610 static void 3611 print_symlink(CPUArchState *cpu_env, const struct syscallname *name, 3612 abi_long arg0, abi_long arg1, abi_long arg2, 3613 abi_long arg3, abi_long arg4, abi_long arg5) 3614 { 3615 print_syscall_prologue(name); 3616 print_string(arg0, 0); 3617 print_string(arg1, 1); 3618 print_syscall_epilogue(name); 3619 } 3620 #endif 3621 3622 #ifdef TARGET_NR_symlinkat 3623 static void 3624 print_symlinkat(CPUArchState *cpu_env, const struct syscallname *name, 3625 abi_long arg0, abi_long arg1, abi_long arg2, 3626 abi_long arg3, abi_long arg4, abi_long arg5) 3627 { 3628 print_syscall_prologue(name); 3629 print_string(arg0, 0); 3630 print_at_dirfd(arg1, 0); 3631 print_string(arg2, 1); 3632 print_syscall_epilogue(name); 3633 } 3634 #endif 3635 3636 #ifdef TARGET_NR_mount 3637 static void 3638 print_mount(CPUArchState *cpu_env, const struct syscallname *name, 3639 abi_long arg0, abi_long arg1, abi_long arg2, 3640 abi_long arg3, abi_long arg4, abi_long arg5) 3641 { 3642 print_syscall_prologue(name); 3643 print_string(arg0, 0); 3644 print_string(arg1, 0); 3645 print_string(arg2, 0); 3646 print_flags(mount_flags, arg3, 0); 3647 print_pointer(arg4, 1); 3648 print_syscall_epilogue(name); 3649 } 3650 #endif 3651 3652 #ifdef TARGET_NR_umount 3653 static void 3654 print_umount(CPUArchState *cpu_env, const struct syscallname *name, 3655 abi_long arg0, abi_long arg1, abi_long arg2, 3656 abi_long arg3, abi_long arg4, abi_long arg5) 3657 { 3658 print_syscall_prologue(name); 3659 print_string(arg0, 1); 3660 print_syscall_epilogue(name); 3661 } 3662 #endif 3663 3664 #ifdef TARGET_NR_umount2 3665 static void 3666 print_umount2(CPUArchState *cpu_env, const struct syscallname *name, 3667 abi_long arg0, abi_long arg1, abi_long arg2, 3668 abi_long arg3, abi_long arg4, abi_long arg5) 3669 { 3670 print_syscall_prologue(name); 3671 print_string(arg0, 0); 3672 print_flags(umount2_flags, arg1, 1); 3673 print_syscall_epilogue(name); 3674 } 3675 #endif 3676 3677 #ifdef TARGET_NR_unlink 3678 static void 3679 print_unlink(CPUArchState *cpu_env, const struct syscallname *name, 3680 abi_long arg0, abi_long arg1, abi_long arg2, 3681 abi_long arg3, abi_long arg4, abi_long arg5) 3682 { 3683 print_syscall_prologue(name); 3684 print_string(arg0, 1); 3685 print_syscall_epilogue(name); 3686 } 3687 #endif 3688 3689 #ifdef TARGET_NR_unlinkat 3690 static void 3691 print_unlinkat(CPUArchState *cpu_env, const struct syscallname *name, 3692 abi_long arg0, abi_long arg1, abi_long arg2, 3693 abi_long arg3, abi_long arg4, abi_long arg5) 3694 { 3695 print_syscall_prologue(name); 3696 print_at_dirfd(arg0, 0); 3697 print_string(arg1, 0); 3698 print_flags(unlinkat_flags, arg2, 1); 3699 print_syscall_epilogue(name); 3700 } 3701 #endif 3702 3703 #ifdef TARGET_NR_unshare 3704 static void 3705 print_unshare(CPUArchState *cpu_env, const struct syscallname *name, 3706 abi_long arg0, abi_long arg1, abi_long arg2, 3707 abi_long arg3, abi_long arg4, abi_long arg5) 3708 { 3709 print_syscall_prologue(name); 3710 print_flags(clone_flags, arg0, 1); 3711 print_syscall_epilogue(name); 3712 } 3713 #endif 3714 3715 #ifdef TARGET_NR_clock_nanosleep 3716 static void 3717 print_clock_nanosleep(CPUArchState *cpu_env, const struct syscallname *name, 3718 abi_long arg0, abi_long arg1, abi_long arg2, 3719 abi_long arg3, abi_long arg4, abi_long arg5) 3720 { 3721 print_syscall_prologue(name); 3722 print_enums(clockids, arg0, 0); 3723 print_raw_param("%d", arg1, 0); 3724 print_timespec(arg2, 0); 3725 print_timespec(arg3, 1); 3726 print_syscall_epilogue(name); 3727 } 3728 #endif 3729 3730 #ifdef TARGET_NR_utime 3731 static void 3732 print_utime(CPUArchState *cpu_env, const struct syscallname *name, 3733 abi_long arg0, abi_long arg1, abi_long arg2, 3734 abi_long arg3, abi_long arg4, abi_long arg5) 3735 { 3736 print_syscall_prologue(name); 3737 print_string(arg0, 0); 3738 print_pointer(arg1, 1); 3739 print_syscall_epilogue(name); 3740 } 3741 #endif 3742 3743 #ifdef TARGET_NR_utimes 3744 static void 3745 print_utimes(CPUArchState *cpu_env, const struct syscallname *name, 3746 abi_long arg0, abi_long arg1, abi_long arg2, 3747 abi_long arg3, abi_long arg4, abi_long arg5) 3748 { 3749 print_syscall_prologue(name); 3750 print_string(arg0, 0); 3751 print_pointer(arg1, 1); 3752 print_syscall_epilogue(name); 3753 } 3754 #endif 3755 3756 #ifdef TARGET_NR_utimensat 3757 static void 3758 print_utimensat(CPUArchState *cpu_env, const struct syscallname *name, 3759 abi_long arg0, abi_long arg1, abi_long arg2, 3760 abi_long arg3, abi_long arg4, abi_long arg5) 3761 { 3762 print_syscall_prologue(name); 3763 print_at_dirfd(arg0, 0); 3764 print_string(arg1, 0); 3765 print_pointer(arg2, 0); 3766 print_flags(at_file_flags, arg3, 1); 3767 print_syscall_epilogue(name); 3768 } 3769 #endif 3770 3771 #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) 3772 static void 3773 print_mmap(CPUArchState *cpu_env, const struct syscallname *name, 3774 abi_long arg0, abi_long arg1, abi_long arg2, 3775 abi_long arg3, abi_long arg4, abi_long arg5) 3776 { 3777 print_syscall_prologue(name); 3778 print_pointer(arg0, 0); 3779 print_raw_param("%d", arg1, 0); 3780 print_flags(mmap_prot_flags, arg2, 0); 3781 print_flags(mmap_flags, arg3, 0); 3782 print_raw_param("%d", arg4, 0); 3783 print_raw_param("%#x", arg5, 1); 3784 print_syscall_epilogue(name); 3785 } 3786 #define print_mmap2 print_mmap 3787 #endif 3788 3789 #ifdef TARGET_NR_mprotect 3790 static void 3791 print_mprotect(CPUArchState *cpu_env, const struct syscallname *name, 3792 abi_long arg0, abi_long arg1, abi_long arg2, 3793 abi_long arg3, abi_long arg4, abi_long arg5) 3794 { 3795 print_syscall_prologue(name); 3796 print_pointer(arg0, 0); 3797 print_raw_param("%d", arg1, 0); 3798 print_flags(mmap_prot_flags, arg2, 1); 3799 print_syscall_epilogue(name); 3800 } 3801 #endif 3802 3803 #ifdef TARGET_NR_munmap 3804 static void 3805 print_munmap(CPUArchState *cpu_env, const struct syscallname *name, 3806 abi_long arg0, abi_long arg1, abi_long arg2, 3807 abi_long arg3, abi_long arg4, abi_long arg5) 3808 { 3809 print_syscall_prologue(name); 3810 print_pointer(arg0, 0); 3811 print_raw_param("%d", arg1, 1); 3812 print_syscall_epilogue(name); 3813 } 3814 #endif 3815 3816 #ifdef TARGET_NR_futex 3817 static void print_futex_op(int cmd, int last) 3818 { 3819 static const char * const futex_names[] = { 3820 #define NAME(X) [X] = #X 3821 NAME(FUTEX_WAIT), 3822 NAME(FUTEX_WAKE), 3823 NAME(FUTEX_FD), 3824 NAME(FUTEX_REQUEUE), 3825 NAME(FUTEX_CMP_REQUEUE), 3826 NAME(FUTEX_WAKE_OP), 3827 NAME(FUTEX_LOCK_PI), 3828 NAME(FUTEX_UNLOCK_PI), 3829 NAME(FUTEX_TRYLOCK_PI), 3830 NAME(FUTEX_WAIT_BITSET), 3831 NAME(FUTEX_WAKE_BITSET), 3832 NAME(FUTEX_WAIT_REQUEUE_PI), 3833 NAME(FUTEX_CMP_REQUEUE_PI), 3834 NAME(FUTEX_LOCK_PI2), 3835 #undef NAME 3836 }; 3837 3838 unsigned base_cmd = cmd & FUTEX_CMD_MASK; 3839 3840 if (base_cmd < ARRAY_SIZE(futex_names)) { 3841 qemu_log("%s%s%s", 3842 (cmd & FUTEX_PRIVATE_FLAG ? "FUTEX_PRIVATE_FLAG|" : ""), 3843 (cmd & FUTEX_CLOCK_REALTIME ? "FUTEX_CLOCK_REALTIME|" : ""), 3844 futex_names[base_cmd]); 3845 } else { 3846 qemu_log("0x%x", cmd); 3847 } 3848 } 3849 3850 static void 3851 print_futex(CPUArchState *cpu_env, const struct syscallname *name, 3852 abi_long arg0, abi_long arg1, abi_long arg2, 3853 abi_long arg3, abi_long arg4, abi_long arg5) 3854 { 3855 abi_long op = arg1 & FUTEX_CMD_MASK; 3856 print_syscall_prologue(name); 3857 print_pointer(arg0, 0); 3858 print_futex_op(arg1, 0); 3859 print_raw_param(",%d", arg2, 0); 3860 switch (op) { 3861 case FUTEX_WAIT: 3862 case FUTEX_WAIT_BITSET: 3863 case FUTEX_LOCK_PI: 3864 case FUTEX_LOCK_PI2: 3865 case FUTEX_WAIT_REQUEUE_PI: 3866 print_timespec(arg3, 0); 3867 break; 3868 default: 3869 print_pointer(arg3, 0); 3870 break; 3871 } 3872 print_pointer(arg4, 0); 3873 print_raw_param("%d", arg4, 1); 3874 print_syscall_epilogue(name); 3875 } 3876 #endif 3877 3878 #ifdef TARGET_NR_prlimit64 3879 static const char *target_ressource_string(abi_ulong r) 3880 { 3881 #define RET_RES_ENTRY(res) case TARGET_##res: return #res; 3882 switch (r) { 3883 RET_RES_ENTRY(RLIMIT_AS); 3884 RET_RES_ENTRY(RLIMIT_CORE); 3885 RET_RES_ENTRY(RLIMIT_CPU); 3886 RET_RES_ENTRY(RLIMIT_DATA); 3887 RET_RES_ENTRY(RLIMIT_FSIZE); 3888 RET_RES_ENTRY(RLIMIT_LOCKS); 3889 RET_RES_ENTRY(RLIMIT_MEMLOCK); 3890 RET_RES_ENTRY(RLIMIT_MSGQUEUE); 3891 RET_RES_ENTRY(RLIMIT_NICE); 3892 RET_RES_ENTRY(RLIMIT_NOFILE); 3893 RET_RES_ENTRY(RLIMIT_NPROC); 3894 RET_RES_ENTRY(RLIMIT_RSS); 3895 RET_RES_ENTRY(RLIMIT_RTPRIO); 3896 #ifdef RLIMIT_RTTIME 3897 RET_RES_ENTRY(RLIMIT_RTTIME); 3898 #endif 3899 RET_RES_ENTRY(RLIMIT_SIGPENDING); 3900 RET_RES_ENTRY(RLIMIT_STACK); 3901 default: 3902 return NULL; 3903 } 3904 #undef RET_RES_ENTRY 3905 } 3906 3907 static void 3908 print_rlimit64(abi_ulong rlim_addr, int last) 3909 { 3910 if (rlim_addr) { 3911 struct target_rlimit64 *rl; 3912 3913 rl = lock_user(VERIFY_READ, rlim_addr, sizeof(*rl), 1); 3914 if (!rl) { 3915 print_pointer(rlim_addr, last); 3916 return; 3917 } 3918 print_raw_param64("{rlim_cur=%" PRId64, tswap64(rl->rlim_cur), 0); 3919 print_raw_param64("rlim_max=%" PRId64 "}", tswap64(rl->rlim_max), 3920 last); 3921 unlock_user(rl, rlim_addr, 0); 3922 } else { 3923 qemu_log("NULL%s", get_comma(last)); 3924 } 3925 } 3926 3927 static void 3928 print_prlimit64(CPUArchState *cpu_env, const struct syscallname *name, 3929 abi_long arg0, abi_long arg1, abi_long arg2, 3930 abi_long arg3, abi_long arg4, abi_long arg5) 3931 { 3932 const char *rlim_name; 3933 3934 print_syscall_prologue(name); 3935 print_raw_param("%d", arg0, 0); 3936 rlim_name = target_ressource_string(arg1); 3937 if (rlim_name) { 3938 qemu_log("%s,", rlim_name); 3939 } else { 3940 print_raw_param("%d", arg1, 0); 3941 } 3942 print_rlimit64(arg2, 0); 3943 print_pointer(arg3, 1); 3944 print_syscall_epilogue(name); 3945 } 3946 3947 static void 3948 print_syscall_ret_prlimit64(CPUArchState *cpu_env, 3949 const struct syscallname *name, 3950 abi_long ret, abi_long arg0, abi_long arg1, 3951 abi_long arg2, abi_long arg3, abi_long arg4, 3952 abi_long arg5) 3953 { 3954 if (!print_syscall_err(ret)) { 3955 qemu_log(TARGET_ABI_FMT_ld, ret); 3956 if (arg3) { 3957 qemu_log(" ("); 3958 print_rlimit64(arg3, 1); 3959 qemu_log(")"); 3960 } 3961 } 3962 qemu_log("\n"); 3963 } 3964 #endif 3965 3966 #ifdef TARGET_NR_kill 3967 static void 3968 print_kill(CPUArchState *cpu_env, const struct syscallname *name, 3969 abi_long arg0, abi_long arg1, abi_long arg2, 3970 abi_long arg3, abi_long arg4, abi_long arg5) 3971 { 3972 print_syscall_prologue(name); 3973 print_raw_param("%d", arg0, 0); 3974 print_signal(arg1, 1); 3975 print_syscall_epilogue(name); 3976 } 3977 #endif 3978 3979 #ifdef TARGET_NR_tkill 3980 static void 3981 print_tkill(CPUArchState *cpu_env, const struct syscallname *name, 3982 abi_long arg0, abi_long arg1, abi_long arg2, 3983 abi_long arg3, abi_long arg4, abi_long arg5) 3984 { 3985 print_syscall_prologue(name); 3986 print_raw_param("%d", arg0, 0); 3987 print_signal(arg1, 1); 3988 print_syscall_epilogue(name); 3989 } 3990 #endif 3991 3992 #ifdef TARGET_NR_tgkill 3993 static void 3994 print_tgkill(CPUArchState *cpu_env, const struct syscallname *name, 3995 abi_long arg0, abi_long arg1, abi_long arg2, 3996 abi_long arg3, abi_long arg4, abi_long arg5) 3997 { 3998 print_syscall_prologue(name); 3999 print_raw_param("%d", arg0, 0); 4000 print_raw_param("%d", arg1, 0); 4001 print_signal(arg2, 1); 4002 print_syscall_epilogue(name); 4003 } 4004 #endif 4005 4006 #if defined(TARGET_NR_pread64) || defined(TARGET_NR_pwrite64) 4007 static void 4008 print_pread64(CPUArchState *cpu_env, const struct syscallname *name, 4009 abi_long arg0, abi_long arg1, abi_long arg2, 4010 abi_long arg3, abi_long arg4, abi_long arg5) 4011 { 4012 if (regpairs_aligned(cpu_env, TARGET_NR_pread64)) { 4013 arg3 = arg4; 4014 arg4 = arg5; 4015 } 4016 print_syscall_prologue(name); 4017 print_raw_param("%d", arg0, 0); 4018 print_pointer(arg1, 0); 4019 print_raw_param("%d", arg2, 0); 4020 print_raw_param("%" PRIu64, target_offset64(arg3, arg4), 1); 4021 print_syscall_epilogue(name); 4022 } 4023 #endif 4024 4025 #ifdef TARGET_NR_statx 4026 static void 4027 print_statx(CPUArchState *cpu_env, const struct syscallname *name, 4028 abi_long arg0, abi_long arg1, abi_long arg2, 4029 abi_long arg3, abi_long arg4, abi_long arg5) 4030 { 4031 print_syscall_prologue(name); 4032 print_at_dirfd(arg0, 0); 4033 print_string(arg1, 0); 4034 print_flags(statx_flags, arg2, 0); 4035 print_flags(statx_mask, arg3, 0); 4036 print_pointer(arg4, 1); 4037 print_syscall_epilogue(name); 4038 } 4039 #endif 4040 4041 #ifdef TARGET_NR_ioctl 4042 static void 4043 print_ioctl(CPUArchState *cpu_env, const struct syscallname *name, 4044 abi_long arg0, abi_long arg1, abi_long arg2, 4045 abi_long arg3, abi_long arg4, abi_long arg5) 4046 { 4047 print_syscall_prologue(name); 4048 print_raw_param("%d", arg0, 0); 4049 4050 const IOCTLEntry *ie; 4051 const argtype *arg_type; 4052 void *argptr; 4053 int target_size; 4054 4055 for (ie = ioctl_entries; ie->target_cmd != 0; ie++) { 4056 if (ie->target_cmd == arg1) { 4057 break; 4058 } 4059 } 4060 4061 if (ie->target_cmd == 0) { 4062 print_raw_param("%#x", arg1, 0); 4063 print_raw_param("%#x", arg2, 1); 4064 } else { 4065 qemu_log("%s", ie->name); 4066 arg_type = ie->arg_type; 4067 4068 if (arg_type[0] != TYPE_NULL) { 4069 qemu_log(","); 4070 4071 switch (arg_type[0]) { 4072 case TYPE_PTRVOID: 4073 print_pointer(arg2, 1); 4074 break; 4075 case TYPE_CHAR: 4076 case TYPE_SHORT: 4077 case TYPE_INT: 4078 print_raw_param("%d", arg2, 1); 4079 break; 4080 case TYPE_LONG: 4081 print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); 4082 break; 4083 case TYPE_ULONG: 4084 print_raw_param(TARGET_ABI_FMT_lu, arg2, 1); 4085 break; 4086 case TYPE_PTR: 4087 switch (ie->access) { 4088 case IOC_R: 4089 print_pointer(arg2, 1); 4090 break; 4091 case IOC_W: 4092 case IOC_RW: 4093 arg_type++; 4094 target_size = thunk_type_size(arg_type, 0); 4095 argptr = lock_user(VERIFY_READ, arg2, target_size, 1); 4096 if (argptr) { 4097 thunk_print(argptr, arg_type); 4098 unlock_user(argptr, arg2, target_size); 4099 } else { 4100 print_pointer(arg2, 1); 4101 } 4102 break; 4103 } 4104 break; 4105 default: 4106 g_assert_not_reached(); 4107 } 4108 } 4109 } 4110 print_syscall_epilogue(name); 4111 } 4112 #endif 4113 4114 /* 4115 * An array of all of the syscalls we know about 4116 */ 4117 4118 static const struct syscallname scnames[] = { 4119 #include "strace.list" 4120 }; 4121 4122 static int nsyscalls = ARRAY_SIZE(scnames); 4123 4124 /* 4125 * The public interface to this module. 4126 */ 4127 void 4128 print_syscall(CPUArchState *cpu_env, int num, 4129 abi_long arg1, abi_long arg2, abi_long arg3, 4130 abi_long arg4, abi_long arg5, abi_long arg6) 4131 { 4132 int i; 4133 FILE *f; 4134 const char *format = "%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," 4135 TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," 4136 TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; 4137 4138 f = qemu_log_trylock(); 4139 if (!f) { 4140 return; 4141 } 4142 fprintf(f, "%d ", getpid()); 4143 4144 for (i = 0; i < nsyscalls; i++) { 4145 if (scnames[i].nr == num) { 4146 if (scnames[i].call != NULL) { 4147 scnames[i].call(cpu_env, &scnames[i], arg1, arg2, arg3, 4148 arg4, arg5, arg6); 4149 } else { 4150 /* XXX: this format system is broken because it uses 4151 host types and host pointers for strings */ 4152 if (scnames[i].format != NULL) { 4153 format = scnames[i].format; 4154 } 4155 fprintf(f, format, scnames[i].name, arg1, arg2, 4156 arg3, arg4, arg5, arg6); 4157 } 4158 qemu_log_unlock(f); 4159 return; 4160 } 4161 } 4162 fprintf(f, "Unknown syscall %d\n", num); 4163 qemu_log_unlock(f); 4164 } 4165 4166 4167 void 4168 print_syscall_ret(CPUArchState *cpu_env, int num, abi_long ret, 4169 abi_long arg1, abi_long arg2, abi_long arg3, 4170 abi_long arg4, abi_long arg5, abi_long arg6) 4171 { 4172 int i; 4173 FILE *f; 4174 4175 f = qemu_log_trylock(); 4176 if (!f) { 4177 return; 4178 } 4179 4180 for (i = 0; i < nsyscalls; i++) { 4181 if (scnames[i].nr == num) { 4182 if (scnames[i].result != NULL) { 4183 scnames[i].result(cpu_env, &scnames[i], ret, 4184 arg1, arg2, arg3, 4185 arg4, arg5, arg6); 4186 } else { 4187 if (!print_syscall_err(ret)) { 4188 fprintf(f, TARGET_ABI_FMT_ld, ret); 4189 } 4190 fprintf(f, "\n"); 4191 } 4192 break; 4193 } 4194 } 4195 qemu_log_unlock(f); 4196 } 4197 4198 void print_taken_signal(int target_signum, const target_siginfo_t *tinfo) 4199 { 4200 /* Print the strace output for a signal being taken: 4201 * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} --- 4202 */ 4203 FILE *f; 4204 4205 f = qemu_log_trylock(); 4206 if (!f) { 4207 return; 4208 } 4209 4210 fprintf(f, "--- "); 4211 print_signal(target_signum, 1); 4212 fprintf(f, " "); 4213 print_siginfo(tinfo); 4214 fprintf(f, " ---\n"); 4215 qemu_log_unlock(f); 4216 } 4217