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