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