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 |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 58 | 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] | 59 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 60 | const kernel_ulong_t addr = u_arg[0]; |
| 61 | const kernel_ulong_t len = u_arg[1]; |
| 62 | const kernel_ulong_t prot = u_arg[2]; |
| 63 | const kernel_ulong_t flags = u_arg[3]; |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 64 | const int fd = u_arg[4]; |
| 65 | |
| 66 | printaddr(addr); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 67 | tprintf(", %" PRI_klu ", ", len); |
| 68 | printflags64(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 |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 71 | printxval64(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 |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 74 | printflags64(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 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 96 | kernel_ulong_t u_arg[6]; |
| 97 | # if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG |
Dmitry V. Levin | cf52778 | 2016-04-22 23:47:46 +0000 | [diff] [blame] | 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 |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 109 | print_mmap(tcp, u_arg, u_arg[5]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 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 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 115 | #ifdef S390 |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 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 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 119 | kernel_ulong_t u_arg[5]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 120 | int i; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 121 | unsigned int narrow_arg[6]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 122 | unsigned long long offset; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 123 | if (umove_or_printaddr(tcp, tcp->u_arg[0], &narrow_arg)) |
| 124 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 125 | for (i = 0; i < 5; i++) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 126 | u_arg[i] = narrow_arg[i]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 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 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 133 | #endif /* S390 */ |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 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 | { |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 138 | /* Example of kernel-side handling of this variety of mmap: |
| 139 | * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls |
| 140 | * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes, |
| 141 | * since the above code converts off to pages. |
| 142 | */ |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 143 | print_mmap(tcp, tcp->u_arg, tcp->u_arg[5]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 144 | |
| 145 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | /* Params are passed directly, offset is in pages */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 149 | SYS_FUNC(mmap_pgoff) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 150 | { |
| 151 | /* Try test/mmap_offset_decode.c */ |
| 152 | unsigned long long offset; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 153 | offset = tcp->u_arg[5]; |
Dmitry V. Levin | c76a363 | 2013-03-05 14:58:24 +0000 | [diff] [blame] | 154 | offset *= get_pagesize(); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 155 | print_mmap(tcp, tcp->u_arg, offset); |
| 156 | |
| 157 | return RVAL_DECODED | RVAL_HEX; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | /* Params are passed directly, offset is in 4k units */ |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 161 | SYS_FUNC(mmap_4koff) |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 162 | { |
| 163 | unsigned long long offset; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 164 | offset = tcp->u_arg[5]; |
Denys Vlasenko | 1ba8543 | 2013-02-19 11:28:20 +0100 | [diff] [blame] | 165 | offset <<= 12; |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 166 | print_mmap(tcp, tcp->u_arg, offset); |
| 167 | |
| 168 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 171 | SYS_FUNC(munmap) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 172 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 173 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 174 | tprintf(", %" PRI_klu, tcp->u_arg[1]); |
| 175 | |
| 176 | return RVAL_DECODED; |
| 177 | } |
| 178 | |
| 179 | static int |
| 180 | do_mprotect(struct tcb *tcp, bool has_pkey) |
| 181 | { |
| 182 | printaddr(tcp->u_arg[0]); |
| 183 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
| 184 | printflags64(mmap_prot, tcp->u_arg[2], "PROT_???"); |
| 185 | |
| 186 | if (has_pkey) |
| 187 | tprintf(", %d", (int) tcp->u_arg[3]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 188 | |
| 189 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 190 | } |
| 191 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 192 | SYS_FUNC(mprotect) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 193 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 194 | return do_mprotect(tcp, false); |
| 195 | } |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 196 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 197 | SYS_FUNC(pkey_mprotect) |
| 198 | { |
| 199 | return do_mprotect(tcp, true); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 200 | } |
| 201 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 202 | #include "xlat/mremap_flags.h" |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 203 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 204 | SYS_FUNC(mremap) |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 205 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 206 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 207 | tprintf(", %" PRI_klu ", %" PRI_klu ", ", tcp->u_arg[1], tcp->u_arg[2]); |
| 208 | printflags64(mremap_flags, tcp->u_arg[3], "MREMAP_???"); |
Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 209 | #ifdef MREMAP_FIXED |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 210 | if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == |
| 211 | (MREMAP_MAYMOVE | MREMAP_FIXED)) { |
| 212 | tprints(", "); |
| 213 | printaddr(tcp->u_arg[4]); |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 214 | } |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 215 | #endif |
| 216 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 219 | #include "xlat/madvise_cmds.h" |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 220 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 221 | SYS_FUNC(madvise) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 222 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 223 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 224 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 225 | printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); |
| 226 | |
| 227 | return RVAL_DECODED; |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 230 | #include "xlat/mlockall_flags.h" |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 231 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 232 | SYS_FUNC(mlockall) |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 233 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 234 | printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); |
| 235 | |
| 236 | return RVAL_DECODED; |
Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 237 | } |
| 238 | |
Dmitry V. Levin | 0ed617b | 2014-04-25 23:30:54 +0000 | [diff] [blame] | 239 | #include "xlat/mctl_sync.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 240 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 241 | SYS_FUNC(msync) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 242 | { |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 243 | /* addr */ |
| 244 | printaddr(tcp->u_arg[0]); |
| 245 | /* len */ |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 246 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 247 | /* flags */ |
| 248 | printflags(mctl_sync, tcp->u_arg[2], "MS_???"); |
| 249 | |
| 250 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 251 | } |
| 252 | |
Dmitry V. Levin | 0d0a50a | 2015-11-15 02:35:57 +0000 | [diff] [blame] | 253 | #include "xlat/mlock_flags.h" |
| 254 | |
| 255 | SYS_FUNC(mlock2) |
| 256 | { |
| 257 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 258 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
Dmitry V. Levin | 0d0a50a | 2015-11-15 02:35:57 +0000 | [diff] [blame] | 259 | printflags(mlock_flags, tcp->u_arg[2], "MLOCK_???"); |
| 260 | |
| 261 | return RVAL_DECODED; |
| 262 | } |
| 263 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 264 | SYS_FUNC(mincore) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 265 | { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 266 | if (entering(tcp)) { |
Dmitry V. Levin | 2c389f6 | 2015-07-19 23:25:56 +0000 | [diff] [blame] | 267 | printaddr(tcp->u_arg[0]); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 268 | tprintf(", %" PRI_klu ", ", tcp->u_arg[1]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 269 | } else { |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 270 | const unsigned long page_size = get_pagesize(); |
| 271 | const unsigned long page_mask = page_size - 1; |
| 272 | unsigned long len = tcp->u_arg[1]; |
| 273 | unsigned char *vec = NULL; |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 274 | |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 275 | len = len / page_size + (len & page_mask ? 1 : 0); |
Dmitry V. Levin | 2c389f6 | 2015-07-19 23:25:56 +0000 | [diff] [blame] | 276 | if (syserror(tcp) || !verbose(tcp) || |
| 277 | !tcp->u_arg[2] || !(vec = malloc(len)) || |
| 278 | umoven(tcp, tcp->u_arg[2], len, vec) < 0) |
| 279 | printaddr(tcp->u_arg[2]); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 280 | else { |
Dmitry V. Levin | dfea1da | 2016-01-29 01:51:54 +0000 | [diff] [blame] | 281 | unsigned long i; |
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 | for (i = 0; i < len; i++) { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 284 | if (i) |
| 285 | tprints(", "); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 286 | if (abbrev(tcp) && i >= max_strlen) { |
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 | break; |
| 289 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 290 | tprints((vec[i] & 1) ? "1" : "0"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 291 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 292 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 293 | } |
Denys Vlasenko | 1d46ba5 | 2011-08-31 14:00:02 +0200 | [diff] [blame] | 294 | free(vec); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 295 | } |
| 296 | return 0; |
| 297 | } |
| 298 | |
Dmitry V. Levin | ece9ce6 | 2015-07-21 15:55:09 +0000 | [diff] [blame] | 299 | #if defined ALPHA || defined IA64 || defined M68K \ |
| 300 | || defined SPARC || defined SPARC64 |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 301 | SYS_FUNC(getpagesize) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 302 | { |
Dmitry V. Levin | b61b2d8 | 2016-01-08 19:20:05 +0000 | [diff] [blame] | 303 | return RVAL_DECODED | RVAL_HEX; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 304 | } |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 305 | #endif |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 306 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 307 | SYS_FUNC(remap_file_pages) |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 308 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 309 | const kernel_ulong_t addr = tcp->u_arg[0]; |
| 310 | const kernel_ulong_t size = tcp->u_arg[1]; |
| 311 | const kernel_ulong_t prot = tcp->u_arg[2]; |
| 312 | const kernel_ulong_t pgoff = tcp->u_arg[3]; |
| 313 | const kernel_ulong_t flags = tcp->u_arg[4]; |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 314 | |
| 315 | printaddr(addr); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 316 | tprintf(", %" PRI_klu ", ", size); |
| 317 | printflags64(mmap_prot, prot, "PROT_???"); |
| 318 | tprintf(", %" PRI_klu ", ", pgoff); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 319 | #ifdef MAP_TYPE |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 320 | printxval64(mmap_flags, flags & MAP_TYPE, "MAP_???"); |
Dmitry V. Levin | 3ae8690 | 2016-04-01 15:31:23 +0000 | [diff] [blame] | 321 | addflags(mmap_flags, flags & ~MAP_TYPE); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 322 | #else |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 323 | printflags64(mmap_flags, flags, "MAP_???"); |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 324 | #endif |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 325 | |
| 326 | return RVAL_DECODED; |
Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 327 | } |
Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 328 | |
Denys Vlasenko | 8470374 | 2012-02-25 02:38:52 +0100 | [diff] [blame] | 329 | #if defined(POWERPC) |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 330 | static bool |
| 331 | print_protmap_entry(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) |
| 332 | { |
| 333 | tprintf("%#08x", * (unsigned int *) elem_buf); |
| 334 | |
| 335 | return true; |
| 336 | } |
| 337 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 338 | SYS_FUNC(subpage_prot) |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 339 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 340 | kernel_ulong_t addr = tcp->u_arg[0]; |
| 341 | kernel_ulong_t len = tcp->u_arg[1]; |
| 342 | kernel_ulong_t nmemb = len >> 16; |
| 343 | kernel_ulong_t map = tcp->u_arg[2]; |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 344 | |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 345 | printaddr(addr); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame^] | 346 | tprintf(", %" PRI_klu ", ", len); |
Dmitry V. Levin | 0f04b9d | 2016-05-07 23:00:52 +0000 | [diff] [blame] | 347 | |
| 348 | unsigned int entry; |
| 349 | print_array(tcp, map, nmemb, &entry, sizeof(entry), |
| 350 | umoven_or_printaddr, print_protmap_entry, 0); |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 351 | |
Dmitry V. Levin | 85813ce | 2015-07-19 23:37:40 +0000 | [diff] [blame] | 352 | return RVAL_DECODED; |
Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 353 | } |
| 354 | #endif |