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