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