blob: 00f5610d1ce09a34374d94eff74cecc1c1bd06a1 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001/*
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 Akkerman4dc8a2a1999-12-23 14:20:14 +00005 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
Roland McGrathe1e584b2003-06-02 19:18:58 +00006 * Copyright (c) 2000 PocketPenguins Inc. Linux for Hitachi SuperH
7 * port by Greg Banks <gbanks@pocketpenguins.com>
Elliott Hughes39bac052017-05-25 16:56:11 -07008 * Copyright (c) 1999-2017 The strace developers.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00009 * 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 Akkerman76baf7c1999-02-19 00:21:36 +000032 */
33
34#include "defs.h"
Roland McGrath05cdd3c2004-03-02 06:16:59 +000035#include <asm/mman.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000036#include <sys/mman.h>
Denys Vlasenko1ba85432013-02-19 11:28:20 +010037
Dmitry V. Levinea1fea62015-03-31 19:45:08 +000038unsigned long
39get_pagesize(void)
Dmitry V. Levinc76a3632013-03-05 14:58:24 +000040{
41 static unsigned long pagesize;
42
43 if (!pagesize)
44 pagesize = sysconf(_SC_PAGESIZE);
45 return pagesize;
46}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000048SYS_FUNC(brk)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000049{
Dmitry V. Levin85813ce2015-07-19 23:37:40 +000050 printaddr(tcp->u_arg[0]);
51
52 return RVAL_DECODED | RVAL_HEX;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000053}
54
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000055#include "xlat/mmap_prot.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000056#include "xlat/mmap_flags.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057
Dmitry V. Levin85813ce2015-07-19 23:37:40 +000058static void
Elliott Hughesd35df492017-02-15 15:19:05 -080059print_mmap(struct tcb *tcp, kernel_ulong_t *u_arg, unsigned long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000060{
Elliott Hughesd35df492017-02-15 15:19:05 -080061 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. Levin3ae86902016-04-01 15:31:23 +000065 const int fd = u_arg[4];
66
67 printaddr(addr);
Elliott Hughesd35df492017-02-15 15:19:05 -080068 tprintf(", %" PRI_klu ", ", len);
69 printflags64(mmap_prot, prot, "PROT_???");
Dmitry V. Levin85813ce2015-07-19 23:37:40 +000070 tprints(", ");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000071#ifdef MAP_TYPE
Elliott Hughesd35df492017-02-15 15:19:05 -080072 printxval64(mmap_flags, flags & MAP_TYPE, "MAP_???");
Dmitry V. Levin3ae86902016-04-01 15:31:23 +000073 addflags(mmap_flags, flags & ~MAP_TYPE);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000074#else
Elliott Hughesd35df492017-02-15 15:19:05 -080075 printflags64(mmap_flags, flags, "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000076#endif
Dmitry V. Levin85813ce2015-07-19 23:37:40 +000077 tprints(", ");
Dmitry V. Levin3ae86902016-04-01 15:31:23 +000078 printfd(tcp, fd);
Dmitry V. Levin85813ce2015-07-19 23:37:40 +000079 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000080}
81
Denys Vlasenko1ba85432013-02-19 11:28:20 +010082/* 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. Levinbc724ce2016-04-22 23:36:26 +000090#if defined AARCH64 || defined ARM \
91 || defined I386 || defined X86_64 || defined X32 \
92 || defined M68K \
93 || defined S390 || defined S390X
Denys Vlasenko1ba85432013-02-19 11:28:20 +010094/* Params are pointed to by u_arg[0], offset is in bytes */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000095SYS_FUNC(old_mmap)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +000096{
Elliott Hughesd35df492017-02-15 15:19:05 -080097 kernel_ulong_t u_arg[6];
98# if ANY_WORDSIZE_LESS_THAN_KERNEL_LONG
Dmitry V. Levincf527782016-04-22 23:47:46 +000099 /* We are here only in a 32-bit personality. */
Dmitry V. Levin3db07f12016-04-22 23:41:36 +0000100 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. Levinbc724ce2016-04-22 23:36:26 +0000106# else
Dmitry V. Levin3db07f12016-04-22 23:41:36 +0000107 if (umove_or_printaddr(tcp, tcp->u_arg[0], &u_arg))
108 return RVAL_DECODED | RVAL_HEX;
Dmitry V. Levinbc724ce2016-04-22 23:36:26 +0000109# endif
Elliott Hughesd35df492017-02-15 15:19:05 -0800110 print_mmap(tcp, u_arg, u_arg[5]);
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000111
112 return RVAL_DECODED | RVAL_HEX;
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000113}
Dmitry V. Levinbc724ce2016-04-22 23:36:26 +0000114#endif /* old_mmap architectures */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000115
Elliott Hughesd35df492017-02-15 15:19:05 -0800116#ifdef S390
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100117/* Params are pointed to by u_arg[0], offset is in pages */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000118SYS_FUNC(old_mmap_pgoff)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100119{
Elliott Hughesd35df492017-02-15 15:19:05 -0800120 kernel_ulong_t u_arg[5];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100121 int i;
Elliott Hughesd35df492017-02-15 15:19:05 -0800122 unsigned int narrow_arg[6];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100123 unsigned long long offset;
Elliott Hughesd35df492017-02-15 15:19:05 -0800124 if (umove_or_printaddr(tcp, tcp->u_arg[0], &narrow_arg))
125 return RVAL_DECODED | RVAL_HEX;
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100126 for (i = 0; i < 5; i++)
Elliott Hughesd35df492017-02-15 15:19:05 -0800127 u_arg[i] = narrow_arg[i];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100128 offset = narrow_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000129 offset *= get_pagesize();
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000130 print_mmap(tcp, u_arg, offset);
131
132 return RVAL_DECODED | RVAL_HEX;
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100133}
Elliott Hughesd35df492017-02-15 15:19:05 -0800134#endif /* S390 */
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100135
136/* Params are passed directly, offset is in bytes */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000137SYS_FUNC(mmap)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000138{
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100139 /* 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 Hughesd35df492017-02-15 15:19:05 -0800144 print_mmap(tcp, tcp->u_arg, tcp->u_arg[5]);
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000145
146 return RVAL_DECODED | RVAL_HEX;
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100147}
148
149/* Params are passed directly, offset is in pages */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000150SYS_FUNC(mmap_pgoff)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100151{
152 /* Try test/mmap_offset_decode.c */
153 unsigned long long offset;
Elliott Hughesd35df492017-02-15 15:19:05 -0800154 offset = tcp->u_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000155 offset *= get_pagesize();
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000156 print_mmap(tcp, tcp->u_arg, offset);
157
158 return RVAL_DECODED | RVAL_HEX;
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100159}
160
161/* Params are passed directly, offset is in 4k units */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000162SYS_FUNC(mmap_4koff)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100163{
164 unsigned long long offset;
Elliott Hughesd35df492017-02-15 15:19:05 -0800165 offset = tcp->u_arg[5];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100166 offset <<= 12;
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000167 print_mmap(tcp, tcp->u_arg, offset);
168
169 return RVAL_DECODED | RVAL_HEX;
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000170}
171
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000172SYS_FUNC(munmap)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000173{
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000174 printaddr(tcp->u_arg[0]);
Elliott Hughesd35df492017-02-15 15:19:05 -0800175 tprintf(", %" PRI_klu, tcp->u_arg[1]);
176
177 return RVAL_DECODED;
178}
179
180static int
181do_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. Levin85813ce2015-07-19 23:37:40 +0000189
190 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000191}
192
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000193SYS_FUNC(mprotect)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000194{
Elliott Hughesd35df492017-02-15 15:19:05 -0800195 return do_mprotect(tcp, false);
196}
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000197
Elliott Hughesd35df492017-02-15 15:19:05 -0800198SYS_FUNC(pkey_mprotect)
199{
200 return do_mprotect(tcp, true);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000201}
202
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000203#include "xlat/mremap_flags.h"
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000204
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000205SYS_FUNC(mremap)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000206{
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000207 printaddr(tcp->u_arg[0]);
Elliott Hughesd35df492017-02-15 15:19:05 -0800208 tprintf(", %" PRI_klu ", %" PRI_klu ", ", tcp->u_arg[1], tcp->u_arg[2]);
209 printflags64(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000210#ifdef MREMAP_FIXED
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000211 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
212 (MREMAP_MAYMOVE | MREMAP_FIXED)) {
213 tprints(", ");
214 printaddr(tcp->u_arg[4]);
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000215 }
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000216#endif
217 return RVAL_DECODED | RVAL_HEX;
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000218}
219
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000220#include "xlat/madvise_cmds.h"
Wichert Akkermanc7926982000-04-10 22:22:31 +0000221
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000222SYS_FUNC(madvise)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000223{
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000224 printaddr(tcp->u_arg[0]);
Elliott Hughesd35df492017-02-15 15:19:05 -0800225 tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000226 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
227
228 return RVAL_DECODED;
Wichert Akkermanc7926982000-04-10 22:22:31 +0000229}
230
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000231#include "xlat/mlockall_flags.h"
Wichert Akkermanc7926982000-04-10 22:22:31 +0000232
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000233SYS_FUNC(mlockall)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000234{
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000235 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
236
237 return RVAL_DECODED;
Wichert Akkermanc7926982000-04-10 22:22:31 +0000238}
239
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000240#include "xlat/mctl_sync.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000241
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000242SYS_FUNC(msync)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000243{
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000244 /* addr */
245 printaddr(tcp->u_arg[0]);
246 /* len */
Elliott Hughesd35df492017-02-15 15:19:05 -0800247 tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000248 /* flags */
249 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
250
251 return RVAL_DECODED;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000252}
253
Dmitry V. Levin0d0a50a2015-11-15 02:35:57 +0000254#include "xlat/mlock_flags.h"
255
256SYS_FUNC(mlock2)
257{
258 printaddr(tcp->u_arg[0]);
Elliott Hughesd35df492017-02-15 15:19:05 -0800259 tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
Dmitry V. Levin0d0a50a2015-11-15 02:35:57 +0000260 printflags(mlock_flags, tcp->u_arg[2], "MLOCK_???");
261
262 return RVAL_DECODED;
263}
264
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000265SYS_FUNC(mincore)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000266{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000267 if (entering(tcp)) {
Dmitry V. Levin2c389f62015-07-19 23:25:56 +0000268 printaddr(tcp->u_arg[0]);
Elliott Hughesd35df492017-02-15 15:19:05 -0800269 tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000270 } else {
Dmitry V. Levindfea1da2016-01-29 01:51:54 +0000271 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 Vlasenko1d46ba52011-08-31 14:00:02 +0200275
Dmitry V. Levindfea1da2016-01-29 01:51:54 +0000276 len = len / page_size + (len & page_mask ? 1 : 0);
Dmitry V. Levin2c389f62015-07-19 23:25:56 +0000277 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 Akkerman76baf7c1999-02-19 00:21:36 +0000281 else {
Dmitry V. Levindfea1da2016-01-29 01:51:54 +0000282 unsigned long i;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200283 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000284 for (i = 0; i < len; i++) {
Elliott Hughesd35df492017-02-15 15:19:05 -0800285 if (i)
286 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000287 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200288 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000289 break;
290 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200291 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000292 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200293 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000294 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200295 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000296 }
297 return 0;
298}
299
Dmitry V. Levinece9ce62015-07-21 15:55:09 +0000300#if defined ALPHA || defined IA64 || defined M68K \
301 || defined SPARC || defined SPARC64
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000302SYS_FUNC(getpagesize)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000303{
Dmitry V. Levinb61b2d82016-01-08 19:20:05 +0000304 return RVAL_DECODED | RVAL_HEX;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000305}
Denys Vlasenko84703742012-02-25 02:38:52 +0100306#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000307
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000308SYS_FUNC(remap_file_pages)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000309{
Elliott Hughesd35df492017-02-15 15:19:05 -0800310 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. Levin3ae86902016-04-01 15:31:23 +0000315
316 printaddr(addr);
Elliott Hughesd35df492017-02-15 15:19:05 -0800317 tprintf(", %" PRI_klu ", ", size);
318 printflags64(mmap_prot, prot, "PROT_???");
319 tprintf(", %" PRI_klu ", ", pgoff);
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000320#ifdef MAP_TYPE
Elliott Hughesd35df492017-02-15 15:19:05 -0800321 printxval64(mmap_flags, flags & MAP_TYPE, "MAP_???");
Dmitry V. Levin3ae86902016-04-01 15:31:23 +0000322 addflags(mmap_flags, flags & ~MAP_TYPE);
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000323#else
Elliott Hughesd35df492017-02-15 15:19:05 -0800324 printflags64(mmap_flags, flags, "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000325#endif
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000326
327 return RVAL_DECODED;
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000328}
Roland McGrathb10a3352004-10-07 18:53:12 +0000329
Denys Vlasenko84703742012-02-25 02:38:52 +0100330#if defined(POWERPC)
Dmitry V. Levin0f04b9d2016-05-07 23:00:52 +0000331static bool
332print_protmap_entry(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data)
333{
Elliott Hughesdc75b012017-07-05 13:54:44 -0700334 tprintf("%#08x", *(unsigned int *) elem_buf);
Dmitry V. Levin0f04b9d2016-05-07 23:00:52 +0000335
336 return true;
337}
338
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000339SYS_FUNC(subpage_prot)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000340{
Elliott Hughesd35df492017-02-15 15:19:05 -0800341 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 McGrath4a6f6522008-08-25 03:09:16 +0000345
Dmitry V. Levin0f04b9d2016-05-07 23:00:52 +0000346 printaddr(addr);
Elliott Hughesd35df492017-02-15 15:19:05 -0800347 tprintf(", %" PRI_klu ", ", len);
Dmitry V. Levin0f04b9d2016-05-07 23:00:52 +0000348
349 unsigned int entry;
350 print_array(tcp, map, nmemb, &entry, sizeof(entry),
351 umoven_or_printaddr, print_protmap_entry, 0);
Roland McGrath4a6f6522008-08-25 03:09:16 +0000352
Dmitry V. Levin85813ce2015-07-19 23:37:40 +0000353 return RVAL_DECODED;
Roland McGrath4a6f6522008-08-25 03:09:16 +0000354}
355#endif