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 | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 42 | |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 43 | static unsigned long |
| 44 | get_pagesize() |
| 45 | { |
| 46 | static unsigned long pagesize; |
| 47 | |
| 48 | if (!pagesize) |
| 49 | pagesize = sysconf(_SC_PAGESIZE); |
| 50 | return pagesize; |
| 51 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | |
| 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 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 212 | static int |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 213 | print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 214 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 215 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 216 | /* addr */ |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 217 | if (!u_arg[0]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 218 | tprints("NULL, "); |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 219 | else |
| 220 | tprintf("%#lx, ", u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 221 | /* len */ |
| 222 | tprintf("%lu, ", u_arg[1]); |
| 223 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 224 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 225 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 226 | /* flags */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 227 | #ifdef MAP_TYPE |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 228 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 229 | # ifdef TILE |
Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 230 | addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE)); |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 231 | # else |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 232 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 233 | # endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 234 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 235 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 236 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 237 | tprints(", "); |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 238 | /* fd */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 239 | printfd(tcp, u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 240 | /* offset */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 241 | tprintf(", %#llx", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 242 | } |
| 243 | return RVAL_HEX; |
| 244 | } |
| 245 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 246 | /* Syscall name<->function correspondence is messed up on many arches. |
| 247 | * For example: |
| 248 | * i386 has __NR_mmap == 90, and it is "old mmap", and |
| 249 | * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets". |
| 250 | * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets". |
| 251 | * Confused? Me too! |
| 252 | */ |
| 253 | |
| 254 | /* Params are pointed to by u_arg[0], offset is in bytes */ |
| 255 | int |
| 256 | sys_old_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 257 | { |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 258 | long u_arg[6]; |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 259 | #if defined(IA64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 260 | /* |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 261 | * IA64 processes never call this routine, they only use the |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 262 | * new 'sys_mmap' interface. Only IA32 processes come here. |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 263 | */ |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 264 | int i; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 265 | unsigned narrow_arg[6]; |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 266 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 267 | return 0; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 268 | for (i = 0; i < 6; i++) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 269 | u_arg[i] = (unsigned long) narrow_arg[i]; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 270 | #elif defined(X86_64) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 271 | /* We are here only in personality 1 (i386) */ |
| 272 | int i; |
| 273 | unsigned narrow_arg[6]; |
| 274 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 275 | return 0; |
| 276 | for (i = 0; i < 6; ++i) |
| 277 | u_arg[i] = (unsigned long) narrow_arg[i]; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 278 | #else |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 279 | 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] | 280 | return 0; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 281 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 282 | return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 283 | } |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 284 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 285 | #if defined(S390) |
| 286 | /* Params are pointed to by u_arg[0], offset is in pages */ |
| 287 | int |
| 288 | sys_old_mmap_pgoff(struct tcb *tcp) |
| 289 | { |
| 290 | long u_arg[5]; |
| 291 | int i; |
| 292 | unsigned narrow_arg[6]; |
| 293 | unsigned long long offset; |
| 294 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 295 | return 0; |
| 296 | for (i = 0; i < 5; i++) |
| 297 | u_arg[i] = (unsigned long) narrow_arg[i]; |
| 298 | offset = narrow_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 299 | offset *= get_pagesize(); |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 300 | return print_mmap(tcp, u_arg, offset); |
| 301 | } |
| 302 | #endif |
| 303 | |
| 304 | /* Params are passed directly, offset is in bytes */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 305 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 306 | sys_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 307 | { |
Denys Vlasenko | 8dedb0d | 2013-02-18 03:13:07 +0100 | [diff] [blame] | 308 | unsigned long long offset = (unsigned long) tcp->u_arg[5]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 309 | #if defined(LINUX_MIPSN32) || defined(X32) |
Denys Vlasenko | 8dedb0d | 2013-02-18 03:13:07 +0100 | [diff] [blame] | 310 | /* Try test/x32_mmap.c */ |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 311 | offset = tcp->ext_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 312 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 313 | /* Example of kernel-side handling of this variety of mmap: |
| 314 | * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls |
| 315 | * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes, |
| 316 | * since the above code converts off to pages. |
| 317 | */ |
| 318 | return print_mmap(tcp, tcp->u_arg, offset); |
| 319 | } |
| 320 | |
| 321 | /* Params are passed directly, offset is in pages */ |
| 322 | int |
| 323 | sys_mmap_pgoff(struct tcb *tcp) |
| 324 | { |
| 325 | /* Try test/mmap_offset_decode.c */ |
| 326 | unsigned long long offset; |
| 327 | offset = (unsigned long) tcp->u_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 328 | offset *= get_pagesize(); |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 329 | return print_mmap(tcp, tcp->u_arg, offset); |
| 330 | } |
| 331 | |
| 332 | /* Params are passed directly, offset is in 4k units */ |
| 333 | int |
| 334 | sys_mmap_4koff(struct tcb *tcp) |
| 335 | { |
| 336 | unsigned long long offset; |
| 337 | offset = (unsigned long) tcp->u_arg[5]; |
| 338 | offset <<= 12; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 339 | return print_mmap(tcp, tcp->u_arg, offset); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 340 | } |
| 341 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 342 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 343 | sys_munmap(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 344 | { |
| 345 | if (entering(tcp)) { |
| 346 | tprintf("%#lx, %lu", |
| 347 | tcp->u_arg[0], tcp->u_arg[1]); |
| 348 | } |
| 349 | return 0; |
| 350 | } |
| 351 | |
| 352 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 353 | sys_mprotect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 354 | { |
| 355 | if (entering(tcp)) { |
| 356 | tprintf("%#lx, %lu, ", |
| 357 | tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 358 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 359 | } |
| 360 | return 0; |
| 361 | } |
| 362 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 363 | static const struct xlat mremap_flags[] = { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 364 | { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" }, |
Chris Metcalf | ff3474a | 2009-12-24 23:19:19 +0000 | [diff] [blame] | 365 | #ifdef MREMAP_FIXED |
| 366 | { MREMAP_FIXED, "MREMAP_FIXED" }, |
| 367 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 368 | { 0, NULL } |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 369 | }; |
| 370 | |
| 371 | int |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 372 | sys_mremap(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 373 | { |
| 374 | if (entering(tcp)) { |
| 375 | tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1], |
| 376 | tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 377 | printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 378 | #ifdef MREMAP_FIXED |
| 379 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 380 | (MREMAP_MAYMOVE | MREMAP_FIXED)) |
| 381 | tprintf(", %#lx", tcp->u_arg[4]); |
| 382 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 383 | } |
| 384 | return RVAL_HEX; |
| 385 | } |
| 386 | |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 387 | static const struct xlat madvise_cmds[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 388 | #ifdef MADV_NORMAL |
| 389 | { MADV_NORMAL, "MADV_NORMAL" }, |
| 390 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 391 | #ifdef MADV_RANDOM |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 392 | { MADV_RANDOM, "MADV_RANDOM" }, |
| 393 | #endif |
| 394 | #ifdef MADV_SEQUENTIAL |
| 395 | { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" }, |
| 396 | #endif |
| 397 | #ifdef MADV_WILLNEED |
| 398 | { MADV_WILLNEED, "MADV_WILLNEED" }, |
| 399 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 400 | #ifdef MADV_DONTNEED |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 401 | { MADV_DONTNEED, "MADV_DONTNEED" }, |
| 402 | #endif |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 403 | #ifdef MADV_REMOVE |
| 404 | { MADV_REMOVE, "MADV_REMOVE" }, |
| 405 | #endif |
| 406 | #ifdef MADV_DONTFORK |
| 407 | { MADV_DONTFORK, "MADV_DONTFORK" }, |
| 408 | #endif |
| 409 | #ifdef MADV_DOFORK |
| 410 | { MADV_DOFORK, "MADV_DOFORK" }, |
| 411 | #endif |
| 412 | #ifdef MADV_HWPOISON |
| 413 | { MADV_HWPOISON, "MADV_HWPOISON" }, |
| 414 | #endif |
| 415 | #ifdef MADV_SOFT_OFFLINE |
| 416 | { MADV_SOFT_OFFLINE, "MADV_SOFT_OFFLINE" }, |
| 417 | #endif |
| 418 | #ifdef MADV_MERGEABLE |
| 419 | { MADV_MERGEABLE, "MADV_MERGEABLE" }, |
| 420 | #endif |
| 421 | #ifdef MADV_UNMERGEABLE |
| 422 | { MADV_UNMERGEABLE, "MADV_UNMERGEABLE" }, |
| 423 | #endif |
| 424 | #ifdef MADV_HUGEPAGE |
| 425 | { MADV_HUGEPAGE, "MADV_HUGEPAGE" }, |
| 426 | #endif |
| 427 | #ifdef MADV_NOHUGEPAGE |
| 428 | { MADV_NOHUGEPAGE, "MADV_NOHUGEPAGE" }, |
| 429 | #endif |
| 430 | #ifdef MADV_DONTDUMP |
| 431 | { MADV_DONTDUMP, "MADV_DONTDUMP" }, |
| 432 | #endif |
| 433 | #ifdef MADV_DODUMP |
| 434 | { MADV_DODUMP, "MADV_DODUMP" }, |
| 435 | #endif |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 436 | { 0, NULL }, |
| 437 | }; |
| 438 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 439 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 440 | sys_madvise(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 441 | { |
| 442 | if (entering(tcp)) { |
| 443 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 444 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 445 | } |
| 446 | return 0; |
| 447 | } |
| 448 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 449 | static const struct xlat mlockall_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 450 | #ifdef MCL_CURRENT |
| 451 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 452 | #endif |
| 453 | #ifdef MCL_FUTURE |
| 454 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 455 | #endif |
| 456 | { 0, NULL} |
| 457 | }; |
| 458 | |
| 459 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 460 | sys_mlockall(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 461 | { |
| 462 | if (entering(tcp)) { |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 463 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 464 | } |
| 465 | return 0; |
| 466 | } |
| 467 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 468 | #ifdef MS_ASYNC |
| 469 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 470 | static const struct xlat mctl_sync[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 471 | #ifdef MS_SYNC |
| 472 | { MS_SYNC, "MS_SYNC" }, |
| 473 | #endif |
John Hughes | aca07f3 | 2001-10-16 18:12:27 +0000 | [diff] [blame] | 474 | { MS_ASYNC, "MS_ASYNC" }, |
| 475 | { MS_INVALIDATE,"MS_INVALIDATE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 476 | { 0, NULL }, |
| 477 | }; |
| 478 | |
| 479 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 480 | sys_msync(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 481 | { |
| 482 | if (entering(tcp)) { |
| 483 | /* addr */ |
| 484 | tprintf("%#lx", tcp->u_arg[0]); |
| 485 | /* len */ |
| 486 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 487 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 488 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 489 | } |
| 490 | return 0; |
| 491 | } |
| 492 | |
| 493 | #endif /* MS_ASYNC */ |
| 494 | |
| 495 | #ifdef MC_SYNC |
| 496 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 497 | static const struct xlat mctl_funcs[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 498 | { MC_LOCK, "MC_LOCK" }, |
| 499 | { MC_LOCKAS, "MC_LOCKAS" }, |
| 500 | { MC_SYNC, "MC_SYNC" }, |
| 501 | { MC_UNLOCK, "MC_UNLOCK" }, |
| 502 | { MC_UNLOCKAS, "MC_UNLOCKAS" }, |
| 503 | { 0, NULL }, |
| 504 | }; |
| 505 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 506 | static const struct xlat mctl_lockas[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 507 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 508 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 509 | { 0, NULL }, |
| 510 | }; |
| 511 | |
| 512 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 513 | sys_mctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 514 | { |
| 515 | int arg, function; |
| 516 | |
| 517 | if (entering(tcp)) { |
| 518 | /* addr */ |
| 519 | tprintf("%#lx", tcp->u_arg[0]); |
| 520 | /* len */ |
| 521 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 522 | /* function */ |
| 523 | function = tcp->u_arg[2]; |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 524 | printflags(mctl_funcs, function, "MC_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 525 | /* arg */ |
| 526 | arg = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 527 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 528 | switch (function) { |
| 529 | case MC_SYNC: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 530 | printflags(mctl_sync, arg, "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 531 | break; |
| 532 | case MC_LOCKAS: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 533 | printflags(mctl_lockas, arg, "MCL_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 534 | break; |
| 535 | default: |
| 536 | tprintf("%#x", arg); |
| 537 | break; |
| 538 | } |
| 539 | } |
| 540 | return 0; |
| 541 | } |
| 542 | |
| 543 | #endif /* MC_SYNC */ |
| 544 | |
| 545 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 546 | sys_mincore(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 547 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 548 | if (entering(tcp)) { |
| 549 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 550 | } else { |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 551 | unsigned long i, len; |
| 552 | char *vec = NULL; |
| 553 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 554 | len = tcp->u_arg[1]; |
| 555 | if (syserror(tcp) || tcp->u_arg[2] == 0 || |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 556 | (vec = malloc(len)) == NULL || |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 557 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 558 | tprintf("%#lx", tcp->u_arg[2]); |
| 559 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 560 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 561 | for (i = 0; i < len; i++) { |
| 562 | if (abbrev(tcp) && i >= max_strlen) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 563 | tprints("..."); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 564 | break; |
| 565 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 566 | tprints((vec[i] & 1) ? "1" : "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 567 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 568 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 569 | } |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 570 | free(vec); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 571 | } |
| 572 | return 0; |
| 573 | } |
| 574 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 575 | #if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 576 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 577 | sys_getpagesize(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 578 | { |
| 579 | if (exiting(tcp)) |
| 580 | return RVAL_HEX; |
| 581 | return 0; |
| 582 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 583 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 584 | |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 585 | #if defined(I386) |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 586 | void |
Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 587 | print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 588 | { |
| 589 | tprintf("base_addr:%#08lx, " |
| 590 | "limit:%d, " |
| 591 | "seg_32bit:%d, " |
| 592 | "contents:%d, " |
| 593 | "read_exec_only:%d, " |
| 594 | "limit_in_pages:%d, " |
| 595 | "seg_not_present:%d, " |
| 596 | "useable:%d}", |
Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 597 | (long) ldt_entry->base_addr, |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 598 | ldt_entry->limit, |
| 599 | ldt_entry->seg_32bit, |
| 600 | ldt_entry->contents, |
| 601 | ldt_entry->read_exec_only, |
| 602 | ldt_entry->limit_in_pages, |
| 603 | ldt_entry->seg_not_present, |
| 604 | ldt_entry->useable); |
| 605 | } |
| 606 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 607 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 608 | sys_modify_ldt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 609 | { |
| 610 | if (entering(tcp)) { |
| 611 | struct modify_ldt_ldt_s copy; |
| 612 | tprintf("%ld", tcp->u_arg[0]); |
| 613 | if (tcp->u_arg[1] == 0 |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 614 | || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 615 | || umove(tcp, tcp->u_arg[1], ©) == -1) |
| 616 | tprintf(", %lx", tcp->u_arg[1]); |
| 617 | else { |
| 618 | tprintf(", {entry_number:%d, ", copy.entry_number); |
| 619 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 620 | tprints("...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 621 | else { |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 622 | print_ldt_entry(©); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 623 | } |
| 624 | } |
| 625 | tprintf(", %lu", tcp->u_arg[2]); |
| 626 | } |
| 627 | return 0; |
| 628 | } |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 629 | |
| 630 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 631 | sys_set_thread_area(struct tcb *tcp) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 632 | { |
| 633 | struct modify_ldt_ldt_s copy; |
| 634 | if (entering(tcp)) { |
| 635 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 636 | if (copy.entry_number == -1) |
| 637 | tprintf("{entry_number:%d -> ", |
| 638 | copy.entry_number); |
| 639 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 640 | tprints("{entry_number:"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 641 | } |
| 642 | } else { |
| 643 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 644 | tprintf("%d, ", copy.entry_number); |
| 645 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 646 | tprints("...}"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 647 | else { |
| 648 | print_ldt_entry(©); |
| 649 | } |
| 650 | } else { |
| 651 | tprintf("%lx", tcp->u_arg[0]); |
| 652 | } |
| 653 | } |
| 654 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 655 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 659 | sys_get_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 (exiting(tcp)) { |
| 663 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 664 | tprintf("{entry_number:%d, ", copy.entry_number); |
| 665 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 666 | tprints("...}"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 667 | else { |
| 668 | print_ldt_entry(©); |
| 669 | } |
| 670 | } else { |
| 671 | tprintf("%lx", tcp->u_arg[0]); |
| 672 | } |
| 673 | } |
| 674 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 675 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 676 | } |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 677 | #endif /* I386 */ |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 678 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 679 | #if defined(M68K) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 680 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 681 | sys_set_thread_area(struct tcb *tcp) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 682 | { |
| 683 | if (entering(tcp)) |
| 684 | tprintf("%#lx", tcp->u_arg[0]); |
| 685 | return 0; |
| 686 | |
| 687 | } |
| 688 | |
| 689 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 690 | sys_get_thread_area(struct tcb *tcp) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 691 | { |
| 692 | return RVAL_HEX; |
| 693 | } |
| 694 | #endif |
| 695 | |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 696 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 697 | sys_remap_file_pages(struct tcb *tcp) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 698 | { |
| 699 | if (entering(tcp)) { |
| 700 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 701 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 702 | tprintf(", %lu, ", tcp->u_arg[3]); |
| 703 | #ifdef MAP_TYPE |
| 704 | printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???"); |
| 705 | addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE); |
| 706 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 707 | printflags(mmap_flags, tcp->u_arg[4], "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 708 | #endif |
| 709 | } |
| 710 | return 0; |
| 711 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 712 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 713 | #define MPOL_DEFAULT 0 |
| 714 | #define MPOL_PREFERRED 1 |
| 715 | #define MPOL_BIND 2 |
| 716 | #define MPOL_INTERLEAVE 3 |
| 717 | |
| 718 | #define MPOL_F_NODE (1<<0) |
| 719 | #define MPOL_F_ADDR (1<<1) |
| 720 | |
| 721 | #define MPOL_MF_STRICT (1<<0) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 722 | #define MPOL_MF_MOVE (1<<1) |
| 723 | #define MPOL_MF_MOVE_ALL (1<<2) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 724 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 725 | static const struct xlat policies[] = { |
| 726 | { MPOL_DEFAULT, "MPOL_DEFAULT" }, |
| 727 | { MPOL_PREFERRED, "MPOL_PREFERRED" }, |
| 728 | { MPOL_BIND, "MPOL_BIND" }, |
| 729 | { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" }, |
| 730 | { 0, NULL } |
| 731 | }; |
| 732 | |
| 733 | static const struct xlat mbindflags[] = { |
| 734 | { MPOL_MF_STRICT, "MPOL_MF_STRICT" }, |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 735 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 736 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 737 | { 0, NULL } |
| 738 | }; |
| 739 | |
| 740 | static const struct xlat mempolicyflags[] = { |
| 741 | { MPOL_F_NODE, "MPOL_F_NODE" }, |
| 742 | { MPOL_F_ADDR, "MPOL_F_ADDR" }, |
| 743 | { 0, NULL } |
| 744 | }; |
| 745 | |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 746 | static const struct xlat move_pages_flags[] = { |
| 747 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 748 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
| 749 | { 0, NULL } |
| 750 | }; |
| 751 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 752 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 753 | 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] | 754 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 755 | unsigned long nlongs, size, end; |
| 756 | |
| 757 | nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long)); |
| 758 | size = nlongs * sizeof(long); |
| 759 | end = ptr + size; |
| 760 | if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes) |
| 761 | && (end > ptr))) { |
| 762 | unsigned long n, cur, abbrev_end; |
| 763 | int failed = 0; |
| 764 | |
| 765 | if (abbrev(tcp)) { |
| 766 | abbrev_end = ptr + max_strlen * sizeof(long); |
| 767 | if (abbrev_end < ptr) |
| 768 | abbrev_end = end; |
| 769 | } else { |
| 770 | abbrev_end = end; |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 771 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 772 | tprints(", {"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 773 | for (cur = ptr; cur < end; cur += sizeof(long)) { |
| 774 | if (cur > ptr) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 775 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 776 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 777 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 778 | break; |
| 779 | } |
| 780 | if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 781 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 782 | failed = 1; |
| 783 | break; |
| 784 | } |
| 785 | tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n); |
| 786 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 787 | tprints("}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 788 | if (failed) |
| 789 | tprintf(" %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 790 | } else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 791 | tprintf(", %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 792 | tprintf(", %lu", maxnodes); |
| 793 | } |
| 794 | |
| 795 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 796 | sys_mbind(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 797 | { |
| 798 | if (entering(tcp)) { |
Chris Metcalf | c5fd1d9 | 2009-12-24 23:19:35 +0000 | [diff] [blame] | 799 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 800 | printxval(policies, tcp->u_arg[2], "MPOL_???"); |
| 801 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 802 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 803 | printflags(mbindflags, tcp->u_arg[5], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 804 | } |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 809 | sys_set_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 810 | { |
| 811 | if (entering(tcp)) { |
| 812 | printxval(policies, tcp->u_arg[0], "MPOL_???"); |
| 813 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0); |
| 814 | } |
| 815 | return 0; |
| 816 | } |
| 817 | |
| 818 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 819 | sys_get_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 820 | { |
| 821 | if (exiting(tcp)) { |
| 822 | int pol; |
| 823 | if (tcp->u_arg[0] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 824 | tprints("NULL"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 825 | else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0) |
| 826 | tprintf("%#lx", tcp->u_arg[0]); |
| 827 | else |
| 828 | printxval(policies, pol, "MPOL_???"); |
| 829 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp)); |
| 830 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 831 | printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 832 | } |
| 833 | return 0; |
| 834 | } |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 835 | |
| 836 | int |
Dmitry V. Levin | 64d0e71 | 2012-03-11 22:44:14 +0000 | [diff] [blame] | 837 | sys_migrate_pages(struct tcb *tcp) |
| 838 | { |
| 839 | if (entering(tcp)) { |
| 840 | tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]); |
| 841 | get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0); |
| 842 | tprints(", "); |
| 843 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0); |
| 844 | } |
| 845 | return 0; |
| 846 | } |
| 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) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 855 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 856 | else { |
| 857 | int i; |
| 858 | long puser = tcp->u_arg[2]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 859 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 860 | for (i = 0; i < npages; ++i) { |
| 861 | void *p; |
| 862 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 863 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 864 | if (umove(tcp, puser, &p) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 865 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 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 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 871 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 872 | } |
| 873 | if (tcp->u_arg[3] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 874 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 875 | else { |
| 876 | int i; |
| 877 | long nodeuser = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 878 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 879 | for (i = 0; i < npages; ++i) { |
| 880 | int node; |
| 881 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 882 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 883 | if (umove(tcp, nodeuser, &node) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 884 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 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 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 890 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 891 | } |
| 892 | } |
| 893 | if (exiting(tcp)) { |
| 894 | unsigned long npages = tcp->u_arg[1]; |
| 895 | if (tcp->u_arg[4] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 896 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 897 | else { |
| 898 | int i; |
| 899 | long statususer = tcp->u_arg[4]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 900 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 901 | for (i = 0; i < npages; ++i) { |
| 902 | int status; |
| 903 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 904 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 905 | if (umove(tcp, statususer, &status) < 0) { |
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 | 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 | } |
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 | } |
| 914 | printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); |
| 915 | } |
| 916 | return 0; |
| 917 | } |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 918 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 919 | #if defined(POWERPC) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 920 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 921 | sys_subpage_prot(struct tcb *tcp) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 922 | { |
| 923 | if (entering(tcp)) { |
| 924 | unsigned long cur, end, abbrev_end, entries; |
| 925 | unsigned int entry; |
| 926 | |
| 927 | tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 928 | entries = tcp->u_arg[1] >> 16; |
| 929 | if (!entries || !tcp->u_arg[2]) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 930 | tprints("{}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 931 | return 0; |
| 932 | } |
| 933 | cur = tcp->u_arg[2]; |
| 934 | end = cur + (sizeof(int) * entries); |
| 935 | if (!verbose(tcp) || end < tcp->u_arg[2]) { |
| 936 | tprintf("%#lx", tcp->u_arg[2]); |
| 937 | return 0; |
| 938 | } |
| 939 | if (abbrev(tcp)) { |
| 940 | abbrev_end = cur + (sizeof(int) * max_strlen); |
| 941 | if (abbrev_end > end) |
| 942 | abbrev_end = end; |
| 943 | } |
| 944 | else |
| 945 | abbrev_end = end; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 946 | tprints("{"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 947 | for (; cur < end; cur += sizeof(int)) { |
| 948 | if (cur > tcp->u_arg[2]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 949 | tprints(", "); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 950 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 951 | tprints("..."); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 952 | break; |
| 953 | } |
| 954 | if (umove(tcp, cur, &entry) < 0) { |
| 955 | tprintf("??? [%#lx]", cur); |
| 956 | break; |
| 957 | } |
| 958 | else |
| 959 | tprintf("%#08x", entry); |
| 960 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 961 | tprints("}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | return 0; |
| 965 | } |
| 966 | #endif |