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