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> |
Elliott Hughes | 39bac05 | 2017-05-25 16:56:11 -0700 | [diff] [blame] | 8 | * Copyright (c) 1999-2017 The strace developers. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer. |
| 16 | * 2. Redistributions in binary form must reproduce the above copyright |
| 17 | * notice, this list of conditions and the following disclaimer in the |
| 18 | * documentation and/or other materials provided with the distribution. |
| 19 | * 3. The name of the author may not be used to endorse or promote products |
| 20 | * derived from this software without specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 32 | */ |
| 33 | |
| 34 | #include "defs.h" |
Roland McGrath | 05cdd3c | 2004-03-02 06:16:59 +0000 | [diff] [blame] | 35 | #include <asm/mman.h> |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 36 | #include <sys/mman.h> |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 37 | |
Dmitry V. Levin | ea1fea6 | 2015-03-31 19:45:08 +0000 | [diff] [blame] | 38 | unsigned long |
| 39 | get_pagesize(void) |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 40 | { |
| 41 | static unsigned long pagesize; |
| 42 | |
| 43 | if (!pagesize) |
| 44 | pagesize = sysconf(_SC_PAGESIZE); |
| 45 | return pagesize; |
| 46 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 48 | SYS_FUNC(brk) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 49 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 50 | printaddr(tcp->u_arg[0]); |
| 51 | |
| 52 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 55 | #include "xlat/mmap_prot.h" |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 56 | #include "xlat/mmap_flags.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 57 | |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 58 | static void |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 59 | print_mmap(struct tcb *tcp, kernel_ulong_t *u_arg, unsigned long long offset) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 60 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 61 | const kernel_ulong_t addr = u_arg[0]; |
| 62 | const kernel_ulong_t len = u_arg[1]; |
| 63 | const kernel_ulong_t prot = u_arg[2]; |
| 64 | const kernel_ulong_t flags = u_arg[3]; |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 65 | const int fd = u_arg[4]; |
| 66 | |
| 67 | printaddr(addr); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 68 | tprintf(", %" PRI_klu ", ", len); |
| 69 | printflags64(mmap_prot, prot, "PROT_???"); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 70 | tprints(", "); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 71 | #ifdef MAP_TYPE |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 72 | printxval64(mmap_flags, flags & MAP_TYPE, "MAP_???"); |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 73 | addflags(mmap_flags, flags & ~MAP_TYPE); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 74 | #else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 75 | printflags64(mmap_flags, flags, "MAP_???"); |
Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 76 | #endif |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 77 | tprints(", "); |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 78 | printfd(tcp, fd); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 79 | tprintf(", %#llx", offset); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 80 | } |
| 81 | |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 82 | /* Syscall name<->function correspondence is messed up on many arches. |
| 83 | * For example: |
| 84 | * i386 has __NR_mmap == 90, and it is "old mmap", and |
| 85 | * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets". |
| 86 | * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets". |
| 87 | * Confused? Me too! |
| 88 | */ |
| 89 | |
Dmitry V. Levin | bc724ce | 2016-04-22 23:36:26 +0000 | [diff] [blame] | 90 | #if defined AARCH64 || defined ARM \ |
| 91 | || defined I386 || defined X86_64 || defined X32 \ |
| 92 | || defined M68K \ |
| 93 | || defined S390 || defined S390X |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 94 | /* 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] | 95 | SYS_FUNC(old_mmap) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 96 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 97 | kernel_ulong_t u_arg[6]; |
| 98 | # if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG |
Dmitry V. Levin | cf52778 | 2016-04-22 23:47:46 +0000 | [diff] [blame] | 99 | /* We are here only in a 32-bit personality. */ |
Dmitry V. Levin | 3db07f1 | 2016-04-22 23:41:36 +0000 | [diff] [blame] | 100 | unsigned int narrow_arg[6]; |
| 101 | if (umove_or_printaddr(tcp, tcp->u_arg[0], &narrow_arg)) |
| 102 | return RVAL_DECODED | RVAL_HEX; |
| 103 | unsigned int i; |
| 104 | for (i = 0; i < 6; i++) |
| 105 | u_arg[i] = narrow_arg[i]; |
Dmitry V. Levin | bc724ce | 2016-04-22 23:36:26 +0000 | [diff] [blame] | 106 | # else |
Dmitry V. Levin | 3db07f1 | 2016-04-22 23:41:36 +0000 | [diff] [blame] | 107 | if (umove_or_printaddr(tcp, tcp->u_arg[0], &u_arg)) |
| 108 | return RVAL_DECODED | RVAL_HEX; |
Dmitry V. Levin | bc724ce | 2016-04-22 23:36:26 +0000 | [diff] [blame] | 109 | # endif |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 110 | print_mmap(tcp, u_arg, u_arg[5]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 111 | |
| 112 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 113 | } |
Dmitry V. Levin | bc724ce | 2016-04-22 23:36:26 +0000 | [diff] [blame] | 114 | #endif /* old_mmap architectures */ |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 115 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 116 | #ifdef S390 |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 117 | /* 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] | 118 | SYS_FUNC(old_mmap_pgoff) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 119 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 120 | kernel_ulong_t u_arg[5]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 121 | int i; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 122 | unsigned int narrow_arg[6]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 123 | unsigned long long offset; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 124 | if (umove_or_printaddr(tcp, tcp->u_arg[0], &narrow_arg)) |
| 125 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 126 | for (i = 0; i < 5; i++) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 127 | u_arg[i] = narrow_arg[i]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 128 | offset = narrow_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 129 | offset *= get_pagesize(); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 130 | print_mmap(tcp, u_arg, offset); |
| 131 | |
| 132 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 133 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 134 | #endif /* S390 */ |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 135 | |
| 136 | /* Params are passed directly, offset is in bytes */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 137 | SYS_FUNC(mmap) |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 138 | { |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 139 | /* Example of kernel-side handling of this variety of mmap: |
| 140 | * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls |
| 141 | * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes, |
| 142 | * since the above code converts off to pages. |
| 143 | */ |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 144 | print_mmap(tcp, tcp->u_arg, tcp->u_arg[5]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 145 | |
| 146 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /* Params are passed directly, offset is in pages */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 150 | SYS_FUNC(mmap_pgoff) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 151 | { |
| 152 | /* Try test/mmap_offset_decode.c */ |
| 153 | unsigned long long offset; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 154 | offset = tcp->u_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 155 | offset *= get_pagesize(); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 156 | print_mmap(tcp, tcp->u_arg, offset); |
| 157 | |
| 158 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | /* Params are passed directly, offset is in 4k units */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 162 | SYS_FUNC(mmap_4koff) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 163 | { |
| 164 | unsigned long long offset; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 165 | offset = tcp->u_arg[5]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 166 | offset <<= 12; |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 167 | print_mmap(tcp, tcp->u_arg, offset); |
| 168 | |
| 169 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 172 | SYS_FUNC(munmap) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 173 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 174 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 175 | tprintf(", %" PRI_klu, tcp->u_arg[1]); |
| 176 | |
| 177 | return RVAL_DECODED; |
| 178 | } |
| 179 | |
| 180 | static int |
| 181 | do_mprotect(struct tcb *tcp, bool has_pkey) |
| 182 | { |
| 183 | printaddr(tcp->u_arg[0]); |
| 184 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
| 185 | printflags64(mmap_prot, tcp->u_arg[2], "PROT_???"); |
| 186 | |
| 187 | if (has_pkey) |
| 188 | tprintf(", %d", (int) tcp->u_arg[3]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 189 | |
| 190 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 191 | } |
| 192 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 193 | SYS_FUNC(mprotect) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 194 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 195 | return do_mprotect(tcp, false); |
| 196 | } |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 197 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 198 | SYS_FUNC(pkey_mprotect) |
| 199 | { |
| 200 | return do_mprotect(tcp, true); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 203 | #include "xlat/mremap_flags.h" |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 204 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 205 | SYS_FUNC(mremap) |
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 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 208 | tprintf(", %" PRI_klu ", %" PRI_klu ", ", tcp->u_arg[1], tcp->u_arg[2]); |
| 209 | printflags64(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 210 | #ifdef MREMAP_FIXED |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 211 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 212 | (MREMAP_MAYMOVE | MREMAP_FIXED)) { |
| 213 | tprints(", "); |
| 214 | printaddr(tcp->u_arg[4]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 215 | } |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 216 | #endif |
| 217 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 218 | } |
| 219 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 220 | #include "xlat/madvise_cmds.h" |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 221 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 222 | SYS_FUNC(madvise) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 223 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 224 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 225 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 226 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
| 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/mlockall_flags.h" |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 232 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 233 | SYS_FUNC(mlockall) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 234 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 235 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
| 236 | |
| 237 | return RVAL_DECODED; |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 240 | #include "xlat/mctl_sync.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 241 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 242 | SYS_FUNC(msync) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 243 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 244 | /* addr */ |
| 245 | printaddr(tcp->u_arg[0]); |
| 246 | /* len */ |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 247 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 248 | /* flags */ |
| 249 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
| 250 | |
| 251 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 252 | } |
| 253 | |
Dmitry V. Levin | 0d0a50a | 2015-11-15 02:35:57 +0000 | [diff] [blame] | 254 | #include "xlat/mlock_flags.h" |
| 255 | |
| 256 | SYS_FUNC(mlock2) |
| 257 | { |
| 258 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 259 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
Dmitry V. Levin | 0d0a50a | 2015-11-15 02:35:57 +0000 | [diff] [blame] | 260 | printflags(mlock_flags, tcp->u_arg[2], "MLOCK_???"); |
| 261 | |
| 262 | return RVAL_DECODED; |
| 263 | } |
| 264 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 265 | SYS_FUNC(mincore) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 266 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 267 | if (entering(tcp)) { |
Dmitry V. Levin | 2c389f6 | 2015-07-19 23:25:56 +0000 | [diff] [blame] | 268 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 269 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 270 | } else { |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 271 | const unsigned long page_size = get_pagesize(); |
| 272 | const unsigned long page_mask = page_size - 1; |
| 273 | unsigned long len = tcp->u_arg[1]; |
| 274 | unsigned char *vec = NULL; |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 275 | |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 276 | len = len / page_size + (len & page_mask ? 1 : 0); |
Dmitry V. Levin | 2c389f6 | 2015-07-19 23:25:56 +0000 | [diff] [blame] | 277 | if (syserror(tcp) || !verbose(tcp) || |
| 278 | !tcp->u_arg[2] || !(vec = malloc(len)) || |
| 279 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 280 | printaddr(tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 281 | else { |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 282 | unsigned long i; |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 283 | tprints("["); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 284 | for (i = 0; i < len; i++) { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 285 | if (i) |
| 286 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 287 | if (abbrev(tcp) && i >= max_strlen) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 288 | tprints("..."); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 289 | break; |
| 290 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 291 | tprints((vec[i] & 1) ? "1" : "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 292 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 293 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 294 | } |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 295 | free(vec); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 296 | } |
| 297 | return 0; |
| 298 | } |
| 299 | |
Dmitry V. Levin | ece9ce6 | 2015-07-21 15:55:09 +0000 | [diff] [blame] | 300 | #if defined ALPHA || defined IA64 || defined M68K \ |
| 301 | || defined SPARC || defined SPARC64 |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 302 | SYS_FUNC(getpagesize) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 303 | { |
Dmitry V. Levin | b61b2d8 | 2016-01-08 19:20:05 +0000 | [diff] [blame] | 304 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 305 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 306 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 307 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 308 | SYS_FUNC(remap_file_pages) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 309 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 310 | const kernel_ulong_t addr = tcp->u_arg[0]; |
| 311 | const kernel_ulong_t size = tcp->u_arg[1]; |
| 312 | const kernel_ulong_t prot = tcp->u_arg[2]; |
| 313 | const kernel_ulong_t pgoff = tcp->u_arg[3]; |
| 314 | const kernel_ulong_t flags = tcp->u_arg[4]; |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 315 | |
| 316 | printaddr(addr); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 317 | tprintf(", %" PRI_klu ", ", size); |
| 318 | printflags64(mmap_prot, prot, "PROT_???"); |
| 319 | tprintf(", %" PRI_klu ", ", pgoff); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 320 | #ifdef MAP_TYPE |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 321 | printxval64(mmap_flags, flags & MAP_TYPE, "MAP_???"); |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 322 | addflags(mmap_flags, flags & ~MAP_TYPE); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 323 | #else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 324 | printflags64(mmap_flags, flags, "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 325 | #endif |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 326 | |
| 327 | return RVAL_DECODED; |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 328 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 329 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 330 | #if defined(POWERPC) |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 331 | static bool |
| 332 | print_protmap_entry(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) |
| 333 | { |
Elliott Hughes | dc75b01 | 2017-07-05 13:54:44 -0700 | [diff] [blame^] | 334 | tprintf("%#08x", *(unsigned int *) elem_buf); |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 335 | |
| 336 | return true; |
| 337 | } |
| 338 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 339 | SYS_FUNC(subpage_prot) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 340 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 341 | kernel_ulong_t addr = tcp->u_arg[0]; |
| 342 | kernel_ulong_t len = tcp->u_arg[1]; |
| 343 | kernel_ulong_t nmemb = len >> 16; |
| 344 | kernel_ulong_t map = tcp->u_arg[2]; |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 345 | |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 346 | printaddr(addr); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 347 | tprintf(", %" PRI_klu ", ", len); |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 348 | |
| 349 | unsigned int entry; |
| 350 | print_array(tcp, map, nmemb, &entry, sizeof(entry), |
| 351 | umoven_or_printaddr, print_protmap_entry, 0); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 352 | |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 353 | return RVAL_DECODED; |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 354 | } |
| 355 | #endif |