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