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 | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 36 | |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 37 | static unsigned long |
| 38 | get_pagesize() |
| 39 | { |
| 40 | static unsigned long pagesize; |
| 41 | |
| 42 | if (!pagesize) |
| 43 | pagesize = sysconf(_SC_PAGESIZE); |
| 44 | return pagesize; |
| 45 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 46 | |
| 47 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 48 | sys_brk(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | { |
| 50 | if (entering(tcp)) { |
| 51 | tprintf("%#lx", tcp->u_arg[0]); |
| 52 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 53 | return RVAL_HEX; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 54 | } |
| 55 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 56 | static const struct xlat mmap_prot[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 57 | XLAT(PROT_NONE), |
| 58 | XLAT(PROT_READ), |
| 59 | XLAT(PROT_WRITE), |
| 60 | XLAT(PROT_EXEC), |
Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 61 | #ifdef PROT_SEM |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 62 | XLAT(PROT_SEM), |
Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 63 | #endif |
| 64 | #ifdef PROT_GROWSDOWN |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 65 | XLAT(PROT_GROWSDOWN), |
Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 66 | #endif |
| 67 | #ifdef PROT_GROWSUP |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 68 | XLAT(PROT_GROWSUP), |
Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 69 | #endif |
Roland McGrath | 586d6ab | 2008-08-25 03:00:47 +0000 | [diff] [blame] | 70 | #ifdef PROT_SAO |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 71 | XLAT(PROT_SAO), |
Roland McGrath | 586d6ab | 2008-08-25 03:00:47 +0000 | [diff] [blame] | 72 | #endif |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 73 | XLAT_END |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 76 | static const struct xlat mmap_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 77 | XLAT(MAP_SHARED), |
| 78 | XLAT(MAP_PRIVATE), |
| 79 | XLAT(MAP_FIXED), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 80 | #ifdef MAP_ANONYMOUS |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 81 | XLAT(MAP_ANONYMOUS), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 82 | #endif |
Dmitry V. Levin | 71f1a13 | 2007-03-29 23:30:09 +0000 | [diff] [blame] | 83 | #ifdef MAP_32BIT |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 84 | XLAT(MAP_32BIT), |
Dmitry V. Levin | 71f1a13 | 2007-03-29 23:30:09 +0000 | [diff] [blame] | 85 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 86 | #ifdef MAP_RENAME |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 87 | XLAT(MAP_RENAME), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 88 | #endif |
| 89 | #ifdef MAP_NORESERVE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 90 | XLAT(MAP_NORESERVE), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 91 | #endif |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 92 | #ifdef MAP_POPULATE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 93 | XLAT(MAP_POPULATE), |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 94 | #endif |
| 95 | #ifdef MAP_NONBLOCK |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 96 | XLAT(MAP_NONBLOCK), |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 97 | #endif |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 98 | /* |
| 99 | * XXX - this was introduced in SunOS 4.x to distinguish between |
| 100 | * the old pre-4.x "mmap()", which: |
| 101 | * |
| 102 | * only let you map devices with an "mmap" routine (e.g., |
| 103 | * frame buffers) in; |
| 104 | * |
| 105 | * required you to specify the mapping address; |
| 106 | * |
| 107 | * returned 0 on success and -1 on failure; |
| 108 | * |
| 109 | * memory and which, and the 4.x "mmap()" which: |
| 110 | * |
| 111 | * can map plain files; |
| 112 | * |
| 113 | * can be asked to pick where to map the file; |
| 114 | * |
| 115 | * returns the address where it mapped the file on success |
| 116 | * and -1 on failure. |
| 117 | * |
| 118 | * It's not actually used in source code that calls "mmap()"; the |
| 119 | * "mmap()" routine adds it for you. |
| 120 | * |
| 121 | * It'd be nice to come up with some way of eliminating it from |
| 122 | * the flags, e.g. reporting calls *without* it as "old_mmap()" |
| 123 | * and calls with it as "mmap()". |
| 124 | */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 125 | #ifdef _MAP_NEW |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 126 | XLAT(_MAP_NEW), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 127 | #endif |
| 128 | #ifdef MAP_GROWSDOWN |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 129 | XLAT(MAP_GROWSDOWN), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 130 | #endif |
| 131 | #ifdef MAP_DENYWRITE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 132 | XLAT(MAP_DENYWRITE), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 133 | #endif |
| 134 | #ifdef MAP_EXECUTABLE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 135 | XLAT(MAP_EXECUTABLE), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 136 | #endif |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 137 | #ifdef MAP_INHERIT |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 138 | XLAT(MAP_INHERIT), |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 139 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 140 | #ifdef MAP_FILE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 141 | XLAT(MAP_FILE), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 142 | #endif |
| 143 | #ifdef MAP_LOCKED |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 144 | XLAT(MAP_LOCKED), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 145 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 146 | /* FreeBSD ones */ |
Denys Vlasenko | 2897fb3 | 2012-03-17 01:29:40 +0100 | [diff] [blame] | 147 | #if defined(MAP_ANON) && (!defined(MAP_ANONYMOUS) || MAP_ANON != MAP_ANONYMOUS) |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 148 | XLAT(MAP_ANON), |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 149 | #endif |
| 150 | #ifdef MAP_HASSEMAPHORE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 151 | XLAT(MAP_HASSEMAPHORE), |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 152 | #endif |
| 153 | #ifdef MAP_STACK |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 154 | XLAT(MAP_STACK), |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 155 | #endif |
Kirill A. Shutemov | b5530a1 | 2014-01-02 13:15:32 +0200 | [diff] [blame] | 156 | #ifdef MAP_HUGETLB |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 157 | XLAT(MAP_HUGETLB), |
Kirill A. Shutemov | b5530a1 | 2014-01-02 13:15:32 +0200 | [diff] [blame] | 158 | #endif |
Bernhard Reutner-Fischer | 21ceeb4 | 2013-02-05 19:31:55 +0100 | [diff] [blame] | 159 | #if defined MAP_UNINITIALIZED && MAP_UNINITIALIZED > 0 |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 160 | XLAT(MAP_UNINITIALIZED), |
Bernhard Reutner-Fischer | 21ceeb4 | 2013-02-05 19:31:55 +0100 | [diff] [blame] | 161 | #endif |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 162 | #ifdef MAP_NOSYNC |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 163 | XLAT(MAP_NOSYNC), |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 164 | #endif |
| 165 | #ifdef MAP_NOCORE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 166 | XLAT(MAP_NOCORE), |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 167 | #endif |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 168 | XLAT_END |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 169 | }; |
| 170 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 171 | static int |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 172 | print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 173 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 174 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 175 | /* addr */ |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 176 | if (!u_arg[0]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 177 | tprints("NULL, "); |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 178 | else |
| 179 | tprintf("%#lx, ", u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 180 | /* len */ |
| 181 | tprintf("%lu, ", u_arg[1]); |
| 182 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 183 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 184 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 185 | /* flags */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 186 | #ifdef MAP_TYPE |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 187 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
| 188 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 189 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 190 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 191 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 192 | tprints(", "); |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 193 | /* fd */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 194 | printfd(tcp, u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 195 | /* offset */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 196 | tprintf(", %#llx", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | } |
| 198 | return RVAL_HEX; |
| 199 | } |
| 200 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 201 | /* Syscall name<->function correspondence is messed up on many arches. |
| 202 | * For example: |
| 203 | * i386 has __NR_mmap == 90, and it is "old mmap", and |
| 204 | * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets". |
| 205 | * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets". |
| 206 | * Confused? Me too! |
| 207 | */ |
| 208 | |
| 209 | /* Params are pointed to by u_arg[0], offset is in bytes */ |
| 210 | int |
| 211 | sys_old_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 212 | { |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 213 | long u_arg[6]; |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 214 | #if defined(IA64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 215 | /* |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 216 | * IA64 processes never call this routine, they only use the |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 217 | * new 'sys_mmap' interface. Only IA32 processes come here. |
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 | int i; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 220 | unsigned narrow_arg[6]; |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 221 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 222 | return 0; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 223 | for (i = 0; i < 6; i++) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 224 | u_arg[i] = (unsigned long) narrow_arg[i]; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 225 | #elif defined(X86_64) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 226 | /* We are here only in personality 1 (i386) */ |
| 227 | int i; |
| 228 | unsigned narrow_arg[6]; |
| 229 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 230 | return 0; |
| 231 | for (i = 0; i < 6; ++i) |
| 232 | u_arg[i] = (unsigned long) narrow_arg[i]; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 233 | #else |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 234 | 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] | 235 | return 0; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 236 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 237 | return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 238 | } |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 239 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 240 | #if defined(S390) |
| 241 | /* Params are pointed to by u_arg[0], offset is in pages */ |
| 242 | int |
| 243 | sys_old_mmap_pgoff(struct tcb *tcp) |
| 244 | { |
| 245 | long u_arg[5]; |
| 246 | int i; |
| 247 | unsigned narrow_arg[6]; |
| 248 | unsigned long long offset; |
| 249 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 250 | return 0; |
| 251 | for (i = 0; i < 5; i++) |
| 252 | u_arg[i] = (unsigned long) narrow_arg[i]; |
| 253 | offset = narrow_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 254 | offset *= get_pagesize(); |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 255 | return print_mmap(tcp, u_arg, offset); |
| 256 | } |
| 257 | #endif |
| 258 | |
| 259 | /* Params are passed directly, offset is in bytes */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 260 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 261 | sys_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 262 | { |
Denys Vlasenko | 8dedb0d | 2013-02-18 03:13:07 +0100 | [diff] [blame] | 263 | unsigned long long offset = (unsigned long) tcp->u_arg[5]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 264 | #if defined(LINUX_MIPSN32) || defined(X32) |
Denys Vlasenko | 8dedb0d | 2013-02-18 03:13:07 +0100 | [diff] [blame] | 265 | /* Try test/x32_mmap.c */ |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 266 | offset = tcp->ext_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 267 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 268 | /* Example of kernel-side handling of this variety of mmap: |
| 269 | * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls |
| 270 | * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes, |
| 271 | * since the above code converts off to pages. |
| 272 | */ |
| 273 | return print_mmap(tcp, tcp->u_arg, offset); |
| 274 | } |
| 275 | |
| 276 | /* Params are passed directly, offset is in pages */ |
| 277 | int |
| 278 | sys_mmap_pgoff(struct tcb *tcp) |
| 279 | { |
| 280 | /* Try test/mmap_offset_decode.c */ |
| 281 | unsigned long long offset; |
| 282 | offset = (unsigned long) tcp->u_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 283 | offset *= get_pagesize(); |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 284 | return print_mmap(tcp, tcp->u_arg, offset); |
| 285 | } |
| 286 | |
| 287 | /* Params are passed directly, offset is in 4k units */ |
| 288 | int |
| 289 | sys_mmap_4koff(struct tcb *tcp) |
| 290 | { |
| 291 | unsigned long long offset; |
| 292 | offset = (unsigned long) tcp->u_arg[5]; |
| 293 | offset <<= 12; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 294 | return print_mmap(tcp, tcp->u_arg, offset); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 295 | } |
| 296 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 297 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 298 | sys_munmap(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 299 | { |
| 300 | if (entering(tcp)) { |
| 301 | tprintf("%#lx, %lu", |
| 302 | tcp->u_arg[0], tcp->u_arg[1]); |
| 303 | } |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 308 | sys_mprotect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 309 | { |
| 310 | if (entering(tcp)) { |
| 311 | tprintf("%#lx, %lu, ", |
| 312 | tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 313 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 314 | } |
| 315 | return 0; |
| 316 | } |
| 317 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 318 | static const struct xlat mremap_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 319 | XLAT(MREMAP_MAYMOVE), |
Chris Metcalf | ff3474a | 2009-12-24 23:19:19 +0000 | [diff] [blame] | 320 | #ifdef MREMAP_FIXED |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 321 | XLAT(MREMAP_FIXED), |
Chris Metcalf | ff3474a | 2009-12-24 23:19:19 +0000 | [diff] [blame] | 322 | #endif |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 323 | XLAT_END |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 324 | }; |
| 325 | |
| 326 | int |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 327 | sys_mremap(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 328 | { |
| 329 | if (entering(tcp)) { |
| 330 | tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1], |
| 331 | tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 332 | printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 333 | #ifdef MREMAP_FIXED |
| 334 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 335 | (MREMAP_MAYMOVE | MREMAP_FIXED)) |
| 336 | tprintf(", %#lx", tcp->u_arg[4]); |
| 337 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 338 | } |
| 339 | return RVAL_HEX; |
| 340 | } |
| 341 | |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 342 | static const struct xlat madvise_cmds[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 343 | #ifdef MADV_NORMAL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 344 | XLAT(MADV_NORMAL), |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 345 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 346 | #ifdef MADV_RANDOM |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 347 | XLAT(MADV_RANDOM), |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 348 | #endif |
| 349 | #ifdef MADV_SEQUENTIAL |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 350 | XLAT(MADV_SEQUENTIAL), |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 351 | #endif |
| 352 | #ifdef MADV_WILLNEED |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 353 | XLAT(MADV_WILLNEED), |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 354 | #endif |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 355 | #ifdef MADV_DONTNEED |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 356 | XLAT(MADV_DONTNEED), |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 357 | #endif |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 358 | #ifdef MADV_REMOVE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 359 | XLAT(MADV_REMOVE), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 360 | #endif |
| 361 | #ifdef MADV_DONTFORK |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 362 | XLAT(MADV_DONTFORK), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 363 | #endif |
| 364 | #ifdef MADV_DOFORK |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 365 | XLAT(MADV_DOFORK), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 366 | #endif |
| 367 | #ifdef MADV_HWPOISON |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 368 | XLAT(MADV_HWPOISON), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 369 | #endif |
| 370 | #ifdef MADV_SOFT_OFFLINE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 371 | XLAT(MADV_SOFT_OFFLINE), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 372 | #endif |
| 373 | #ifdef MADV_MERGEABLE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 374 | XLAT(MADV_MERGEABLE), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 375 | #endif |
| 376 | #ifdef MADV_UNMERGEABLE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 377 | XLAT(MADV_UNMERGEABLE), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 378 | #endif |
| 379 | #ifdef MADV_HUGEPAGE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 380 | XLAT(MADV_HUGEPAGE), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 381 | #endif |
| 382 | #ifdef MADV_NOHUGEPAGE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 383 | XLAT(MADV_NOHUGEPAGE), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 384 | #endif |
| 385 | #ifdef MADV_DONTDUMP |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 386 | XLAT(MADV_DONTDUMP), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 387 | #endif |
| 388 | #ifdef MADV_DODUMP |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 389 | XLAT(MADV_DODUMP), |
Dmitry V. Levin | 3ec134b | 2013-03-14 18:55:26 +0000 | [diff] [blame] | 390 | #endif |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 391 | XLAT_END |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 392 | }; |
| 393 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 394 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 395 | sys_madvise(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 396 | { |
| 397 | if (entering(tcp)) { |
| 398 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 399 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 400 | } |
| 401 | return 0; |
| 402 | } |
| 403 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 404 | static const struct xlat mlockall_flags[] = { |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 405 | #ifdef MCL_CURRENT |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 406 | XLAT(MCL_CURRENT), |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 407 | #endif |
| 408 | #ifdef MCL_FUTURE |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 409 | XLAT(MCL_FUTURE), |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 410 | #endif |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 411 | XLAT_END |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 412 | }; |
| 413 | |
| 414 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 415 | sys_mlockall(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 416 | { |
| 417 | if (entering(tcp)) { |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 418 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 419 | } |
| 420 | return 0; |
| 421 | } |
| 422 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 423 | #ifdef MS_ASYNC |
| 424 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 425 | static const struct xlat mctl_sync[] = { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 426 | #ifdef MS_SYNC |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 427 | XLAT(MS_SYNC), |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 428 | #endif |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 429 | XLAT(MS_ASYNC), |
| 430 | XLAT(MS_INVALIDATE), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 431 | XLAT_END |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 432 | }; |
| 433 | |
| 434 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 435 | sys_msync(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 436 | { |
| 437 | if (entering(tcp)) { |
| 438 | /* addr */ |
| 439 | tprintf("%#lx", tcp->u_arg[0]); |
| 440 | /* len */ |
| 441 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 442 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 443 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 444 | } |
| 445 | return 0; |
| 446 | } |
| 447 | |
| 448 | #endif /* MS_ASYNC */ |
| 449 | |
| 450 | #ifdef MC_SYNC |
| 451 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 452 | static const struct xlat mctl_funcs[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 453 | XLAT(MC_LOCK), |
| 454 | XLAT(MC_LOCKAS), |
| 455 | XLAT(MC_SYNC), |
| 456 | XLAT(MC_UNLOCK), |
| 457 | XLAT(MC_UNLOCKAS), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 458 | XLAT_END |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 459 | }; |
| 460 | |
Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 461 | static const struct xlat mctl_lockas[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 462 | XLAT(MCL_CURRENT), |
| 463 | XLAT(MCL_FUTURE), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 464 | XLAT_END |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 465 | }; |
| 466 | |
| 467 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 468 | sys_mctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 469 | { |
| 470 | int arg, function; |
| 471 | |
| 472 | if (entering(tcp)) { |
| 473 | /* addr */ |
| 474 | tprintf("%#lx", tcp->u_arg[0]); |
| 475 | /* len */ |
| 476 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 477 | /* function */ |
| 478 | function = tcp->u_arg[2]; |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 479 | printflags(mctl_funcs, function, "MC_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 480 | /* arg */ |
| 481 | arg = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 482 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 483 | switch (function) { |
| 484 | case MC_SYNC: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 485 | printflags(mctl_sync, arg, "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 486 | break; |
| 487 | case MC_LOCKAS: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 488 | printflags(mctl_lockas, arg, "MCL_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 489 | break; |
| 490 | default: |
| 491 | tprintf("%#x", arg); |
| 492 | break; |
| 493 | } |
| 494 | } |
| 495 | return 0; |
| 496 | } |
| 497 | |
| 498 | #endif /* MC_SYNC */ |
| 499 | |
| 500 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 501 | sys_mincore(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 502 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 503 | if (entering(tcp)) { |
| 504 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 505 | } else { |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 506 | unsigned long i, len; |
| 507 | char *vec = NULL; |
| 508 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 509 | len = tcp->u_arg[1]; |
| 510 | if (syserror(tcp) || tcp->u_arg[2] == 0 || |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 511 | (vec = malloc(len)) == NULL || |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 512 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 513 | tprintf("%#lx", tcp->u_arg[2]); |
| 514 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 515 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 516 | for (i = 0; i < len; i++) { |
| 517 | if (abbrev(tcp) && i >= max_strlen) { |
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 | break; |
| 520 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 521 | tprints((vec[i] & 1) ? "1" : "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 522 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 523 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 524 | } |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 525 | free(vec); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 526 | } |
| 527 | return 0; |
| 528 | } |
| 529 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 530 | #if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 531 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 532 | sys_getpagesize(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 533 | { |
| 534 | if (exiting(tcp)) |
| 535 | return RVAL_HEX; |
| 536 | return 0; |
| 537 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 538 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 539 | |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 540 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 541 | sys_remap_file_pages(struct tcb *tcp) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 542 | { |
| 543 | if (entering(tcp)) { |
| 544 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 545 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 546 | tprintf(", %lu, ", tcp->u_arg[3]); |
| 547 | #ifdef MAP_TYPE |
| 548 | printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???"); |
| 549 | addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE); |
| 550 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 551 | printflags(mmap_flags, tcp->u_arg[4], "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 552 | #endif |
| 553 | } |
| 554 | return 0; |
| 555 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 556 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 557 | #define MPOL_DEFAULT 0 |
| 558 | #define MPOL_PREFERRED 1 |
| 559 | #define MPOL_BIND 2 |
| 560 | #define MPOL_INTERLEAVE 3 |
| 561 | |
| 562 | #define MPOL_F_NODE (1<<0) |
| 563 | #define MPOL_F_ADDR (1<<1) |
| 564 | |
| 565 | #define MPOL_MF_STRICT (1<<0) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 566 | #define MPOL_MF_MOVE (1<<1) |
| 567 | #define MPOL_MF_MOVE_ALL (1<<2) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 568 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 569 | static const struct xlat policies[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 570 | XLAT(MPOL_DEFAULT), |
| 571 | XLAT(MPOL_PREFERRED), |
| 572 | XLAT(MPOL_BIND), |
| 573 | XLAT(MPOL_INTERLEAVE), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 574 | XLAT_END |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 575 | }; |
| 576 | |
| 577 | static const struct xlat mbindflags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 578 | XLAT(MPOL_MF_STRICT), |
| 579 | XLAT(MPOL_MF_MOVE), |
| 580 | XLAT(MPOL_MF_MOVE_ALL), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 581 | XLAT_END |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 582 | }; |
| 583 | |
| 584 | static const struct xlat mempolicyflags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 585 | XLAT(MPOL_F_NODE), |
| 586 | XLAT(MPOL_F_ADDR), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 587 | XLAT_END |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 588 | }; |
| 589 | |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 590 | static const struct xlat move_pages_flags[] = { |
Dmitry V. Levin | bce0cc6 | 2014-02-05 01:33:50 +0000 | [diff] [blame] | 591 | XLAT(MPOL_MF_MOVE), |
| 592 | XLAT(MPOL_MF_MOVE_ALL), |
Dmitry V. Levin | 5945273 | 2014-02-05 02:20:51 +0000 | [diff] [blame] | 593 | XLAT_END |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 594 | }; |
| 595 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 596 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 597 | 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] | 598 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 599 | unsigned long nlongs, size, end; |
| 600 | |
| 601 | nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long)); |
| 602 | size = nlongs * sizeof(long); |
| 603 | end = ptr + size; |
| 604 | if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes) |
| 605 | && (end > ptr))) { |
| 606 | unsigned long n, cur, abbrev_end; |
| 607 | int failed = 0; |
| 608 | |
| 609 | if (abbrev(tcp)) { |
| 610 | abbrev_end = ptr + max_strlen * sizeof(long); |
| 611 | if (abbrev_end < ptr) |
| 612 | abbrev_end = end; |
| 613 | } else { |
| 614 | abbrev_end = end; |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 615 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 616 | tprints(", {"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 617 | for (cur = ptr; cur < end; cur += sizeof(long)) { |
| 618 | if (cur > ptr) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 619 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 620 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 621 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 622 | break; |
| 623 | } |
| 624 | if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 625 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 626 | failed = 1; |
| 627 | break; |
| 628 | } |
| 629 | tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n); |
| 630 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 631 | tprints("}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 632 | if (failed) |
| 633 | tprintf(" %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 634 | } else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 635 | tprintf(", %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 636 | tprintf(", %lu", maxnodes); |
| 637 | } |
| 638 | |
| 639 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 640 | sys_mbind(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 641 | { |
| 642 | if (entering(tcp)) { |
Chris Metcalf | c5fd1d9 | 2009-12-24 23:19:35 +0000 | [diff] [blame] | 643 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 644 | printxval(policies, tcp->u_arg[2], "MPOL_???"); |
| 645 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 646 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 647 | printflags(mbindflags, tcp->u_arg[5], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 648 | } |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 653 | sys_set_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 654 | { |
| 655 | if (entering(tcp)) { |
| 656 | printxval(policies, tcp->u_arg[0], "MPOL_???"); |
| 657 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0); |
| 658 | } |
| 659 | return 0; |
| 660 | } |
| 661 | |
| 662 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 663 | sys_get_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 664 | { |
| 665 | if (exiting(tcp)) { |
| 666 | int pol; |
| 667 | if (tcp->u_arg[0] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 668 | tprints("NULL"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 669 | else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0) |
| 670 | tprintf("%#lx", tcp->u_arg[0]); |
| 671 | else |
| 672 | printxval(policies, pol, "MPOL_???"); |
| 673 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp)); |
| 674 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 675 | printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 676 | } |
| 677 | return 0; |
| 678 | } |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 679 | |
| 680 | int |
Dmitry V. Levin | 64d0e71 | 2012-03-11 22:44:14 +0000 | [diff] [blame] | 681 | sys_migrate_pages(struct tcb *tcp) |
| 682 | { |
| 683 | if (entering(tcp)) { |
| 684 | tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]); |
| 685 | get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0); |
| 686 | tprints(", "); |
| 687 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0); |
| 688 | } |
| 689 | return 0; |
| 690 | } |
| 691 | |
| 692 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 693 | sys_move_pages(struct tcb *tcp) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 694 | { |
| 695 | if (entering(tcp)) { |
| 696 | unsigned long npages = tcp->u_arg[1]; |
| 697 | tprintf("%ld, %lu, ", tcp->u_arg[0], npages); |
| 698 | if (tcp->u_arg[2] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 699 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 700 | else { |
| 701 | int i; |
| 702 | long puser = tcp->u_arg[2]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 703 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 704 | for (i = 0; i < npages; ++i) { |
| 705 | void *p; |
| 706 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 707 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 708 | if (umove(tcp, puser, &p) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 709 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 710 | break; |
| 711 | } |
| 712 | tprintf("%p", p); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 713 | puser += sizeof(void *); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 714 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 715 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 716 | } |
| 717 | if (tcp->u_arg[3] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 718 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 719 | else { |
| 720 | int i; |
| 721 | long nodeuser = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 722 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 723 | for (i = 0; i < npages; ++i) { |
| 724 | int node; |
| 725 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 726 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 727 | if (umove(tcp, nodeuser, &node) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 728 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 729 | break; |
| 730 | } |
| 731 | tprintf("%#x", node); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 732 | nodeuser += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 733 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 734 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 735 | } |
| 736 | } |
| 737 | if (exiting(tcp)) { |
| 738 | unsigned long npages = tcp->u_arg[1]; |
| 739 | if (tcp->u_arg[4] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 740 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 741 | else { |
| 742 | int i; |
| 743 | long statususer = tcp->u_arg[4]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 744 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 745 | for (i = 0; i < npages; ++i) { |
| 746 | int status; |
| 747 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 748 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 749 | if (umove(tcp, statususer, &status) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 750 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 751 | break; |
| 752 | } |
| 753 | tprintf("%#x", status); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 754 | statususer += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 755 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 756 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 757 | } |
| 758 | printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); |
| 759 | } |
| 760 | return 0; |
| 761 | } |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 762 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 763 | #if defined(POWERPC) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 764 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 765 | sys_subpage_prot(struct tcb *tcp) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 766 | { |
| 767 | if (entering(tcp)) { |
| 768 | unsigned long cur, end, abbrev_end, entries; |
| 769 | unsigned int entry; |
| 770 | |
| 771 | tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 772 | entries = tcp->u_arg[1] >> 16; |
| 773 | if (!entries || !tcp->u_arg[2]) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 774 | tprints("{}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 775 | return 0; |
| 776 | } |
| 777 | cur = tcp->u_arg[2]; |
| 778 | end = cur + (sizeof(int) * entries); |
| 779 | if (!verbose(tcp) || end < tcp->u_arg[2]) { |
| 780 | tprintf("%#lx", tcp->u_arg[2]); |
| 781 | return 0; |
| 782 | } |
| 783 | if (abbrev(tcp)) { |
| 784 | abbrev_end = cur + (sizeof(int) * max_strlen); |
| 785 | if (abbrev_end > end) |
| 786 | abbrev_end = end; |
| 787 | } |
| 788 | else |
| 789 | abbrev_end = end; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 790 | tprints("{"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 791 | for (; cur < end; cur += sizeof(int)) { |
| 792 | if (cur > tcp->u_arg[2]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 793 | tprints(", "); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 794 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 795 | tprints("..."); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 796 | break; |
| 797 | } |
| 798 | if (umove(tcp, cur, &entry) < 0) { |
| 799 | tprintf("??? [%#lx]", cur); |
| 800 | break; |
| 801 | } |
| 802 | else |
| 803 | tprintf("%#08x", entry); |
| 804 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 805 | tprints("}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 806 | } |
| 807 | |
| 808 | return 0; |
| 809 | } |
| 810 | #endif |