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