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 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 56 | #include "xlat/mmap_prot.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 57 | #include "xlat/mmap_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 58 | |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 59 | static int |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 60 | print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 61 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 62 | if (entering(tcp)) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 63 | /* addr */ |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 64 | if (!u_arg[0]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 65 | tprints("NULL, "); |
Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 66 | else |
| 67 | tprintf("%#lx, ", u_arg[0]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 68 | /* len */ |
| 69 | tprintf("%lu, ", u_arg[1]); |
| 70 | /* prot */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 71 | printflags(mmap_prot, u_arg[2], "PROT_???"); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 72 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 73 | /* flags */ |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 74 | #ifdef MAP_TYPE |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 75 | printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); |
| 76 | addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 77 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 78 | printflags(mmap_flags, u_arg[3], "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 79 | #endif |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 80 | tprints(", "); |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 81 | /* fd */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 82 | printfd(tcp, u_arg[4]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 83 | /* offset */ |
Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 84 | tprintf(", %#llx", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 85 | } |
| 86 | return RVAL_HEX; |
| 87 | } |
| 88 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 89 | /* Syscall name<->function correspondence is messed up on many arches. |
| 90 | * For example: |
| 91 | * i386 has __NR_mmap == 90, and it is "old mmap", and |
| 92 | * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets". |
| 93 | * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets". |
| 94 | * Confused? Me too! |
| 95 | */ |
| 96 | |
| 97 | /* Params are pointed to by u_arg[0], offset is in bytes */ |
| 98 | int |
| 99 | sys_old_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 100 | { |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 101 | long u_arg[6]; |
Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 102 | #if defined(IA64) |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 103 | /* |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 104 | * IA64 processes never call this routine, they only use the |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 105 | * new 'sys_mmap' interface. Only IA32 processes come here. |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 106 | */ |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 107 | int i; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 108 | unsigned narrow_arg[6]; |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 109 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 110 | return 0; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 111 | for (i = 0; i < 6; i++) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 112 | u_arg[i] = (unsigned long) narrow_arg[i]; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 113 | #elif defined(X86_64) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 114 | /* We are here only in personality 1 (i386) */ |
| 115 | int i; |
| 116 | unsigned narrow_arg[6]; |
| 117 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 118 | return 0; |
| 119 | for (i = 0; i < 6; ++i) |
| 120 | u_arg[i] = (unsigned long) narrow_arg[i]; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 121 | #else |
Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 122 | 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] | 123 | return 0; |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 124 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 125 | return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 126 | } |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 127 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 128 | #if defined(S390) |
| 129 | /* Params are pointed to by u_arg[0], offset is in pages */ |
| 130 | int |
| 131 | sys_old_mmap_pgoff(struct tcb *tcp) |
| 132 | { |
| 133 | long u_arg[5]; |
| 134 | int i; |
| 135 | unsigned narrow_arg[6]; |
| 136 | unsigned long long offset; |
| 137 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1) |
| 138 | return 0; |
| 139 | for (i = 0; i < 5; i++) |
| 140 | u_arg[i] = (unsigned long) narrow_arg[i]; |
| 141 | offset = narrow_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 142 | offset *= get_pagesize(); |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 143 | return print_mmap(tcp, u_arg, offset); |
| 144 | } |
| 145 | #endif |
| 146 | |
| 147 | /* Params are passed directly, offset is in bytes */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 148 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 149 | sys_mmap(struct tcb *tcp) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 150 | { |
Denys Vlasenko | 8dedb0d | 2013-02-18 03:13:07 +0100 | [diff] [blame] | 151 | unsigned long long offset = (unsigned long) tcp->u_arg[5]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 152 | #if defined(LINUX_MIPSN32) || defined(X32) |
Denys Vlasenko | 8dedb0d | 2013-02-18 03:13:07 +0100 | [diff] [blame] | 153 | /* Try test/x32_mmap.c */ |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 154 | offset = tcp->ext_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 155 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 156 | /* Example of kernel-side handling of this variety of mmap: |
| 157 | * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls |
| 158 | * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes, |
| 159 | * since the above code converts off to pages. |
| 160 | */ |
| 161 | return print_mmap(tcp, tcp->u_arg, offset); |
| 162 | } |
| 163 | |
| 164 | /* Params are passed directly, offset is in pages */ |
| 165 | int |
| 166 | sys_mmap_pgoff(struct tcb *tcp) |
| 167 | { |
| 168 | /* Try test/mmap_offset_decode.c */ |
| 169 | unsigned long long offset; |
| 170 | offset = (unsigned long) tcp->u_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 171 | offset *= get_pagesize(); |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 172 | return print_mmap(tcp, tcp->u_arg, offset); |
| 173 | } |
| 174 | |
| 175 | /* Params are passed directly, offset is in 4k units */ |
| 176 | int |
| 177 | sys_mmap_4koff(struct tcb *tcp) |
| 178 | { |
| 179 | unsigned long long offset; |
| 180 | offset = (unsigned long) tcp->u_arg[5]; |
| 181 | offset <<= 12; |
Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 182 | return print_mmap(tcp, tcp->u_arg, offset); |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 185 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 186 | sys_munmap(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 187 | { |
| 188 | if (entering(tcp)) { |
| 189 | tprintf("%#lx, %lu", |
| 190 | tcp->u_arg[0], tcp->u_arg[1]); |
| 191 | } |
| 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 196 | sys_mprotect(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 197 | { |
| 198 | if (entering(tcp)) { |
| 199 | tprintf("%#lx, %lu, ", |
| 200 | tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 201 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 202 | } |
| 203 | return 0; |
| 204 | } |
| 205 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 206 | #include "xlat/mremap_flags.h" |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 207 | |
| 208 | int |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 209 | sys_mremap(struct tcb *tcp) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 210 | { |
| 211 | if (entering(tcp)) { |
| 212 | tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1], |
| 213 | tcp->u_arg[2]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 214 | printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 215 | #ifdef MREMAP_FIXED |
| 216 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 217 | (MREMAP_MAYMOVE | MREMAP_FIXED)) |
| 218 | tprintf(", %#lx", tcp->u_arg[4]); |
| 219 | #endif |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 220 | } |
| 221 | return RVAL_HEX; |
| 222 | } |
| 223 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 224 | #include "xlat/madvise_cmds.h" |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 225 | |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 226 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 227 | sys_madvise(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 228 | { |
| 229 | if (entering(tcp)) { |
| 230 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 231 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 232 | } |
| 233 | return 0; |
| 234 | } |
| 235 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 236 | #include "xlat/mlockall_flags.h" |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 237 | |
| 238 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 239 | sys_mlockall(struct tcb *tcp) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 240 | { |
| 241 | if (entering(tcp)) { |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 242 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 243 | } |
| 244 | return 0; |
| 245 | } |
| 246 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | #ifdef MS_ASYNC |
| 248 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 249 | #include "xlat/mctl_sync.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 250 | |
| 251 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 252 | sys_msync(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 253 | { |
| 254 | if (entering(tcp)) { |
| 255 | /* addr */ |
| 256 | tprintf("%#lx", tcp->u_arg[0]); |
| 257 | /* len */ |
| 258 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 259 | /* flags */ |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 260 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 261 | } |
| 262 | return 0; |
| 263 | } |
| 264 | |
| 265 | #endif /* MS_ASYNC */ |
| 266 | |
| 267 | #ifdef MC_SYNC |
| 268 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 269 | #include "xlat/mctl_funcs.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 270 | #include "xlat/mctl_lockas.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 271 | |
| 272 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 273 | sys_mctl(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 274 | { |
| 275 | int arg, function; |
| 276 | |
| 277 | if (entering(tcp)) { |
| 278 | /* addr */ |
| 279 | tprintf("%#lx", tcp->u_arg[0]); |
| 280 | /* len */ |
| 281 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 282 | /* function */ |
| 283 | function = tcp->u_arg[2]; |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 284 | printflags(mctl_funcs, function, "MC_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 285 | /* arg */ |
| 286 | arg = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 287 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 288 | switch (function) { |
| 289 | case MC_SYNC: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 290 | printflags(mctl_sync, arg, "MS_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 291 | break; |
| 292 | case MC_LOCKAS: |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 293 | printflags(mctl_lockas, arg, "MCL_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 294 | break; |
| 295 | default: |
| 296 | tprintf("%#x", arg); |
| 297 | break; |
| 298 | } |
| 299 | } |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | #endif /* MC_SYNC */ |
| 304 | |
| 305 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 306 | sys_mincore(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 307 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 308 | if (entering(tcp)) { |
| 309 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 310 | } else { |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 311 | unsigned long i, len; |
| 312 | char *vec = NULL; |
| 313 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 314 | len = tcp->u_arg[1]; |
| 315 | if (syserror(tcp) || tcp->u_arg[2] == 0 || |
Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 316 | (vec = malloc(len)) == NULL || |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 317 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 318 | tprintf("%#lx", tcp->u_arg[2]); |
| 319 | else { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 320 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 321 | for (i = 0; i < len; i++) { |
| 322 | if (abbrev(tcp) && i >= max_strlen) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 323 | tprints("..."); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 324 | break; |
| 325 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 326 | tprints((vec[i] & 1) ? "1" : "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 327 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 328 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 329 | } |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 330 | free(vec); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 331 | } |
| 332 | return 0; |
| 333 | } |
| 334 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 335 | #if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 336 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 337 | sys_getpagesize(struct tcb *tcp) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 338 | { |
| 339 | if (exiting(tcp)) |
| 340 | return RVAL_HEX; |
| 341 | return 0; |
| 342 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 343 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 344 | |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 345 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 346 | sys_remap_file_pages(struct tcb *tcp) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 347 | { |
| 348 | if (entering(tcp)) { |
| 349 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 350 | printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 351 | tprintf(", %lu, ", tcp->u_arg[3]); |
| 352 | #ifdef MAP_TYPE |
| 353 | printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???"); |
| 354 | addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE); |
| 355 | #else |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 356 | printflags(mmap_flags, tcp->u_arg[4], "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 357 | #endif |
| 358 | } |
| 359 | return 0; |
| 360 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 361 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 362 | #define MPOL_DEFAULT 0 |
| 363 | #define MPOL_PREFERRED 1 |
| 364 | #define MPOL_BIND 2 |
| 365 | #define MPOL_INTERLEAVE 3 |
| 366 | |
| 367 | #define MPOL_F_NODE (1<<0) |
| 368 | #define MPOL_F_ADDR (1<<1) |
| 369 | |
| 370 | #define MPOL_MF_STRICT (1<<0) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 371 | #define MPOL_MF_MOVE (1<<1) |
| 372 | #define MPOL_MF_MOVE_ALL (1<<2) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 373 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 374 | #include "xlat/policies.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 375 | #include "xlat/mbindflags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 376 | #include "xlat/mempolicyflags.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 377 | #include "xlat/move_pages_flags.h" |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 378 | |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 379 | static void |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 380 | 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] | 381 | { |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 382 | unsigned long nlongs, size, end; |
| 383 | |
| 384 | nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long)); |
| 385 | size = nlongs * sizeof(long); |
| 386 | end = ptr + size; |
| 387 | if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes) |
| 388 | && (end > ptr))) { |
| 389 | unsigned long n, cur, abbrev_end; |
| 390 | int failed = 0; |
| 391 | |
| 392 | if (abbrev(tcp)) { |
| 393 | abbrev_end = ptr + max_strlen * sizeof(long); |
| 394 | if (abbrev_end < ptr) |
| 395 | abbrev_end = end; |
| 396 | } else { |
| 397 | abbrev_end = end; |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 398 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 399 | tprints(", {"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 400 | for (cur = ptr; cur < end; cur += sizeof(long)) { |
| 401 | if (cur > ptr) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 402 | tprints(", "); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 403 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 404 | tprints("..."); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 405 | break; |
| 406 | } |
| 407 | if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 408 | tprints("?"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 409 | failed = 1; |
| 410 | break; |
| 411 | } |
| 412 | tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n); |
| 413 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 414 | tprints("}"); |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 415 | if (failed) |
| 416 | tprintf(" %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 417 | } else |
Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 418 | tprintf(", %#lx", ptr); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 419 | tprintf(", %lu", maxnodes); |
| 420 | } |
| 421 | |
| 422 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 423 | sys_mbind(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 424 | { |
| 425 | if (entering(tcp)) { |
Chris Metcalf | c5fd1d9 | 2009-12-24 23:19:35 +0000 | [diff] [blame] | 426 | tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 427 | printxval(policies, tcp->u_arg[2], "MPOL_???"); |
| 428 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 429 | tprints(", "); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 430 | printflags(mbindflags, tcp->u_arg[5], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 431 | } |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 436 | sys_set_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 437 | { |
| 438 | if (entering(tcp)) { |
| 439 | printxval(policies, tcp->u_arg[0], "MPOL_???"); |
| 440 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0); |
| 441 | } |
| 442 | return 0; |
| 443 | } |
| 444 | |
| 445 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 446 | sys_get_mempolicy(struct tcb *tcp) |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 447 | { |
| 448 | if (exiting(tcp)) { |
| 449 | int pol; |
| 450 | if (tcp->u_arg[0] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 451 | tprints("NULL"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 452 | else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0) |
| 453 | tprintf("%#lx", tcp->u_arg[0]); |
| 454 | else |
| 455 | printxval(policies, pol, "MPOL_???"); |
| 456 | get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp)); |
| 457 | tprintf(", %#lx, ", tcp->u_arg[3]); |
Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 458 | printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???"); |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 459 | } |
| 460 | return 0; |
| 461 | } |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 462 | |
| 463 | int |
Dmitry V. Levin | 64d0e71 | 2012-03-11 22:44:14 +0000 | [diff] [blame] | 464 | sys_migrate_pages(struct tcb *tcp) |
| 465 | { |
| 466 | if (entering(tcp)) { |
| 467 | tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]); |
| 468 | get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0); |
| 469 | tprints(", "); |
| 470 | get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0); |
| 471 | } |
| 472 | return 0; |
| 473 | } |
| 474 | |
| 475 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 476 | sys_move_pages(struct tcb *tcp) |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 477 | { |
| 478 | if (entering(tcp)) { |
| 479 | unsigned long npages = tcp->u_arg[1]; |
| 480 | tprintf("%ld, %lu, ", tcp->u_arg[0], npages); |
| 481 | if (tcp->u_arg[2] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 482 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 483 | else { |
| 484 | int i; |
| 485 | long puser = tcp->u_arg[2]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 486 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 487 | for (i = 0; i < npages; ++i) { |
| 488 | void *p; |
| 489 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 490 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 491 | if (umove(tcp, puser, &p) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 492 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 493 | break; |
| 494 | } |
| 495 | tprintf("%p", p); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 496 | puser += sizeof(void *); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 497 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 498 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 499 | } |
| 500 | if (tcp->u_arg[3] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 501 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 502 | else { |
| 503 | int i; |
| 504 | long nodeuser = tcp->u_arg[3]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 505 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 506 | for (i = 0; i < npages; ++i) { |
| 507 | int node; |
| 508 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 509 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 510 | if (umove(tcp, nodeuser, &node) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 511 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 512 | break; |
| 513 | } |
| 514 | tprintf("%#x", node); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 515 | nodeuser += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 516 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 517 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 518 | } |
| 519 | } |
| 520 | if (exiting(tcp)) { |
| 521 | unsigned long npages = tcp->u_arg[1]; |
| 522 | if (tcp->u_arg[4] == 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 523 | tprints("NULL, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 524 | else { |
| 525 | int i; |
| 526 | long statususer = tcp->u_arg[4]; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 527 | tprints("{"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 528 | for (i = 0; i < npages; ++i) { |
| 529 | int status; |
| 530 | if (i > 0) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 531 | tprints(", "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 532 | if (umove(tcp, statususer, &status) < 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 533 | tprints("???"); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 534 | break; |
| 535 | } |
| 536 | tprintf("%#x", status); |
Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 537 | statususer += sizeof(int); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 538 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 539 | tprints("}, "); |
Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 540 | } |
| 541 | printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); |
| 542 | } |
| 543 | return 0; |
| 544 | } |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 545 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 546 | #if defined(POWERPC) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 547 | int |
Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 548 | sys_subpage_prot(struct tcb *tcp) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 549 | { |
| 550 | if (entering(tcp)) { |
| 551 | unsigned long cur, end, abbrev_end, entries; |
| 552 | unsigned int entry; |
| 553 | |
| 554 | tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]); |
| 555 | entries = tcp->u_arg[1] >> 16; |
| 556 | if (!entries || !tcp->u_arg[2]) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 557 | tprints("{}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 558 | return 0; |
| 559 | } |
| 560 | cur = tcp->u_arg[2]; |
| 561 | end = cur + (sizeof(int) * entries); |
| 562 | if (!verbose(tcp) || end < tcp->u_arg[2]) { |
| 563 | tprintf("%#lx", tcp->u_arg[2]); |
| 564 | return 0; |
| 565 | } |
| 566 | if (abbrev(tcp)) { |
| 567 | abbrev_end = cur + (sizeof(int) * max_strlen); |
| 568 | if (abbrev_end > end) |
| 569 | abbrev_end = end; |
| 570 | } |
| 571 | else |
| 572 | abbrev_end = end; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 573 | tprints("{"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 574 | for (; cur < end; cur += sizeof(int)) { |
| 575 | if (cur > tcp->u_arg[2]) |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 576 | tprints(", "); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 577 | if (cur >= abbrev_end) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 578 | tprints("..."); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 579 | break; |
| 580 | } |
| 581 | if (umove(tcp, cur, &entry) < 0) { |
| 582 | tprintf("??? [%#lx]", cur); |
| 583 | break; |
| 584 | } |
| 585 | else |
| 586 | tprintf("%#08x", entry); |
| 587 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 588 | tprints("}"); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | return 0; |
| 592 | } |
| 593 | #endif |