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