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