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