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