Peter Maydell | d39594e | 2016-01-26 18:17:02 +0000 | [diff] [blame] | 1 | #include "qemu/osdep.h" |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2 | #include <sys/ipc.h> |
| 3 | #include <sys/msg.h> |
| 4 | #include <sys/sem.h> |
| 5 | #include <sys/shm.h> |
| 6 | #include <sys/select.h> |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 7 | #include <sys/mount.h> |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 8 | #include <arpa/inet.h> |
| 9 | #include <netinet/tcp.h> |
| 10 | #include <linux/if_packet.h> |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 11 | #include <linux/netlink.h> |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 12 | #include <sched.h> |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 13 | #include "qemu.h" |
| 14 | |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 15 | struct syscallname { |
| 16 | int nr; |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 17 | const char *name; |
| 18 | const char *format; |
| 19 | void (*call)(const struct syscallname *, |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 20 | abi_long, abi_long, abi_long, |
| 21 | abi_long, abi_long, abi_long); |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 22 | void (*result)(const struct syscallname *, abi_long); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 23 | }; |
| 24 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 25 | #ifdef __GNUC__ |
| 26 | /* |
| 27 | * It is possible that target doesn't have syscall that uses |
| 28 | * following flags but we don't want the compiler to warn |
| 29 | * us about them being unused. Same applies to utility print |
| 30 | * functions. It is ok to keep them while not used. |
| 31 | */ |
| 32 | #define UNUSED __attribute__ ((unused)) |
| 33 | #else |
| 34 | #define UNUSED |
| 35 | #endif |
| 36 | |
| 37 | /* |
| 38 | * Structure used to translate flag values into strings. This is |
| 39 | * similar that is in the actual strace tool. |
| 40 | */ |
| 41 | struct flags { |
| 42 | abi_long f_value; /* flag */ |
| 43 | const char *f_string; /* stringified flag */ |
| 44 | }; |
| 45 | |
| 46 | /* common flags for all architectures */ |
| 47 | #define FLAG_GENERIC(name) { name, #name } |
| 48 | /* target specific flags (syscall_defs.h has TARGET_<flag>) */ |
| 49 | #define FLAG_TARGET(name) { TARGET_ ## name, #name } |
| 50 | /* end of flags array */ |
| 51 | #define FLAG_END { 0, NULL } |
| 52 | |
| 53 | UNUSED static const char *get_comma(int); |
| 54 | UNUSED static void print_pointer(abi_long, int); |
| 55 | UNUSED static void print_flags(const struct flags *, abi_long, int); |
| 56 | UNUSED static void print_at_dirfd(abi_long, int); |
| 57 | UNUSED static void print_file_mode(abi_long, int); |
| 58 | UNUSED static void print_open_flags(abi_long, int); |
| 59 | UNUSED static void print_syscall_prologue(const struct syscallname *); |
| 60 | UNUSED static void print_syscall_epilogue(const struct syscallname *); |
| 61 | UNUSED static void print_string(abi_long, int); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 62 | UNUSED static void print_buf(abi_long addr, abi_long len, int last); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 63 | UNUSED static void print_raw_param(const char *, abi_long, int); |
| 64 | UNUSED static void print_timeval(abi_ulong, int); |
Philippe Mathieu-Daudé | 6d33e03 | 2019-10-21 13:48:50 +0200 | [diff] [blame] | 65 | UNUSED static void print_timezone(abi_ulong, int); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 66 | UNUSED static void print_number(abi_long, int); |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 67 | UNUSED static void print_signal(abi_ulong, int); |
Philippe Mathieu-Daudé | 42b15d7 | 2019-10-21 13:48:56 +0200 | [diff] [blame] | 68 | UNUSED static void print_sockaddr(abi_ulong, abi_long, int); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 69 | UNUSED static void print_socket_domain(int domain); |
| 70 | UNUSED static void print_socket_type(int type); |
| 71 | UNUSED static void print_socket_protocol(int domain, int type, int protocol); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 72 | |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 73 | /* |
| 74 | * Utility functions |
| 75 | */ |
| 76 | static void |
| 77 | print_ipc_cmd(int cmd) |
| 78 | { |
| 79 | #define output_cmd(val) \ |
| 80 | if( cmd == val ) { \ |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 81 | qemu_log(#val); \ |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 82 | return; \ |
| 83 | } |
| 84 | |
| 85 | cmd &= 0xff; |
| 86 | |
| 87 | /* General IPC commands */ |
| 88 | output_cmd( IPC_RMID ); |
| 89 | output_cmd( IPC_SET ); |
| 90 | output_cmd( IPC_STAT ); |
| 91 | output_cmd( IPC_INFO ); |
| 92 | /* msgctl() commands */ |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 93 | output_cmd( MSG_STAT ); |
| 94 | output_cmd( MSG_INFO ); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 95 | /* shmctl() commands */ |
| 96 | output_cmd( SHM_LOCK ); |
| 97 | output_cmd( SHM_UNLOCK ); |
| 98 | output_cmd( SHM_STAT ); |
| 99 | output_cmd( SHM_INFO ); |
| 100 | /* semctl() commands */ |
| 101 | output_cmd( GETPID ); |
| 102 | output_cmd( GETVAL ); |
| 103 | output_cmd( GETALL ); |
| 104 | output_cmd( GETNCNT ); |
| 105 | output_cmd( GETZCNT ); |
| 106 | output_cmd( SETVAL ); |
| 107 | output_cmd( SETALL ); |
| 108 | output_cmd( SEM_STAT ); |
| 109 | output_cmd( SEM_INFO ); |
| 110 | output_cmd( IPC_RMID ); |
| 111 | output_cmd( IPC_RMID ); |
| 112 | output_cmd( IPC_RMID ); |
| 113 | output_cmd( IPC_RMID ); |
| 114 | output_cmd( IPC_RMID ); |
| 115 | output_cmd( IPC_RMID ); |
| 116 | output_cmd( IPC_RMID ); |
| 117 | output_cmd( IPC_RMID ); |
| 118 | output_cmd( IPC_RMID ); |
| 119 | |
| 120 | /* Some value we don't recognize */ |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 121 | qemu_log("%d", cmd); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 124 | static void |
| 125 | print_signal(abi_ulong arg, int last) |
| 126 | { |
| 127 | const char *signal_name = NULL; |
| 128 | switch(arg) { |
| 129 | case TARGET_SIGHUP: signal_name = "SIGHUP"; break; |
| 130 | case TARGET_SIGINT: signal_name = "SIGINT"; break; |
| 131 | case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break; |
| 132 | case TARGET_SIGILL: signal_name = "SIGILL"; break; |
| 133 | case TARGET_SIGABRT: signal_name = "SIGABRT"; break; |
| 134 | case TARGET_SIGFPE: signal_name = "SIGFPE"; break; |
| 135 | case TARGET_SIGKILL: signal_name = "SIGKILL"; break; |
| 136 | case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break; |
| 137 | case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break; |
| 138 | case TARGET_SIGALRM: signal_name = "SIGALRM"; break; |
| 139 | case TARGET_SIGTERM: signal_name = "SIGTERM"; break; |
| 140 | case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break; |
| 141 | case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break; |
| 142 | case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break; |
| 143 | case TARGET_SIGCONT: signal_name = "SIGCONT"; break; |
| 144 | case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break; |
| 145 | case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break; |
| 146 | case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break; |
| 147 | } |
| 148 | if (signal_name == NULL) { |
Peter Maydell | abe2084 | 2013-03-28 14:33:24 +0000 | [diff] [blame] | 149 | print_raw_param("%ld", arg, last); |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 150 | return; |
| 151 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 152 | qemu_log("%s%s", signal_name, get_comma(last)); |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 153 | } |
| 154 | |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 155 | static void print_si_code(int arg) |
| 156 | { |
| 157 | const char *codename = NULL; |
| 158 | |
| 159 | switch (arg) { |
| 160 | case SI_USER: |
| 161 | codename = "SI_USER"; |
| 162 | break; |
| 163 | case SI_KERNEL: |
| 164 | codename = "SI_KERNEL"; |
| 165 | break; |
| 166 | case SI_QUEUE: |
| 167 | codename = "SI_QUEUE"; |
| 168 | break; |
| 169 | case SI_TIMER: |
| 170 | codename = "SI_TIMER"; |
| 171 | break; |
| 172 | case SI_MESGQ: |
| 173 | codename = "SI_MESGQ"; |
| 174 | break; |
| 175 | case SI_ASYNCIO: |
| 176 | codename = "SI_ASYNCIO"; |
| 177 | break; |
| 178 | case SI_SIGIO: |
| 179 | codename = "SI_SIGIO"; |
| 180 | break; |
| 181 | case SI_TKILL: |
| 182 | codename = "SI_TKILL"; |
| 183 | break; |
| 184 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 185 | qemu_log("%d", arg); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 186 | return; |
| 187 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 188 | qemu_log("%s", codename); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Miloš Stojanović | ba9fcea | 2017-05-15 16:59:49 +0200 | [diff] [blame] | 191 | static void get_target_siginfo(target_siginfo_t *tinfo, |
| 192 | const target_siginfo_t *info) |
| 193 | { |
| 194 | abi_ulong sival_ptr; |
| 195 | |
| 196 | int sig; |
| 197 | int si_errno; |
| 198 | int si_code; |
| 199 | int si_type; |
| 200 | |
| 201 | __get_user(sig, &info->si_signo); |
| 202 | __get_user(si_errno, &tinfo->si_errno); |
| 203 | __get_user(si_code, &info->si_code); |
| 204 | |
| 205 | tinfo->si_signo = sig; |
| 206 | tinfo->si_errno = si_errno; |
| 207 | tinfo->si_code = si_code; |
| 208 | |
| 209 | /* Ensure we don't leak random junk to the guest later */ |
| 210 | memset(tinfo->_sifields._pad, 0, sizeof(tinfo->_sifields._pad)); |
| 211 | |
| 212 | /* This is awkward, because we have to use a combination of |
| 213 | * the si_code and si_signo to figure out which of the union's |
| 214 | * members are valid. (Within the host kernel it is always possible |
| 215 | * to tell, but the kernel carefully avoids giving userspace the |
| 216 | * high 16 bits of si_code, so we don't have the information to |
| 217 | * do this the easy way...) We therefore make our best guess, |
| 218 | * bearing in mind that a guest can spoof most of the si_codes |
| 219 | * via rt_sigqueueinfo() if it likes. |
| 220 | * |
| 221 | * Once we have made our guess, we record it in the top 16 bits of |
| 222 | * the si_code, so that print_siginfo() later can use it. |
| 223 | * print_siginfo() will strip these top bits out before printing |
| 224 | * the si_code. |
| 225 | */ |
| 226 | |
| 227 | switch (si_code) { |
| 228 | case SI_USER: |
| 229 | case SI_TKILL: |
| 230 | case SI_KERNEL: |
| 231 | /* Sent via kill(), tkill() or tgkill(), or direct from the kernel. |
| 232 | * These are the only unspoofable si_code values. |
| 233 | */ |
| 234 | __get_user(tinfo->_sifields._kill._pid, &info->_sifields._kill._pid); |
| 235 | __get_user(tinfo->_sifields._kill._uid, &info->_sifields._kill._uid); |
| 236 | si_type = QEMU_SI_KILL; |
| 237 | break; |
| 238 | default: |
| 239 | /* Everything else is spoofable. Make best guess based on signal */ |
| 240 | switch (sig) { |
| 241 | case TARGET_SIGCHLD: |
| 242 | __get_user(tinfo->_sifields._sigchld._pid, |
| 243 | &info->_sifields._sigchld._pid); |
| 244 | __get_user(tinfo->_sifields._sigchld._uid, |
| 245 | &info->_sifields._sigchld._uid); |
| 246 | __get_user(tinfo->_sifields._sigchld._status, |
| 247 | &info->_sifields._sigchld._status); |
| 248 | __get_user(tinfo->_sifields._sigchld._utime, |
| 249 | &info->_sifields._sigchld._utime); |
| 250 | __get_user(tinfo->_sifields._sigchld._stime, |
| 251 | &info->_sifields._sigchld._stime); |
| 252 | si_type = QEMU_SI_CHLD; |
| 253 | break; |
| 254 | case TARGET_SIGIO: |
| 255 | __get_user(tinfo->_sifields._sigpoll._band, |
| 256 | &info->_sifields._sigpoll._band); |
| 257 | __get_user(tinfo->_sifields._sigpoll._fd, |
| 258 | &info->_sifields._sigpoll._fd); |
| 259 | si_type = QEMU_SI_POLL; |
| 260 | break; |
| 261 | default: |
| 262 | /* Assume a sigqueue()/mq_notify()/rt_sigqueueinfo() source. */ |
| 263 | __get_user(tinfo->_sifields._rt._pid, &info->_sifields._rt._pid); |
| 264 | __get_user(tinfo->_sifields._rt._uid, &info->_sifields._rt._uid); |
| 265 | /* XXX: potential problem if 64 bit */ |
| 266 | __get_user(sival_ptr, &info->_sifields._rt._sigval.sival_ptr); |
| 267 | tinfo->_sifields._rt._sigval.sival_ptr = sival_ptr; |
| 268 | |
| 269 | si_type = QEMU_SI_RT; |
| 270 | break; |
| 271 | } |
| 272 | break; |
| 273 | } |
| 274 | |
| 275 | tinfo->si_code = deposit32(si_code, 16, 16, si_type); |
| 276 | } |
| 277 | |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 278 | static void print_siginfo(const target_siginfo_t *tinfo) |
| 279 | { |
| 280 | /* Print a target_siginfo_t in the format desired for printing |
| 281 | * signals being taken. We assume the target_siginfo_t is in the |
| 282 | * internal form where the top 16 bits of si_code indicate which |
| 283 | * part of the union is valid, rather than in the guest-visible |
| 284 | * form where the bottom 16 bits are sign-extended into the top 16. |
| 285 | */ |
| 286 | int si_type = extract32(tinfo->si_code, 16, 16); |
| 287 | int si_code = sextract32(tinfo->si_code, 0, 16); |
| 288 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 289 | qemu_log("{si_signo="); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 290 | print_signal(tinfo->si_signo, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 291 | qemu_log(", si_code="); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 292 | print_si_code(si_code); |
| 293 | |
| 294 | switch (si_type) { |
| 295 | case QEMU_SI_KILL: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 296 | qemu_log(", si_pid=%u, si_uid=%u", |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 297 | (unsigned int)tinfo->_sifields._kill._pid, |
| 298 | (unsigned int)tinfo->_sifields._kill._uid); |
| 299 | break; |
| 300 | case QEMU_SI_TIMER: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 301 | qemu_log(", si_timer1=%u, si_timer2=%u", |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 302 | tinfo->_sifields._timer._timer1, |
| 303 | tinfo->_sifields._timer._timer2); |
| 304 | break; |
| 305 | case QEMU_SI_POLL: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 306 | qemu_log(", si_band=%d, si_fd=%d", |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 307 | tinfo->_sifields._sigpoll._band, |
| 308 | tinfo->_sifields._sigpoll._fd); |
| 309 | break; |
| 310 | case QEMU_SI_FAULT: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 311 | qemu_log(", si_addr="); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 312 | print_pointer(tinfo->_sifields._sigfault._addr, 1); |
| 313 | break; |
| 314 | case QEMU_SI_CHLD: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 315 | qemu_log(", si_pid=%u, si_uid=%u, si_status=%d" |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 316 | ", si_utime=" TARGET_ABI_FMT_ld |
| 317 | ", si_stime=" TARGET_ABI_FMT_ld, |
| 318 | (unsigned int)(tinfo->_sifields._sigchld._pid), |
| 319 | (unsigned int)(tinfo->_sifields._sigchld._uid), |
| 320 | tinfo->_sifields._sigchld._status, |
| 321 | tinfo->_sifields._sigchld._utime, |
| 322 | tinfo->_sifields._sigchld._stime); |
| 323 | break; |
| 324 | case QEMU_SI_RT: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 325 | qemu_log(", si_pid=%u, si_uid=%u, si_sigval=" TARGET_ABI_FMT_ld, |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 326 | (unsigned int)tinfo->_sifields._rt._pid, |
| 327 | (unsigned int)tinfo->_sifields._rt._uid, |
| 328 | tinfo->_sifields._rt._sigval.sival_ptr); |
| 329 | break; |
| 330 | default: |
| 331 | g_assert_not_reached(); |
| 332 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 333 | qemu_log("}"); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 334 | } |
| 335 | |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 336 | static void |
Philippe Mathieu-Daudé | 42b15d7 | 2019-10-21 13:48:56 +0200 | [diff] [blame] | 337 | print_sockaddr(abi_ulong addr, abi_long addrlen, int last) |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 338 | { |
| 339 | struct target_sockaddr *sa; |
| 340 | int i; |
| 341 | int sa_family; |
| 342 | |
| 343 | sa = lock_user(VERIFY_READ, addr, addrlen, 1); |
| 344 | if (sa) { |
| 345 | sa_family = tswap16(sa->sa_family); |
| 346 | switch (sa_family) { |
| 347 | case AF_UNIX: { |
| 348 | struct target_sockaddr_un *un = (struct target_sockaddr_un *)sa; |
| 349 | int i; |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 350 | qemu_log("{sun_family=AF_UNIX,sun_path=\""); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 351 | for (i = 0; i < addrlen - |
| 352 | offsetof(struct target_sockaddr_un, sun_path) && |
| 353 | un->sun_path[i]; i++) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 354 | qemu_log("%c", un->sun_path[i]); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 355 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 356 | qemu_log("\"}"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 357 | break; |
| 358 | } |
| 359 | case AF_INET: { |
| 360 | struct target_sockaddr_in *in = (struct target_sockaddr_in *)sa; |
| 361 | uint8_t *c = (uint8_t *)&in->sin_addr.s_addr; |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 362 | qemu_log("{sin_family=AF_INET,sin_port=htons(%d),", |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 363 | ntohs(in->sin_port)); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 364 | qemu_log("sin_addr=inet_addr(\"%d.%d.%d.%d\")", |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 365 | c[0], c[1], c[2], c[3]); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 366 | qemu_log("}"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 367 | break; |
| 368 | } |
| 369 | case AF_PACKET: { |
| 370 | struct target_sockaddr_ll *ll = (struct target_sockaddr_ll *)sa; |
| 371 | uint8_t *c = (uint8_t *)&ll->sll_addr; |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 372 | qemu_log("{sll_family=AF_PACKET," |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 373 | "sll_protocol=htons(0x%04x),if%d,pkttype=", |
| 374 | ntohs(ll->sll_protocol), ll->sll_ifindex); |
| 375 | switch (ll->sll_pkttype) { |
| 376 | case PACKET_HOST: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 377 | qemu_log("PACKET_HOST"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 378 | break; |
| 379 | case PACKET_BROADCAST: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 380 | qemu_log("PACKET_BROADCAST"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 381 | break; |
| 382 | case PACKET_MULTICAST: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 383 | qemu_log("PACKET_MULTICAST"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 384 | break; |
| 385 | case PACKET_OTHERHOST: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 386 | qemu_log("PACKET_OTHERHOST"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 387 | break; |
| 388 | case PACKET_OUTGOING: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 389 | qemu_log("PACKET_OUTGOING"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 390 | break; |
| 391 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 392 | qemu_log("%d", ll->sll_pkttype); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 393 | break; |
| 394 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 395 | qemu_log(",sll_addr=%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 396 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 397 | qemu_log("}"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 398 | break; |
| 399 | } |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 400 | case AF_NETLINK: { |
| 401 | struct target_sockaddr_nl *nl = (struct target_sockaddr_nl *)sa; |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 402 | qemu_log("{nl_family=AF_NETLINK,nl_pid=%u,nl_groups=%u}", |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 403 | tswap32(nl->nl_pid), tswap32(nl->nl_groups)); |
| 404 | break; |
| 405 | } |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 406 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 407 | qemu_log("{sa_family=%d, sa_data={", sa->sa_family); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 408 | for (i = 0; i < 13; i++) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 409 | qemu_log("%02x, ", sa->sa_data[i]); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 410 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 411 | qemu_log("%02x}", sa->sa_data[i]); |
| 412 | qemu_log("}"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 413 | break; |
| 414 | } |
| 415 | unlock_user(sa, addr, 0); |
| 416 | } else { |
| 417 | print_raw_param("0x"TARGET_ABI_FMT_lx, addr, 0); |
| 418 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 419 | qemu_log(", "TARGET_ABI_FMT_ld"%s", addrlen, get_comma(last)); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | static void |
| 423 | print_socket_domain(int domain) |
| 424 | { |
| 425 | switch (domain) { |
| 426 | case PF_UNIX: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 427 | qemu_log("PF_UNIX"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 428 | break; |
| 429 | case PF_INET: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 430 | qemu_log("PF_INET"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 431 | break; |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 432 | case PF_NETLINK: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 433 | qemu_log("PF_NETLINK"); |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 434 | break; |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 435 | case PF_PACKET: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 436 | qemu_log("PF_PACKET"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 437 | break; |
| 438 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 439 | qemu_log("%d", domain); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 440 | break; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | static void |
| 445 | print_socket_type(int type) |
| 446 | { |
Laurent Vivier | 2039b1b | 2020-03-12 17:55:30 +0100 | [diff] [blame^] | 447 | switch (type & TARGET_SOCK_TYPE_MASK) { |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 448 | case TARGET_SOCK_DGRAM: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 449 | qemu_log("SOCK_DGRAM"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 450 | break; |
| 451 | case TARGET_SOCK_STREAM: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 452 | qemu_log("SOCK_STREAM"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 453 | break; |
| 454 | case TARGET_SOCK_RAW: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 455 | qemu_log("SOCK_RAW"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 456 | break; |
| 457 | case TARGET_SOCK_RDM: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 458 | qemu_log("SOCK_RDM"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 459 | break; |
| 460 | case TARGET_SOCK_SEQPACKET: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 461 | qemu_log("SOCK_SEQPACKET"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 462 | break; |
| 463 | case TARGET_SOCK_PACKET: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 464 | qemu_log("SOCK_PACKET"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 465 | break; |
| 466 | } |
Laurent Vivier | 2039b1b | 2020-03-12 17:55:30 +0100 | [diff] [blame^] | 467 | if (type & TARGET_SOCK_CLOEXEC) { |
| 468 | qemu_log("|SOCK_CLOEXEC"); |
| 469 | } |
| 470 | if (type & TARGET_SOCK_NONBLOCK) { |
| 471 | qemu_log("|SOCK_NONBLOCK"); |
| 472 | } |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 473 | } |
| 474 | |
| 475 | static void |
| 476 | print_socket_protocol(int domain, int type, int protocol) |
| 477 | { |
| 478 | if (domain == AF_PACKET || |
| 479 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { |
| 480 | switch (protocol) { |
| 481 | case 0x0003: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 482 | qemu_log("ETH_P_ALL"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 483 | break; |
| 484 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 485 | qemu_log("%d", protocol); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 486 | } |
| 487 | return; |
| 488 | } |
| 489 | |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 490 | if (domain == PF_NETLINK) { |
| 491 | switch (protocol) { |
| 492 | case NETLINK_ROUTE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 493 | qemu_log("NETLINK_ROUTE"); |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 494 | break; |
| 495 | case NETLINK_AUDIT: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 496 | qemu_log("NETLINK_AUDIT"); |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 497 | break; |
| 498 | case NETLINK_NETFILTER: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 499 | qemu_log("NETLINK_NETFILTER"); |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 500 | break; |
| 501 | case NETLINK_KOBJECT_UEVENT: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 502 | qemu_log("NETLINK_KOBJECT_UEVENT"); |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 503 | break; |
| 504 | case NETLINK_RDMA: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 505 | qemu_log("NETLINK_RDMA"); |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 506 | break; |
| 507 | case NETLINK_CRYPTO: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 508 | qemu_log("NETLINK_CRYPTO"); |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 509 | break; |
| 510 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 511 | qemu_log("%d", protocol); |
Philippe Mathieu-Daudé | 814ae70 | 2019-10-21 13:48:53 +0200 | [diff] [blame] | 512 | break; |
| 513 | } |
| 514 | return; |
| 515 | } |
| 516 | |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 517 | switch (protocol) { |
| 518 | case IPPROTO_IP: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 519 | qemu_log("IPPROTO_IP"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 520 | break; |
| 521 | case IPPROTO_TCP: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 522 | qemu_log("IPPROTO_TCP"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 523 | break; |
| 524 | case IPPROTO_UDP: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 525 | qemu_log("IPPROTO_UDP"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 526 | break; |
| 527 | case IPPROTO_RAW: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 528 | qemu_log("IPPROTO_RAW"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 529 | break; |
| 530 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 531 | qemu_log("%d", protocol); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 532 | break; |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 537 | #ifdef TARGET_NR__newselect |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 538 | static void |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 539 | print_fdset(int n, abi_ulong target_fds_addr) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 540 | { |
| 541 | int i; |
| 542 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 543 | qemu_log("["); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 544 | if( target_fds_addr ) { |
bellard | 579a97f | 2007-11-11 14:26:47 +0000 | [diff] [blame] | 545 | abi_long *target_fds; |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 546 | |
bellard | 579a97f | 2007-11-11 14:26:47 +0000 | [diff] [blame] | 547 | target_fds = lock_user(VERIFY_READ, |
| 548 | target_fds_addr, |
| 549 | sizeof(*target_fds)*(n / TARGET_ABI_BITS + 1), |
| 550 | 1); |
| 551 | |
| 552 | if (!target_fds) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 553 | return; |
| 554 | |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 555 | for (i=n; i>=0; i--) { |
Matthias Braun | cbb21ee | 2011-08-12 19:57:41 +0200 | [diff] [blame] | 556 | if ((tswapal(target_fds[i / TARGET_ABI_BITS]) >> (i & (TARGET_ABI_BITS - 1))) & 1) |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 557 | qemu_log("%d,", i); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 558 | } |
| 559 | unlock_user(target_fds, target_fds_addr, 0); |
| 560 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 561 | qemu_log("]"); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 562 | } |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 563 | #endif |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 564 | |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 565 | #ifdef TARGET_NR_clock_adjtime |
| 566 | /* IDs of the various system clocks */ |
| 567 | #define TARGET_CLOCK_REALTIME 0 |
| 568 | #define TARGET_CLOCK_MONOTONIC 1 |
| 569 | #define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 |
| 570 | #define TARGET_CLOCK_THREAD_CPUTIME_ID 3 |
| 571 | #define TARGET_CLOCK_MONOTONIC_RAW 4 |
| 572 | #define TARGET_CLOCK_REALTIME_COARSE 5 |
| 573 | #define TARGET_CLOCK_MONOTONIC_COARSE 6 |
| 574 | #define TARGET_CLOCK_BOOTTIME 7 |
| 575 | #define TARGET_CLOCK_REALTIME_ALARM 8 |
| 576 | #define TARGET_CLOCK_BOOTTIME_ALARM 9 |
| 577 | #define TARGET_CLOCK_SGI_CYCLE 10 |
| 578 | #define TARGET_CLOCK_TAI 11 |
| 579 | |
| 580 | static void |
| 581 | print_clockid(int clockid, int last) |
| 582 | { |
| 583 | switch (clockid) { |
| 584 | case TARGET_CLOCK_REALTIME: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 585 | qemu_log("CLOCK_REALTIME"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 586 | break; |
| 587 | case TARGET_CLOCK_MONOTONIC: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 588 | qemu_log("CLOCK_MONOTONIC"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 589 | break; |
| 590 | case TARGET_CLOCK_PROCESS_CPUTIME_ID: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 591 | qemu_log("CLOCK_PROCESS_CPUTIME_ID"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 592 | break; |
| 593 | case TARGET_CLOCK_THREAD_CPUTIME_ID: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 594 | qemu_log("CLOCK_THREAD_CPUTIME_ID"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 595 | break; |
| 596 | case TARGET_CLOCK_MONOTONIC_RAW: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 597 | qemu_log("CLOCK_MONOTONIC_RAW"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 598 | break; |
| 599 | case TARGET_CLOCK_REALTIME_COARSE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 600 | qemu_log("CLOCK_REALTIME_COARSE"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 601 | break; |
| 602 | case TARGET_CLOCK_MONOTONIC_COARSE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 603 | qemu_log("CLOCK_MONOTONIC_COARSE"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 604 | break; |
| 605 | case TARGET_CLOCK_BOOTTIME: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 606 | qemu_log("CLOCK_BOOTTIME"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 607 | break; |
| 608 | case TARGET_CLOCK_REALTIME_ALARM: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 609 | qemu_log("CLOCK_REALTIME_ALARM"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 610 | break; |
| 611 | case TARGET_CLOCK_BOOTTIME_ALARM: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 612 | qemu_log("CLOCK_BOOTTIME_ALARM"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 613 | break; |
| 614 | case TARGET_CLOCK_SGI_CYCLE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 615 | qemu_log("CLOCK_SGI_CYCLE"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 616 | break; |
| 617 | case TARGET_CLOCK_TAI: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 618 | qemu_log("CLOCK_TAI"); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 619 | break; |
| 620 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 621 | qemu_log("%d", clockid); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 622 | break; |
| 623 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 624 | qemu_log("%s", get_comma(last)); |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 625 | } |
| 626 | #endif |
| 627 | |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 628 | /* |
| 629 | * Sysycall specific output functions |
| 630 | */ |
| 631 | |
| 632 | /* select */ |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 633 | #ifdef TARGET_NR__newselect |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 634 | static long newselect_arg1 = 0; |
| 635 | static long newselect_arg2 = 0; |
| 636 | static long newselect_arg3 = 0; |
| 637 | static long newselect_arg4 = 0; |
| 638 | static long newselect_arg5 = 0; |
| 639 | |
| 640 | static void |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 641 | print_newselect(const struct syscallname *name, |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 642 | abi_long arg1, abi_long arg2, abi_long arg3, |
| 643 | abi_long arg4, abi_long arg5, abi_long arg6) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 644 | { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 645 | qemu_log("%s(" TARGET_ABI_FMT_ld ",", name->name, arg1); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 646 | print_fdset(arg1, arg2); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 647 | qemu_log(","); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 648 | print_fdset(arg1, arg3); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 649 | qemu_log(","); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 650 | print_fdset(arg1, arg4); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 651 | qemu_log(","); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 652 | print_timeval(arg5, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 653 | qemu_log(")"); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 654 | |
| 655 | /* save for use in the return output function below */ |
| 656 | newselect_arg1=arg1; |
| 657 | newselect_arg2=arg2; |
| 658 | newselect_arg3=arg3; |
| 659 | newselect_arg4=arg4; |
| 660 | newselect_arg5=arg5; |
| 661 | } |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 662 | #endif |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 663 | |
blueswir1 | 3e46b2e | 2008-10-03 19:01:41 +0000 | [diff] [blame] | 664 | #ifdef TARGET_NR_semctl |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 665 | static void |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 666 | print_semctl(const struct syscallname *name, |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 667 | abi_long arg1, abi_long arg2, abi_long arg3, |
| 668 | abi_long arg4, abi_long arg5, abi_long arg6) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 669 | { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 670 | qemu_log("%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", |
| 671 | name->name, arg1, arg2); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 672 | print_ipc_cmd(arg3); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 673 | qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 674 | } |
blueswir1 | 3e46b2e | 2008-10-03 19:01:41 +0000 | [diff] [blame] | 675 | #endif |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 676 | |
| 677 | static void |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 678 | print_execve(const struct syscallname *name, |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 679 | abi_long arg1, abi_long arg2, abi_long arg3, |
| 680 | abi_long arg4, abi_long arg5, abi_long arg6) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 681 | { |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 682 | abi_ulong arg_ptr_addr; |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 683 | char *s; |
| 684 | |
bellard | 579a97f | 2007-11-11 14:26:47 +0000 | [diff] [blame] | 685 | if (!(s = lock_user_string(arg1))) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 686 | return; |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 687 | qemu_log("%s(\"%s\",{", name->name, s); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 688 | unlock_user(s, arg1, 0); |
| 689 | |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 690 | for (arg_ptr_addr = arg2; ; arg_ptr_addr += sizeof(abi_ulong)) { |
blueswir1 | 98448f5 | 2008-09-30 18:16:09 +0000 | [diff] [blame] | 691 | abi_ulong *arg_ptr, arg_addr; |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 692 | |
Paolo Bonzini | 7d37435 | 2018-12-13 23:37:37 +0100 | [diff] [blame] | 693 | arg_ptr = lock_user(VERIFY_READ, arg_ptr_addr, sizeof(abi_ulong), 1); |
bellard | 579a97f | 2007-11-11 14:26:47 +0000 | [diff] [blame] | 694 | if (!arg_ptr) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 695 | return; |
Matthias Braun | cbb21ee | 2011-08-12 19:57:41 +0200 | [diff] [blame] | 696 | arg_addr = tswapal(*arg_ptr); |
Paolo Bonzini | 7d37435 | 2018-12-13 23:37:37 +0100 | [diff] [blame] | 697 | unlock_user(arg_ptr, arg_ptr_addr, 0); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 698 | if (!arg_addr) |
| 699 | break; |
bellard | 579a97f | 2007-11-11 14:26:47 +0000 | [diff] [blame] | 700 | if ((s = lock_user_string(arg_addr))) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 701 | qemu_log("\"%s\",", s); |
blueswir1 | 98448f5 | 2008-09-30 18:16:09 +0000 | [diff] [blame] | 702 | unlock_user(s, arg_addr, 0); |
bellard | 579a97f | 2007-11-11 14:26:47 +0000 | [diff] [blame] | 703 | } |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 704 | } |
| 705 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 706 | qemu_log("NULL})"); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 707 | } |
| 708 | |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 709 | #ifdef TARGET_NR_ipc |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 710 | static void |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 711 | print_ipc(const struct syscallname *name, |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 712 | abi_long arg1, abi_long arg2, abi_long arg3, |
| 713 | abi_long arg4, abi_long arg5, abi_long arg6) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 714 | { |
| 715 | switch(arg1) { |
| 716 | case IPCOP_semctl: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 717 | qemu_log("semctl(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ",", |
| 718 | arg1, arg2); |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 719 | print_ipc_cmd(arg3); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 720 | qemu_log(",0x" TARGET_ABI_FMT_lx ")", arg4); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 721 | break; |
| 722 | default: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 723 | qemu_log(("%s(" |
| 724 | TARGET_ABI_FMT_ld "," |
| 725 | TARGET_ABI_FMT_ld "," |
| 726 | TARGET_ABI_FMT_ld "," |
| 727 | TARGET_ABI_FMT_ld |
| 728 | ")"), |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 729 | name->name, arg1, arg2, arg3, arg4); |
| 730 | } |
| 731 | } |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 732 | #endif |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 733 | |
| 734 | /* |
| 735 | * Variants for the return value output function |
| 736 | */ |
| 737 | |
| 738 | static void |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 739 | print_syscall_ret_addr(const struct syscallname *name, abi_long ret) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 740 | { |
Peter Maydell | 7dcdaea | 2016-06-06 19:58:18 +0100 | [diff] [blame] | 741 | const char *errstr = NULL; |
Alexander Graf | 962b289 | 2011-11-21 12:04:07 +0100 | [diff] [blame] | 742 | |
Peter Maydell | 2a7e124 | 2011-11-21 12:21:19 +0000 | [diff] [blame] | 743 | if (ret < 0) { |
| 744 | errstr = target_strerror(-ret); |
Alexander Graf | 962b289 | 2011-11-21 12:04:07 +0100 | [diff] [blame] | 745 | } |
Peter Maydell | 2a7e124 | 2011-11-21 12:21:19 +0000 | [diff] [blame] | 746 | if (errstr) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 747 | qemu_log(" = -1 errno=%d (%s)\n", (int)-ret, errstr); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 748 | } else { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 749 | qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 750 | } |
| 751 | } |
| 752 | |
ths | f3e3285 | 2007-11-03 15:12:16 +0000 | [diff] [blame] | 753 | #if 0 /* currently unused */ |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 754 | static void |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 755 | print_syscall_ret_raw(struct syscallname *name, abi_long ret) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 756 | { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 757 | qemu_log(" = 0x" TARGET_ABI_FMT_lx "\n", ret); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 758 | } |
ths | f3e3285 | 2007-11-03 15:12:16 +0000 | [diff] [blame] | 759 | #endif |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 760 | |
ths | f3e3285 | 2007-11-03 15:12:16 +0000 | [diff] [blame] | 761 | #ifdef TARGET_NR__newselect |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 762 | static void |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 763 | print_syscall_ret_newselect(const struct syscallname *name, abi_long ret) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 764 | { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 765 | qemu_log(" = 0x" TARGET_ABI_FMT_lx " (", ret); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 766 | print_fdset(newselect_arg1,newselect_arg2); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 767 | qemu_log(","); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 768 | print_fdset(newselect_arg1,newselect_arg3); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 769 | qemu_log(","); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 770 | print_fdset(newselect_arg1,newselect_arg4); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 771 | qemu_log(","); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 772 | print_timeval(newselect_arg5, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 773 | qemu_log(")\n"); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 774 | } |
ths | f3e3285 | 2007-11-03 15:12:16 +0000 | [diff] [blame] | 775 | #endif |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 776 | |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 777 | /* special meanings of adjtimex()' non-negative return values */ |
| 778 | #define TARGET_TIME_OK 0 /* clock synchronized, no leap second */ |
| 779 | #define TARGET_TIME_INS 1 /* insert leap second */ |
| 780 | #define TARGET_TIME_DEL 2 /* delete leap second */ |
| 781 | #define TARGET_TIME_OOP 3 /* leap second in progress */ |
| 782 | #define TARGET_TIME_WAIT 4 /* leap second has occurred */ |
| 783 | #define TARGET_TIME_ERROR 5 /* clock not synchronized */ |
| 784 | static void |
| 785 | print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret) |
| 786 | { |
| 787 | const char *errstr = NULL; |
| 788 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 789 | qemu_log(" = "); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 790 | if (ret < 0) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 791 | qemu_log("-1 errno=%d", errno); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 792 | errstr = target_strerror(-ret); |
| 793 | if (errstr) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 794 | qemu_log(" (%s)", errstr); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 795 | } |
| 796 | } else { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 797 | qemu_log(TARGET_ABI_FMT_ld, ret); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 798 | switch (ret) { |
| 799 | case TARGET_TIME_OK: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 800 | qemu_log(" TIME_OK (clock synchronized, no leap second)"); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 801 | break; |
| 802 | case TARGET_TIME_INS: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 803 | qemu_log(" TIME_INS (insert leap second)"); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 804 | break; |
| 805 | case TARGET_TIME_DEL: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 806 | qemu_log(" TIME_DEL (delete leap second)"); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 807 | break; |
| 808 | case TARGET_TIME_OOP: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 809 | qemu_log(" TIME_OOP (leap second in progress)"); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 810 | break; |
| 811 | case TARGET_TIME_WAIT: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 812 | qemu_log(" TIME_WAIT (leap second has occurred)"); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 813 | break; |
| 814 | case TARGET_TIME_ERROR: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 815 | qemu_log(" TIME_ERROR (clock not synchronized)"); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 816 | break; |
| 817 | } |
| 818 | } |
| 819 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 820 | qemu_log("\n"); |
Aleksandar Markovic | 19f59bc | 2016-09-22 18:56:50 +0200 | [diff] [blame] | 821 | } |
| 822 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 823 | UNUSED static struct flags access_flags[] = { |
| 824 | FLAG_GENERIC(F_OK), |
| 825 | FLAG_GENERIC(R_OK), |
| 826 | FLAG_GENERIC(W_OK), |
| 827 | FLAG_GENERIC(X_OK), |
| 828 | FLAG_END, |
| 829 | }; |
| 830 | |
| 831 | UNUSED static struct flags at_file_flags[] = { |
| 832 | #ifdef AT_EACCESS |
| 833 | FLAG_GENERIC(AT_EACCESS), |
| 834 | #endif |
| 835 | #ifdef AT_SYMLINK_NOFOLLOW |
| 836 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), |
| 837 | #endif |
| 838 | FLAG_END, |
| 839 | }; |
| 840 | |
| 841 | UNUSED static struct flags unlinkat_flags[] = { |
| 842 | #ifdef AT_REMOVEDIR |
| 843 | FLAG_GENERIC(AT_REMOVEDIR), |
| 844 | #endif |
| 845 | FLAG_END, |
| 846 | }; |
| 847 | |
| 848 | UNUSED static struct flags mode_flags[] = { |
| 849 | FLAG_GENERIC(S_IFSOCK), |
| 850 | FLAG_GENERIC(S_IFLNK), |
| 851 | FLAG_GENERIC(S_IFREG), |
| 852 | FLAG_GENERIC(S_IFBLK), |
| 853 | FLAG_GENERIC(S_IFDIR), |
| 854 | FLAG_GENERIC(S_IFCHR), |
| 855 | FLAG_GENERIC(S_IFIFO), |
| 856 | FLAG_END, |
| 857 | }; |
| 858 | |
| 859 | UNUSED static struct flags open_access_flags[] = { |
| 860 | FLAG_TARGET(O_RDONLY), |
| 861 | FLAG_TARGET(O_WRONLY), |
| 862 | FLAG_TARGET(O_RDWR), |
| 863 | FLAG_END, |
| 864 | }; |
| 865 | |
| 866 | UNUSED static struct flags open_flags[] = { |
| 867 | FLAG_TARGET(O_APPEND), |
| 868 | FLAG_TARGET(O_CREAT), |
| 869 | FLAG_TARGET(O_DIRECTORY), |
| 870 | FLAG_TARGET(O_EXCL), |
| 871 | FLAG_TARGET(O_LARGEFILE), |
| 872 | FLAG_TARGET(O_NOCTTY), |
| 873 | FLAG_TARGET(O_NOFOLLOW), |
| 874 | FLAG_TARGET(O_NONBLOCK), /* also O_NDELAY */ |
Richard Henderson | afc8763 | 2012-07-25 14:30:34 -0700 | [diff] [blame] | 875 | FLAG_TARGET(O_DSYNC), |
| 876 | FLAG_TARGET(__O_SYNC), |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 877 | FLAG_TARGET(O_TRUNC), |
| 878 | #ifdef O_DIRECT |
| 879 | FLAG_TARGET(O_DIRECT), |
| 880 | #endif |
Richard Henderson | afc8763 | 2012-07-25 14:30:34 -0700 | [diff] [blame] | 881 | #ifdef O_NOATIME |
| 882 | FLAG_TARGET(O_NOATIME), |
| 883 | #endif |
| 884 | #ifdef O_CLOEXEC |
| 885 | FLAG_TARGET(O_CLOEXEC), |
| 886 | #endif |
| 887 | #ifdef O_PATH |
| 888 | FLAG_TARGET(O_PATH), |
| 889 | #endif |
Riku Voipio | 5f9cee4 | 2017-08-08 16:01:19 +0300 | [diff] [blame] | 890 | #ifdef O_TMPFILE |
| 891 | FLAG_TARGET(O_TMPFILE), |
| 892 | FLAG_TARGET(__O_TMPFILE), |
| 893 | #endif |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 894 | FLAG_END, |
| 895 | }; |
| 896 | |
| 897 | UNUSED static struct flags mount_flags[] = { |
| 898 | #ifdef MS_BIND |
| 899 | FLAG_GENERIC(MS_BIND), |
| 900 | #endif |
| 901 | #ifdef MS_DIRSYNC |
| 902 | FLAG_GENERIC(MS_DIRSYNC), |
| 903 | #endif |
| 904 | FLAG_GENERIC(MS_MANDLOCK), |
| 905 | #ifdef MS_MOVE |
| 906 | FLAG_GENERIC(MS_MOVE), |
| 907 | #endif |
| 908 | FLAG_GENERIC(MS_NOATIME), |
| 909 | FLAG_GENERIC(MS_NODEV), |
| 910 | FLAG_GENERIC(MS_NODIRATIME), |
| 911 | FLAG_GENERIC(MS_NOEXEC), |
| 912 | FLAG_GENERIC(MS_NOSUID), |
| 913 | FLAG_GENERIC(MS_RDONLY), |
| 914 | #ifdef MS_RELATIME |
| 915 | FLAG_GENERIC(MS_RELATIME), |
| 916 | #endif |
| 917 | FLAG_GENERIC(MS_REMOUNT), |
| 918 | FLAG_GENERIC(MS_SYNCHRONOUS), |
| 919 | FLAG_END, |
| 920 | }; |
| 921 | |
| 922 | UNUSED static struct flags umount2_flags[] = { |
| 923 | #ifdef MNT_FORCE |
| 924 | FLAG_GENERIC(MNT_FORCE), |
| 925 | #endif |
| 926 | #ifdef MNT_DETACH |
| 927 | FLAG_GENERIC(MNT_DETACH), |
| 928 | #endif |
| 929 | #ifdef MNT_EXPIRE |
| 930 | FLAG_GENERIC(MNT_EXPIRE), |
| 931 | #endif |
| 932 | FLAG_END, |
| 933 | }; |
| 934 | |
| 935 | UNUSED static struct flags mmap_prot_flags[] = { |
| 936 | FLAG_GENERIC(PROT_NONE), |
| 937 | FLAG_GENERIC(PROT_EXEC), |
| 938 | FLAG_GENERIC(PROT_READ), |
| 939 | FLAG_GENERIC(PROT_WRITE), |
Paul Brook | 9e0b74a | 2010-06-16 13:03:51 +0100 | [diff] [blame] | 940 | FLAG_TARGET(PROT_SEM), |
| 941 | FLAG_GENERIC(PROT_GROWSDOWN), |
| 942 | FLAG_GENERIC(PROT_GROWSUP), |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 943 | FLAG_END, |
| 944 | }; |
| 945 | |
| 946 | UNUSED static struct flags mmap_flags[] = { |
| 947 | FLAG_TARGET(MAP_SHARED), |
| 948 | FLAG_TARGET(MAP_PRIVATE), |
| 949 | FLAG_TARGET(MAP_ANONYMOUS), |
| 950 | FLAG_TARGET(MAP_DENYWRITE), |
| 951 | FLAG_TARGET(MAP_FIXED), |
| 952 | FLAG_TARGET(MAP_GROWSDOWN), |
Mike Frysinger | 906c1b8 | 2011-02-07 01:05:52 -0500 | [diff] [blame] | 953 | FLAG_TARGET(MAP_EXECUTABLE), |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 954 | #ifdef MAP_LOCKED |
| 955 | FLAG_TARGET(MAP_LOCKED), |
| 956 | #endif |
| 957 | #ifdef MAP_NONBLOCK |
| 958 | FLAG_TARGET(MAP_NONBLOCK), |
| 959 | #endif |
| 960 | FLAG_TARGET(MAP_NORESERVE), |
| 961 | #ifdef MAP_POPULATE |
| 962 | FLAG_TARGET(MAP_POPULATE), |
| 963 | #endif |
Mike Frysinger | 906c1b8 | 2011-02-07 01:05:52 -0500 | [diff] [blame] | 964 | #ifdef TARGET_MAP_UNINITIALIZED |
| 965 | FLAG_TARGET(MAP_UNINITIALIZED), |
| 966 | #endif |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 967 | FLAG_END, |
| 968 | }; |
| 969 | |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 970 | UNUSED static struct flags clone_flags[] = { |
| 971 | FLAG_GENERIC(CLONE_VM), |
| 972 | FLAG_GENERIC(CLONE_FS), |
| 973 | FLAG_GENERIC(CLONE_FILES), |
| 974 | FLAG_GENERIC(CLONE_SIGHAND), |
| 975 | FLAG_GENERIC(CLONE_PTRACE), |
| 976 | FLAG_GENERIC(CLONE_VFORK), |
| 977 | FLAG_GENERIC(CLONE_PARENT), |
| 978 | FLAG_GENERIC(CLONE_THREAD), |
| 979 | FLAG_GENERIC(CLONE_NEWNS), |
| 980 | FLAG_GENERIC(CLONE_SYSVSEM), |
| 981 | FLAG_GENERIC(CLONE_SETTLS), |
| 982 | FLAG_GENERIC(CLONE_PARENT_SETTID), |
| 983 | FLAG_GENERIC(CLONE_CHILD_CLEARTID), |
| 984 | FLAG_GENERIC(CLONE_DETACHED), |
| 985 | FLAG_GENERIC(CLONE_UNTRACED), |
| 986 | FLAG_GENERIC(CLONE_CHILD_SETTID), |
Stefan Weil | 6f11f01 | 2011-04-27 10:44:38 +0200 | [diff] [blame] | 987 | #if defined(CLONE_NEWUTS) |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 988 | FLAG_GENERIC(CLONE_NEWUTS), |
Stefan Weil | 6f11f01 | 2011-04-27 10:44:38 +0200 | [diff] [blame] | 989 | #endif |
| 990 | #if defined(CLONE_NEWIPC) |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 991 | FLAG_GENERIC(CLONE_NEWIPC), |
Stefan Weil | 6f11f01 | 2011-04-27 10:44:38 +0200 | [diff] [blame] | 992 | #endif |
| 993 | #if defined(CLONE_NEWUSER) |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 994 | FLAG_GENERIC(CLONE_NEWUSER), |
Stefan Weil | 6f11f01 | 2011-04-27 10:44:38 +0200 | [diff] [blame] | 995 | #endif |
| 996 | #if defined(CLONE_NEWPID) |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 997 | FLAG_GENERIC(CLONE_NEWPID), |
Stefan Weil | 6f11f01 | 2011-04-27 10:44:38 +0200 | [diff] [blame] | 998 | #endif |
| 999 | #if defined(CLONE_NEWNET) |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1000 | FLAG_GENERIC(CLONE_NEWNET), |
Stefan Weil | 6f11f01 | 2011-04-27 10:44:38 +0200 | [diff] [blame] | 1001 | #endif |
| 1002 | #if defined(CLONE_IO) |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1003 | FLAG_GENERIC(CLONE_IO), |
Stefan Weil | 6f11f01 | 2011-04-27 10:44:38 +0200 | [diff] [blame] | 1004 | #endif |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1005 | FLAG_END, |
| 1006 | }; |
| 1007 | |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1008 | UNUSED static struct flags msg_flags[] = { |
| 1009 | /* send */ |
| 1010 | FLAG_GENERIC(MSG_CONFIRM), |
| 1011 | FLAG_GENERIC(MSG_DONTROUTE), |
| 1012 | FLAG_GENERIC(MSG_DONTWAIT), |
| 1013 | FLAG_GENERIC(MSG_EOR), |
| 1014 | FLAG_GENERIC(MSG_MORE), |
| 1015 | FLAG_GENERIC(MSG_NOSIGNAL), |
| 1016 | FLAG_GENERIC(MSG_OOB), |
| 1017 | /* recv */ |
| 1018 | FLAG_GENERIC(MSG_CMSG_CLOEXEC), |
| 1019 | FLAG_GENERIC(MSG_ERRQUEUE), |
| 1020 | FLAG_GENERIC(MSG_PEEK), |
| 1021 | FLAG_GENERIC(MSG_TRUNC), |
| 1022 | FLAG_GENERIC(MSG_WAITALL), |
| 1023 | /* recvmsg */ |
| 1024 | FLAG_GENERIC(MSG_CTRUNC), |
| 1025 | FLAG_END, |
| 1026 | }; |
| 1027 | |
Jim Wilson | d42744f | 2019-06-28 12:43:35 +0200 | [diff] [blame] | 1028 | UNUSED static struct flags statx_flags[] = { |
| 1029 | #ifdef AT_EMPTY_PATH |
| 1030 | FLAG_GENERIC(AT_EMPTY_PATH), |
| 1031 | #endif |
| 1032 | #ifdef AT_NO_AUTOMOUNT |
| 1033 | FLAG_GENERIC(AT_NO_AUTOMOUNT), |
| 1034 | #endif |
| 1035 | #ifdef AT_SYMLINK_NOFOLLOW |
| 1036 | FLAG_GENERIC(AT_SYMLINK_NOFOLLOW), |
| 1037 | #endif |
| 1038 | #ifdef AT_STATX_SYNC_AS_STAT |
| 1039 | FLAG_GENERIC(AT_STATX_SYNC_AS_STAT), |
| 1040 | #endif |
| 1041 | #ifdef AT_STATX_FORCE_SYNC |
| 1042 | FLAG_GENERIC(AT_STATX_FORCE_SYNC), |
| 1043 | #endif |
| 1044 | #ifdef AT_STATX_DONT_SYNC |
| 1045 | FLAG_GENERIC(AT_STATX_DONT_SYNC), |
| 1046 | #endif |
| 1047 | FLAG_END, |
| 1048 | }; |
| 1049 | |
| 1050 | UNUSED static struct flags statx_mask[] = { |
| 1051 | /* This must come first, because it includes everything. */ |
| 1052 | #ifdef STATX_ALL |
| 1053 | FLAG_GENERIC(STATX_ALL), |
| 1054 | #endif |
| 1055 | /* This must come second; it includes everything except STATX_BTIME. */ |
| 1056 | #ifdef STATX_BASIC_STATS |
| 1057 | FLAG_GENERIC(STATX_BASIC_STATS), |
| 1058 | #endif |
| 1059 | #ifdef STATX_TYPE |
| 1060 | FLAG_GENERIC(STATX_TYPE), |
| 1061 | #endif |
| 1062 | #ifdef STATX_MODE |
| 1063 | FLAG_GENERIC(STATX_MODE), |
| 1064 | #endif |
| 1065 | #ifdef STATX_NLINK |
| 1066 | FLAG_GENERIC(STATX_NLINK), |
| 1067 | #endif |
| 1068 | #ifdef STATX_UID |
| 1069 | FLAG_GENERIC(STATX_UID), |
| 1070 | #endif |
| 1071 | #ifdef STATX_GID |
| 1072 | FLAG_GENERIC(STATX_GID), |
| 1073 | #endif |
| 1074 | #ifdef STATX_ATIME |
| 1075 | FLAG_GENERIC(STATX_ATIME), |
| 1076 | #endif |
| 1077 | #ifdef STATX_MTIME |
| 1078 | FLAG_GENERIC(STATX_MTIME), |
| 1079 | #endif |
| 1080 | #ifdef STATX_CTIME |
| 1081 | FLAG_GENERIC(STATX_CTIME), |
| 1082 | #endif |
| 1083 | #ifdef STATX_INO |
| 1084 | FLAG_GENERIC(STATX_INO), |
| 1085 | #endif |
| 1086 | #ifdef STATX_SIZE |
| 1087 | FLAG_GENERIC(STATX_SIZE), |
| 1088 | #endif |
| 1089 | #ifdef STATX_BLOCKS |
| 1090 | FLAG_GENERIC(STATX_BLOCKS), |
| 1091 | #endif |
| 1092 | #ifdef STATX_BTIME |
| 1093 | FLAG_GENERIC(STATX_BTIME), |
| 1094 | #endif |
| 1095 | FLAG_END, |
| 1096 | }; |
| 1097 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1098 | /* |
| 1099 | * print_xxx utility functions. These are used to print syscall |
| 1100 | * parameters in certain format. All of these have parameter |
| 1101 | * named 'last'. This parameter is used to add comma to output |
| 1102 | * when last == 0. |
| 1103 | */ |
| 1104 | |
| 1105 | static const char * |
| 1106 | get_comma(int last) |
| 1107 | { |
| 1108 | return ((last) ? "" : ","); |
| 1109 | } |
| 1110 | |
| 1111 | static void |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 1112 | print_flags(const struct flags *f, abi_long flags, int last) |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1113 | { |
| 1114 | const char *sep = ""; |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1115 | int n; |
| 1116 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1117 | if ((flags == 0) && (f->f_value == 0)) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1118 | qemu_log("%s%s", f->f_string, get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1119 | return; |
| 1120 | } |
| 1121 | for (n = 0; f->f_string != NULL; f++) { |
| 1122 | if ((f->f_value != 0) && ((flags & f->f_value) == f->f_value)) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1123 | qemu_log("%s%s", sep, f->f_string); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1124 | flags &= ~f->f_value; |
| 1125 | sep = "|"; |
| 1126 | n++; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | if (n > 0) { |
| 1131 | /* print rest of the flags as numeric */ |
| 1132 | if (flags != 0) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1133 | qemu_log("%s%#x%s", sep, (unsigned int)flags, get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1134 | } else { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1135 | qemu_log("%s", get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1136 | } |
| 1137 | } else { |
| 1138 | /* no string version of flags found, print them in hex then */ |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1139 | qemu_log("%#x%s", (unsigned int)flags, get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | static void |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 1144 | print_at_dirfd(abi_long dirfd, int last) |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1145 | { |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1146 | #ifdef AT_FDCWD |
| 1147 | if (dirfd == AT_FDCWD) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1148 | qemu_log("AT_FDCWD%s", get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1149 | return; |
| 1150 | } |
| 1151 | #endif |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1152 | qemu_log("%d%s", (int)dirfd, get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | static void |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 1156 | print_file_mode(abi_long mode, int last) |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1157 | { |
| 1158 | const char *sep = ""; |
| 1159 | const struct flags *m; |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1160 | |
| 1161 | for (m = &mode_flags[0]; m->f_string != NULL; m++) { |
| 1162 | if ((m->f_value & mode) == m->f_value) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1163 | qemu_log("%s%s", m->f_string, sep); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1164 | sep = "|"; |
| 1165 | mode &= ~m->f_value; |
| 1166 | break; |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | mode &= ~S_IFMT; |
| 1171 | /* print rest of the mode as octal */ |
| 1172 | if (mode != 0) |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1173 | qemu_log("%s%#o", sep, (unsigned int)mode); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1174 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1175 | qemu_log("%s", get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | static void |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 1179 | print_open_flags(abi_long flags, int last) |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1180 | { |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1181 | print_flags(open_access_flags, flags & TARGET_O_ACCMODE, 1); |
| 1182 | flags &= ~TARGET_O_ACCMODE; |
| 1183 | if (flags == 0) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1184 | qemu_log("%s", get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1185 | return; |
| 1186 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1187 | qemu_log("|"); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1188 | print_flags(open_flags, flags, last); |
| 1189 | } |
| 1190 | |
| 1191 | static void |
| 1192 | print_syscall_prologue(const struct syscallname *sc) |
| 1193 | { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1194 | qemu_log("%s(", sc->name); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | /*ARGSUSED*/ |
| 1198 | static void |
| 1199 | print_syscall_epilogue(const struct syscallname *sc) |
| 1200 | { |
| 1201 | (void)sc; |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1202 | qemu_log(")"); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | static void |
| 1206 | print_string(abi_long addr, int last) |
| 1207 | { |
| 1208 | char *s; |
| 1209 | |
| 1210 | if ((s = lock_user_string(addr)) != NULL) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1211 | qemu_log("\"%s\"%s", s, get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1212 | unlock_user(s, addr, 0); |
| 1213 | } else { |
| 1214 | /* can't get string out of it, so print it as pointer */ |
| 1215 | print_pointer(addr, last); |
| 1216 | } |
| 1217 | } |
| 1218 | |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1219 | #define MAX_PRINT_BUF 40 |
| 1220 | static void |
| 1221 | print_buf(abi_long addr, abi_long len, int last) |
| 1222 | { |
| 1223 | uint8_t *s; |
| 1224 | int i; |
| 1225 | |
| 1226 | s = lock_user(VERIFY_READ, addr, len, 1); |
| 1227 | if (s) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1228 | qemu_log("\""); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1229 | for (i = 0; i < MAX_PRINT_BUF && i < len; i++) { |
| 1230 | if (isprint(s[i])) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1231 | qemu_log("%c", s[i]); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1232 | } else { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1233 | qemu_log("\\%o", s[i]); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1234 | } |
| 1235 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1236 | qemu_log("\""); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1237 | if (i != len) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1238 | qemu_log("..."); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1239 | } |
| 1240 | if (!last) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1241 | qemu_log(","); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1242 | } |
| 1243 | unlock_user(s, addr, 0); |
| 1244 | } else { |
| 1245 | print_pointer(addr, last); |
| 1246 | } |
| 1247 | } |
| 1248 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1249 | /* |
| 1250 | * Prints out raw parameter using given format. Caller needs |
| 1251 | * to do byte swapping if needed. |
| 1252 | */ |
| 1253 | static void |
| 1254 | print_raw_param(const char *fmt, abi_long param, int last) |
| 1255 | { |
| 1256 | char format[64]; |
| 1257 | |
| 1258 | (void) snprintf(format, sizeof (format), "%s%s", fmt, get_comma(last)); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1259 | qemu_log(format, param); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | static void |
| 1263 | print_pointer(abi_long p, int last) |
| 1264 | { |
| 1265 | if (p == 0) |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1266 | qemu_log("NULL%s", get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1267 | else |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1268 | qemu_log("0x" TARGET_ABI_FMT_lx "%s", p, get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1269 | } |
| 1270 | |
| 1271 | /* |
| 1272 | * Reads 32-bit (int) number from guest address space from |
| 1273 | * address 'addr' and prints it. |
| 1274 | */ |
| 1275 | static void |
| 1276 | print_number(abi_long addr, int last) |
| 1277 | { |
| 1278 | if (addr == 0) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1279 | qemu_log("NULL%s", get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1280 | } else { |
| 1281 | int num; |
| 1282 | |
| 1283 | get_user_s32(num, addr); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1284 | qemu_log("[%d]%s", num, get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | static void |
| 1289 | print_timeval(abi_ulong tv_addr, int last) |
| 1290 | { |
| 1291 | if( tv_addr ) { |
| 1292 | struct target_timeval *tv; |
| 1293 | |
| 1294 | tv = lock_user(VERIFY_READ, tv_addr, sizeof(*tv), 1); |
Philippe Mathieu-Daudé | 8f93089 | 2019-10-21 13:48:49 +0200 | [diff] [blame] | 1295 | if (!tv) { |
| 1296 | print_pointer(tv_addr, last); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1297 | return; |
Philippe Mathieu-Daudé | 8f93089 | 2019-10-21 13:48:49 +0200 | [diff] [blame] | 1298 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1299 | qemu_log("{" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "}%s", |
Laurent Vivier | 910ee4e | 2012-12-31 09:45:06 +0000 | [diff] [blame] | 1300 | tswapal(tv->tv_sec), tswapal(tv->tv_usec), get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1301 | unlock_user(tv, tv_addr, 0); |
| 1302 | } else |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1303 | qemu_log("NULL%s", get_comma(last)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1304 | } |
| 1305 | |
Philippe Mathieu-Daudé | 6d33e03 | 2019-10-21 13:48:50 +0200 | [diff] [blame] | 1306 | static void |
| 1307 | print_timezone(abi_ulong tz_addr, int last) |
| 1308 | { |
| 1309 | if (tz_addr) { |
| 1310 | struct target_timezone *tz; |
| 1311 | |
| 1312 | tz = lock_user(VERIFY_READ, tz_addr, sizeof(*tz), 1); |
| 1313 | if (!tz) { |
| 1314 | print_pointer(tz_addr, last); |
| 1315 | return; |
| 1316 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1317 | qemu_log("{%d,%d}%s", tswap32(tz->tz_minuteswest), |
Philippe Mathieu-Daudé | 6d33e03 | 2019-10-21 13:48:50 +0200 | [diff] [blame] | 1318 | tswap32(tz->tz_dsttime), get_comma(last)); |
| 1319 | unlock_user(tz, tz_addr, 0); |
| 1320 | } else { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1321 | qemu_log("NULL%s", get_comma(last)); |
Philippe Mathieu-Daudé | 6d33e03 | 2019-10-21 13:48:50 +0200 | [diff] [blame] | 1322 | } |
| 1323 | } |
| 1324 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1325 | #undef UNUSED |
| 1326 | |
| 1327 | #ifdef TARGET_NR_accept |
| 1328 | static void |
| 1329 | print_accept(const struct syscallname *name, |
| 1330 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1331 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1332 | { |
| 1333 | print_syscall_prologue(name); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 1334 | print_raw_param("%d", arg0, 0); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1335 | print_pointer(arg1, 0); |
| 1336 | print_number(arg2, 1); |
| 1337 | print_syscall_epilogue(name); |
| 1338 | } |
| 1339 | #endif |
| 1340 | |
| 1341 | #ifdef TARGET_NR_access |
| 1342 | static void |
| 1343 | print_access(const struct syscallname *name, |
| 1344 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1345 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1346 | { |
| 1347 | print_syscall_prologue(name); |
| 1348 | print_string(arg0, 0); |
| 1349 | print_flags(access_flags, arg1, 1); |
| 1350 | print_syscall_epilogue(name); |
| 1351 | } |
| 1352 | #endif |
| 1353 | |
| 1354 | #ifdef TARGET_NR_brk |
| 1355 | static void |
| 1356 | print_brk(const struct syscallname *name, |
| 1357 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1358 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1359 | { |
| 1360 | print_syscall_prologue(name); |
| 1361 | print_pointer(arg0, 1); |
| 1362 | print_syscall_epilogue(name); |
| 1363 | } |
| 1364 | #endif |
| 1365 | |
| 1366 | #ifdef TARGET_NR_chdir |
| 1367 | static void |
| 1368 | print_chdir(const struct syscallname *name, |
| 1369 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1370 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1371 | { |
| 1372 | print_syscall_prologue(name); |
| 1373 | print_string(arg0, 1); |
| 1374 | print_syscall_epilogue(name); |
| 1375 | } |
| 1376 | #endif |
| 1377 | |
Helge Deller | 1b7695f | 2019-02-27 20:11:15 +0100 | [diff] [blame] | 1378 | #ifdef TARGET_NR_chroot |
| 1379 | static void |
| 1380 | print_chroot(const struct syscallname *name, |
| 1381 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1382 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1383 | { |
| 1384 | print_syscall_prologue(name); |
| 1385 | print_string(arg0, 1); |
| 1386 | print_syscall_epilogue(name); |
| 1387 | } |
| 1388 | #endif |
| 1389 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1390 | #ifdef TARGET_NR_chmod |
| 1391 | static void |
| 1392 | print_chmod(const struct syscallname *name, |
| 1393 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1394 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1395 | { |
| 1396 | print_syscall_prologue(name); |
| 1397 | print_string(arg0, 0); |
| 1398 | print_file_mode(arg1, 1); |
| 1399 | print_syscall_epilogue(name); |
| 1400 | } |
| 1401 | #endif |
| 1402 | |
Aleksandar Markovic | 38860a0 | 2016-10-10 13:23:29 +0200 | [diff] [blame] | 1403 | #ifdef TARGET_NR_clock_adjtime |
| 1404 | static void |
| 1405 | print_clock_adjtime(const struct syscallname *name, |
| 1406 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1407 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1408 | { |
| 1409 | print_syscall_prologue(name); |
| 1410 | print_clockid(arg0, 0); |
| 1411 | print_pointer(arg1, 1); |
| 1412 | print_syscall_epilogue(name); |
| 1413 | } |
| 1414 | #endif |
| 1415 | |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1416 | #ifdef TARGET_NR_clone |
Laurent Vivier | 84bd828 | 2016-06-11 02:19:47 +0200 | [diff] [blame] | 1417 | static void do_print_clone(unsigned int flags, abi_ulong newsp, |
| 1418 | abi_ulong parent_tidptr, target_ulong newtls, |
| 1419 | abi_ulong child_tidptr) |
| 1420 | { |
| 1421 | print_flags(clone_flags, flags, 0); |
| 1422 | print_raw_param("child_stack=0x" TARGET_ABI_FMT_lx, newsp, 0); |
| 1423 | print_raw_param("parent_tidptr=0x" TARGET_ABI_FMT_lx, parent_tidptr, 0); |
| 1424 | print_raw_param("tls=0x" TARGET_ABI_FMT_lx, newtls, 0); |
| 1425 | print_raw_param("child_tidptr=0x" TARGET_ABI_FMT_lx, child_tidptr, 1); |
| 1426 | } |
| 1427 | |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1428 | static void |
| 1429 | print_clone(const struct syscallname *name, |
Laurent Vivier | 84bd828 | 2016-06-11 02:19:47 +0200 | [diff] [blame] | 1430 | abi_long arg1, abi_long arg2, abi_long arg3, |
| 1431 | abi_long arg4, abi_long arg5, abi_long arg6) |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1432 | { |
| 1433 | print_syscall_prologue(name); |
Laurent Vivier | 84bd828 | 2016-06-11 02:19:47 +0200 | [diff] [blame] | 1434 | #if defined(TARGET_MICROBLAZE) |
| 1435 | do_print_clone(arg1, arg2, arg4, arg6, arg5); |
| 1436 | #elif defined(TARGET_CLONE_BACKWARDS) |
| 1437 | do_print_clone(arg1, arg2, arg3, arg4, arg5); |
| 1438 | #elif defined(TARGET_CLONE_BACKWARDS2) |
| 1439 | do_print_clone(arg2, arg1, arg3, arg5, arg4); |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1440 | #else |
Laurent Vivier | 84bd828 | 2016-06-11 02:19:47 +0200 | [diff] [blame] | 1441 | do_print_clone(arg1, arg2, arg3, arg5, arg4); |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1442 | #endif |
| 1443 | print_syscall_epilogue(name); |
| 1444 | } |
| 1445 | #endif |
| 1446 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1447 | #ifdef TARGET_NR_creat |
| 1448 | static void |
| 1449 | print_creat(const struct syscallname *name, |
| 1450 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1451 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1452 | { |
| 1453 | print_syscall_prologue(name); |
| 1454 | print_string(arg0, 0); |
| 1455 | print_file_mode(arg1, 1); |
| 1456 | print_syscall_epilogue(name); |
| 1457 | } |
| 1458 | #endif |
| 1459 | |
| 1460 | #ifdef TARGET_NR_execv |
| 1461 | static void |
| 1462 | print_execv(const struct syscallname *name, |
| 1463 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1464 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1465 | { |
| 1466 | print_syscall_prologue(name); |
| 1467 | print_string(arg0, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 1468 | print_raw_param("0x" TARGET_ABI_FMT_lx, arg1, 1); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1469 | print_syscall_epilogue(name); |
| 1470 | } |
| 1471 | #endif |
| 1472 | |
| 1473 | #ifdef TARGET_NR_faccessat |
| 1474 | static void |
| 1475 | print_faccessat(const struct syscallname *name, |
| 1476 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1477 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1478 | { |
| 1479 | print_syscall_prologue(name); |
| 1480 | print_at_dirfd(arg0, 0); |
| 1481 | print_string(arg1, 0); |
| 1482 | print_flags(access_flags, arg2, 0); |
| 1483 | print_flags(at_file_flags, arg3, 1); |
| 1484 | print_syscall_epilogue(name); |
| 1485 | } |
| 1486 | #endif |
| 1487 | |
| 1488 | #ifdef TARGET_NR_fchmodat |
| 1489 | static void |
| 1490 | print_fchmodat(const struct syscallname *name, |
| 1491 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1492 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1493 | { |
| 1494 | print_syscall_prologue(name); |
| 1495 | print_at_dirfd(arg0, 0); |
| 1496 | print_string(arg1, 0); |
| 1497 | print_file_mode(arg2, 0); |
| 1498 | print_flags(at_file_flags, arg3, 1); |
| 1499 | print_syscall_epilogue(name); |
| 1500 | } |
| 1501 | #endif |
| 1502 | |
| 1503 | #ifdef TARGET_NR_fchownat |
| 1504 | static void |
| 1505 | print_fchownat(const struct syscallname *name, |
| 1506 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1507 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1508 | { |
| 1509 | print_syscall_prologue(name); |
| 1510 | print_at_dirfd(arg0, 0); |
| 1511 | print_string(arg1, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 1512 | print_raw_param("%d", arg2, 0); |
| 1513 | print_raw_param("%d", arg3, 0); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1514 | print_flags(at_file_flags, arg4, 1); |
| 1515 | print_syscall_epilogue(name); |
| 1516 | } |
| 1517 | #endif |
| 1518 | |
| 1519 | #if defined(TARGET_NR_fcntl) || defined(TARGET_NR_fcntl64) |
| 1520 | static void |
| 1521 | print_fcntl(const struct syscallname *name, |
| 1522 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1523 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1524 | { |
| 1525 | print_syscall_prologue(name); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 1526 | print_raw_param("%d", arg0, 0); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1527 | switch(arg1) { |
| 1528 | case TARGET_F_DUPFD: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1529 | qemu_log("F_DUPFD,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1530 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
| 1531 | break; |
| 1532 | case TARGET_F_GETFD: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1533 | qemu_log("F_GETFD"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1534 | break; |
| 1535 | case TARGET_F_SETFD: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1536 | qemu_log("F_SETFD,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1537 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
| 1538 | break; |
| 1539 | case TARGET_F_GETFL: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1540 | qemu_log("F_GETFL"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1541 | break; |
| 1542 | case TARGET_F_SETFL: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1543 | qemu_log("F_SETFL,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1544 | print_open_flags(arg2, 1); |
| 1545 | break; |
| 1546 | case TARGET_F_GETLK: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1547 | qemu_log("F_GETLK,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1548 | print_pointer(arg2, 1); |
| 1549 | break; |
| 1550 | case TARGET_F_SETLK: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1551 | qemu_log("F_SETLK,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1552 | print_pointer(arg2, 1); |
| 1553 | break; |
| 1554 | case TARGET_F_SETLKW: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1555 | qemu_log("F_SETLKW,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1556 | print_pointer(arg2, 1); |
| 1557 | break; |
| 1558 | case TARGET_F_GETOWN: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1559 | qemu_log("F_GETOWN"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1560 | break; |
| 1561 | case TARGET_F_SETOWN: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1562 | qemu_log("F_SETOWN,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1563 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
| 1564 | break; |
| 1565 | case TARGET_F_GETSIG: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1566 | qemu_log("F_GETSIG"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1567 | break; |
| 1568 | case TARGET_F_SETSIG: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1569 | qemu_log("F_SETSIG,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1570 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
| 1571 | break; |
| 1572 | #if TARGET_ABI_BITS == 32 |
| 1573 | case TARGET_F_GETLK64: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1574 | qemu_log("F_GETLK64,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1575 | print_pointer(arg2, 1); |
| 1576 | break; |
| 1577 | case TARGET_F_SETLK64: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1578 | qemu_log("F_SETLK64,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1579 | print_pointer(arg2, 1); |
| 1580 | break; |
| 1581 | case TARGET_F_SETLKW64: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1582 | qemu_log("F_SETLKW64,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1583 | print_pointer(arg2, 1); |
| 1584 | break; |
| 1585 | #endif |
| 1586 | case TARGET_F_SETLEASE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1587 | qemu_log("F_SETLEASE,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1588 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
| 1589 | break; |
| 1590 | case TARGET_F_GETLEASE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1591 | qemu_log("F_GETLEASE"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1592 | break; |
Peter Maydell | 7e3b92e | 2016-06-20 15:50:37 +0100 | [diff] [blame] | 1593 | case TARGET_F_SETPIPE_SZ: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1594 | qemu_log("F_SETPIPE_SZ,"); |
Peter Maydell | 7e3b92e | 2016-06-20 15:50:37 +0100 | [diff] [blame] | 1595 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
| 1596 | break; |
| 1597 | case TARGET_F_GETPIPE_SZ: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1598 | qemu_log("F_GETPIPE_SZ"); |
Peter Maydell | 7e3b92e | 2016-06-20 15:50:37 +0100 | [diff] [blame] | 1599 | break; |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1600 | case TARGET_F_DUPFD_CLOEXEC: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1601 | qemu_log("F_DUPFD_CLOEXEC,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1602 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 1); |
| 1603 | break; |
| 1604 | case TARGET_F_NOTIFY: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1605 | qemu_log("F_NOTIFY,"); |
Laurent Vivier | d95ec14 | 2012-12-31 21:00:11 +0100 | [diff] [blame] | 1606 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
| 1607 | break; |
| 1608 | default: |
| 1609 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); |
| 1610 | print_pointer(arg2, 1); |
| 1611 | break; |
| 1612 | } |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1613 | print_syscall_epilogue(name); |
| 1614 | } |
| 1615 | #define print_fcntl64 print_fcntl |
| 1616 | #endif |
| 1617 | |
| 1618 | |
| 1619 | #ifdef TARGET_NR_futimesat |
| 1620 | static void |
| 1621 | print_futimesat(const struct syscallname *name, |
| 1622 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1623 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1624 | { |
| 1625 | print_syscall_prologue(name); |
| 1626 | print_at_dirfd(arg0, 0); |
| 1627 | print_string(arg1, 0); |
| 1628 | print_timeval(arg2, 0); |
| 1629 | print_timeval(arg2 + sizeof (struct target_timeval), 1); |
| 1630 | print_syscall_epilogue(name); |
| 1631 | } |
| 1632 | #endif |
| 1633 | |
Philippe Mathieu-Daudé | 0d2187c | 2019-10-21 13:48:51 +0200 | [diff] [blame] | 1634 | #ifdef TARGET_NR_settimeofday |
| 1635 | static void |
| 1636 | print_settimeofday(const struct syscallname *name, |
| 1637 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1638 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1639 | { |
| 1640 | print_syscall_prologue(name); |
| 1641 | print_timeval(arg0, 0); |
| 1642 | print_timezone(arg1, 1); |
| 1643 | print_syscall_epilogue(name); |
| 1644 | } |
| 1645 | #endif |
| 1646 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 1647 | #ifdef TARGET_NR_link |
| 1648 | static void |
| 1649 | print_link(const struct syscallname *name, |
| 1650 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1651 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1652 | { |
| 1653 | print_syscall_prologue(name); |
| 1654 | print_string(arg0, 0); |
| 1655 | print_string(arg1, 1); |
| 1656 | print_syscall_epilogue(name); |
| 1657 | } |
| 1658 | #endif |
| 1659 | |
| 1660 | #ifdef TARGET_NR_linkat |
| 1661 | static void |
| 1662 | print_linkat(const struct syscallname *name, |
| 1663 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1664 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1665 | { |
| 1666 | print_syscall_prologue(name); |
| 1667 | print_at_dirfd(arg0, 0); |
| 1668 | print_string(arg1, 0); |
| 1669 | print_at_dirfd(arg2, 0); |
| 1670 | print_string(arg3, 0); |
| 1671 | print_flags(at_file_flags, arg4, 1); |
| 1672 | print_syscall_epilogue(name); |
| 1673 | } |
| 1674 | #endif |
| 1675 | |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1676 | #ifdef TARGET_NR__llseek |
| 1677 | static void |
| 1678 | print__llseek(const struct syscallname *name, |
| 1679 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1680 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1681 | { |
| 1682 | const char *whence = "UNKNOWN"; |
| 1683 | print_syscall_prologue(name); |
| 1684 | print_raw_param("%d", arg0, 0); |
| 1685 | print_raw_param("%ld", arg1, 0); |
| 1686 | print_raw_param("%ld", arg2, 0); |
| 1687 | print_pointer(arg3, 0); |
| 1688 | switch(arg4) { |
| 1689 | case SEEK_SET: whence = "SEEK_SET"; break; |
| 1690 | case SEEK_CUR: whence = "SEEK_CUR"; break; |
| 1691 | case SEEK_END: whence = "SEEK_END"; break; |
| 1692 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1693 | qemu_log("%s", whence); |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 1694 | print_syscall_epilogue(name); |
| 1695 | } |
| 1696 | #endif |
| 1697 | |
Laurent Vivier | 8997d1b | 2016-06-11 02:19:46 +0200 | [diff] [blame] | 1698 | #if defined(TARGET_NR_socket) |
| 1699 | static void |
| 1700 | print_socket(const struct syscallname *name, |
| 1701 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 1702 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 1703 | { |
| 1704 | abi_ulong domain = arg0, type = arg1, protocol = arg2; |
| 1705 | |
| 1706 | print_syscall_prologue(name); |
| 1707 | print_socket_domain(domain); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1708 | qemu_log(","); |
Laurent Vivier | 8997d1b | 2016-06-11 02:19:46 +0200 | [diff] [blame] | 1709 | print_socket_type(type); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1710 | qemu_log(","); |
Laurent Vivier | 8997d1b | 2016-06-11 02:19:46 +0200 | [diff] [blame] | 1711 | if (domain == AF_PACKET || |
| 1712 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { |
| 1713 | protocol = tswap16(protocol); |
| 1714 | } |
| 1715 | print_socket_protocol(domain, type, protocol); |
| 1716 | print_syscall_epilogue(name); |
| 1717 | } |
| 1718 | |
| 1719 | #endif |
| 1720 | |
Philippe Mathieu-Daudé | bb10540 | 2019-10-21 13:48:55 +0200 | [diff] [blame] | 1721 | #if defined(TARGET_NR_socketcall) || defined(TARGET_NR_bind) |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1722 | |
Philippe Mathieu-Daudé | d84fe1e | 2019-10-21 13:48:54 +0200 | [diff] [blame] | 1723 | static void print_sockfd(abi_long sockfd, int last) |
| 1724 | { |
| 1725 | print_raw_param(TARGET_ABI_FMT_ld, sockfd, last); |
| 1726 | } |
| 1727 | |
| 1728 | #endif |
| 1729 | |
| 1730 | #if defined(TARGET_NR_socketcall) |
| 1731 | |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1732 | #define get_user_ualx(x, gaddr, idx) \ |
| 1733 | get_user_ual(x, (gaddr) + (idx) * sizeof(abi_long)) |
| 1734 | |
| 1735 | static void do_print_socket(const char *name, abi_long arg1) |
| 1736 | { |
| 1737 | abi_ulong domain, type, protocol; |
| 1738 | |
| 1739 | get_user_ualx(domain, arg1, 0); |
| 1740 | get_user_ualx(type, arg1, 1); |
| 1741 | get_user_ualx(protocol, arg1, 2); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1742 | qemu_log("%s(", name); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1743 | print_socket_domain(domain); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1744 | qemu_log(","); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1745 | print_socket_type(type); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1746 | qemu_log(","); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1747 | if (domain == AF_PACKET || |
| 1748 | (domain == AF_INET && type == TARGET_SOCK_PACKET)) { |
| 1749 | protocol = tswap16(protocol); |
| 1750 | } |
| 1751 | print_socket_protocol(domain, type, protocol); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1752 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1753 | } |
| 1754 | |
| 1755 | static void do_print_sockaddr(const char *name, abi_long arg1) |
| 1756 | { |
| 1757 | abi_ulong sockfd, addr, addrlen; |
| 1758 | |
| 1759 | get_user_ualx(sockfd, arg1, 0); |
| 1760 | get_user_ualx(addr, arg1, 1); |
| 1761 | get_user_ualx(addrlen, arg1, 2); |
| 1762 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1763 | qemu_log("%s(", name); |
Philippe Mathieu-Daudé | d84fe1e | 2019-10-21 13:48:54 +0200 | [diff] [blame] | 1764 | print_sockfd(sockfd, 0); |
Philippe Mathieu-Daudé | 42b15d7 | 2019-10-21 13:48:56 +0200 | [diff] [blame] | 1765 | print_sockaddr(addr, addrlen, 0); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1766 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1767 | } |
| 1768 | |
| 1769 | static void do_print_listen(const char *name, abi_long arg1) |
| 1770 | { |
| 1771 | abi_ulong sockfd, backlog; |
| 1772 | |
| 1773 | get_user_ualx(sockfd, arg1, 0); |
| 1774 | get_user_ualx(backlog, arg1, 1); |
| 1775 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1776 | qemu_log("%s(", name); |
Philippe Mathieu-Daudé | d84fe1e | 2019-10-21 13:48:54 +0200 | [diff] [blame] | 1777 | print_sockfd(sockfd, 0); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1778 | print_raw_param(TARGET_ABI_FMT_ld, backlog, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1779 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1780 | } |
| 1781 | |
| 1782 | static void do_print_socketpair(const char *name, abi_long arg1) |
| 1783 | { |
| 1784 | abi_ulong domain, type, protocol, tab; |
| 1785 | |
| 1786 | get_user_ualx(domain, arg1, 0); |
| 1787 | get_user_ualx(type, arg1, 1); |
| 1788 | get_user_ualx(protocol, arg1, 2); |
| 1789 | get_user_ualx(tab, arg1, 3); |
| 1790 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1791 | qemu_log("%s(", name); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1792 | print_socket_domain(domain); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1793 | qemu_log(","); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1794 | print_socket_type(type); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1795 | qemu_log(","); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1796 | print_socket_protocol(domain, type, protocol); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1797 | qemu_log(","); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1798 | print_raw_param(TARGET_ABI_FMT_lx, tab, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1799 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1800 | } |
| 1801 | |
| 1802 | static void do_print_sendrecv(const char *name, abi_long arg1) |
| 1803 | { |
| 1804 | abi_ulong sockfd, msg, len, flags; |
| 1805 | |
| 1806 | get_user_ualx(sockfd, arg1, 0); |
| 1807 | get_user_ualx(msg, arg1, 1); |
| 1808 | get_user_ualx(len, arg1, 2); |
| 1809 | get_user_ualx(flags, arg1, 3); |
| 1810 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1811 | qemu_log("%s(", name); |
Philippe Mathieu-Daudé | d84fe1e | 2019-10-21 13:48:54 +0200 | [diff] [blame] | 1812 | print_sockfd(sockfd, 0); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1813 | print_buf(msg, len, 0); |
| 1814 | print_raw_param(TARGET_ABI_FMT_ld, len, 0); |
| 1815 | print_flags(msg_flags, flags, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1816 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1817 | } |
| 1818 | |
| 1819 | static void do_print_msgaddr(const char *name, abi_long arg1) |
| 1820 | { |
| 1821 | abi_ulong sockfd, msg, len, flags, addr, addrlen; |
| 1822 | |
| 1823 | get_user_ualx(sockfd, arg1, 0); |
| 1824 | get_user_ualx(msg, arg1, 1); |
| 1825 | get_user_ualx(len, arg1, 2); |
| 1826 | get_user_ualx(flags, arg1, 3); |
| 1827 | get_user_ualx(addr, arg1, 4); |
| 1828 | get_user_ualx(addrlen, arg1, 5); |
| 1829 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1830 | qemu_log("%s(", name); |
Philippe Mathieu-Daudé | d84fe1e | 2019-10-21 13:48:54 +0200 | [diff] [blame] | 1831 | print_sockfd(sockfd, 0); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1832 | print_buf(msg, len, 0); |
| 1833 | print_raw_param(TARGET_ABI_FMT_ld, len, 0); |
| 1834 | print_flags(msg_flags, flags, 0); |
Philippe Mathieu-Daudé | 42b15d7 | 2019-10-21 13:48:56 +0200 | [diff] [blame] | 1835 | print_sockaddr(addr, addrlen, 0); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1836 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1837 | } |
| 1838 | |
| 1839 | static void do_print_shutdown(const char *name, abi_long arg1) |
| 1840 | { |
| 1841 | abi_ulong sockfd, how; |
| 1842 | |
| 1843 | get_user_ualx(sockfd, arg1, 0); |
| 1844 | get_user_ualx(how, arg1, 1); |
| 1845 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1846 | qemu_log("shutdown("); |
Philippe Mathieu-Daudé | d84fe1e | 2019-10-21 13:48:54 +0200 | [diff] [blame] | 1847 | print_sockfd(sockfd, 0); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1848 | switch (how) { |
| 1849 | case SHUT_RD: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1850 | qemu_log("SHUT_RD"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1851 | break; |
| 1852 | case SHUT_WR: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1853 | qemu_log("SHUT_WR"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1854 | break; |
| 1855 | case SHUT_RDWR: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1856 | qemu_log("SHUT_RDWR"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1857 | break; |
| 1858 | default: |
| 1859 | print_raw_param(TARGET_ABI_FMT_ld, how, 1); |
| 1860 | break; |
| 1861 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1862 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1863 | } |
| 1864 | |
| 1865 | static void do_print_msg(const char *name, abi_long arg1) |
| 1866 | { |
| 1867 | abi_ulong sockfd, msg, flags; |
| 1868 | |
| 1869 | get_user_ualx(sockfd, arg1, 0); |
| 1870 | get_user_ualx(msg, arg1, 1); |
| 1871 | get_user_ualx(flags, arg1, 2); |
| 1872 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1873 | qemu_log("%s(", name); |
Philippe Mathieu-Daudé | d84fe1e | 2019-10-21 13:48:54 +0200 | [diff] [blame] | 1874 | print_sockfd(sockfd, 0); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1875 | print_pointer(msg, 0); |
| 1876 | print_flags(msg_flags, flags, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1877 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1878 | } |
| 1879 | |
| 1880 | static void do_print_sockopt(const char *name, abi_long arg1) |
| 1881 | { |
| 1882 | abi_ulong sockfd, level, optname, optval, optlen; |
| 1883 | |
| 1884 | get_user_ualx(sockfd, arg1, 0); |
| 1885 | get_user_ualx(level, arg1, 1); |
| 1886 | get_user_ualx(optname, arg1, 2); |
| 1887 | get_user_ualx(optval, arg1, 3); |
| 1888 | get_user_ualx(optlen, arg1, 4); |
| 1889 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1890 | qemu_log("%s(", name); |
Philippe Mathieu-Daudé | d84fe1e | 2019-10-21 13:48:54 +0200 | [diff] [blame] | 1891 | print_sockfd(sockfd, 0); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1892 | switch (level) { |
| 1893 | case SOL_TCP: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1894 | qemu_log("SOL_TCP,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1895 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
| 1896 | print_pointer(optval, 0); |
| 1897 | break; |
| 1898 | case SOL_IP: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1899 | qemu_log("SOL_IP,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1900 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
| 1901 | print_pointer(optval, 0); |
| 1902 | break; |
| 1903 | case SOL_RAW: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1904 | qemu_log("SOL_RAW,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1905 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
| 1906 | print_pointer(optval, 0); |
| 1907 | break; |
| 1908 | case TARGET_SOL_SOCKET: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1909 | qemu_log("SOL_SOCKET,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1910 | switch (optname) { |
| 1911 | case TARGET_SO_DEBUG: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1912 | qemu_log("SO_DEBUG,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1913 | print_optint: |
| 1914 | print_number(optval, 0); |
| 1915 | break; |
| 1916 | case TARGET_SO_REUSEADDR: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1917 | qemu_log("SO_REUSEADDR,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1918 | goto print_optint; |
Yunqiang Su | 113a9dd | 2018-10-30 13:55:08 +0100 | [diff] [blame] | 1919 | case TARGET_SO_REUSEPORT: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1920 | qemu_log("SO_REUSEPORT,"); |
Yunqiang Su | 113a9dd | 2018-10-30 13:55:08 +0100 | [diff] [blame] | 1921 | goto print_optint; |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1922 | case TARGET_SO_TYPE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1923 | qemu_log("SO_TYPE,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1924 | goto print_optint; |
| 1925 | case TARGET_SO_ERROR: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1926 | qemu_log("SO_ERROR,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1927 | goto print_optint; |
| 1928 | case TARGET_SO_DONTROUTE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1929 | qemu_log("SO_DONTROUTE,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1930 | goto print_optint; |
| 1931 | case TARGET_SO_BROADCAST: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1932 | qemu_log("SO_BROADCAST,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1933 | goto print_optint; |
| 1934 | case TARGET_SO_SNDBUF: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1935 | qemu_log("SO_SNDBUF,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1936 | goto print_optint; |
| 1937 | case TARGET_SO_RCVBUF: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1938 | qemu_log("SO_RCVBUF,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1939 | goto print_optint; |
| 1940 | case TARGET_SO_KEEPALIVE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1941 | qemu_log("SO_KEEPALIVE,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1942 | goto print_optint; |
| 1943 | case TARGET_SO_OOBINLINE: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1944 | qemu_log("SO_OOBINLINE,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1945 | goto print_optint; |
| 1946 | case TARGET_SO_NO_CHECK: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1947 | qemu_log("SO_NO_CHECK,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1948 | goto print_optint; |
| 1949 | case TARGET_SO_PRIORITY: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1950 | qemu_log("SO_PRIORITY,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1951 | goto print_optint; |
| 1952 | case TARGET_SO_BSDCOMPAT: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1953 | qemu_log("SO_BSDCOMPAT,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1954 | goto print_optint; |
| 1955 | case TARGET_SO_PASSCRED: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1956 | qemu_log("SO_PASSCRED,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1957 | goto print_optint; |
| 1958 | case TARGET_SO_TIMESTAMP: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1959 | qemu_log("SO_TIMESTAMP,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1960 | goto print_optint; |
| 1961 | case TARGET_SO_RCVLOWAT: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1962 | qemu_log("SO_RCVLOWAT,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1963 | goto print_optint; |
| 1964 | case TARGET_SO_RCVTIMEO: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1965 | qemu_log("SO_RCVTIMEO,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1966 | print_timeval(optval, 0); |
| 1967 | break; |
| 1968 | case TARGET_SO_SNDTIMEO: |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1969 | qemu_log("SO_SNDTIMEO,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1970 | print_timeval(optval, 0); |
| 1971 | break; |
| 1972 | case TARGET_SO_ATTACH_FILTER: { |
| 1973 | struct target_sock_fprog *fprog; |
| 1974 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1975 | qemu_log("SO_ATTACH_FILTER,"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1976 | |
| 1977 | if (lock_user_struct(VERIFY_READ, fprog, optval, 0)) { |
| 1978 | struct target_sock_filter *filter; |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1979 | qemu_log("{"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1980 | if (lock_user_struct(VERIFY_READ, filter, |
| 1981 | tswapal(fprog->filter), 0)) { |
| 1982 | int i; |
| 1983 | for (i = 0; i < tswap16(fprog->len) - 1; i++) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1984 | qemu_log("[%d]{0x%x,%d,%d,0x%x},", |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1985 | i, tswap16(filter[i].code), |
| 1986 | filter[i].jt, filter[i].jf, |
| 1987 | tswap32(filter[i].k)); |
| 1988 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1989 | qemu_log("[%d]{0x%x,%d,%d,0x%x}", |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1990 | i, tswap16(filter[i].code), |
| 1991 | filter[i].jt, filter[i].jf, |
| 1992 | tswap32(filter[i].k)); |
| 1993 | } else { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1994 | qemu_log(TARGET_ABI_FMT_lx, tswapal(fprog->filter)); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1995 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 1996 | qemu_log(",%d},", tswap16(fprog->len)); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 1997 | unlock_user(fprog, optval, 0); |
| 1998 | } else { |
| 1999 | print_pointer(optval, 0); |
| 2000 | } |
| 2001 | break; |
| 2002 | } |
| 2003 | default: |
| 2004 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
| 2005 | print_pointer(optval, 0); |
| 2006 | break; |
| 2007 | } |
| 2008 | break; |
| 2009 | default: |
| 2010 | print_raw_param(TARGET_ABI_FMT_ld, level, 0); |
| 2011 | print_raw_param(TARGET_ABI_FMT_ld, optname, 0); |
| 2012 | print_pointer(optval, 0); |
| 2013 | break; |
| 2014 | } |
| 2015 | print_raw_param(TARGET_ABI_FMT_ld, optlen, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2016 | qemu_log(")"); |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | #define PRINT_SOCKOP(name, func) \ |
Aleksandar Markovic | ff71a45 | 2016-09-22 18:56:57 +0200 | [diff] [blame] | 2020 | [TARGET_SYS_##name] = { #name, func } |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 2021 | |
| 2022 | static struct { |
| 2023 | const char *name; |
| 2024 | void (*print)(const char *, abi_long); |
| 2025 | } scall[] = { |
Aleksandar Markovic | ff71a45 | 2016-09-22 18:56:57 +0200 | [diff] [blame] | 2026 | PRINT_SOCKOP(SOCKET, do_print_socket), |
| 2027 | PRINT_SOCKOP(BIND, do_print_sockaddr), |
| 2028 | PRINT_SOCKOP(CONNECT, do_print_sockaddr), |
| 2029 | PRINT_SOCKOP(LISTEN, do_print_listen), |
| 2030 | PRINT_SOCKOP(ACCEPT, do_print_sockaddr), |
| 2031 | PRINT_SOCKOP(GETSOCKNAME, do_print_sockaddr), |
| 2032 | PRINT_SOCKOP(GETPEERNAME, do_print_sockaddr), |
| 2033 | PRINT_SOCKOP(SOCKETPAIR, do_print_socketpair), |
| 2034 | PRINT_SOCKOP(SEND, do_print_sendrecv), |
| 2035 | PRINT_SOCKOP(RECV, do_print_sendrecv), |
| 2036 | PRINT_SOCKOP(SENDTO, do_print_msgaddr), |
| 2037 | PRINT_SOCKOP(RECVFROM, do_print_msgaddr), |
| 2038 | PRINT_SOCKOP(SHUTDOWN, do_print_shutdown), |
| 2039 | PRINT_SOCKOP(SETSOCKOPT, do_print_sockopt), |
| 2040 | PRINT_SOCKOP(GETSOCKOPT, do_print_sockopt), |
| 2041 | PRINT_SOCKOP(SENDMSG, do_print_msg), |
| 2042 | PRINT_SOCKOP(RECVMSG, do_print_msg), |
| 2043 | PRINT_SOCKOP(ACCEPT4, NULL), |
| 2044 | PRINT_SOCKOP(RECVMMSG, NULL), |
| 2045 | PRINT_SOCKOP(SENDMMSG, NULL), |
Laurent Vivier | fb3aabf | 2016-06-11 02:19:45 +0200 | [diff] [blame] | 2046 | }; |
| 2047 | |
| 2048 | static void |
| 2049 | print_socketcall(const struct syscallname *name, |
| 2050 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2051 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2052 | { |
| 2053 | if (arg0 >= 0 && arg0 < ARRAY_SIZE(scall) && scall[arg0].print) { |
| 2054 | scall[arg0].print(scall[arg0].name, arg1); |
| 2055 | return; |
| 2056 | } |
| 2057 | print_syscall_prologue(name); |
| 2058 | print_raw_param(TARGET_ABI_FMT_ld, arg0, 0); |
| 2059 | print_raw_param(TARGET_ABI_FMT_ld, arg1, 0); |
| 2060 | print_raw_param(TARGET_ABI_FMT_ld, arg2, 0); |
| 2061 | print_raw_param(TARGET_ABI_FMT_ld, arg3, 0); |
| 2062 | print_raw_param(TARGET_ABI_FMT_ld, arg4, 0); |
| 2063 | print_raw_param(TARGET_ABI_FMT_ld, arg5, 0); |
| 2064 | print_syscall_epilogue(name); |
| 2065 | } |
| 2066 | #endif |
| 2067 | |
Philippe Mathieu-Daudé | bb10540 | 2019-10-21 13:48:55 +0200 | [diff] [blame] | 2068 | #if defined(TARGET_NR_bind) |
| 2069 | static void |
| 2070 | print_bind(const struct syscallname *name, |
| 2071 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2072 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2073 | { |
| 2074 | print_syscall_prologue(name); |
| 2075 | print_sockfd(arg0, 0); |
| 2076 | print_sockaddr(arg1, arg2, 1); |
| 2077 | print_syscall_epilogue(name); |
| 2078 | } |
| 2079 | #endif |
| 2080 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2081 | #if defined(TARGET_NR_stat) || defined(TARGET_NR_stat64) || \ |
| 2082 | defined(TARGET_NR_lstat) || defined(TARGET_NR_lstat64) |
| 2083 | static void |
| 2084 | print_stat(const struct syscallname *name, |
| 2085 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2086 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2087 | { |
| 2088 | print_syscall_prologue(name); |
| 2089 | print_string(arg0, 0); |
| 2090 | print_pointer(arg1, 1); |
| 2091 | print_syscall_epilogue(name); |
| 2092 | } |
| 2093 | #define print_lstat print_stat |
| 2094 | #define print_stat64 print_stat |
| 2095 | #define print_lstat64 print_stat |
| 2096 | #endif |
| 2097 | |
| 2098 | #if defined(TARGET_NR_fstat) || defined(TARGET_NR_fstat64) |
| 2099 | static void |
| 2100 | print_fstat(const struct syscallname *name, |
| 2101 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2102 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2103 | { |
| 2104 | print_syscall_prologue(name); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2105 | print_raw_param("%d", arg0, 0); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2106 | print_pointer(arg1, 1); |
| 2107 | print_syscall_epilogue(name); |
| 2108 | } |
| 2109 | #define print_fstat64 print_fstat |
| 2110 | #endif |
| 2111 | |
| 2112 | #ifdef TARGET_NR_mkdir |
| 2113 | static void |
| 2114 | print_mkdir(const struct syscallname *name, |
| 2115 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2116 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2117 | { |
| 2118 | print_syscall_prologue(name); |
| 2119 | print_string(arg0, 0); |
| 2120 | print_file_mode(arg1, 1); |
| 2121 | print_syscall_epilogue(name); |
| 2122 | } |
| 2123 | #endif |
| 2124 | |
| 2125 | #ifdef TARGET_NR_mkdirat |
| 2126 | static void |
| 2127 | print_mkdirat(const struct syscallname *name, |
| 2128 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2129 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2130 | { |
| 2131 | print_syscall_prologue(name); |
| 2132 | print_at_dirfd(arg0, 0); |
| 2133 | print_string(arg1, 0); |
| 2134 | print_file_mode(arg2, 1); |
| 2135 | print_syscall_epilogue(name); |
| 2136 | } |
| 2137 | #endif |
| 2138 | |
Laurent Vivier | 4de596c | 2011-02-15 21:10:43 +0100 | [diff] [blame] | 2139 | #ifdef TARGET_NR_rmdir |
| 2140 | static void |
| 2141 | print_rmdir(const struct syscallname *name, |
| 2142 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2143 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2144 | { |
| 2145 | print_syscall_prologue(name); |
| 2146 | print_string(arg0, 0); |
| 2147 | print_syscall_epilogue(name); |
| 2148 | } |
| 2149 | #endif |
| 2150 | |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 2151 | #ifdef TARGET_NR_rt_sigaction |
| 2152 | static void |
| 2153 | print_rt_sigaction(const struct syscallname *name, |
| 2154 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2155 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2156 | { |
| 2157 | print_syscall_prologue(name); |
| 2158 | print_signal(arg0, 0); |
| 2159 | print_pointer(arg1, 0); |
| 2160 | print_pointer(arg2, 1); |
| 2161 | print_syscall_epilogue(name); |
| 2162 | } |
| 2163 | #endif |
| 2164 | |
| 2165 | #ifdef TARGET_NR_rt_sigprocmask |
| 2166 | static void |
| 2167 | print_rt_sigprocmask(const struct syscallname *name, |
| 2168 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2169 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2170 | { |
| 2171 | const char *how = "UNKNOWN"; |
| 2172 | print_syscall_prologue(name); |
| 2173 | switch(arg0) { |
| 2174 | case TARGET_SIG_BLOCK: how = "SIG_BLOCK"; break; |
| 2175 | case TARGET_SIG_UNBLOCK: how = "SIG_UNBLOCK"; break; |
| 2176 | case TARGET_SIG_SETMASK: how = "SIG_SETMASK"; break; |
| 2177 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2178 | qemu_log("%s,", how); |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 2179 | print_pointer(arg1, 0); |
| 2180 | print_pointer(arg2, 1); |
| 2181 | print_syscall_epilogue(name); |
| 2182 | } |
| 2183 | #endif |
| 2184 | |
Miloš Stojanović | 5162264 | 2017-05-15 16:59:42 +0200 | [diff] [blame] | 2185 | #ifdef TARGET_NR_rt_sigqueueinfo |
| 2186 | static void |
| 2187 | print_rt_sigqueueinfo(const struct syscallname *name, |
| 2188 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2189 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2190 | { |
Miloš Stojanović | ba9fcea | 2017-05-15 16:59:49 +0200 | [diff] [blame] | 2191 | void *p; |
| 2192 | target_siginfo_t uinfo; |
| 2193 | |
Miloš Stojanović | 5162264 | 2017-05-15 16:59:42 +0200 | [diff] [blame] | 2194 | print_syscall_prologue(name); |
| 2195 | print_raw_param("%d", arg0, 0); |
| 2196 | print_signal(arg1, 0); |
Miloš Stojanović | ba9fcea | 2017-05-15 16:59:49 +0200 | [diff] [blame] | 2197 | p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1); |
| 2198 | if (p) { |
| 2199 | get_target_siginfo(&uinfo, p); |
| 2200 | print_siginfo(&uinfo); |
| 2201 | |
| 2202 | unlock_user(p, arg2, 0); |
| 2203 | } else { |
| 2204 | print_pointer(arg2, 1); |
| 2205 | } |
Miloš Stojanović | 5162264 | 2017-05-15 16:59:42 +0200 | [diff] [blame] | 2206 | print_syscall_epilogue(name); |
| 2207 | } |
| 2208 | #endif |
| 2209 | |
Miloš Stojanović | 243e0fe | 2017-05-15 16:59:47 +0200 | [diff] [blame] | 2210 | #ifdef TARGET_NR_rt_tgsigqueueinfo |
| 2211 | static void |
| 2212 | print_rt_tgsigqueueinfo(const struct syscallname *name, |
| 2213 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2214 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2215 | { |
Miloš Stojanović | ba9fcea | 2017-05-15 16:59:49 +0200 | [diff] [blame] | 2216 | void *p; |
| 2217 | target_siginfo_t uinfo; |
| 2218 | |
Miloš Stojanović | 243e0fe | 2017-05-15 16:59:47 +0200 | [diff] [blame] | 2219 | print_syscall_prologue(name); |
| 2220 | print_raw_param("%d", arg0, 0); |
| 2221 | print_raw_param("%d", arg1, 0); |
| 2222 | print_signal(arg2, 0); |
Miloš Stojanović | ba9fcea | 2017-05-15 16:59:49 +0200 | [diff] [blame] | 2223 | p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1); |
| 2224 | if (p) { |
| 2225 | get_target_siginfo(&uinfo, p); |
| 2226 | print_siginfo(&uinfo); |
| 2227 | |
| 2228 | unlock_user(p, arg3, 0); |
| 2229 | } else { |
| 2230 | print_pointer(arg3, 1); |
| 2231 | } |
Miloš Stojanović | 243e0fe | 2017-05-15 16:59:47 +0200 | [diff] [blame] | 2232 | print_syscall_epilogue(name); |
| 2233 | } |
| 2234 | #endif |
| 2235 | |
Aleksandar Markovic | da2c8ad | 2016-09-22 18:56:58 +0200 | [diff] [blame] | 2236 | #ifdef TARGET_NR_syslog |
| 2237 | static void |
| 2238 | print_syslog_action(abi_ulong arg, int last) |
| 2239 | { |
| 2240 | const char *type; |
| 2241 | |
| 2242 | switch (arg) { |
| 2243 | case TARGET_SYSLOG_ACTION_CLOSE: { |
| 2244 | type = "SYSLOG_ACTION_CLOSE"; |
| 2245 | break; |
| 2246 | } |
| 2247 | case TARGET_SYSLOG_ACTION_OPEN: { |
| 2248 | type = "SYSLOG_ACTION_OPEN"; |
| 2249 | break; |
| 2250 | } |
| 2251 | case TARGET_SYSLOG_ACTION_READ: { |
| 2252 | type = "SYSLOG_ACTION_READ"; |
| 2253 | break; |
| 2254 | } |
| 2255 | case TARGET_SYSLOG_ACTION_READ_ALL: { |
| 2256 | type = "SYSLOG_ACTION_READ_ALL"; |
| 2257 | break; |
| 2258 | } |
| 2259 | case TARGET_SYSLOG_ACTION_READ_CLEAR: { |
| 2260 | type = "SYSLOG_ACTION_READ_CLEAR"; |
| 2261 | break; |
| 2262 | } |
| 2263 | case TARGET_SYSLOG_ACTION_CLEAR: { |
| 2264 | type = "SYSLOG_ACTION_CLEAR"; |
| 2265 | break; |
| 2266 | } |
| 2267 | case TARGET_SYSLOG_ACTION_CONSOLE_OFF: { |
| 2268 | type = "SYSLOG_ACTION_CONSOLE_OFF"; |
| 2269 | break; |
| 2270 | } |
| 2271 | case TARGET_SYSLOG_ACTION_CONSOLE_ON: { |
| 2272 | type = "SYSLOG_ACTION_CONSOLE_ON"; |
| 2273 | break; |
| 2274 | } |
| 2275 | case TARGET_SYSLOG_ACTION_CONSOLE_LEVEL: { |
| 2276 | type = "SYSLOG_ACTION_CONSOLE_LEVEL"; |
| 2277 | break; |
| 2278 | } |
| 2279 | case TARGET_SYSLOG_ACTION_SIZE_UNREAD: { |
| 2280 | type = "SYSLOG_ACTION_SIZE_UNREAD"; |
| 2281 | break; |
| 2282 | } |
| 2283 | case TARGET_SYSLOG_ACTION_SIZE_BUFFER: { |
| 2284 | type = "SYSLOG_ACTION_SIZE_BUFFER"; |
| 2285 | break; |
| 2286 | } |
| 2287 | default: { |
| 2288 | print_raw_param("%ld", arg, last); |
| 2289 | return; |
| 2290 | } |
| 2291 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2292 | qemu_log("%s%s", type, get_comma(last)); |
Aleksandar Markovic | da2c8ad | 2016-09-22 18:56:58 +0200 | [diff] [blame] | 2293 | } |
| 2294 | |
| 2295 | static void |
| 2296 | print_syslog(const struct syscallname *name, |
| 2297 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2298 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2299 | { |
| 2300 | print_syscall_prologue(name); |
| 2301 | print_syslog_action(arg0, 0); |
| 2302 | print_pointer(arg1, 0); |
| 2303 | print_raw_param("%d", arg2, 1); |
| 2304 | print_syscall_epilogue(name); |
| 2305 | } |
| 2306 | #endif |
| 2307 | |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2308 | #ifdef TARGET_NR_mknod |
| 2309 | static void |
| 2310 | print_mknod(const struct syscallname *name, |
| 2311 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2312 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2313 | { |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2314 | int hasdev = (arg1 & (S_IFCHR|S_IFBLK)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2315 | |
| 2316 | print_syscall_prologue(name); |
| 2317 | print_string(arg0, 0); |
| 2318 | print_file_mode(arg1, (hasdev == 0)); |
| 2319 | if (hasdev) { |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2320 | print_raw_param("makedev(%d", major(arg2), 0); |
| 2321 | print_raw_param("%d)", minor(arg2), 1); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2322 | } |
| 2323 | print_syscall_epilogue(name); |
| 2324 | } |
| 2325 | #endif |
| 2326 | |
| 2327 | #ifdef TARGET_NR_mknodat |
| 2328 | static void |
| 2329 | print_mknodat(const struct syscallname *name, |
| 2330 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2331 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2332 | { |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2333 | int hasdev = (arg2 & (S_IFCHR|S_IFBLK)); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2334 | |
| 2335 | print_syscall_prologue(name); |
| 2336 | print_at_dirfd(arg0, 0); |
| 2337 | print_string(arg1, 0); |
| 2338 | print_file_mode(arg2, (hasdev == 0)); |
| 2339 | if (hasdev) { |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2340 | print_raw_param("makedev(%d", major(arg3), 0); |
| 2341 | print_raw_param("%d)", minor(arg3), 1); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2342 | } |
| 2343 | print_syscall_epilogue(name); |
| 2344 | } |
| 2345 | #endif |
| 2346 | |
| 2347 | #ifdef TARGET_NR_mq_open |
| 2348 | static void |
| 2349 | print_mq_open(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 | { |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2353 | int is_creat = (arg1 & TARGET_O_CREAT); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2354 | |
| 2355 | print_syscall_prologue(name); |
| 2356 | print_string(arg0, 0); |
| 2357 | print_open_flags(arg1, (is_creat == 0)); |
| 2358 | if (is_creat) { |
| 2359 | print_file_mode(arg2, 0); |
| 2360 | print_pointer(arg3, 1); |
| 2361 | } |
| 2362 | print_syscall_epilogue(name); |
| 2363 | } |
| 2364 | #endif |
| 2365 | |
| 2366 | #ifdef TARGET_NR_open |
| 2367 | static void |
| 2368 | print_open(const struct syscallname *name, |
| 2369 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2370 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2371 | { |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2372 | int is_creat = (arg1 & TARGET_O_CREAT); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2373 | |
| 2374 | print_syscall_prologue(name); |
| 2375 | print_string(arg0, 0); |
| 2376 | print_open_flags(arg1, (is_creat == 0)); |
| 2377 | if (is_creat) |
| 2378 | print_file_mode(arg2, 1); |
| 2379 | print_syscall_epilogue(name); |
| 2380 | } |
| 2381 | #endif |
| 2382 | |
| 2383 | #ifdef TARGET_NR_openat |
| 2384 | static void |
| 2385 | print_openat(const struct syscallname *name, |
| 2386 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2387 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2388 | { |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2389 | int is_creat = (arg2 & TARGET_O_CREAT); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2390 | |
| 2391 | print_syscall_prologue(name); |
| 2392 | print_at_dirfd(arg0, 0); |
| 2393 | print_string(arg1, 0); |
| 2394 | print_open_flags(arg2, (is_creat == 0)); |
| 2395 | if (is_creat) |
| 2396 | print_file_mode(arg3, 1); |
| 2397 | print_syscall_epilogue(name); |
| 2398 | } |
| 2399 | #endif |
| 2400 | |
| 2401 | #ifdef TARGET_NR_mq_unlink |
| 2402 | static void |
| 2403 | print_mq_unlink(const struct syscallname *name, |
| 2404 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2405 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2406 | { |
| 2407 | print_syscall_prologue(name); |
| 2408 | print_string(arg0, 1); |
| 2409 | print_syscall_epilogue(name); |
| 2410 | } |
| 2411 | #endif |
| 2412 | |
| 2413 | #if defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat) |
| 2414 | static void |
| 2415 | print_fstatat64(const struct syscallname *name, |
| 2416 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2417 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2418 | { |
| 2419 | print_syscall_prologue(name); |
| 2420 | print_at_dirfd(arg0, 0); |
| 2421 | print_string(arg1, 0); |
| 2422 | print_pointer(arg2, 0); |
| 2423 | print_flags(at_file_flags, arg3, 1); |
| 2424 | print_syscall_epilogue(name); |
| 2425 | } |
| 2426 | #define print_newfstatat print_fstatat64 |
| 2427 | #endif |
| 2428 | |
| 2429 | #ifdef TARGET_NR_readlink |
| 2430 | static void |
| 2431 | print_readlink(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_string(arg0, 0); |
| 2437 | print_pointer(arg1, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2438 | print_raw_param("%u", arg2, 1); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2439 | print_syscall_epilogue(name); |
| 2440 | } |
| 2441 | #endif |
| 2442 | |
| 2443 | #ifdef TARGET_NR_readlinkat |
| 2444 | static void |
| 2445 | print_readlinkat(const struct syscallname *name, |
| 2446 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2447 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2448 | { |
| 2449 | print_syscall_prologue(name); |
| 2450 | print_at_dirfd(arg0, 0); |
| 2451 | print_string(arg1, 0); |
| 2452 | print_pointer(arg2, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2453 | print_raw_param("%u", arg3, 1); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2454 | print_syscall_epilogue(name); |
| 2455 | } |
| 2456 | #endif |
| 2457 | |
| 2458 | #ifdef TARGET_NR_rename |
| 2459 | static void |
| 2460 | print_rename(const struct syscallname *name, |
| 2461 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2462 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2463 | { |
| 2464 | print_syscall_prologue(name); |
| 2465 | print_string(arg0, 0); |
| 2466 | print_string(arg1, 1); |
| 2467 | print_syscall_epilogue(name); |
| 2468 | } |
| 2469 | #endif |
| 2470 | |
| 2471 | #ifdef TARGET_NR_renameat |
| 2472 | static void |
| 2473 | print_renameat(const struct syscallname *name, |
| 2474 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2475 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2476 | { |
| 2477 | print_syscall_prologue(name); |
| 2478 | print_at_dirfd(arg0, 0); |
| 2479 | print_string(arg1, 0); |
| 2480 | print_at_dirfd(arg2, 0); |
| 2481 | print_string(arg3, 1); |
| 2482 | print_syscall_epilogue(name); |
| 2483 | } |
| 2484 | #endif |
| 2485 | |
| 2486 | #ifdef TARGET_NR_statfs |
| 2487 | static void |
| 2488 | print_statfs(const struct syscallname *name, |
| 2489 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2490 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2491 | { |
| 2492 | print_syscall_prologue(name); |
| 2493 | print_string(arg0, 0); |
| 2494 | print_pointer(arg1, 1); |
| 2495 | print_syscall_epilogue(name); |
| 2496 | } |
Aleksandar Rikalo | 4f7f892 | 2018-08-02 16:16:00 +0200 | [diff] [blame] | 2497 | #endif |
| 2498 | |
| 2499 | #ifdef TARGET_NR_statfs64 |
| 2500 | static void |
| 2501 | print_statfs64(const struct syscallname *name, |
| 2502 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2503 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2504 | { |
| 2505 | print_syscall_prologue(name); |
| 2506 | print_string(arg0, 0); |
| 2507 | print_pointer(arg1, 1); |
| 2508 | print_syscall_epilogue(name); |
| 2509 | } |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2510 | #endif |
| 2511 | |
| 2512 | #ifdef TARGET_NR_symlink |
| 2513 | static void |
| 2514 | print_symlink(const struct syscallname *name, |
| 2515 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2516 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2517 | { |
| 2518 | print_syscall_prologue(name); |
| 2519 | print_string(arg0, 0); |
| 2520 | print_string(arg1, 1); |
| 2521 | print_syscall_epilogue(name); |
| 2522 | } |
| 2523 | #endif |
| 2524 | |
| 2525 | #ifdef TARGET_NR_symlinkat |
| 2526 | static void |
| 2527 | print_symlinkat(const struct syscallname *name, |
| 2528 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2529 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2530 | { |
| 2531 | print_syscall_prologue(name); |
| 2532 | print_string(arg0, 0); |
| 2533 | print_at_dirfd(arg1, 0); |
| 2534 | print_string(arg2, 1); |
| 2535 | print_syscall_epilogue(name); |
| 2536 | } |
| 2537 | #endif |
| 2538 | |
| 2539 | #ifdef TARGET_NR_mount |
| 2540 | static void |
| 2541 | print_mount(const struct syscallname *name, |
| 2542 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2543 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2544 | { |
| 2545 | print_syscall_prologue(name); |
| 2546 | print_string(arg0, 0); |
| 2547 | print_string(arg1, 0); |
| 2548 | print_string(arg2, 0); |
| 2549 | print_flags(mount_flags, arg3, 0); |
| 2550 | print_pointer(arg4, 1); |
| 2551 | print_syscall_epilogue(name); |
| 2552 | } |
| 2553 | #endif |
| 2554 | |
| 2555 | #ifdef TARGET_NR_umount |
| 2556 | static void |
| 2557 | print_umount(const struct syscallname *name, |
| 2558 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2559 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2560 | { |
| 2561 | print_syscall_prologue(name); |
| 2562 | print_string(arg0, 1); |
| 2563 | print_syscall_epilogue(name); |
| 2564 | } |
| 2565 | #endif |
| 2566 | |
| 2567 | #ifdef TARGET_NR_umount2 |
| 2568 | static void |
| 2569 | print_umount2(const struct syscallname *name, |
| 2570 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2571 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2572 | { |
| 2573 | print_syscall_prologue(name); |
| 2574 | print_string(arg0, 0); |
| 2575 | print_flags(umount2_flags, arg1, 1); |
| 2576 | print_syscall_epilogue(name); |
| 2577 | } |
| 2578 | #endif |
| 2579 | |
| 2580 | #ifdef TARGET_NR_unlink |
| 2581 | static void |
| 2582 | print_unlink(const struct syscallname *name, |
| 2583 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2584 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2585 | { |
| 2586 | print_syscall_prologue(name); |
| 2587 | print_string(arg0, 1); |
| 2588 | print_syscall_epilogue(name); |
| 2589 | } |
| 2590 | #endif |
| 2591 | |
| 2592 | #ifdef TARGET_NR_unlinkat |
| 2593 | static void |
| 2594 | print_unlinkat(const struct syscallname *name, |
| 2595 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2596 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2597 | { |
| 2598 | print_syscall_prologue(name); |
| 2599 | print_at_dirfd(arg0, 0); |
| 2600 | print_string(arg1, 0); |
| 2601 | print_flags(unlinkat_flags, arg2, 1); |
| 2602 | print_syscall_epilogue(name); |
| 2603 | } |
| 2604 | #endif |
| 2605 | |
| 2606 | #ifdef TARGET_NR_utime |
| 2607 | static void |
| 2608 | print_utime(const struct syscallname *name, |
| 2609 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2610 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2611 | { |
| 2612 | print_syscall_prologue(name); |
| 2613 | print_string(arg0, 0); |
| 2614 | print_pointer(arg1, 1); |
| 2615 | print_syscall_epilogue(name); |
| 2616 | } |
| 2617 | #endif |
| 2618 | |
| 2619 | #ifdef TARGET_NR_utimes |
| 2620 | static void |
| 2621 | print_utimes(const struct syscallname *name, |
| 2622 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2623 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2624 | { |
| 2625 | print_syscall_prologue(name); |
| 2626 | print_string(arg0, 0); |
| 2627 | print_pointer(arg1, 1); |
| 2628 | print_syscall_epilogue(name); |
| 2629 | } |
| 2630 | #endif |
| 2631 | |
| 2632 | #ifdef TARGET_NR_utimensat |
| 2633 | static void |
| 2634 | print_utimensat(const struct syscallname *name, |
| 2635 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2636 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2637 | { |
| 2638 | print_syscall_prologue(name); |
| 2639 | print_at_dirfd(arg0, 0); |
| 2640 | print_string(arg1, 0); |
| 2641 | print_pointer(arg2, 0); |
| 2642 | print_flags(at_file_flags, arg3, 1); |
| 2643 | print_syscall_epilogue(name); |
| 2644 | } |
| 2645 | #endif |
| 2646 | |
Mike Frysinger | 8d9016c | 2011-02-07 01:05:57 -0500 | [diff] [blame] | 2647 | #if defined(TARGET_NR_mmap) || defined(TARGET_NR_mmap2) |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2648 | static void |
| 2649 | print_mmap(const struct syscallname *name, |
| 2650 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2651 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2652 | { |
| 2653 | print_syscall_prologue(name); |
| 2654 | print_pointer(arg0, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2655 | print_raw_param("%d", arg1, 0); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2656 | print_flags(mmap_prot_flags, arg2, 0); |
| 2657 | print_flags(mmap_flags, arg3, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2658 | print_raw_param("%d", arg4, 0); |
| 2659 | print_raw_param("%#x", arg5, 1); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2660 | print_syscall_epilogue(name); |
| 2661 | } |
| 2662 | #define print_mmap2 print_mmap |
| 2663 | #endif |
| 2664 | |
| 2665 | #ifdef TARGET_NR_mprotect |
| 2666 | static void |
| 2667 | print_mprotect(const struct syscallname *name, |
| 2668 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2669 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2670 | { |
| 2671 | print_syscall_prologue(name); |
| 2672 | print_pointer(arg0, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2673 | print_raw_param("%d", arg1, 0); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2674 | print_flags(mmap_prot_flags, arg2, 1); |
| 2675 | print_syscall_epilogue(name); |
| 2676 | } |
| 2677 | #endif |
| 2678 | |
| 2679 | #ifdef TARGET_NR_munmap |
| 2680 | static void |
| 2681 | print_munmap(const struct syscallname *name, |
| 2682 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2683 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2684 | { |
| 2685 | print_syscall_prologue(name); |
| 2686 | print_pointer(arg0, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2687 | print_raw_param("%d", arg1, 1); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2688 | print_syscall_epilogue(name); |
| 2689 | } |
| 2690 | #endif |
| 2691 | |
| 2692 | #ifdef TARGET_NR_futex |
| 2693 | static void print_futex_op(abi_long tflag, int last) |
| 2694 | { |
| 2695 | #define print_op(val) \ |
| 2696 | if( cmd == val ) { \ |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2697 | qemu_log(#val); \ |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2698 | return; \ |
| 2699 | } |
| 2700 | |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2701 | int cmd = (int)tflag; |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2702 | #ifdef FUTEX_PRIVATE_FLAG |
Paul Brook | 5f2243f | 2010-02-19 16:04:51 +0000 | [diff] [blame] | 2703 | if (cmd & FUTEX_PRIVATE_FLAG) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2704 | qemu_log("FUTEX_PRIVATE_FLAG|"); |
Paul Brook | 5f2243f | 2010-02-19 16:04:51 +0000 | [diff] [blame] | 2705 | cmd &= ~FUTEX_PRIVATE_FLAG; |
| 2706 | } |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2707 | #endif |
John Rigby | bfb669f | 2013-02-23 16:14:08 -0700 | [diff] [blame] | 2708 | #ifdef FUTEX_CLOCK_REALTIME |
| 2709 | if (cmd & FUTEX_CLOCK_REALTIME) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2710 | qemu_log("FUTEX_CLOCK_REALTIME|"); |
John Rigby | bfb669f | 2013-02-23 16:14:08 -0700 | [diff] [blame] | 2711 | cmd &= ~FUTEX_CLOCK_REALTIME; |
| 2712 | } |
| 2713 | #endif |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2714 | print_op(FUTEX_WAIT) |
| 2715 | print_op(FUTEX_WAKE) |
| 2716 | print_op(FUTEX_FD) |
| 2717 | print_op(FUTEX_REQUEUE) |
| 2718 | print_op(FUTEX_CMP_REQUEUE) |
| 2719 | print_op(FUTEX_WAKE_OP) |
| 2720 | print_op(FUTEX_LOCK_PI) |
| 2721 | print_op(FUTEX_UNLOCK_PI) |
| 2722 | print_op(FUTEX_TRYLOCK_PI) |
| 2723 | #ifdef FUTEX_WAIT_BITSET |
| 2724 | print_op(FUTEX_WAIT_BITSET) |
| 2725 | #endif |
| 2726 | #ifdef FUTEX_WAKE_BITSET |
| 2727 | print_op(FUTEX_WAKE_BITSET) |
| 2728 | #endif |
| 2729 | /* unknown values */ |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2730 | qemu_log("%d", cmd); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2731 | } |
| 2732 | |
| 2733 | static void |
| 2734 | print_futex(const struct syscallname *name, |
| 2735 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2736 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2737 | { |
| 2738 | print_syscall_prologue(name); |
| 2739 | print_pointer(arg0, 0); |
| 2740 | print_futex_op(arg1, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2741 | print_raw_param(",%d", arg2, 0); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2742 | print_pointer(arg3, 0); /* struct timespec */ |
| 2743 | print_pointer(arg4, 0); |
Laurent Vivier | d2ee72a | 2011-02-15 21:10:44 +0100 | [diff] [blame] | 2744 | print_raw_param("%d", arg4, 1); |
Mika Westerberg | 74d753a | 2009-04-07 16:57:29 +0300 | [diff] [blame] | 2745 | print_syscall_epilogue(name); |
| 2746 | } |
| 2747 | #endif |
| 2748 | |
Laurent Vivier | 608e559 | 2011-04-07 00:25:32 +0200 | [diff] [blame] | 2749 | #ifdef TARGET_NR_kill |
| 2750 | static void |
| 2751 | print_kill(const struct syscallname *name, |
| 2752 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2753 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2754 | { |
| 2755 | print_syscall_prologue(name); |
| 2756 | print_raw_param("%d", arg0, 0); |
| 2757 | print_signal(arg1, 1); |
| 2758 | print_syscall_epilogue(name); |
| 2759 | } |
| 2760 | #endif |
| 2761 | |
Miloš Stojanović | 5162264 | 2017-05-15 16:59:42 +0200 | [diff] [blame] | 2762 | #ifdef TARGET_NR_tkill |
| 2763 | static void |
| 2764 | print_tkill(const struct syscallname *name, |
| 2765 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2766 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2767 | { |
| 2768 | print_syscall_prologue(name); |
| 2769 | print_raw_param("%d", arg0, 0); |
| 2770 | print_signal(arg1, 1); |
| 2771 | print_syscall_epilogue(name); |
| 2772 | } |
| 2773 | #endif |
| 2774 | |
| 2775 | #ifdef TARGET_NR_tgkill |
| 2776 | static void |
| 2777 | print_tgkill(const struct syscallname *name, |
| 2778 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2779 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2780 | { |
| 2781 | print_syscall_prologue(name); |
| 2782 | print_raw_param("%d", arg0, 0); |
| 2783 | print_raw_param("%d", arg1, 0); |
| 2784 | print_signal(arg2, 1); |
| 2785 | print_syscall_epilogue(name); |
| 2786 | } |
| 2787 | #endif |
| 2788 | |
Jim Wilson | d42744f | 2019-06-28 12:43:35 +0200 | [diff] [blame] | 2789 | #ifdef TARGET_NR_statx |
| 2790 | static void |
| 2791 | print_statx(const struct syscallname *name, |
| 2792 | abi_long arg0, abi_long arg1, abi_long arg2, |
| 2793 | abi_long arg3, abi_long arg4, abi_long arg5) |
| 2794 | { |
| 2795 | print_syscall_prologue(name); |
| 2796 | print_at_dirfd(arg0, 0); |
| 2797 | print_string(arg1, 0); |
| 2798 | print_flags(statx_flags, arg2, 0); |
| 2799 | print_flags(statx_mask, arg3, 0); |
| 2800 | print_pointer(arg4, 1); |
| 2801 | print_syscall_epilogue(name); |
| 2802 | } |
| 2803 | #endif |
| 2804 | |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2805 | /* |
| 2806 | * An array of all of the syscalls we know about |
| 2807 | */ |
| 2808 | |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 2809 | static const struct syscallname scnames[] = { |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2810 | #include "strace.list" |
| 2811 | }; |
| 2812 | |
malc | b1503cd | 2008-12-22 20:33:55 +0000 | [diff] [blame] | 2813 | static int nsyscalls = ARRAY_SIZE(scnames); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2814 | |
| 2815 | /* |
| 2816 | * The public interface to this module. |
| 2817 | */ |
| 2818 | void |
| 2819 | print_syscall(int num, |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 2820 | abi_long arg1, abi_long arg2, abi_long arg3, |
| 2821 | abi_long arg4, abi_long arg5, abi_long arg6) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2822 | { |
| 2823 | int i; |
blueswir1 | 7ccfb2e | 2008-09-14 06:45:34 +0000 | [diff] [blame] | 2824 | const char *format="%s(" TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld "," TARGET_ABI_FMT_ld ")"; |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2825 | |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2826 | qemu_log("%d ", getpid()); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2827 | |
| 2828 | for(i=0;i<nsyscalls;i++) |
| 2829 | if( scnames[i].nr == num ) { |
| 2830 | if( scnames[i].call != NULL ) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2831 | scnames[i].call( |
| 2832 | &scnames[i], arg1, arg2, arg3, arg4, arg5, arg6); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2833 | } else { |
bellard | 6b23f77 | 2007-11-14 18:04:05 +0000 | [diff] [blame] | 2834 | /* XXX: this format system is broken because it uses |
| 2835 | host types and host pointers for strings */ |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2836 | if( scnames[i].format != NULL ) |
| 2837 | format = scnames[i].format; |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2838 | qemu_log(format, |
| 2839 | scnames[i].name, arg1, arg2, arg3, arg4, arg5, arg6); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2840 | } |
pbrook | 74c11e5 | 2008-05-29 13:49:09 +0000 | [diff] [blame] | 2841 | return; |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2842 | } |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2843 | qemu_log("Unknown syscall %d\n", num); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2844 | } |
| 2845 | |
| 2846 | |
| 2847 | void |
bellard | c16f9ed | 2007-11-11 17:23:29 +0000 | [diff] [blame] | 2848 | print_syscall_ret(int num, abi_long ret) |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2849 | { |
| 2850 | int i; |
Peter Maydell | 7dcdaea | 2016-06-06 19:58:18 +0100 | [diff] [blame] | 2851 | const char *errstr = NULL; |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2852 | |
| 2853 | for(i=0;i<nsyscalls;i++) |
| 2854 | if( scnames[i].nr == num ) { |
| 2855 | if( scnames[i].result != NULL ) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2856 | scnames[i].result(&scnames[i], ret); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2857 | } else { |
Alexander Graf | 962b289 | 2011-11-21 12:04:07 +0100 | [diff] [blame] | 2858 | if (ret < 0) { |
| 2859 | errstr = target_strerror(-ret); |
| 2860 | } |
| 2861 | if (errstr) { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2862 | qemu_log(" = -1 errno=" TARGET_ABI_FMT_ld " (%s)\n", |
Alexander Graf | 962b289 | 2011-11-21 12:04:07 +0100 | [diff] [blame] | 2863 | -ret, errstr); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2864 | } else { |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2865 | qemu_log(" = " TARGET_ABI_FMT_ld "\n", ret); |
ths | 33189d3 | 2007-11-01 00:13:36 +0000 | [diff] [blame] | 2866 | } |
| 2867 | } |
| 2868 | break; |
| 2869 | } |
| 2870 | } |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 2871 | |
| 2872 | void print_taken_signal(int target_signum, const target_siginfo_t *tinfo) |
| 2873 | { |
| 2874 | /* Print the strace output for a signal being taken: |
| 2875 | * --- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} --- |
| 2876 | */ |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2877 | qemu_log("--- "); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 2878 | print_signal(target_signum, 1); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2879 | qemu_log(" "); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 2880 | print_siginfo(tinfo); |
Josh Kunz | 4b25a50 | 2020-02-03 18:54:14 -0800 | [diff] [blame] | 2881 | qemu_log(" ---\n"); |
Peter Maydell | 0cb581d | 2016-07-18 18:12:24 +0100 | [diff] [blame] | 2882 | } |