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