Dmitry V. Levin | 38a34c9 | 2015-12-17 17:56:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2002-2003 Roland McGrath <roland@redhat.com> |
| 3 | * Copyright (c) 2007-2008 Ulrich Drepper <drepper@redhat.com> |
| 4 | * Copyright (c) 2009 Andreas Schwab <schwab@redhat.com> |
| 5 | * Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org> |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. The name of the author may not be used to endorse or promote products |
| 17 | * derived from this software without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 31 | #include "defs.h" |
| 32 | |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 33 | #ifndef FUTEX_PRIVATE_FLAG |
| 34 | # define FUTEX_PRIVATE_FLAG 128 |
| 35 | #endif |
| 36 | #ifndef FUTEX_CLOCK_REALTIME |
| 37 | # define FUTEX_CLOCK_REALTIME 256 |
| 38 | #endif |
Dmitry V. Levin | 003cc9f | 2015-06-17 19:00:17 +0000 | [diff] [blame] | 39 | |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 40 | #include "xlat/futexops.h" |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 41 | #include "xlat/futexwakeops.h" |
| 42 | #include "xlat/futexwakecmps.h" |
| 43 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 44 | SYS_FUNC(futex) |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 45 | { |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 46 | const long uaddr = tcp->u_arg[0]; |
| 47 | const int op = tcp->u_arg[1]; |
| 48 | const int cmd = op & 127; |
| 49 | const long timeout = tcp->u_arg[3]; |
| 50 | const long uaddr2 = tcp->u_arg[4]; |
| 51 | const unsigned int val = tcp->u_arg[2]; |
| 52 | const unsigned int val2 = tcp->u_arg[3]; |
| 53 | const unsigned int val3 = tcp->u_arg[5]; |
| 54 | |
| 55 | printaddr(uaddr); |
| 56 | tprints(", "); |
| 57 | printxval(futexops, op, "FUTEX_???"); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 58 | switch (cmd) { |
| 59 | case FUTEX_WAIT: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 60 | tprintf(", %u", val); |
| 61 | tprints(", "); |
| 62 | print_timespec(tcp, timeout); |
| 63 | break; |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 64 | case FUTEX_LOCK_PI: |
| 65 | tprints(", "); |
Dmitry V. Levin | 5938526 | 2015-09-18 15:16:11 +0000 | [diff] [blame] | 66 | print_timespec(tcp, timeout); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 67 | break; |
| 68 | case FUTEX_WAIT_BITSET: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 69 | tprintf(", %u", val); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 70 | tprints(", "); |
Dmitry V. Levin | 5938526 | 2015-09-18 15:16:11 +0000 | [diff] [blame] | 71 | print_timespec(tcp, timeout); |
Eugene Syromyatnikov | a3e1ad3 | 2016-08-30 00:00:58 +0300 | [diff] [blame] | 72 | tprintf(", %#x", val3); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 73 | break; |
| 74 | case FUTEX_WAKE_BITSET: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 75 | tprintf(", %u", val); |
Eugene Syromyatnikov | a3e1ad3 | 2016-08-30 00:00:58 +0300 | [diff] [blame] | 76 | tprintf(", %#x", val3); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 77 | break; |
| 78 | case FUTEX_REQUEUE: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 79 | tprintf(", %u", val); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 80 | tprintf(", %u, ", val2); |
| 81 | printaddr(uaddr2); |
| 82 | break; |
| 83 | case FUTEX_CMP_REQUEUE: |
| 84 | case FUTEX_CMP_REQUEUE_PI: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 85 | tprintf(", %u", val); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 86 | tprintf(", %u, ", val2); |
| 87 | printaddr(uaddr2); |
| 88 | tprintf(", %u", val3); |
| 89 | break; |
| 90 | case FUTEX_WAKE_OP: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 91 | tprintf(", %u", val); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 92 | tprintf(", %u, ", val2); |
| 93 | printaddr(uaddr2); |
| 94 | tprints(", {"); |
| 95 | if ((val3 >> 28) & 8) |
| 96 | tprints("FUTEX_OP_OPARG_SHIFT|"); |
| 97 | printxval(futexwakeops, (val3 >> 28) & 0x7, "FUTEX_OP_???"); |
| 98 | tprintf(", %u, ", (val3 >> 12) & 0xfff); |
Eugene Syromyatnikov | bfa22a5 | 2016-08-29 23:56:24 +0300 | [diff] [blame] | 99 | printxval(futexwakecmps, (val3 >> 24) & 0xf, "FUTEX_OP_CMP_???"); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 100 | tprintf(", %u}", val3 & 0xfff); |
| 101 | break; |
| 102 | case FUTEX_WAIT_REQUEUE_PI: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 103 | tprintf(", %u", val); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 104 | tprints(", "); |
Dmitry V. Levin | 5938526 | 2015-09-18 15:16:11 +0000 | [diff] [blame] | 105 | print_timespec(tcp, timeout); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 106 | tprints(", "); |
| 107 | printaddr(uaddr2); |
| 108 | break; |
Eugene Syromyatnikov | 3e0e105 | 2016-08-29 23:57:38 +0300 | [diff] [blame] | 109 | case FUTEX_FD: |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 110 | case FUTEX_WAKE: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 111 | tprintf(", %u", val); |
| 112 | break; |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 113 | case FUTEX_UNLOCK_PI: |
| 114 | case FUTEX_TRYLOCK_PI: |
| 115 | break; |
| 116 | default: |
Eugene Syromyatnikov | 110da33 | 2016-08-30 00:01:45 +0300 | [diff] [blame] | 117 | tprintf(", %u", val); |
Eugene Syromyatnikov | ebeae24 | 2016-08-29 23:59:01 +0300 | [diff] [blame] | 118 | tprintf(", %#lx", timeout); |
| 119 | tprints(", "); |
| 120 | printaddr(uaddr2); |
| 121 | tprintf(", %#x", val3); |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 122 | break; |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 123 | } |
Dmitry V. Levin | b582109 | 2015-07-20 13:15:51 +0000 | [diff] [blame] | 124 | |
| 125 | return RVAL_DECODED; |
Dmitry V. Levin | e314f80 | 2014-12-11 19:25:02 +0000 | [diff] [blame] | 126 | } |