Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 6 | * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH |
| 7 | * port by Greg Banks <gbanks@pocketpenguins.com> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 8 | * All rights reserved. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * 3. The name of the author may not be used to endorse or promote products |
| 19 | * derived from this software without specific prior written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | * $Id$ |
| 33 | */ |
| 34 | |
| 35 | #include "defs.h" |
| 36 | |
Roland McGrath | 05cdd3c | 2004-03-02 06:16:59 +0000 | [diff] [blame] | 37 | #include <asm/mman.h> |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 38 | #include <sys/mman.h> |
Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 39 | |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 40 | #if defined(LINUX) && defined(I386) |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 41 | # include <asm/ldt.h> |
Roland McGrath | 7decfb2 | 2004-03-01 22:10:52 +0000 | [diff] [blame] | 42 | # ifdef HAVE_STRUCT_USER_DESC |
| 43 | # define modify_ldt_ldt_s user_desc |
| 44 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 45 | #endif |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 46 | #if defined(LINUX) && defined(SH64) |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 47 | # include <asm/page.h> /* for PAGE_SHIFT */ |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 48 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 50 | #ifdef HAVE_LONG_LONG_OFF_T |
| 51 | /* |
| 52 | * Ugly hacks for systems that have a long long off_t |
| 53 | */ |
| 54 | #define sys_mmap64 sys_mmap |
| 55 | #endif |
| 56 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 58 | sys_brk(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 59 | { |
| 60 | if (entering(tcp)) { |
| 61 | tprintf("%#lx", tcp->u_arg[0]); |
| 62 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 63 | return RVAL_HEX; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 66 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 67 | static const struct xlat mmap_prot[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 68 | { PROT_NONE, "PROT_NONE", }, |
| 69 | { PROT_READ, "PROT_READ" }, |
| 70 | { PROT_WRITE, "PROT_WRITE" }, |
| 71 | { PROT_EXEC, "PROT_EXEC" }, |
Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 72 | #ifdef PROT_SEM |
| 73 | { PROT_SEM, "PROT_SEM" }, |
| 74 | #endif |
| 75 | #ifdef PROT_GROWSDOWN |
| 76 | { PROT_GROWSDOWN,"PROT_GROWSDOWN"}, |
| 77 | #endif |
| 78 | #ifdef PROT_GROWSUP |
| 79 | { PROT_GROWSUP, "PROT_GROWSUP" }, |
| 80 | #endif |
Roland McGrath | 586d6ab | 2008-08-25 03:00:47 +0000 | [diff] [blame] | 81 | #ifdef PROT_SAO |
| 82 | { PROT_SAO, "PROT_SAO" }, |
| 83 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 84 | { 0, NULL }, |
| 85 | }; |
| 86 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 87 | static const struct xlat mmap_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 88 | { MAP_SHARED, "MAP_SHARED" }, |
| 89 | { MAP_PRIVATE, "MAP_PRIVATE" }, |
| 90 | { MAP_FIXED, "MAP_FIXED" }, |
| 91 | #ifdef MAP_ANONYMOUS |
| 92 | { MAP_ANONYMOUS,"MAP_ANONYMOUS" }, |
| 93 | #endif |
Dmitry V. Levin | 71f1a13 | 2007-03-29 23:30:09 +0000 | [diff] [blame] | 94 | #ifdef MAP_32BIT |
| 95 | { MAP_32BIT, "MAP_32BIT" }, |
| 96 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 97 | #ifdef MAP_RENAME |
| 98 | { MAP_RENAME, "MAP_RENAME" }, |
| 99 | #endif |
| 100 | #ifdef MAP_NORESERVE |
| 101 | { MAP_NORESERVE,"MAP_NORESERVE" }, |
| 102 | #endif |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 103 | #ifdef MAP_POPULATE |
| 104 | { MAP_POPULATE, "MAP_POPULATE" }, |
| 105 | #endif |
| 106 | #ifdef MAP_NONBLOCK |
| 107 | { MAP_NONBLOCK, "MAP_NONBLOCK" }, |
| 108 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 109 | /* |
| 110 | * XXX - this was introduced in SunOS 4.x to distinguish between |
| 111 | * the old pre-4.x "mmap()", which: |
| 112 | * |
| 113 | * only let you map devices with an "mmap" routine (e.g., |
| 114 | * frame buffers) in; |
| 115 | * |
| 116 | * required you to specify the mapping address; |
| 117 | * |
| 118 | * returned 0 on success and -1 on failure; |
| 119 | * |
| 120 | * memory and which, and the 4.x "mmap()" which: |
| 121 | * |
| 122 | * can map plain files; |
| 123 | * |
| 124 | * can be asked to pick where to map the file; |
| 125 | * |
| 126 | * returns the address where it mapped the file on success |
| 127 | * and -1 on failure. |
| 128 | * |
| 129 | * It's not actually used in source code that calls "mmap()"; the |
| 130 | * "mmap()" routine adds it for you. |
| 131 | * |
| 132 | * It'd be nice to come up with some way of eliminating it from |
| 133 | * the flags, e.g. reporting calls *without* it as "old_mmap()" |
| 134 | * and calls with it as "mmap()". |
| 135 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 136 | #ifdef _MAP_NEW |
| 137 | { _MAP_NEW, "_MAP_NEW" }, |
| 138 | #endif |
| 139 | #ifdef MAP_GROWSDOWN |
| 140 | { MAP_GROWSDOWN,"MAP_GROWSDOWN" }, |
| 141 | #endif |
| 142 | #ifdef MAP_DENYWRITE |
| 143 | { MAP_DENYWRITE,"MAP_DENYWRITE" }, |
| 144 | #endif |
| 145 | #ifdef MAP_EXECUTABLE |
| 146 | { MAP_EXECUTABLE,"MAP_EXECUTABLE"}, |
| 147 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 148 | #ifdef MAP_INHERIT |
| 149 | { MAP_INHERIT,"MAP_INHERIT" }, |
| 150 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 151 | #ifdef MAP_FILE |
| 152 | { MAP_FILE,"MAP_FILE"}, |
| 153 | #endif |
| 154 | #ifdef MAP_LOCKED |
| 155 | { MAP_LOCKED,"MAP_LOCKED"}, |
| 156 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 157 | /* FreeBSD ones */ |
| 158 | #ifdef MAP_ANON |
| 159 | { MAP_ANON, "MAP_ANON" }, |
| 160 | #endif |
| 161 | #ifdef MAP_HASSEMAPHORE |
| 162 | { MAP_HASSEMAPHORE, "MAP_HASSEMAPHORE" }, |
| 163 | #endif |
| 164 | #ifdef MAP_STACK |
| 165 | { MAP_STACK, "MAP_STACK" }, |
| 166 | #endif |
| 167 | #ifdef MAP_NOSYNC |
| 168 | { MAP_NOSYNC, "MAP_NOSYNC" }, |
| 169 | #endif |
| 170 | #ifdef MAP_NOCORE |
| 171 | { MAP_NOCORE, "MAP_NOCORE" }, |
| 172 | #endif |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 173 | #ifdef TILE |
| 174 | { MAP_CACHE_NO_LOCAL, "MAP_CACHE_NO_LOCAL" }, |
| 175 | { MAP_CACHE_NO_L2, "MAP_CACHE_NO_L2" }, |
| 176 | { MAP_CACHE_NO_L1, "MAP_CACHE_NO_L1" }, |
| 177 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 178 | { 0, NULL }, |
| 179 | }; |
| 180 | |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 181 | #ifdef TILE |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 182 | static int |
| 183 | addtileflags(long flags) |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 184 | { |
| 185 | long home = flags & _MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK); |
| 186 | flags &= ~_MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK); |
| 187 | |
| 188 | if (flags & _MAP_CACHE_INCOHERENT) { |
| 189 | flags &= ~_MAP_CACHE_INCOHERENT; |
| 190 | if (home == MAP_CACHE_HOME_NONE) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 191 | tprints("|MAP_CACHE_INCOHERENT"); |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 192 | return flags; |
| 193 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 194 | tprints("|_MAP_CACHE_INCOHERENT"); |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | switch (home) { |
| 198 | case 0: break; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 199 | case MAP_CACHE_HOME_HERE: tprints("|MAP_CACHE_HOME_HERE"); break; |
| 200 | case MAP_CACHE_HOME_NONE: tprints("|MAP_CACHE_HOME_NONE"); break; |
| 201 | case MAP_CACHE_HOME_SINGLE: tprints("|MAP_CACHE_HOME_SINGLE"); break; |
| 202 | case MAP_CACHE_HOME_TASK: tprints("|MAP_CACHE_HOME_TASK"); break; |
| 203 | case MAP_CACHE_HOME_HASH: tprints("|MAP_CACHE_HOME_HASH"); break; |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 204 | default: |
| 205 | tprintf("|MAP_CACHE_HOME(%d)", |
| 206 | (home >> _MAP_CACHE_HOME_SHIFT) ); |
| 207 | break; |
| 208 | } |
| 209 | |
| 210 | return flags; |
| 211 | } |
| 212 | #endif |
| 213 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 214 | #if !HAVE_LONG_LONG_OFF_T |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 215 | static int |
| 216 | print_mmap(struct tcb *tcp, long *u_arg, long long offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 217 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 218 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 219 | /* addr */ |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 220 | if (!u_arg[0]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 221 | tprints("NULL, "); |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 222 | else |
| 223 | tprintf("%#lx, ", u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 224 | /* len */ |
| 225 | tprintf("%lu, ", u_arg[1]); |
| 226 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 227 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 228 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 229 | /* flags */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 230 | #ifdef MAP_TYPE |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 231 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 232 | #ifdef TILE |
| 233 | addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE)); |
| 234 | #else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 235 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 236 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 237 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 238 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 239 | #endif |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 240 | /* fd */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 241 | tprints(", "); |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 242 | printfd(tcp, u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 243 | /* offset */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 244 | tprintf(", %#llx", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 245 | } |
| 246 | return RVAL_HEX; |
| 247 | } |
| 248 | |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 249 | int sys_old_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 250 | { |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 251 | #if defined(IA64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 252 | /* |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 253 | * IA64 processes never call this routine, they only use the |
| 254 | * new `sys_mmap' interface. |
| 255 | * For IA32 processes, this code converts the integer arguments |
| 256 | * that they pushed onto the stack, into longs. |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 257 | * |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 258 | * Note that addresses with bit 31 set will be sign extended. |
| 259 | * Fortunately, those addresses are not currently being generated |
| 260 | * for IA32 processes so it's not a problem. |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 261 | */ |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 262 | int i; |
| 263 | long u_arg[6]; |
| 264 | int narrow_arg[6]; |
| 265 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 266 | return 0; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 267 | for (i = 0; i < 6; i++) |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 268 | u_arg[i] = narrow_arg[i]; |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 269 | #elif defined(SH) || defined(SH64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 270 | /* SH has always passed the args in registers */ |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 271 | long *u_arg = tcp->u_arg; |
Roland McGrath | 6b1d43e | 2003-03-31 01:05:01 +0000 | [diff] [blame] | 272 | #else |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 273 | long u_arg[6]; |
Roland McGrath | 520e21f | 2005-07-05 09:50:18 +0000 | [diff] [blame] | 274 | # if defined(X86_64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 275 | if (current_personality == 1) { |
| 276 | int i; |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 277 | unsigned narrow_arg[6]; |
| 278 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 279 | return 0; |
| 280 | for (i = 0; i < 6; ++i) |
| 281 | u_arg[i] = narrow_arg[i]; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 282 | } |
| 283 | else |
Roland McGrath | 520e21f | 2005-07-05 09:50:18 +0000 | [diff] [blame] | 284 | # endif |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 285 | if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 286 | return 0; |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 287 | #endif /* other architectures */ |
| 288 | |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 289 | return print_mmap(tcp, u_arg, u_arg[5]); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 290 | } |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 291 | |
| 292 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 293 | sys_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 294 | { |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 295 | long long offset = tcp->u_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 296 | |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 297 | /* FIXME: why only SH64? i386 mmap2 syscall ends up |
| 298 | * in this function, but does not convert offset |
| 299 | * from pages to bytes. See test/mmap_offset_decode.c |
| 300 | * Why SH64 and i386 are handled differently? |
| 301 | */ |
Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 302 | #if defined(LINUX) && defined(SH64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 303 | /* |
| 304 | * Old mmap differs from new mmap in specifying the |
| 305 | * offset in units of bytes rather than pages. We |
| 306 | * pretend it's in byte units so the user only ever |
| 307 | * sees bytes in the printout. |
| 308 | */ |
| 309 | offset <<= PAGE_SHIFT; |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 310 | #endif |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 311 | #if defined(LINUX_MIPSN32) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 312 | offset = tcp->ext_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 313 | #endif |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 314 | return print_mmap(tcp, tcp->u_arg, offset); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 315 | } |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 316 | #endif /* !HAVE_LONG_LONG_OFF_T */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 317 | |
John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 318 | #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T |
Denys Vlasenko | d5e66c4 | 2011-08-23 17:51:58 +0200 | [diff] [blame] | 319 | /* TODO: comment which arches use this routine. |
| 320 | * For one, does ALPHA on Linux use this?? |
| 321 | * From code it seems that it might use 7 or 8 registers, |
| 322 | * which is strange - Linux syscalls can pass maximum of 6 parameters! |
| 323 | */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 324 | int |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 325 | sys_mmap64(struct tcb *tcp) |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 326 | { |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 327 | if (entering(tcp)) { |
Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 328 | #if !defined(LINUX) || defined(ALPHA) |
| 329 | long *u_arg = tcp->u_arg; |
| 330 | #else |
| 331 | long u_arg[7]; |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 332 | if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, |
| 333 | (char *) u_arg) == -1) |
| 334 | return 0; |
Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 335 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 336 | /* addr */ |
H.J. Lu | d0cd443 | 2012-02-03 10:07:42 -0800 | [diff] [blame] | 337 | if (!u_arg[0]) |
| 338 | tprints("NULL, "); |
| 339 | else |
| 340 | tprintf("%#lx, ", u_arg[0]); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 341 | /* len */ |
| 342 | tprintf("%lu, ", u_arg[1]); |
| 343 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 344 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 345 | tprints(", "); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 346 | /* flags */ |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 347 | #ifdef MAP_TYPE |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 348 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
| 349 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 350 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 351 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 352 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 353 | /* fd */ |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 354 | tprints(", "); |
Denys Vlasenko | d5e66c4 | 2011-08-23 17:51:58 +0200 | [diff] [blame] | 355 | printfd(tcp, u_arg[4]); |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 356 | /* offset */ |
Denys Vlasenko | d5e66c4 | 2011-08-23 17:51:58 +0200 | [diff] [blame] | 357 | #if !defined(LINUX) || defined(ALPHA) |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 358 | printllval(tcp, ", %#llx", 5); |
Denys Vlasenko | d5e66c4 | 2011-08-23 17:51:58 +0200 | [diff] [blame] | 359 | #else |
| 360 | /* NOTE: not verified that [5] and [6] should be used. |
| 361 | * It's possible that long long is 64-bit aligned in memory |
| 362 | * and we need to use [6] and [7] here instead: |
| 363 | */ |
| 364 | tprintf(", %#llx", LONG_LONG(u_arg[5], u_arg[6])); |
| 365 | #endif |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 366 | } |
| 367 | return RVAL_HEX; |
| 368 | } |
Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 369 | #endif /* _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T */ |
John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 370 | |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 371 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 372 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 373 | sys_munmap(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 374 | { |
| 375 | if (entering(tcp)) { |
| 376 | tprintf("%#lx, %lu", |
| 377 | tcp->u_arg[0], tcp->u_arg[1]); |
| 378 | } |
| 379 | return 0; |
| 380 | } |
| 381 | |
| 382 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 383 | sys_mprotect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 384 | { |
| 385 | if (entering(tcp)) { |
| 386 | tprintf("%#lx, %lu, ", |
| 387 | tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 388 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 389 | } |
| 390 | return 0; |
| 391 | } |
| 392 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 393 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 394 | static const struct xlat mremap_flags[] = { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 395 | { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" }, |
Chris Metcalf | ff3474a | 2009-12-24 23:19:19 +0000 | [diff] [blame] | 396 | #ifdef MREMAP_FIXED |
| 397 | { MREMAP_FIXED, "MREMAP_FIXED" }, |
| 398 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 399 | { 0, NULL } |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 400 | }; |
| 401 | |
| 402 | int |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 403 | sys_mremap(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 404 | { |
| 405 | if (entering(tcp)) { |
| 406 | tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1], |
| 407 | tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 408 | printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 409 | #ifdef MREMAP_FIXED |
| 410 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 411 | (MREMAP_MAYMOVE | MREMAP_FIXED)) |
| 412 | tprintf(", %#lx", tcp->u_arg[4]); |
| 413 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 414 | } |
| 415 | return RVAL_HEX; |
| 416 | } |
| 417 | |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 418 | static const struct xlat madvise_cmds[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 419 | #ifdef MADV_NORMAL |
| 420 | { MADV_NORMAL, "MADV_NORMAL" }, |
| 421 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 422 | #ifdef MADV_RANDOM |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 423 | { MADV_RANDOM, "MADV_RANDOM" }, |
| 424 | #endif |
| 425 | #ifdef MADV_SEQUENTIAL |
| 426 | { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" }, |
| 427 | #endif |
| 428 | #ifdef MADV_WILLNEED |
| 429 | { MADV_WILLNEED, "MADV_WILLNEED" }, |
| 430 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 431 | #ifdef MADV_DONTNEED |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 432 | { MADV_DONTNEED, "MADV_DONTNEED" }, |
| 433 | #endif |
| 434 | { 0, NULL }, |
| 435 | }; |
| 436 | |
| 437 | |
| 438 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 439 | sys_madvise(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 440 | { |
| 441 | if (entering(tcp)) { |
| 442 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 443 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 444 | } |
| 445 | return 0; |
| 446 | } |
| 447 | |
| 448 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 449 | static const struct xlat mlockall_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 450 | #ifdef MCL_CURRENT |
| 451 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 452 | #endif |
| 453 | #ifdef MCL_FUTURE |
| 454 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 455 | #endif |
| 456 | { 0, NULL} |
| 457 | }; |
| 458 | |
| 459 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 460 | sys_mlockall(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 461 | { |
| 462 | if (entering(tcp)) { |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 463 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 464 | } |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 469 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 470 | #ifdef MS_ASYNC |
| 471 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 472 | static const struct xlat mctl_sync[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 473 | #ifdef MS_SYNC |
| 474 | { MS_SYNC, "MS_SYNC" }, |
| 475 | #endif |
John Hughes | aca07f3 | 2001-10-16 18:12:27 +0000 | [diff] [blame] | 476 | { MS_ASYNC, "MS_ASYNC" }, |
| 477 | { MS_INVALIDATE,"MS_INVALIDATE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 478 | { 0, NULL }, |
| 479 | }; |
| 480 | |
| 481 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 482 | sys_msync(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 483 | { |
| 484 | if (entering(tcp)) { |
| 485 | /* addr */ |
| 486 | tprintf("%#lx", tcp->u_arg[0]); |
| 487 | /* len */ |
| 488 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 489 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 490 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 491 | } |
| 492 | return 0; |
| 493 | } |
| 494 | |
| 495 | #endif /* MS_ASYNC */ |
| 496 | |
| 497 | #ifdef MC_SYNC |
| 498 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 499 | static const struct xlat mctl_funcs[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 500 | { MC_LOCK, "MC_LOCK" }, |
| 501 | { MC_LOCKAS, "MC_LOCKAS" }, |
| 502 | { MC_SYNC, "MC_SYNC" }, |
| 503 | { MC_UNLOCK, "MC_UNLOCK" }, |
| 504 | { MC_UNLOCKAS, "MC_UNLOCKAS" }, |
| 505 | { 0, NULL }, |
| 506 | }; |
| 507 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 508 | static const struct xlat mctl_lockas[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 509 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 510 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 511 | { 0, NULL }, |
| 512 | }; |
| 513 | |
| 514 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 515 | sys_mctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 516 | { |
| 517 | int arg, function; |
| 518 | |
| 519 | if (entering(tcp)) { |
| 520 | /* addr */ |
| 521 | tprintf("%#lx", tcp->u_arg[0]); |
| 522 | /* len */ |
| 523 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 524 | /* function */ |
| 525 | function = tcp->u_arg[2]; |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 526 | printflags(mctl_funcs, function, "MC_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 527 | /* arg */ |
| 528 | arg = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 529 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 530 | switch (function) { |
| 531 | case MC_SYNC: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 532 | printflags(mctl_sync, arg, "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 533 | break; |
| 534 | case MC_LOCKAS: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 535 | printflags(mctl_lockas, arg, "MCL_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 536 | break; |
| 537 | default: |
| 538 | tprintf("%#x", arg); |
| 539 | break; |
| 540 | } |
| 541 | } |
| 542 | return 0; |
| 543 | } |
| 544 | |
| 545 | #endif /* MC_SYNC */ |
| 546 | |
| 547 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 548 | sys_mincore(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 549 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 550 | if (entering(tcp)) { |
| 551 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 552 | } else { |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 553 | unsigned long i, len; |
| 554 | char *vec = NULL; |
| 555 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 556 | len = tcp->u_arg[1]; |
| 557 | if (syserror(tcp) || tcp->u_arg[2] == 0 || |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 558 | (vec = malloc(len)) == NULL || |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 559 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 560 | tprintf("%#lx", tcp->u_arg[2]); |
| 561 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 562 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 563 | for (i = 0; i < len; i++) { |
| 564 | if (abbrev(tcp) && i >= max_strlen) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 565 | tprints("..."); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 566 | break; |
| 567 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 568 | tprints((vec[i] & 1) ? "1" : "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 569 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 570 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 571 | } |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 572 | free(vec); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 573 | } |
| 574 | return 0; |
| 575 | } |
| 576 | |
Roland McGrath | da6c92c | 2007-09-12 01:26:29 +0000 | [diff] [blame] | 577 | #if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 578 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 579 | sys_getpagesize(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 580 | { |
| 581 | if (exiting(tcp)) |
| 582 | return RVAL_HEX; |
| 583 | return 0; |
| 584 | } |
Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 585 | #endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 586 | |
| 587 | #if defined(LINUX) && defined(__i386__) |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 588 | void |
Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 589 | print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 590 | { |
| 591 | tprintf("base_addr:%#08lx, " |
| 592 | "limit:%d, " |
| 593 | "seg_32bit:%d, " |
| 594 | "contents:%d, " |
| 595 | "read_exec_only:%d, " |
| 596 | "limit_in_pages:%d, " |
| 597 | "seg_not_present:%d, " |
| 598 | "useable:%d}", |
Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 599 | (long) ldt_entry->base_addr, |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 600 | ldt_entry->limit, |
| 601 | ldt_entry->seg_32bit, |
| 602 | ldt_entry->contents, |
| 603 | ldt_entry->read_exec_only, |
| 604 | ldt_entry->limit_in_pages, |
| 605 | ldt_entry->seg_not_present, |
| 606 | ldt_entry->useable); |
| 607 | } |
| 608 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 609 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 610 | sys_modify_ldt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 611 | { |
| 612 | if (entering(tcp)) { |
| 613 | struct modify_ldt_ldt_s copy; |
| 614 | tprintf("%ld", tcp->u_arg[0]); |
| 615 | if (tcp->u_arg[1] == 0 |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 616 | || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 617 | || umove(tcp, tcp->u_arg[1], ©) == -1) |
| 618 | tprintf(", %lx", tcp->u_arg[1]); |
| 619 | else { |
| 620 | tprintf(", {entry_number:%d, ", copy.entry_number); |
| 621 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 622 | tprints("...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 623 | else { |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 624 | print_ldt_entry(©); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 625 | } |
| 626 | } |
| 627 | tprintf(", %lu", tcp->u_arg[2]); |
| 628 | } |
| 629 | return 0; |
| 630 | } |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 631 | |
| 632 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 633 | sys_set_thread_area(struct tcb *tcp) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 634 | { |
| 635 | struct modify_ldt_ldt_s copy; |
| 636 | if (entering(tcp)) { |
| 637 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 638 | if (copy.entry_number == -1) |
| 639 | tprintf("{entry_number:%d -> ", |
| 640 | copy.entry_number); |
| 641 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 642 | tprints("{entry_number:"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 643 | } |
| 644 | } else { |
| 645 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 646 | tprintf("%d, ", copy.entry_number); |
| 647 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 648 | tprints("...}"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 649 | else { |
| 650 | print_ldt_entry(©); |
| 651 | } |
| 652 | } else { |
| 653 | tprintf("%lx", tcp->u_arg[0]); |
| 654 | } |
| 655 | } |
| 656 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 657 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 661 | sys_get_thread_area(struct tcb *tcp) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 662 | { |
| 663 | struct modify_ldt_ldt_s copy; |
| 664 | if (exiting(tcp)) { |
| 665 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 666 | tprintf("{entry_number:%d, ", copy.entry_number); |
| 667 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 668 | tprints("...}"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 669 | else { |
| 670 | print_ldt_entry(©); |
| 671 | } |
| 672 | } else { |
| 673 | tprintf("%lx", tcp->u_arg[0]); |
| 674 | } |
| 675 | } |
| 676 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 677 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 678 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 679 | #endif /* LINUX && __i386__ */ |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 680 | |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 681 | #if defined(LINUX) && defined(M68K) |
| 682 | |
| 683 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 684 | sys_set_thread_area(struct tcb *tcp) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 685 | { |
| 686 | if (entering(tcp)) |
| 687 | tprintf("%#lx", tcp->u_arg[0]); |
| 688 | return 0; |
| 689 | |
| 690 | } |
| 691 | |
| 692 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 693 | sys_get_thread_area(struct tcb *tcp) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 694 | { |
| 695 | return RVAL_HEX; |
| 696 | } |
| 697 | #endif |
| 698 | |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 699 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 700 | sys_remap_file_pages(struct tcb *tcp) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 701 | { |
| 702 | if (entering(tcp)) { |
| 703 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 704 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 705 | tprintf(", %lu, ", tcp->u_arg[3]); |
| 706 | #ifdef MAP_TYPE |
| 707 | printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???"); |
| 708 | addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE); |
| 709 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 710 | printflags(mmap_flags, tcp->u_arg[4], "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 711 | #endif |
| 712 | } |
| 713 | return 0; |
| 714 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 715 | |
| 716 | |
| 717 | #define MPOL_DEFAULT 0 |
| 718 | #define MPOL_PREFERRED 1 |
| 719 | #define MPOL_BIND 2 |
| 720 | #define MPOL_INTERLEAVE 3 |
| 721 | |
| 722 | #define MPOL_F_NODE (1<<0) |
| 723 | #define MPOL_F_ADDR (1<<1) |
| 724 | |
| 725 | #define MPOL_MF_STRICT (1<<0) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 726 | #define MPOL_MF_MOVE (1<<1) |
| 727 | #define MPOL_MF_MOVE_ALL (1<<2) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 728 | |
| 729 | |
| 730 | static const struct xlat policies[] = { |
| 731 | { MPOL_DEFAULT, "MPOL_DEFAULT" }, |
| 732 | { MPOL_PREFERRED, "MPOL_PREFERRED" }, |
| 733 | { MPOL_BIND, "MPOL_BIND" }, |
| 734 | { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" }, |
| 735 | { 0, NULL } |
| 736 | }; |
| 737 | |
| 738 | static const struct xlat mbindflags[] = { |
| 739 | { MPOL_MF_STRICT, "MPOL_MF_STRICT" }, |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 740 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 741 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 742 | { 0, NULL } |
| 743 | }; |
| 744 | |
| 745 | static const struct xlat mempolicyflags[] = { |
| 746 | { MPOL_F_NODE, "MPOL_F_NODE" }, |
| 747 | { MPOL_F_ADDR, "MPOL_F_ADDR" }, |
| 748 | { 0, NULL } |
| 749 | }; |
| 750 | |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 751 | static const struct xlat move_pages_flags[] = { |
| 752 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 753 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
| 754 | { 0, NULL } |
| 755 | }; |
| 756 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 757 | |
| 758 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 759 | get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 760 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 761 | unsigned long nlongs, size, end; |
| 762 | |
| 763 | nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long)); |
| 764 | size = nlongs * sizeof(long); |
| 765 | end = ptr + size; |
| 766 | if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes) |
| 767 | && (end > ptr))) { |
| 768 | unsigned long n, cur, abbrev_end; |
| 769 | int failed = 0; |
| 770 | |
| 771 | if (abbrev(tcp)) { |
| 772 | abbrev_end = ptr + max_strlen * sizeof(long); |
| 773 | if (abbrev_end < ptr) |
| 774 | abbrev_end = end; |
| 775 | } else { |
| 776 | abbrev_end = end; |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 777 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 778 | tprints(", {"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 779 | for (cur = ptr; cur < end; cur += sizeof(long)) { |
| 780 | if (cur > ptr) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 781 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 782 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 783 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 784 | break; |
| 785 | } |
| 786 | if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 787 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 788 | failed = 1; |
| 789 | break; |
| 790 | } |
| 791 | tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n); |
| 792 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 793 | tprints("}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 794 | if (failed) |
| 795 | tprintf(" %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 796 | } else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 797 | tprintf(", %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 798 | tprintf(", %lu", maxnodes); |
| 799 | } |
| 800 | |
| 801 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 802 | sys_mbind(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 803 | { |
| 804 | if (entering(tcp)) { |
Chris Metcalf | c5fd1d9 | 2009-12-24 23:19:35 +0000 | [diff] [blame] | 805 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 806 | printxval(policies, tcp->u_arg[2], "MPOL_???"); |
| 807 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 808 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 809 | printflags(mbindflags, tcp->u_arg[5], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 810 | } |
| 811 | return 0; |
| 812 | } |
| 813 | |
| 814 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 815 | sys_set_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 816 | { |
| 817 | if (entering(tcp)) { |
| 818 | printxval(policies, tcp->u_arg[0], "MPOL_???"); |
| 819 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0); |
| 820 | } |
| 821 | return 0; |
| 822 | } |
| 823 | |
| 824 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 825 | sys_get_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 826 | { |
| 827 | if (exiting(tcp)) { |
| 828 | int pol; |
| 829 | if (tcp->u_arg[0] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 830 | tprints("NULL"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 831 | else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0) |
| 832 | tprintf("%#lx", tcp->u_arg[0]); |
| 833 | else |
| 834 | printxval(policies, pol, "MPOL_???"); |
| 835 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp)); |
| 836 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 837 | printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 838 | } |
| 839 | return 0; |
| 840 | } |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 841 | |
| 842 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 843 | sys_move_pages(struct tcb *tcp) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 844 | { |
| 845 | if (entering(tcp)) { |
| 846 | unsigned long npages = tcp->u_arg[1]; |
| 847 | tprintf("%ld, %lu, ", tcp->u_arg[0], npages); |
| 848 | if (tcp->u_arg[2] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 849 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 850 | else { |
| 851 | int i; |
| 852 | long puser = tcp->u_arg[2]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 853 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 854 | for (i = 0; i < npages; ++i) { |
| 855 | void *p; |
| 856 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 857 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 858 | if (umove(tcp, puser, &p) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 859 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 860 | break; |
| 861 | } |
| 862 | tprintf("%p", p); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 863 | puser += sizeof(void *); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 864 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 865 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 866 | } |
| 867 | if (tcp->u_arg[3] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 868 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 869 | else { |
| 870 | int i; |
| 871 | long nodeuser = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 872 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 873 | for (i = 0; i < npages; ++i) { |
| 874 | int node; |
| 875 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 876 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 877 | if (umove(tcp, nodeuser, &node) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 878 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 879 | break; |
| 880 | } |
| 881 | tprintf("%#x", node); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 882 | nodeuser += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 883 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 884 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 885 | } |
| 886 | } |
| 887 | if (exiting(tcp)) { |
| 888 | unsigned long npages = tcp->u_arg[1]; |
| 889 | if (tcp->u_arg[4] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 890 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 891 | else { |
| 892 | int i; |
| 893 | long statususer = tcp->u_arg[4]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 894 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 895 | for (i = 0; i < npages; ++i) { |
| 896 | int status; |
| 897 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 898 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 899 | if (umove(tcp, statususer, &status) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 900 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 901 | break; |
| 902 | } |
| 903 | tprintf("%#x", status); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 904 | statususer += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 905 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 906 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 907 | } |
| 908 | printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); |
| 909 | } |
| 910 | return 0; |
| 911 | } |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 912 | |
| 913 | #if defined(LINUX) && defined(POWERPC) |
| 914 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 915 | sys_subpage_prot(struct tcb *tcp) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 916 | { |
| 917 | if (entering(tcp)) { |
| 918 | unsigned long cur, end, abbrev_end, entries; |
| 919 | unsigned int entry; |
| 920 | |
| 921 | tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 922 | entries = tcp->u_arg[1] >> 16; |
| 923 | if (!entries || !tcp->u_arg[2]) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 924 | tprints("{}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 925 | return 0; |
| 926 | } |
| 927 | cur = tcp->u_arg[2]; |
| 928 | end = cur + (sizeof(int) * entries); |
| 929 | if (!verbose(tcp) || end < tcp->u_arg[2]) { |
| 930 | tprintf("%#lx", tcp->u_arg[2]); |
| 931 | return 0; |
| 932 | } |
| 933 | if (abbrev(tcp)) { |
| 934 | abbrev_end = cur + (sizeof(int) * max_strlen); |
| 935 | if (abbrev_end > end) |
| 936 | abbrev_end = end; |
| 937 | } |
| 938 | else |
| 939 | abbrev_end = end; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 940 | tprints("{"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 941 | for (; cur < end; cur += sizeof(int)) { |
| 942 | if (cur > tcp->u_arg[2]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 943 | tprints(", "); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 944 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 945 | tprints("..."); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 946 | break; |
| 947 | } |
| 948 | if (umove(tcp, cur, &entry) < 0) { |
| 949 | tprintf("??? [%#lx]", cur); |
| 950 | break; |
| 951 | } |
| 952 | else |
| 953 | tprintf("%#08x", entry); |
| 954 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 955 | tprints("}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | return 0; |
| 959 | } |
| 960 | #endif |