blob: ef273c7e62b5a69bb5839e06ddb1baabd201e69f [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>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00008 * 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 Akkerman76baf7c1999-02-19 00:21:36 +000031 */
32
33#include "defs.h"
Roland McGrath05cdd3c2004-03-02 06:16:59 +000034#include <asm/mman.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000035#include <sys/mman.h>
Denys Vlasenko84703742012-02-25 02:38:52 +010036#if defined(I386)
Denys Vlasenko72a58482011-08-19 16:01:51 +020037# include <asm/ldt.h>
Roland McGrath7decfb22004-03-01 22:10:52 +000038# ifdef HAVE_STRUCT_USER_DESC
39# define modify_ldt_ldt_s user_desc
40# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000041#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +010042
Dmitry V. Levinc76a3632013-03-05 14:58:24 +000043static unsigned long
44get_pagesize()
45{
46 static unsigned long pagesize;
47
48 if (!pagesize)
49 pagesize = sysconf(_SC_PAGESIZE);
50 return pagesize;
51}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052
53int
Denys Vlasenko12014262011-05-30 14:00:14 +020054sys_brk(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000055{
56 if (entering(tcp)) {
57 tprintf("%#lx", tcp->u_arg[0]);
58 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000059 return RVAL_HEX;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000060}
61
Roland McGrathd9f816f2004-09-04 03:39:20 +000062static const struct xlat mmap_prot[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000063 { PROT_NONE, "PROT_NONE", },
64 { PROT_READ, "PROT_READ" },
65 { PROT_WRITE, "PROT_WRITE" },
66 { PROT_EXEC, "PROT_EXEC" },
Roland McGrath47eb0e22003-09-25 23:06:04 +000067#ifdef PROT_SEM
68 { PROT_SEM, "PROT_SEM" },
69#endif
70#ifdef PROT_GROWSDOWN
71 { PROT_GROWSDOWN,"PROT_GROWSDOWN"},
72#endif
73#ifdef PROT_GROWSUP
74 { PROT_GROWSUP, "PROT_GROWSUP" },
75#endif
Roland McGrath586d6ab2008-08-25 03:00:47 +000076#ifdef PROT_SAO
77 { PROT_SAO, "PROT_SAO" },
78#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000079 { 0, NULL },
80};
81
Roland McGrathd9f816f2004-09-04 03:39:20 +000082static const struct xlat mmap_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000083 { MAP_SHARED, "MAP_SHARED" },
84 { MAP_PRIVATE, "MAP_PRIVATE" },
85 { MAP_FIXED, "MAP_FIXED" },
86#ifdef MAP_ANONYMOUS
87 { MAP_ANONYMOUS,"MAP_ANONYMOUS" },
88#endif
Dmitry V. Levin71f1a132007-03-29 23:30:09 +000089#ifdef MAP_32BIT
90 { MAP_32BIT, "MAP_32BIT" },
91#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000092#ifdef MAP_RENAME
93 { MAP_RENAME, "MAP_RENAME" },
94#endif
95#ifdef MAP_NORESERVE
96 { MAP_NORESERVE,"MAP_NORESERVE" },
97#endif
Roland McGrath72c5b7b2003-03-05 04:08:00 +000098#ifdef MAP_POPULATE
99 { MAP_POPULATE, "MAP_POPULATE" },
100#endif
101#ifdef MAP_NONBLOCK
102 { MAP_NONBLOCK, "MAP_NONBLOCK" },
103#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000104 /*
105 * XXX - this was introduced in SunOS 4.x to distinguish between
106 * the old pre-4.x "mmap()", which:
107 *
108 * only let you map devices with an "mmap" routine (e.g.,
109 * frame buffers) in;
110 *
111 * required you to specify the mapping address;
112 *
113 * returned 0 on success and -1 on failure;
114 *
115 * memory and which, and the 4.x "mmap()" which:
116 *
117 * can map plain files;
118 *
119 * can be asked to pick where to map the file;
120 *
121 * returns the address where it mapped the file on success
122 * and -1 on failure.
123 *
124 * It's not actually used in source code that calls "mmap()"; the
125 * "mmap()" routine adds it for you.
126 *
127 * It'd be nice to come up with some way of eliminating it from
128 * the flags, e.g. reporting calls *without* it as "old_mmap()"
129 * and calls with it as "mmap()".
130 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000131#ifdef _MAP_NEW
132 { _MAP_NEW, "_MAP_NEW" },
133#endif
134#ifdef MAP_GROWSDOWN
135 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
136#endif
137#ifdef MAP_DENYWRITE
138 { MAP_DENYWRITE,"MAP_DENYWRITE" },
139#endif
140#ifdef MAP_EXECUTABLE
141 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
142#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000143#ifdef MAP_INHERIT
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100144 { MAP_INHERIT, "MAP_INHERIT" },
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000145#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000146#ifdef MAP_FILE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100147 { MAP_FILE, "MAP_FILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000148#endif
149#ifdef MAP_LOCKED
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100150 { MAP_LOCKED, "MAP_LOCKED" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000151#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000152 /* FreeBSD ones */
Denys Vlasenko2897fb32012-03-17 01:29:40 +0100153#if defined(MAP_ANON) && (!defined(MAP_ANONYMOUS) || MAP_ANON != MAP_ANONYMOUS)
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100154 { MAP_ANON, "MAP_ANON" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000155#endif
156#ifdef MAP_HASSEMAPHORE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100157 { MAP_HASSEMAPHORE,"MAP_HASSEMAPHORE"},
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000158#endif
159#ifdef MAP_STACK
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100160 { MAP_STACK, "MAP_STACK" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000161#endif
Bernhard Reutner-Fischer21ceeb42013-02-05 19:31:55 +0100162#if defined MAP_UNINITIALIZED && MAP_UNINITIALIZED > 0
163 { MAP_UNINITIALIZED,"MAP_UNINITIALIZED"},
164#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000165#ifdef MAP_NOSYNC
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100166 { MAP_NOSYNC, "MAP_NOSYNC" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000167#endif
168#ifdef MAP_NOCORE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100169 { MAP_NOCORE, "MAP_NOCORE" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000170#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000171 { 0, NULL },
172};
173
Dmitry V. Levin31382132011-03-04 05:08:02 +0300174static int
Denys Vlasenko923255c2013-02-18 02:36:36 +0100175print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000176{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000177 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000178 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +0000179 if (!u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200180 tprints("NULL, ");
Wichert Akkerman8829a551999-06-11 13:18:40 +0000181 else
182 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000183 /* len */
184 tprintf("%lu, ", u_arg[1]);
185 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000186 printflags(mmap_prot, u_arg[2], "PROT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200187 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000188 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000189#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000190 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
191 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000192#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000193 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000194#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200195 tprints(", ");
Denys Vlasenko923255c2013-02-18 02:36:36 +0100196 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300197 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000198 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300199 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000200 }
201 return RVAL_HEX;
202}
203
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100204/* Syscall name<->function correspondence is messed up on many arches.
205 * For example:
206 * i386 has __NR_mmap == 90, and it is "old mmap", and
207 * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets".
208 * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets".
209 * Confused? Me too!
210 */
211
212/* Params are pointed to by u_arg[0], offset is in bytes */
213int
214sys_old_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000215{
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100216 long u_arg[6];
Denys Vlasenko72a58482011-08-19 16:01:51 +0200217#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000218 /*
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200219 * IA64 processes never call this routine, they only use the
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100220 * new 'sys_mmap' interface. Only IA32 processes come here.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000221 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200222 int i;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100223 unsigned narrow_arg[6];
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200224 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
225 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000226 for (i = 0; i < 6; i++)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100227 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100228#elif defined(X86_64)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100229 /* We are here only in personality 1 (i386) */
230 int i;
231 unsigned narrow_arg[6];
232 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
233 return 0;
234 for (i = 0; i < 6; ++i)
235 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100236#else
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200237 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000238 return 0;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100239#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100240 return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000241}
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000242
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100243#if defined(S390)
244/* Params are pointed to by u_arg[0], offset is in pages */
245int
246sys_old_mmap_pgoff(struct tcb *tcp)
247{
248 long u_arg[5];
249 int i;
250 unsigned narrow_arg[6];
251 unsigned long long offset;
252 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
253 return 0;
254 for (i = 0; i < 5; i++)
255 u_arg[i] = (unsigned long) narrow_arg[i];
256 offset = narrow_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000257 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100258 return print_mmap(tcp, u_arg, offset);
259}
260#endif
261
262/* Params are passed directly, offset is in bytes */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000263int
Denys Vlasenko12014262011-05-30 14:00:14 +0200264sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000265{
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100266 unsigned long long offset = (unsigned long) tcp->u_arg[5];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100267#if defined(LINUX_MIPSN32) || defined(X32)
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100268 /* Try test/x32_mmap.c */
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000269 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000270#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100271 /* Example of kernel-side handling of this variety of mmap:
272 * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls
273 * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes,
274 * since the above code converts off to pages.
275 */
276 return print_mmap(tcp, tcp->u_arg, offset);
277}
278
279/* Params are passed directly, offset is in pages */
280int
281sys_mmap_pgoff(struct tcb *tcp)
282{
283 /* Try test/mmap_offset_decode.c */
284 unsigned long long offset;
285 offset = (unsigned long) tcp->u_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000286 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100287 return print_mmap(tcp, tcp->u_arg, offset);
288}
289
290/* Params are passed directly, offset is in 4k units */
291int
292sys_mmap_4koff(struct tcb *tcp)
293{
294 unsigned long long offset;
295 offset = (unsigned long) tcp->u_arg[5];
296 offset <<= 12;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000297 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000298}
299
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000300int
Denys Vlasenko12014262011-05-30 14:00:14 +0200301sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000302{
303 if (entering(tcp)) {
304 tprintf("%#lx, %lu",
305 tcp->u_arg[0], tcp->u_arg[1]);
306 }
307 return 0;
308}
309
310int
Denys Vlasenko12014262011-05-30 14:00:14 +0200311sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000312{
313 if (entering(tcp)) {
314 tprintf("%#lx, %lu, ",
315 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000316 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000317 }
318 return 0;
319}
320
Roland McGrathd9f816f2004-09-04 03:39:20 +0000321static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000322 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000323#ifdef MREMAP_FIXED
324 { MREMAP_FIXED, "MREMAP_FIXED" },
325#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000326 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000327};
328
329int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000330sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000331{
332 if (entering(tcp)) {
333 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
334 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000335 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000336#ifdef MREMAP_FIXED
337 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
338 (MREMAP_MAYMOVE | MREMAP_FIXED))
339 tprintf(", %#lx", tcp->u_arg[4]);
340#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000341 }
342 return RVAL_HEX;
343}
344
Roland McGrathf4021b12008-08-25 02:59:36 +0000345static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000346#ifdef MADV_NORMAL
347 { MADV_NORMAL, "MADV_NORMAL" },
348#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000349#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000350 { MADV_RANDOM, "MADV_RANDOM" },
351#endif
352#ifdef MADV_SEQUENTIAL
353 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
354#endif
355#ifdef MADV_WILLNEED
356 { MADV_WILLNEED, "MADV_WILLNEED" },
357#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000358#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000359 { MADV_DONTNEED, "MADV_DONTNEED" },
360#endif
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000361#ifdef MADV_REMOVE
362 { MADV_REMOVE, "MADV_REMOVE" },
363#endif
364#ifdef MADV_DONTFORK
365 { MADV_DONTFORK, "MADV_DONTFORK" },
366#endif
367#ifdef MADV_DOFORK
368 { MADV_DOFORK, "MADV_DOFORK" },
369#endif
370#ifdef MADV_HWPOISON
371 { MADV_HWPOISON, "MADV_HWPOISON" },
372#endif
373#ifdef MADV_SOFT_OFFLINE
374 { MADV_SOFT_OFFLINE, "MADV_SOFT_OFFLINE" },
375#endif
376#ifdef MADV_MERGEABLE
377 { MADV_MERGEABLE, "MADV_MERGEABLE" },
378#endif
379#ifdef MADV_UNMERGEABLE
380 { MADV_UNMERGEABLE, "MADV_UNMERGEABLE" },
381#endif
382#ifdef MADV_HUGEPAGE
383 { MADV_HUGEPAGE, "MADV_HUGEPAGE" },
384#endif
385#ifdef MADV_NOHUGEPAGE
386 { MADV_NOHUGEPAGE, "MADV_NOHUGEPAGE" },
387#endif
388#ifdef MADV_DONTDUMP
389 { MADV_DONTDUMP, "MADV_DONTDUMP" },
390#endif
391#ifdef MADV_DODUMP
392 { MADV_DODUMP, "MADV_DODUMP" },
393#endif
Wichert Akkermanc7926982000-04-10 22:22:31 +0000394 { 0, NULL },
395};
396
Wichert Akkermanc7926982000-04-10 22:22:31 +0000397int
Denys Vlasenko12014262011-05-30 14:00:14 +0200398sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000399{
400 if (entering(tcp)) {
401 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000402 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000403 }
404 return 0;
405}
406
Roland McGrathd9f816f2004-09-04 03:39:20 +0000407static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000408#ifdef MCL_CURRENT
409 { MCL_CURRENT, "MCL_CURRENT" },
410#endif
411#ifdef MCL_FUTURE
412 { MCL_FUTURE, "MCL_FUTURE" },
413#endif
414 { 0, NULL}
415};
416
417int
Denys Vlasenko12014262011-05-30 14:00:14 +0200418sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000419{
420 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000421 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000422 }
423 return 0;
424}
425
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000426#ifdef MS_ASYNC
427
Roland McGrathd9f816f2004-09-04 03:39:20 +0000428static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000429#ifdef MS_SYNC
430 { MS_SYNC, "MS_SYNC" },
431#endif
John Hughesaca07f32001-10-16 18:12:27 +0000432 { MS_ASYNC, "MS_ASYNC" },
433 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000434 { 0, NULL },
435};
436
437int
Denys Vlasenko12014262011-05-30 14:00:14 +0200438sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000439{
440 if (entering(tcp)) {
441 /* addr */
442 tprintf("%#lx", tcp->u_arg[0]);
443 /* len */
444 tprintf(", %lu, ", tcp->u_arg[1]);
445 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000446 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000447 }
448 return 0;
449}
450
451#endif /* MS_ASYNC */
452
453#ifdef MC_SYNC
454
Roland McGrathd9f816f2004-09-04 03:39:20 +0000455static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000456 { MC_LOCK, "MC_LOCK" },
457 { MC_LOCKAS, "MC_LOCKAS" },
458 { MC_SYNC, "MC_SYNC" },
459 { MC_UNLOCK, "MC_UNLOCK" },
460 { MC_UNLOCKAS, "MC_UNLOCKAS" },
461 { 0, NULL },
462};
463
Roland McGrathd9f816f2004-09-04 03:39:20 +0000464static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000465 { MCL_CURRENT, "MCL_CURRENT" },
466 { MCL_FUTURE, "MCL_FUTURE" },
467 { 0, NULL },
468};
469
470int
Denys Vlasenko12014262011-05-30 14:00:14 +0200471sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000472{
473 int arg, function;
474
475 if (entering(tcp)) {
476 /* addr */
477 tprintf("%#lx", tcp->u_arg[0]);
478 /* len */
479 tprintf(", %lu, ", tcp->u_arg[1]);
480 /* function */
481 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000482 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000483 /* arg */
484 arg = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200485 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000486 switch (function) {
487 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000488 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000489 break;
490 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000491 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000492 break;
493 default:
494 tprintf("%#x", arg);
495 break;
496 }
497 }
498 return 0;
499}
500
501#endif /* MC_SYNC */
502
503int
Denys Vlasenko12014262011-05-30 14:00:14 +0200504sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000505{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000506 if (entering(tcp)) {
507 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
508 } else {
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200509 unsigned long i, len;
510 char *vec = NULL;
511
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000512 len = tcp->u_arg[1];
513 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000514 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000515 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
516 tprintf("%#lx", tcp->u_arg[2]);
517 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200518 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000519 for (i = 0; i < len; i++) {
520 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200521 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000522 break;
523 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200524 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000525 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200526 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000527 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200528 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000529 }
530 return 0;
531}
532
Denys Vlasenko84703742012-02-25 02:38:52 +0100533#if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000534int
Denys Vlasenko12014262011-05-30 14:00:14 +0200535sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000536{
537 if (exiting(tcp))
538 return RVAL_HEX;
539 return 0;
540}
Denys Vlasenko84703742012-02-25 02:38:52 +0100541#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000542
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100543#if defined(I386)
Roland McGrath909875b2002-12-22 03:34:36 +0000544void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000545print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000546{
547 tprintf("base_addr:%#08lx, "
548 "limit:%d, "
549 "seg_32bit:%d, "
550 "contents:%d, "
551 "read_exec_only:%d, "
552 "limit_in_pages:%d, "
553 "seg_not_present:%d, "
554 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000555 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000556 ldt_entry->limit,
557 ldt_entry->seg_32bit,
558 ldt_entry->contents,
559 ldt_entry->read_exec_only,
560 ldt_entry->limit_in_pages,
561 ldt_entry->seg_not_present,
562 ldt_entry->useable);
563}
564
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000565int
Denys Vlasenko12014262011-05-30 14:00:14 +0200566sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000567{
568 if (entering(tcp)) {
569 struct modify_ldt_ldt_s copy;
570 tprintf("%ld", tcp->u_arg[0]);
571 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200572 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000573 || umove(tcp, tcp->u_arg[1], &copy) == -1)
574 tprintf(", %lx", tcp->u_arg[1]);
575 else {
576 tprintf(", {entry_number:%d, ", copy.entry_number);
577 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200578 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000579 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000580 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000581 }
582 }
583 tprintf(", %lu", tcp->u_arg[2]);
584 }
585 return 0;
586}
Roland McGrath34e4a692002-12-15 23:58:17 +0000587
588int
Denys Vlasenko12014262011-05-30 14:00:14 +0200589sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000590{
591 struct modify_ldt_ldt_s copy;
592 if (entering(tcp)) {
593 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
594 if (copy.entry_number == -1)
595 tprintf("{entry_number:%d -> ",
596 copy.entry_number);
597 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200598 tprints("{entry_number:");
Roland McGrath34e4a692002-12-15 23:58:17 +0000599 }
600 } else {
601 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
602 tprintf("%d, ", copy.entry_number);
603 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200604 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000605 else {
606 print_ldt_entry(&copy);
607 }
608 } else {
609 tprintf("%lx", tcp->u_arg[0]);
610 }
611 }
612 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000613
Roland McGrath34e4a692002-12-15 23:58:17 +0000614}
615
616int
Denys Vlasenko12014262011-05-30 14:00:14 +0200617sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000618{
619 struct modify_ldt_ldt_s copy;
620 if (exiting(tcp)) {
621 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
622 tprintf("{entry_number:%d, ", copy.entry_number);
623 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200624 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000625 else {
626 print_ldt_entry(&copy);
627 }
628 } else {
629 tprintf("%lx", tcp->u_arg[0]);
630 }
631 }
632 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000633
Roland McGrath34e4a692002-12-15 23:58:17 +0000634}
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100635#endif /* I386 */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000636
Denys Vlasenko84703742012-02-25 02:38:52 +0100637#if defined(M68K)
Andreas Schwab58743222010-05-28 22:28:51 +0200638int
Denys Vlasenko12014262011-05-30 14:00:14 +0200639sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200640{
641 if (entering(tcp))
642 tprintf("%#lx", tcp->u_arg[0]);
643 return 0;
644
645}
646
647int
Denys Vlasenko12014262011-05-30 14:00:14 +0200648sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200649{
650 return RVAL_HEX;
651}
652#endif
653
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000654int
Denys Vlasenko12014262011-05-30 14:00:14 +0200655sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000656{
657 if (entering(tcp)) {
658 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000659 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000660 tprintf(", %lu, ", tcp->u_arg[3]);
661#ifdef MAP_TYPE
662 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
663 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
664#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000665 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000666#endif
667 }
668 return 0;
669}
Roland McGrathb10a3352004-10-07 18:53:12 +0000670
Roland McGrathb10a3352004-10-07 18:53:12 +0000671#define MPOL_DEFAULT 0
672#define MPOL_PREFERRED 1
673#define MPOL_BIND 2
674#define MPOL_INTERLEAVE 3
675
676#define MPOL_F_NODE (1<<0)
677#define MPOL_F_ADDR (1<<1)
678
679#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000680#define MPOL_MF_MOVE (1<<1)
681#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000682
Roland McGrathb10a3352004-10-07 18:53:12 +0000683static const struct xlat policies[] = {
684 { MPOL_DEFAULT, "MPOL_DEFAULT" },
685 { MPOL_PREFERRED, "MPOL_PREFERRED" },
686 { MPOL_BIND, "MPOL_BIND" },
687 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
688 { 0, NULL }
689};
690
691static const struct xlat mbindflags[] = {
692 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000693 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
694 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000695 { 0, NULL }
696};
697
698static const struct xlat mempolicyflags[] = {
699 { MPOL_F_NODE, "MPOL_F_NODE" },
700 { MPOL_F_ADDR, "MPOL_F_ADDR" },
701 { 0, NULL }
702};
703
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000704static const struct xlat move_pages_flags[] = {
705 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
706 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
707 { 0, NULL }
708};
709
Roland McGrathb10a3352004-10-07 18:53:12 +0000710static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200711get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000712{
Roland McGrathaa524c82005-06-01 19:22:06 +0000713 unsigned long nlongs, size, end;
714
715 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
716 size = nlongs * sizeof(long);
717 end = ptr + size;
718 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
719 && (end > ptr))) {
720 unsigned long n, cur, abbrev_end;
721 int failed = 0;
722
723 if (abbrev(tcp)) {
724 abbrev_end = ptr + max_strlen * sizeof(long);
725 if (abbrev_end < ptr)
726 abbrev_end = end;
727 } else {
728 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000729 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200730 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +0000731 for (cur = ptr; cur < end; cur += sizeof(long)) {
732 if (cur > ptr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200733 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000734 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200735 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000736 break;
737 }
738 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200739 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000740 failed = 1;
741 break;
742 }
743 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
744 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200745 tprints("}");
Roland McGrathaa524c82005-06-01 19:22:06 +0000746 if (failed)
747 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000748 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000749 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000750 tprintf(", %lu", maxnodes);
751}
752
753int
Denys Vlasenko12014262011-05-30 14:00:14 +0200754sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000755{
756 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000757 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000758 printxval(policies, tcp->u_arg[2], "MPOL_???");
759 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200760 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000761 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000762 }
763 return 0;
764}
765
766int
Denys Vlasenko12014262011-05-30 14:00:14 +0200767sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000768{
769 if (entering(tcp)) {
770 printxval(policies, tcp->u_arg[0], "MPOL_???");
771 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
772 }
773 return 0;
774}
775
776int
Denys Vlasenko12014262011-05-30 14:00:14 +0200777sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000778{
779 if (exiting(tcp)) {
780 int pol;
781 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200782 tprints("NULL");
Roland McGrathb10a3352004-10-07 18:53:12 +0000783 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
784 tprintf("%#lx", tcp->u_arg[0]);
785 else
786 printxval(policies, pol, "MPOL_???");
787 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
788 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000789 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000790 }
791 return 0;
792}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000793
794int
Dmitry V. Levin64d0e712012-03-11 22:44:14 +0000795sys_migrate_pages(struct tcb *tcp)
796{
797 if (entering(tcp)) {
798 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
799 get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0);
800 tprints(", ");
801 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0);
802 }
803 return 0;
804}
805
806int
Denys Vlasenko12014262011-05-30 14:00:14 +0200807sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000808{
809 if (entering(tcp)) {
810 unsigned long npages = tcp->u_arg[1];
811 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
812 if (tcp->u_arg[2] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200813 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000814 else {
815 int i;
816 long puser = tcp->u_arg[2];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200817 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000818 for (i = 0; i < npages; ++i) {
819 void *p;
820 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200821 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000822 if (umove(tcp, puser, &p) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200823 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000824 break;
825 }
826 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200827 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000828 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200829 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000830 }
831 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200832 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000833 else {
834 int i;
835 long nodeuser = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200836 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000837 for (i = 0; i < npages; ++i) {
838 int node;
839 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200840 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000841 if (umove(tcp, nodeuser, &node) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200842 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000843 break;
844 }
845 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200846 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000847 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200848 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000849 }
850 }
851 if (exiting(tcp)) {
852 unsigned long npages = tcp->u_arg[1];
853 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200854 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000855 else {
856 int i;
857 long statususer = tcp->u_arg[4];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200858 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000859 for (i = 0; i < npages; ++i) {
860 int status;
861 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200862 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000863 if (umove(tcp, statususer, &status) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200864 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000865 break;
866 }
867 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200868 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000869 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200870 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000871 }
872 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
873 }
874 return 0;
875}
Roland McGrath4a6f6522008-08-25 03:09:16 +0000876
Denys Vlasenko84703742012-02-25 02:38:52 +0100877#if defined(POWERPC)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000878int
Denys Vlasenko12014262011-05-30 14:00:14 +0200879sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000880{
881 if (entering(tcp)) {
882 unsigned long cur, end, abbrev_end, entries;
883 unsigned int entry;
884
885 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
886 entries = tcp->u_arg[1] >> 16;
887 if (!entries || !tcp->u_arg[2]) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200888 tprints("{}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000889 return 0;
890 }
891 cur = tcp->u_arg[2];
892 end = cur + (sizeof(int) * entries);
893 if (!verbose(tcp) || end < tcp->u_arg[2]) {
894 tprintf("%#lx", tcp->u_arg[2]);
895 return 0;
896 }
897 if (abbrev(tcp)) {
898 abbrev_end = cur + (sizeof(int) * max_strlen);
899 if (abbrev_end > end)
900 abbrev_end = end;
901 }
902 else
903 abbrev_end = end;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200904 tprints("{");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000905 for (; cur < end; cur += sizeof(int)) {
906 if (cur > tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200907 tprints(", ");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000908 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200909 tprints("...");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000910 break;
911 }
912 if (umove(tcp, cur, &entry) < 0) {
913 tprintf("??? [%#lx]", cur);
914 break;
915 }
916 else
917 tprintf("%#08x", entry);
918 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200919 tprints("}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000920 }
921
922 return 0;
923}
924#endif