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 | ea1fea6 | 2015-03-31 19:45:08 +0000 | [diff] [blame] | 37 | unsigned long |
| 38 | get_pagesize(void) |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 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 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 47 | SYS_FUNC(brk) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 48 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 49 | printaddr(tcp->u_arg[0]); |
| 50 | |
| 51 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 54 | #include "xlat/mmap_prot.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 55 | #include "xlat/mmap_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 56 | |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 57 | static void |
Denys Vlasenko | 923255c | 2013-02-18 02:36:36 +0100 | [diff] [blame] | 58 | print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 59 | { |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 60 | const unsigned long addr = u_arg[0]; |
| 61 | const unsigned long len = u_arg[1]; |
| 62 | const unsigned long prot = u_arg[2]; |
| 63 | const unsigned long flags = u_arg[3]; |
| 64 | const int fd = u_arg[4]; |
| 65 | |
| 66 | printaddr(addr); |
| 67 | tprintf(", %lu, ", len); |
Dmitry V. Levin | 1168114 | 2016-05-16 22:58:45 +0000 | [diff] [blame] | 68 | printflags_long(mmap_prot, prot, "PROT_???"); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 69 | tprints(", "); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 70 | #ifdef MAP_TYPE |
Dmitry V. Levin | 1168114 | 2016-05-16 22:58:45 +0000 | [diff] [blame] | 71 | printxval_long(mmap_flags, flags & MAP_TYPE, "MAP_???"); |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 72 | addflags(mmap_flags, flags & ~MAP_TYPE); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 73 | #else |
Dmitry V. Levin | 1168114 | 2016-05-16 22:58:45 +0000 | [diff] [blame] | 74 | printflags_long(mmap_flags, flags, "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 75 | #endif |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 76 | tprints(", "); |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 77 | printfd(tcp, fd); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 78 | tprintf(", %#llx", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 79 | } |
| 80 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 81 | /* Syscall name<->function correspondence is messed up on many arches. |
| 82 | * For example: |
| 83 | * i386 has __NR_mmap == 90, and it is "old mmap", and |
| 84 | * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets". |
| 85 | * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets". |
| 86 | * Confused? Me too! |
| 87 | */ |
| 88 | |
Dmitry V. Levin | bc724ce | 2016-04-22 23:36:26 +0000 | [diff] [blame] | 89 | #if defined AARCH64 || defined ARM \ |
| 90 | || defined I386 || defined X86_64 || defined X32 \ |
| 91 | || defined M68K \ |
| 92 | || defined S390 || defined S390X |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 93 | /* Params are pointed to by u_arg[0], offset is in bytes */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 94 | SYS_FUNC(old_mmap) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 95 | { |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 96 | long u_arg[6]; |
Dmitry V. Levin | cf52778 | 2016-04-22 23:47:46 +0000 | [diff] [blame] | 97 | # if defined AARCH64 || defined X86_64 |
| 98 | /* We are here only in a 32-bit personality. */ |
Dmitry V. Levin | 3db07f1 | 2016-04-22 23:41:36 +0000 | [diff] [blame] | 99 | unsigned int narrow_arg[6]; |
| 100 | if (umove_or_printaddr(tcp, tcp->u_arg[0], &narrow_arg)) |
| 101 | return RVAL_DECODED | RVAL_HEX; |
| 102 | unsigned int i; |
| 103 | for (i = 0; i < 6; i++) |
| 104 | u_arg[i] = narrow_arg[i]; |
Dmitry V. Levin | bc724ce | 2016-04-22 23:36:26 +0000 | [diff] [blame] | 105 | # else |
Dmitry V. Levin | 3db07f1 | 2016-04-22 23:41:36 +0000 | [diff] [blame] | 106 | if (umove_or_printaddr(tcp, tcp->u_arg[0], &u_arg)) |
| 107 | return RVAL_DECODED | RVAL_HEX; |
Dmitry V. Levin | bc724ce | 2016-04-22 23:36:26 +0000 | [diff] [blame] | 108 | # endif |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 109 | print_mmap(tcp, u_arg, (unsigned long) u_arg[5]); |
| 110 | |
| 111 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 112 | } |
Dmitry V. Levin | bc724ce | 2016-04-22 23:36:26 +0000 | [diff] [blame] | 113 | #endif /* old_mmap architectures */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 114 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 115 | #if defined(S390) |
| 116 | /* Params are pointed to by u_arg[0], offset is in pages */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 117 | SYS_FUNC(old_mmap_pgoff) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 118 | { |
| 119 | long u_arg[5]; |
| 120 | int i; |
| 121 | unsigned narrow_arg[6]; |
| 122 | unsigned long long offset; |
Denys Vlasenko | 7e69ed9 | 2015-03-21 19:50:53 +0100 | [diff] [blame] | 123 | if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), narrow_arg) == -1) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 124 | return 0; |
| 125 | for (i = 0; i < 5; i++) |
| 126 | u_arg[i] = (unsigned long) narrow_arg[i]; |
| 127 | offset = narrow_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 128 | offset *= get_pagesize(); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 129 | print_mmap(tcp, u_arg, offset); |
| 130 | |
| 131 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 132 | } |
| 133 | #endif |
| 134 | |
| 135 | /* Params are passed directly, offset is in bytes */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 136 | SYS_FUNC(mmap) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 137 | { |
Dmitry V. Levin | b0c5113 | 2016-06-17 16:12:13 +0000 | [diff] [blame] | 138 | unsigned long long offset = |
| 139 | #if HAVE_STRUCT_TCB_EXT_ARG |
| 140 | tcp->ext_arg[5]; /* try test/x32_mmap.c */ |
| 141 | #else |
| 142 | (unsigned long) tcp->u_arg[5]; |
Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 143 | #endif |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 144 | /* Example of kernel-side handling of this variety of mmap: |
| 145 | * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls |
| 146 | * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes, |
| 147 | * since the above code converts off to pages. |
| 148 | */ |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 149 | print_mmap(tcp, tcp->u_arg, offset); |
| 150 | |
| 151 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | /* Params are passed directly, offset is in pages */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 155 | SYS_FUNC(mmap_pgoff) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 156 | { |
| 157 | /* Try test/mmap_offset_decode.c */ |
| 158 | unsigned long long offset; |
| 159 | offset = (unsigned long) tcp->u_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 160 | offset *= get_pagesize(); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 161 | print_mmap(tcp, tcp->u_arg, offset); |
| 162 | |
| 163 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | /* Params are passed directly, offset is in 4k units */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 167 | SYS_FUNC(mmap_4koff) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 168 | { |
| 169 | unsigned long long offset; |
| 170 | offset = (unsigned long) tcp->u_arg[5]; |
| 171 | offset <<= 12; |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 172 | print_mmap(tcp, tcp->u_arg, offset); |
| 173 | |
| 174 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 177 | SYS_FUNC(munmap) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 178 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 179 | printaddr(tcp->u_arg[0]); |
| 180 | tprintf(", %lu", tcp->u_arg[1]); |
| 181 | |
| 182 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 183 | } |
| 184 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 185 | SYS_FUNC(mprotect) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 186 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 187 | printaddr(tcp->u_arg[0]); |
| 188 | tprintf(", %lu, ", tcp->u_arg[1]); |
Dmitry V. Levin | 1168114 | 2016-05-16 22:58:45 +0000 | [diff] [blame] | 189 | printflags_long(mmap_prot, tcp->u_arg[2], "PROT_???"); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 190 | |
| 191 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 192 | } |
| 193 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 194 | #include "xlat/mremap_flags.h" |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 195 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 196 | SYS_FUNC(mremap) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 197 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 198 | printaddr(tcp->u_arg[0]); |
| 199 | tprintf(", %lu, %lu, ", tcp->u_arg[1], tcp->u_arg[2]); |
Dmitry V. Levin | 1168114 | 2016-05-16 22:58:45 +0000 | [diff] [blame] | 200 | printflags_long(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 201 | #ifdef MREMAP_FIXED |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 202 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 203 | (MREMAP_MAYMOVE | MREMAP_FIXED)) { |
| 204 | tprints(", "); |
| 205 | printaddr(tcp->u_arg[4]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 206 | } |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 207 | #endif |
| 208 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 211 | #include "xlat/madvise_cmds.h" |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 212 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 213 | SYS_FUNC(madvise) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 214 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 215 | printaddr(tcp->u_arg[0]); |
| 216 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 217 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
| 218 | |
| 219 | return RVAL_DECODED; |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 220 | } |
| 221 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 222 | #include "xlat/mlockall_flags.h" |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 223 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 224 | SYS_FUNC(mlockall) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 225 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 226 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
| 227 | |
| 228 | return RVAL_DECODED; |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 229 | } |
| 230 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 231 | #include "xlat/mctl_sync.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 232 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 233 | SYS_FUNC(msync) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 235 | /* addr */ |
| 236 | printaddr(tcp->u_arg[0]); |
| 237 | /* len */ |
| 238 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 239 | /* flags */ |
| 240 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
| 241 | |
| 242 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 243 | } |
| 244 | |
Dmitry V. Levin | 0d0a50a | 2015-11-15 02:35:57 +0000 | [diff] [blame] | 245 | #include "xlat/mlock_flags.h" |
| 246 | |
| 247 | SYS_FUNC(mlock2) |
| 248 | { |
| 249 | printaddr(tcp->u_arg[0]); |
| 250 | tprintf(", %lu, ", tcp->u_arg[1]); |
| 251 | printflags(mlock_flags, tcp->u_arg[2], "MLOCK_???"); |
| 252 | |
| 253 | return RVAL_DECODED; |
| 254 | } |
| 255 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 256 | SYS_FUNC(mincore) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 257 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 258 | if (entering(tcp)) { |
Dmitry V. Levin | 2c389f6 | 2015-07-19 23:25:56 +0000 | [diff] [blame] | 259 | printaddr(tcp->u_arg[0]); |
| 260 | tprintf(", %lu, ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 261 | } else { |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 262 | const unsigned long page_size = get_pagesize(); |
| 263 | const unsigned long page_mask = page_size - 1; |
| 264 | unsigned long len = tcp->u_arg[1]; |
| 265 | unsigned char *vec = NULL; |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 266 | |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 267 | len = len / page_size + (len & page_mask ? 1 : 0); |
Dmitry V. Levin | 2c389f6 | 2015-07-19 23:25:56 +0000 | [diff] [blame] | 268 | if (syserror(tcp) || !verbose(tcp) || |
| 269 | !tcp->u_arg[2] || !(vec = malloc(len)) || |
| 270 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 271 | printaddr(tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 272 | else { |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 273 | unsigned long i; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 274 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 275 | for (i = 0; i < len; i++) { |
| 276 | if (abbrev(tcp) && i >= max_strlen) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 277 | tprints("..."); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 278 | break; |
| 279 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 280 | tprints((vec[i] & 1) ? "1" : "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 281 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 282 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 283 | } |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 284 | free(vec); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 285 | } |
| 286 | return 0; |
| 287 | } |
| 288 | |
Dmitry V. Levin | ece9ce6 | 2015-07-21 15:55:09 +0000 | [diff] [blame] | 289 | #if defined ALPHA || defined IA64 || defined M68K \ |
| 290 | || defined SPARC || defined SPARC64 |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 291 | SYS_FUNC(getpagesize) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 292 | { |
Dmitry V. Levin | b61b2d8 | 2016-01-08 19:20:05 +0000 | [diff] [blame] | 293 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 294 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 295 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 296 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 297 | SYS_FUNC(remap_file_pages) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 298 | { |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 299 | const unsigned long addr = tcp->u_arg[0]; |
| 300 | const unsigned long size = tcp->u_arg[1]; |
| 301 | const unsigned long prot = tcp->u_arg[2]; |
| 302 | const unsigned long pgoff = tcp->u_arg[3]; |
| 303 | const unsigned long flags = tcp->u_arg[4]; |
| 304 | |
| 305 | printaddr(addr); |
| 306 | tprintf(", %lu, ", size); |
Dmitry V. Levin | 1168114 | 2016-05-16 22:58:45 +0000 | [diff] [blame] | 307 | printflags_long(mmap_prot, prot, "PROT_???"); |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 308 | tprintf(", %lu, ", pgoff); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 309 | #ifdef MAP_TYPE |
Dmitry V. Levin | 1168114 | 2016-05-16 22:58:45 +0000 | [diff] [blame] | 310 | printxval_long(mmap_flags, flags & MAP_TYPE, "MAP_???"); |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 311 | addflags(mmap_flags, flags & ~MAP_TYPE); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 312 | #else |
Dmitry V. Levin | 1168114 | 2016-05-16 22:58:45 +0000 | [diff] [blame] | 313 | printflags_long(mmap_flags, flags, "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 314 | #endif |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 315 | |
| 316 | return RVAL_DECODED; |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 317 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 318 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 319 | #if defined(POWERPC) |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 320 | static bool |
| 321 | print_protmap_entry(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) |
| 322 | { |
| 323 | tprintf("%#08x", * (unsigned int *) elem_buf); |
| 324 | |
| 325 | return true; |
| 326 | } |
| 327 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 328 | SYS_FUNC(subpage_prot) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 329 | { |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 330 | unsigned long addr = tcp->u_arg[0]; |
| 331 | unsigned long len = tcp->u_arg[1]; |
| 332 | unsigned long nmemb = len >> 16; |
| 333 | unsigned long map = tcp->u_arg[2]; |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 334 | |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 335 | printaddr(addr); |
| 336 | tprintf(", %lu, ", len); |
| 337 | |
| 338 | unsigned int entry; |
| 339 | print_array(tcp, map, nmemb, &entry, sizeof(entry), |
| 340 | umoven_or_printaddr, print_protmap_entry, 0); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 341 | |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 342 | return RVAL_DECODED; |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 343 | } |
| 344 | #endif |