Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 6 | * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH |
| 7 | * port by Greg Banks <gbanks@pocketpenguins.com> |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 8 | * All rights reserved. |
| 9 | * |
| 10 | * Redistribution and use in source and binary forms, with or without |
| 11 | * modification, are permitted provided that the following conditions |
| 12 | * are met: |
| 13 | * 1. Redistributions of source code must retain the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer. |
| 15 | * 2. Redistributions in binary form must reproduce the above copyright |
| 16 | * notice, this list of conditions and the following disclaimer in the |
| 17 | * documentation and/or other materials provided with the distribution. |
| 18 | * 3. The name of the author may not be used to endorse or promote products |
| 19 | * derived from this software without specific prior written permission. |
| 20 | * |
| 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 26 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 30 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 31 | */ |
| 32 | |
| 33 | #include "defs.h" |
Roland McGrath | 05cdd3c | 2004-03-02 06:16:59 +0000 | [diff] [blame] | 34 | #include <asm/mman.h> |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 35 | #include <sys/mman.h> |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 36 | #if defined(I386) |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 37 | # include <asm/ldt.h> |
Roland McGrath | 7decfb2 | 2004-03-01 22:10:52 +0000 | [diff] [blame] | 38 | # ifdef HAVE_STRUCT_USER_DESC |
| 39 | # define modify_ldt_ldt_s user_desc |
| 40 | # endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 41 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 42 | |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 43 | static unsigned long |
| 44 | get_pagesize() |
| 45 | { |
| 46 | static unsigned long pagesize; |
| 47 | |
| 48 | if (!pagesize) |
| 49 | pagesize = sysconf(_SC_PAGESIZE); |
| 50 | return pagesize; |
| 51 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | |
| 53 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 54 | sys_brk(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 55 | { |
| 56 | if (entering(tcp)) { |
| 57 | tprintf("%#lx", tcp->u_arg[0]); |
| 58 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 59 | return RVAL_HEX; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 62 | static const struct xlat mmap_prot[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 63 | { PROT_NONE, "PROT_NONE", }, |
| 64 | { PROT_READ, "PROT_READ" }, |
| 65 | { PROT_WRITE, "PROT_WRITE" }, |
| 66 | { PROT_EXEC, "PROT_EXEC" }, |
Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 67 | #ifdef PROT_SEM |
| 68 | { PROT_SEM, "PROT_SEM" }, |
| 69 | #endif |
| 70 | #ifdef PROT_GROWSDOWN |
| 71 | { PROT_GROWSDOWN,"PROT_GROWSDOWN"}, |
| 72 | #endif |
| 73 | #ifdef PROT_GROWSUP |
| 74 | { PROT_GROWSUP, "PROT_GROWSUP" }, |
| 75 | #endif |
Roland McGrath | 586d6ab | 2008-08-25 03:00:47 +0000 | [diff] [blame] | 76 | #ifdef PROT_SAO |
| 77 | { PROT_SAO, "PROT_SAO" }, |
| 78 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 79 | { 0, NULL }, |
| 80 | }; |
| 81 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 82 | static const struct xlat mmap_flags[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 83 | { MAP_SHARED, "MAP_SHARED" }, |
| 84 | { MAP_PRIVATE, "MAP_PRIVATE" }, |
| 85 | { MAP_FIXED, "MAP_FIXED" }, |
| 86 | #ifdef MAP_ANONYMOUS |
| 87 | { MAP_ANONYMOUS,"MAP_ANONYMOUS" }, |
| 88 | #endif |
Dmitry V. Levin | 71f1a13 | 2007-03-29 23:30:09 +0000 | [diff] [blame] | 89 | #ifdef MAP_32BIT |
| 90 | { MAP_32BIT, "MAP_32BIT" }, |
| 91 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 92 | #ifdef MAP_RENAME |
| 93 | { MAP_RENAME, "MAP_RENAME" }, |
| 94 | #endif |
| 95 | #ifdef MAP_NORESERVE |
| 96 | { MAP_NORESERVE,"MAP_NORESERVE" }, |
| 97 | #endif |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 98 | #ifdef MAP_POPULATE |
| 99 | { MAP_POPULATE, "MAP_POPULATE" }, |
| 100 | #endif |
| 101 | #ifdef MAP_NONBLOCK |
| 102 | { MAP_NONBLOCK, "MAP_NONBLOCK" }, |
| 103 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 104 | /* |
| 105 | * XXX - this was introduced in SunOS 4.x to distinguish between |
| 106 | * the old pre-4.x "mmap()", which: |
| 107 | * |
| 108 | * only let you map devices with an "mmap" routine (e.g., |
| 109 | * frame buffers) in; |
| 110 | * |
| 111 | * required you to specify the mapping address; |
| 112 | * |
| 113 | * returned 0 on success and -1 on failure; |
| 114 | * |
| 115 | * memory and which, and the 4.x "mmap()" which: |
| 116 | * |
| 117 | * can map plain files; |
| 118 | * |
| 119 | * can be asked to pick where to map the file; |
| 120 | * |
| 121 | * returns the address where it mapped the file on success |
| 122 | * and -1 on failure. |
| 123 | * |
| 124 | * It's not actually used in source code that calls "mmap()"; the |
| 125 | * "mmap()" routine adds it for you. |
| 126 | * |
| 127 | * It'd be nice to come up with some way of eliminating it from |
| 128 | * the flags, e.g. reporting calls *without* it as "old_mmap()" |
| 129 | * and calls with it as "mmap()". |
| 130 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 131 | #ifdef _MAP_NEW |
| 132 | { _MAP_NEW, "_MAP_NEW" }, |
| 133 | #endif |
| 134 | #ifdef MAP_GROWSDOWN |
| 135 | { MAP_GROWSDOWN,"MAP_GROWSDOWN" }, |
| 136 | #endif |
| 137 | #ifdef MAP_DENYWRITE |
| 138 | { MAP_DENYWRITE,"MAP_DENYWRITE" }, |
| 139 | #endif |
| 140 | #ifdef MAP_EXECUTABLE |
| 141 | { MAP_EXECUTABLE,"MAP_EXECUTABLE"}, |
| 142 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 143 | #ifdef MAP_INHERIT |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 144 | { MAP_INHERIT, "MAP_INHERIT" }, |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 145 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 146 | #ifdef MAP_FILE |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 147 | { MAP_FILE, "MAP_FILE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 148 | #endif |
| 149 | #ifdef MAP_LOCKED |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 150 | { MAP_LOCKED, "MAP_LOCKED" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 151 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 152 | /* FreeBSD ones */ |
Denys Vlasenko | 2897fb3 | 2012-03-17 01:29:40 +0100 | [diff] [blame] | 153 | #if defined(MAP_ANON) && (!defined(MAP_ANONYMOUS) || MAP_ANON != MAP_ANONYMOUS) |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 154 | { MAP_ANON, "MAP_ANON" }, |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 155 | #endif |
| 156 | #ifdef MAP_HASSEMAPHORE |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 157 | { MAP_HASSEMAPHORE,"MAP_HASSEMAPHORE"}, |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 158 | #endif |
| 159 | #ifdef MAP_STACK |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 160 | { MAP_STACK, "MAP_STACK" }, |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 161 | #endif |
Bernhard Reutner-Fischer | 21ceeb4 | 2013-02-05 19:31:55 +0100 | [diff] [blame] | 162 | #if defined MAP_UNINITIALIZED && MAP_UNINITIALIZED > 0 |
| 163 | { MAP_UNINITIALIZED,"MAP_UNINITIALIZED"}, |
| 164 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 165 | #ifdef MAP_NOSYNC |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 166 | { MAP_NOSYNC, "MAP_NOSYNC" }, |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 167 | #endif |
| 168 | #ifdef MAP_NOCORE |
Denys Vlasenko | 3e3490a | 2012-03-17 01:27:37 +0100 | [diff] [blame] | 169 | { MAP_NOCORE, "MAP_NOCORE" }, |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 170 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 171 | { 0, NULL }, |
| 172 | }; |
| 173 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 174 | static int |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 175 | print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 176 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 177 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 178 | /* addr */ |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 179 | if (!u_arg[0]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 180 | tprints("NULL, "); |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 181 | else |
| 182 | tprintf("%#lx, ", u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 183 | /* len */ |
| 184 | tprintf("%lu, ", u_arg[1]); |
| 185 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 186 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 187 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 188 | /* flags */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 189 | #ifdef MAP_TYPE |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 190 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
| 191 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 192 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 193 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 194 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 195 | tprints(", "); |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 196 | /* fd */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 197 | printfd(tcp, u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 198 | /* offset */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 199 | tprintf(", %#llx", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 200 | } |
| 201 | return RVAL_HEX; |
| 202 | } |
| 203 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 204 | /* Syscall name<->function correspondence is messed up on many arches. |
| 205 | * For example: |
| 206 | * i386 has __NR_mmap == 90, and it is "old mmap", and |
| 207 | * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets". |
| 208 | * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets". |
| 209 | * Confused? Me too! |
| 210 | */ |
| 211 | |
| 212 | /* Params are pointed to by u_arg[0], offset is in bytes */ |
| 213 | int |
| 214 | sys_old_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 215 | { |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 216 | long u_arg[6]; |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 217 | #if defined(IA64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 218 | /* |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 219 | * IA64 processes never call this routine, they only use the |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 220 | * new 'sys_mmap' interface. Only IA32 processes come here. |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 221 | */ |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 222 | int i; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 223 | unsigned narrow_arg[6]; |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 224 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 225 | return 0; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 226 | for (i = 0; i < 6; i++) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 227 | u_arg[i] = (unsigned long) narrow_arg[i]; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 228 | #elif defined(X86_64) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 229 | /* We are here only in personality 1 (i386) */ |
| 230 | int i; |
| 231 | unsigned narrow_arg[6]; |
| 232 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 233 | return 0; |
| 234 | for (i = 0; i < 6; ++i) |
| 235 | u_arg[i] = (unsigned long) narrow_arg[i]; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 236 | #else |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 237 | 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] | 238 | return 0; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 239 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 240 | return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 241 | } |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 242 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 243 | #if defined(S390) |
| 244 | /* Params are pointed to by u_arg[0], offset is in pages */ |
| 245 | int |
| 246 | sys_old_mmap_pgoff(struct tcb *tcp) |
| 247 | { |
| 248 | long u_arg[5]; |
| 249 | int i; |
| 250 | unsigned narrow_arg[6]; |
| 251 | unsigned long long offset; |
| 252 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 253 | return 0; |
| 254 | for (i = 0; i < 5; i++) |
| 255 | u_arg[i] = (unsigned long) narrow_arg[i]; |
| 256 | offset = narrow_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 257 | offset *= get_pagesize(); |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 258 | return print_mmap(tcp, u_arg, offset); |
| 259 | } |
| 260 | #endif |
| 261 | |
| 262 | /* Params are passed directly, offset is in bytes */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 263 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 264 | sys_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 265 | { |
Denys Vlasenko | 8dedb0d | 2013-02-18 03:13:07 +0100 | [diff] [blame] | 266 | unsigned long long offset = (unsigned long) tcp->u_arg[5]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 267 | #if defined(LINUX_MIPSN32) || defined(X32) |
Denys Vlasenko | 8dedb0d | 2013-02-18 03:13:07 +0100 | [diff] [blame] | 268 | /* Try test/x32_mmap.c */ |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 269 | offset = tcp->ext_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 270 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 271 | /* Example of kernel-side handling of this variety of mmap: |
| 272 | * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls |
| 273 | * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes, |
| 274 | * since the above code converts off to pages. |
| 275 | */ |
| 276 | return print_mmap(tcp, tcp->u_arg, offset); |
| 277 | } |
| 278 | |
| 279 | /* Params are passed directly, offset is in pages */ |
| 280 | int |
| 281 | sys_mmap_pgoff(struct tcb *tcp) |
| 282 | { |
| 283 | /* Try test/mmap_offset_decode.c */ |
| 284 | unsigned long long offset; |
| 285 | offset = (unsigned long) tcp->u_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 286 | offset *= get_pagesize(); |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 287 | return print_mmap(tcp, tcp->u_arg, offset); |
| 288 | } |
| 289 | |
| 290 | /* Params are passed directly, offset is in 4k units */ |
| 291 | int |
| 292 | sys_mmap_4koff(struct tcb *tcp) |
| 293 | { |
| 294 | unsigned long long offset; |
| 295 | offset = (unsigned long) tcp->u_arg[5]; |
| 296 | offset <<= 12; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 297 | return print_mmap(tcp, tcp->u_arg, offset); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 298 | } |
| 299 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 300 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 301 | sys_munmap(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 302 | { |
| 303 | if (entering(tcp)) { |
| 304 | tprintf("%#lx, %lu", |
| 305 | tcp->u_arg[0], tcp->u_arg[1]); |
| 306 | } |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 311 | sys_mprotect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 312 | { |
| 313 | if (entering(tcp)) { |
| 314 | tprintf("%#lx, %lu, ", |
| 315 | tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 316 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 317 | } |
| 318 | return 0; |
| 319 | } |
| 320 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 321 | static const struct xlat mremap_flags[] = { |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 322 | { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" }, |
Chris Metcalf | ff3474a | 2009-12-24 23:19:19 +0000 | [diff] [blame] | 323 | #ifdef MREMAP_FIXED |
| 324 | { MREMAP_FIXED, "MREMAP_FIXED" }, |
| 325 | #endif |
Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 326 | { 0, NULL } |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 327 | }; |
| 328 | |
| 329 | int |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 330 | sys_mremap(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 331 | { |
| 332 | if (entering(tcp)) { |
| 333 | tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1], |
| 334 | tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 335 | printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 336 | #ifdef MREMAP_FIXED |
| 337 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 338 | (MREMAP_MAYMOVE | MREMAP_FIXED)) |
| 339 | tprintf(", %#lx", tcp->u_arg[4]); |
| 340 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 341 | } |
| 342 | return RVAL_HEX; |
| 343 | } |
| 344 | |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 345 | static const struct xlat madvise_cmds[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 346 | #ifdef MADV_NORMAL |
| 347 | { MADV_NORMAL, "MADV_NORMAL" }, |
| 348 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 349 | #ifdef MADV_RANDOM |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 350 | { MADV_RANDOM, "MADV_RANDOM" }, |
| 351 | #endif |
| 352 | #ifdef MADV_SEQUENTIAL |
| 353 | { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" }, |
| 354 | #endif |
| 355 | #ifdef MADV_WILLNEED |
| 356 | { MADV_WILLNEED, "MADV_WILLNEED" }, |
| 357 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 358 | #ifdef MADV_DONTNEED |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 359 | { MADV_DONTNEED, "MADV_DONTNEED" }, |
| 360 | #endif |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 361 | #ifdef MADV_REMOVE |
| 362 | { MADV_REMOVE, "MADV_REMOVE" }, |
| 363 | #endif |
| 364 | #ifdef MADV_DONTFORK |
| 365 | { MADV_DONTFORK, "MADV_DONTFORK" }, |
| 366 | #endif |
| 367 | #ifdef MADV_DOFORK |
| 368 | { MADV_DOFORK, "MADV_DOFORK" }, |
| 369 | #endif |
| 370 | #ifdef MADV_HWPOISON |
| 371 | { MADV_HWPOISON, "MADV_HWPOISON" }, |
| 372 | #endif |
| 373 | #ifdef MADV_SOFT_OFFLINE |
| 374 | { MADV_SOFT_OFFLINE, "MADV_SOFT_OFFLINE" }, |
| 375 | #endif |
| 376 | #ifdef MADV_MERGEABLE |
| 377 | { MADV_MERGEABLE, "MADV_MERGEABLE" }, |
| 378 | #endif |
| 379 | #ifdef MADV_UNMERGEABLE |
| 380 | { MADV_UNMERGEABLE, "MADV_UNMERGEABLE" }, |
| 381 | #endif |
| 382 | #ifdef MADV_HUGEPAGE |
| 383 | { MADV_HUGEPAGE, "MADV_HUGEPAGE" }, |
| 384 | #endif |
| 385 | #ifdef MADV_NOHUGEPAGE |
| 386 | { MADV_NOHUGEPAGE, "MADV_NOHUGEPAGE" }, |
| 387 | #endif |
| 388 | #ifdef MADV_DONTDUMP |
| 389 | { MADV_DONTDUMP, "MADV_DONTDUMP" }, |
| 390 | #endif |
| 391 | #ifdef MADV_DODUMP |
| 392 | { MADV_DODUMP, "MADV_DODUMP" }, |
| 393 | #endif |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 394 | { 0, NULL }, |
| 395 | }; |
| 396 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 397 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 398 | sys_madvise(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 399 | { |
| 400 | if (entering(tcp)) { |
| 401 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 402 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 403 | } |
| 404 | return 0; |
| 405 | } |
| 406 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 407 | static const struct xlat mlockall_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 408 | #ifdef MCL_CURRENT |
| 409 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 410 | #endif |
| 411 | #ifdef MCL_FUTURE |
| 412 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 413 | #endif |
| 414 | { 0, NULL} |
| 415 | }; |
| 416 | |
| 417 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 418 | sys_mlockall(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 419 | { |
| 420 | if (entering(tcp)) { |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 421 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 422 | } |
| 423 | return 0; |
| 424 | } |
| 425 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 426 | #ifdef MS_ASYNC |
| 427 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 428 | static const struct xlat mctl_sync[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 429 | #ifdef MS_SYNC |
| 430 | { MS_SYNC, "MS_SYNC" }, |
| 431 | #endif |
John Hughes | aca07f3 | 2001-10-16 18:12:27 +0000 | [diff] [blame] | 432 | { MS_ASYNC, "MS_ASYNC" }, |
| 433 | { MS_INVALIDATE,"MS_INVALIDATE" }, |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 434 | { 0, NULL }, |
| 435 | }; |
| 436 | |
| 437 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 438 | sys_msync(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 439 | { |
| 440 | if (entering(tcp)) { |
| 441 | /* addr */ |
| 442 | tprintf("%#lx", tcp->u_arg[0]); |
| 443 | /* len */ |
| 444 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 445 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 446 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 447 | } |
| 448 | return 0; |
| 449 | } |
| 450 | |
| 451 | #endif /* MS_ASYNC */ |
| 452 | |
| 453 | #ifdef MC_SYNC |
| 454 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 455 | static const struct xlat mctl_funcs[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 456 | { MC_LOCK, "MC_LOCK" }, |
| 457 | { MC_LOCKAS, "MC_LOCKAS" }, |
| 458 | { MC_SYNC, "MC_SYNC" }, |
| 459 | { MC_UNLOCK, "MC_UNLOCK" }, |
| 460 | { MC_UNLOCKAS, "MC_UNLOCKAS" }, |
| 461 | { 0, NULL }, |
| 462 | }; |
| 463 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 464 | static const struct xlat mctl_lockas[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 465 | { MCL_CURRENT, "MCL_CURRENT" }, |
| 466 | { MCL_FUTURE, "MCL_FUTURE" }, |
| 467 | { 0, NULL }, |
| 468 | }; |
| 469 | |
| 470 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 471 | sys_mctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 472 | { |
| 473 | int arg, function; |
| 474 | |
| 475 | if (entering(tcp)) { |
| 476 | /* addr */ |
| 477 | tprintf("%#lx", tcp->u_arg[0]); |
| 478 | /* len */ |
| 479 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 480 | /* function */ |
| 481 | function = tcp->u_arg[2]; |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 482 | printflags(mctl_funcs, function, "MC_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 483 | /* arg */ |
| 484 | arg = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 485 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 486 | switch (function) { |
| 487 | case MC_SYNC: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 488 | printflags(mctl_sync, arg, "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 489 | break; |
| 490 | case MC_LOCKAS: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 491 | printflags(mctl_lockas, arg, "MCL_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 492 | break; |
| 493 | default: |
| 494 | tprintf("%#x", arg); |
| 495 | break; |
| 496 | } |
| 497 | } |
| 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | #endif /* MC_SYNC */ |
| 502 | |
| 503 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 504 | sys_mincore(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 505 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 506 | if (entering(tcp)) { |
| 507 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 508 | } else { |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 509 | unsigned long i, len; |
| 510 | char *vec = NULL; |
| 511 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 512 | len = tcp->u_arg[1]; |
| 513 | if (syserror(tcp) || tcp->u_arg[2] == 0 || |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 514 | (vec = malloc(len)) == NULL || |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 515 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 516 | tprintf("%#lx", tcp->u_arg[2]); |
| 517 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 518 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 519 | for (i = 0; i < len; i++) { |
| 520 | if (abbrev(tcp) && i >= max_strlen) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 521 | tprints("..."); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 522 | break; |
| 523 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 524 | tprints((vec[i] & 1) ? "1" : "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 525 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 526 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 527 | } |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 528 | free(vec); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 529 | } |
| 530 | return 0; |
| 531 | } |
| 532 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 533 | #if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 534 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 535 | sys_getpagesize(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 536 | { |
| 537 | if (exiting(tcp)) |
| 538 | return RVAL_HEX; |
| 539 | return 0; |
| 540 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 541 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 542 | |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 543 | #if defined(I386) |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 544 | void |
Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 545 | print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 546 | { |
| 547 | tprintf("base_addr:%#08lx, " |
| 548 | "limit:%d, " |
| 549 | "seg_32bit:%d, " |
| 550 | "contents:%d, " |
| 551 | "read_exec_only:%d, " |
| 552 | "limit_in_pages:%d, " |
| 553 | "seg_not_present:%d, " |
| 554 | "useable:%d}", |
Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 555 | (long) ldt_entry->base_addr, |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 556 | ldt_entry->limit, |
| 557 | ldt_entry->seg_32bit, |
| 558 | ldt_entry->contents, |
| 559 | ldt_entry->read_exec_only, |
| 560 | ldt_entry->limit_in_pages, |
| 561 | ldt_entry->seg_not_present, |
| 562 | ldt_entry->useable); |
| 563 | } |
| 564 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 565 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 566 | sys_modify_ldt(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 567 | { |
| 568 | if (entering(tcp)) { |
| 569 | struct modify_ldt_ldt_s copy; |
| 570 | tprintf("%ld", tcp->u_arg[0]); |
| 571 | if (tcp->u_arg[1] == 0 |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 572 | || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 573 | || umove(tcp, tcp->u_arg[1], ©) == -1) |
| 574 | tprintf(", %lx", tcp->u_arg[1]); |
| 575 | else { |
| 576 | tprintf(", {entry_number:%d, ", copy.entry_number); |
| 577 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 578 | tprints("...}"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 579 | else { |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 580 | print_ldt_entry(©); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 581 | } |
| 582 | } |
| 583 | tprintf(", %lu", tcp->u_arg[2]); |
| 584 | } |
| 585 | return 0; |
| 586 | } |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 587 | |
| 588 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 589 | sys_set_thread_area(struct tcb *tcp) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 590 | { |
| 591 | struct modify_ldt_ldt_s copy; |
| 592 | if (entering(tcp)) { |
| 593 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 594 | if (copy.entry_number == -1) |
| 595 | tprintf("{entry_number:%d -> ", |
| 596 | copy.entry_number); |
| 597 | else |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 598 | tprints("{entry_number:"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 599 | } |
| 600 | } else { |
| 601 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 602 | tprintf("%d, ", copy.entry_number); |
| 603 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 604 | tprints("...}"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 605 | else { |
| 606 | print_ldt_entry(©); |
| 607 | } |
| 608 | } else { |
| 609 | tprintf("%lx", tcp->u_arg[0]); |
| 610 | } |
| 611 | } |
| 612 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 613 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 617 | sys_get_thread_area(struct tcb *tcp) |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 618 | { |
| 619 | struct modify_ldt_ldt_s copy; |
| 620 | if (exiting(tcp)) { |
| 621 | if (umove(tcp, tcp->u_arg[0], ©) != -1) { |
| 622 | tprintf("{entry_number:%d, ", copy.entry_number); |
| 623 | if (!verbose(tcp)) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 624 | tprints("...}"); |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 625 | else { |
| 626 | print_ldt_entry(©); |
| 627 | } |
| 628 | } else { |
| 629 | tprintf("%lx", tcp->u_arg[0]); |
| 630 | } |
| 631 | } |
| 632 | return 0; |
Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 633 | |
Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 634 | } |
Denys Vlasenko | c36c352 | 2012-02-25 02:47:15 +0100 | [diff] [blame] | 635 | #endif /* I386 */ |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 636 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 637 | #if defined(M68K) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 638 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 639 | sys_set_thread_area(struct tcb *tcp) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 640 | { |
| 641 | if (entering(tcp)) |
| 642 | tprintf("%#lx", tcp->u_arg[0]); |
| 643 | return 0; |
| 644 | |
| 645 | } |
| 646 | |
| 647 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 648 | sys_get_thread_area(struct tcb *tcp) |
Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 649 | { |
| 650 | return RVAL_HEX; |
| 651 | } |
| 652 | #endif |
| 653 | |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 654 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 655 | sys_remap_file_pages(struct tcb *tcp) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 656 | { |
| 657 | if (entering(tcp)) { |
| 658 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 659 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 660 | tprintf(", %lu, ", tcp->u_arg[3]); |
| 661 | #ifdef MAP_TYPE |
| 662 | printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???"); |
| 663 | addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE); |
| 664 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 665 | printflags(mmap_flags, tcp->u_arg[4], "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 666 | #endif |
| 667 | } |
| 668 | return 0; |
| 669 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 670 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 671 | #define MPOL_DEFAULT 0 |
| 672 | #define MPOL_PREFERRED 1 |
| 673 | #define MPOL_BIND 2 |
| 674 | #define MPOL_INTERLEAVE 3 |
| 675 | |
| 676 | #define MPOL_F_NODE (1<<0) |
| 677 | #define MPOL_F_ADDR (1<<1) |
| 678 | |
| 679 | #define MPOL_MF_STRICT (1<<0) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 680 | #define MPOL_MF_MOVE (1<<1) |
| 681 | #define MPOL_MF_MOVE_ALL (1<<2) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 682 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 683 | static const struct xlat policies[] = { |
| 684 | { MPOL_DEFAULT, "MPOL_DEFAULT" }, |
| 685 | { MPOL_PREFERRED, "MPOL_PREFERRED" }, |
| 686 | { MPOL_BIND, "MPOL_BIND" }, |
| 687 | { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" }, |
| 688 | { 0, NULL } |
| 689 | }; |
| 690 | |
| 691 | static const struct xlat mbindflags[] = { |
| 692 | { MPOL_MF_STRICT, "MPOL_MF_STRICT" }, |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 693 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 694 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 695 | { 0, NULL } |
| 696 | }; |
| 697 | |
| 698 | static const struct xlat mempolicyflags[] = { |
| 699 | { MPOL_F_NODE, "MPOL_F_NODE" }, |
| 700 | { MPOL_F_ADDR, "MPOL_F_ADDR" }, |
| 701 | { 0, NULL } |
| 702 | }; |
| 703 | |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 704 | static const struct xlat move_pages_flags[] = { |
| 705 | { MPOL_MF_MOVE, "MPOL_MF_MOVE" }, |
| 706 | { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" }, |
| 707 | { 0, NULL } |
| 708 | }; |
| 709 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 710 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 711 | 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] | 712 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 713 | unsigned long nlongs, size, end; |
| 714 | |
| 715 | nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long)); |
| 716 | size = nlongs * sizeof(long); |
| 717 | end = ptr + size; |
| 718 | if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes) |
| 719 | && (end > ptr))) { |
| 720 | unsigned long n, cur, abbrev_end; |
| 721 | int failed = 0; |
| 722 | |
| 723 | if (abbrev(tcp)) { |
| 724 | abbrev_end = ptr + max_strlen * sizeof(long); |
| 725 | if (abbrev_end < ptr) |
| 726 | abbrev_end = end; |
| 727 | } else { |
| 728 | abbrev_end = end; |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 729 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 730 | tprints(", {"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 731 | for (cur = ptr; cur < end; cur += sizeof(long)) { |
| 732 | if (cur > ptr) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 733 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 734 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 735 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 736 | break; |
| 737 | } |
| 738 | if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 739 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 740 | failed = 1; |
| 741 | break; |
| 742 | } |
| 743 | tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n); |
| 744 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 745 | tprints("}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 746 | if (failed) |
| 747 | tprintf(" %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 748 | } else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 749 | tprintf(", %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 750 | tprintf(", %lu", maxnodes); |
| 751 | } |
| 752 | |
| 753 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 754 | sys_mbind(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 755 | { |
| 756 | if (entering(tcp)) { |
Chris Metcalf | c5fd1d9 | 2009-12-24 23:19:35 +0000 | [diff] [blame] | 757 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 758 | printxval(policies, tcp->u_arg[2], "MPOL_???"); |
| 759 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 760 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 761 | printflags(mbindflags, tcp->u_arg[5], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 762 | } |
| 763 | return 0; |
| 764 | } |
| 765 | |
| 766 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 767 | sys_set_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 768 | { |
| 769 | if (entering(tcp)) { |
| 770 | printxval(policies, tcp->u_arg[0], "MPOL_???"); |
| 771 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0); |
| 772 | } |
| 773 | return 0; |
| 774 | } |
| 775 | |
| 776 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 777 | sys_get_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 778 | { |
| 779 | if (exiting(tcp)) { |
| 780 | int pol; |
| 781 | if (tcp->u_arg[0] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 782 | tprints("NULL"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 783 | else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0) |
| 784 | tprintf("%#lx", tcp->u_arg[0]); |
| 785 | else |
| 786 | printxval(policies, pol, "MPOL_???"); |
| 787 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp)); |
| 788 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 789 | printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 790 | } |
| 791 | return 0; |
| 792 | } |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 793 | |
| 794 | int |
Dmitry V. Levin | 64d0e71 | 2012-03-11 22:44:14 +0000 | [diff] [blame] | 795 | sys_migrate_pages(struct tcb *tcp) |
| 796 | { |
| 797 | if (entering(tcp)) { |
| 798 | tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]); |
| 799 | get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0); |
| 800 | tprints(", "); |
| 801 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0); |
| 802 | } |
| 803 | return 0; |
| 804 | } |
| 805 | |
| 806 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 807 | sys_move_pages(struct tcb *tcp) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 808 | { |
| 809 | if (entering(tcp)) { |
| 810 | unsigned long npages = tcp->u_arg[1]; |
| 811 | tprintf("%ld, %lu, ", tcp->u_arg[0], npages); |
| 812 | if (tcp->u_arg[2] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 813 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 814 | else { |
| 815 | int i; |
| 816 | long puser = tcp->u_arg[2]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 817 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 818 | for (i = 0; i < npages; ++i) { |
| 819 | void *p; |
| 820 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 821 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 822 | if (umove(tcp, puser, &p) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 823 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 824 | break; |
| 825 | } |
| 826 | tprintf("%p", p); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 827 | puser += sizeof(void *); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 828 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 829 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 830 | } |
| 831 | if (tcp->u_arg[3] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 832 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 833 | else { |
| 834 | int i; |
| 835 | long nodeuser = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 836 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 837 | for (i = 0; i < npages; ++i) { |
| 838 | int node; |
| 839 | if (i > 0) |
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 | if (umove(tcp, nodeuser, &node) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 842 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 843 | break; |
| 844 | } |
| 845 | tprintf("%#x", node); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 846 | nodeuser += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 847 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 848 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 849 | } |
| 850 | } |
| 851 | if (exiting(tcp)) { |
| 852 | unsigned long npages = tcp->u_arg[1]; |
| 853 | if (tcp->u_arg[4] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 854 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 855 | else { |
| 856 | int i; |
| 857 | long statususer = tcp->u_arg[4]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 858 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 859 | for (i = 0; i < npages; ++i) { |
| 860 | int status; |
| 861 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 862 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 863 | if (umove(tcp, statususer, &status) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 864 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 865 | break; |
| 866 | } |
| 867 | tprintf("%#x", status); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 868 | statususer += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 869 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 870 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 871 | } |
| 872 | printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); |
| 873 | } |
| 874 | return 0; |
| 875 | } |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 876 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 877 | #if defined(POWERPC) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 878 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 879 | sys_subpage_prot(struct tcb *tcp) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 880 | { |
| 881 | if (entering(tcp)) { |
| 882 | unsigned long cur, end, abbrev_end, entries; |
| 883 | unsigned int entry; |
| 884 | |
| 885 | tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 886 | entries = tcp->u_arg[1] >> 16; |
| 887 | if (!entries || !tcp->u_arg[2]) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 888 | tprints("{}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 889 | return 0; |
| 890 | } |
| 891 | cur = tcp->u_arg[2]; |
| 892 | end = cur + (sizeof(int) * entries); |
| 893 | if (!verbose(tcp) || end < tcp->u_arg[2]) { |
| 894 | tprintf("%#lx", tcp->u_arg[2]); |
| 895 | return 0; |
| 896 | } |
| 897 | if (abbrev(tcp)) { |
| 898 | abbrev_end = cur + (sizeof(int) * max_strlen); |
| 899 | if (abbrev_end > end) |
| 900 | abbrev_end = end; |
| 901 | } |
| 902 | else |
| 903 | abbrev_end = end; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 904 | tprints("{"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 905 | for (; cur < end; cur += sizeof(int)) { |
| 906 | if (cur > tcp->u_arg[2]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 907 | tprints(", "); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 908 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 909 | tprints("..."); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 910 | break; |
| 911 | } |
| 912 | if (umove(tcp, cur, &entry) < 0) { |
| 913 | tprintf("??? [%#lx]", cur); |
| 914 | break; |
| 915 | } |
| 916 | else |
| 917 | tprintf("%#08x", entry); |
| 918 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 919 | tprints("}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | return 0; |
| 923 | } |
| 924 | #endif |