blob: 3bd41b46c5669751823789ceb64174ed7db0fbd7 [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
Chris Metcalfc8c66982009-12-28 10:00:15 -0500171#ifdef TILE
172 { MAP_CACHE_NO_LOCAL, "MAP_CACHE_NO_LOCAL" },
173 { MAP_CACHE_NO_L2, "MAP_CACHE_NO_L2" },
174 { MAP_CACHE_NO_L1, "MAP_CACHE_NO_L1" },
175#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000176 { 0, NULL },
177};
178
Chris Metcalfc8c66982009-12-28 10:00:15 -0500179#ifdef TILE
Denys Vlasenko72a58482011-08-19 16:01:51 +0200180static int
181addtileflags(long flags)
Chris Metcalfc8c66982009-12-28 10:00:15 -0500182{
183 long home = flags & _MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
184 flags &= ~_MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
185
186 if (flags & _MAP_CACHE_INCOHERENT) {
187 flags &= ~_MAP_CACHE_INCOHERENT;
188 if (home == MAP_CACHE_HOME_NONE) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200189 tprints("|MAP_CACHE_INCOHERENT");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500190 return flags;
191 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200192 tprints("|_MAP_CACHE_INCOHERENT");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500193 }
194
195 switch (home) {
196 case 0: break;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200197 case MAP_CACHE_HOME_HERE: tprints("|MAP_CACHE_HOME_HERE"); break;
198 case MAP_CACHE_HOME_NONE: tprints("|MAP_CACHE_HOME_NONE"); break;
199 case MAP_CACHE_HOME_SINGLE: tprints("|MAP_CACHE_HOME_SINGLE"); break;
200 case MAP_CACHE_HOME_TASK: tprints("|MAP_CACHE_HOME_TASK"); break;
201 case MAP_CACHE_HOME_HASH: tprints("|MAP_CACHE_HOME_HASH"); break;
Chris Metcalfc8c66982009-12-28 10:00:15 -0500202 default:
Chris Metcalf0b99a8a2013-02-05 17:48:33 +0100203 tprintf("|MAP_CACHE_HOME(%ld)",
Chris Metcalfc8c66982009-12-28 10:00:15 -0500204 (home >> _MAP_CACHE_HOME_SHIFT) );
205 break;
206 }
207
208 return flags;
209}
210#endif
211
Dmitry V. Levin31382132011-03-04 05:08:02 +0300212static int
Denys Vlasenko923255c2013-02-18 02:36:36 +0100213print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000214{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000215 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000216 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +0000217 if (!u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200218 tprints("NULL, ");
Wichert Akkerman8829a551999-06-11 13:18:40 +0000219 else
220 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000221 /* len */
222 tprintf("%lu, ", u_arg[1]);
223 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000224 printflags(mmap_prot, u_arg[2], "PROT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200225 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000226 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000227#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000228 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
Denys Vlasenko923255c2013-02-18 02:36:36 +0100229# ifdef TILE
Chris Metcalfc8c66982009-12-28 10:00:15 -0500230 addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE));
Denys Vlasenko923255c2013-02-18 02:36:36 +0100231# else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000232 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Denys Vlasenko923255c2013-02-18 02:36:36 +0100233# endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000234#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000235 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000236#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200237 tprints(", ");
Denys Vlasenko923255c2013-02-18 02:36:36 +0100238 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300239 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000240 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300241 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000242 }
243 return RVAL_HEX;
244}
245
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100246/* Syscall name<->function correspondence is messed up on many arches.
247 * For example:
248 * i386 has __NR_mmap == 90, and it is "old mmap", and
249 * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets".
250 * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets".
251 * Confused? Me too!
252 */
253
254/* Params are pointed to by u_arg[0], offset is in bytes */
255int
256sys_old_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000257{
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100258 long u_arg[6];
Denys Vlasenko72a58482011-08-19 16:01:51 +0200259#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000260 /*
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200261 * IA64 processes never call this routine, they only use the
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100262 * new 'sys_mmap' interface. Only IA32 processes come here.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000263 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200264 int i;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100265 unsigned narrow_arg[6];
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200266 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
267 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000268 for (i = 0; i < 6; i++)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100269 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100270#elif defined(X86_64)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100271 /* We are here only in personality 1 (i386) */
272 int i;
273 unsigned narrow_arg[6];
274 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
275 return 0;
276 for (i = 0; i < 6; ++i)
277 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100278#else
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200279 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000280 return 0;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100281#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100282 return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000283}
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000284
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100285#if defined(S390)
286/* Params are pointed to by u_arg[0], offset is in pages */
287int
288sys_old_mmap_pgoff(struct tcb *tcp)
289{
290 long u_arg[5];
291 int i;
292 unsigned narrow_arg[6];
293 unsigned long long offset;
294 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
295 return 0;
296 for (i = 0; i < 5; i++)
297 u_arg[i] = (unsigned long) narrow_arg[i];
298 offset = narrow_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000299 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100300 return print_mmap(tcp, u_arg, offset);
301}
302#endif
303
304/* Params are passed directly, offset is in bytes */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000305int
Denys Vlasenko12014262011-05-30 14:00:14 +0200306sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000307{
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100308 unsigned long long offset = (unsigned long) tcp->u_arg[5];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100309#if defined(LINUX_MIPSN32) || defined(X32)
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100310 /* Try test/x32_mmap.c */
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000311 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000312#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100313 /* Example of kernel-side handling of this variety of mmap:
314 * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls
315 * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes,
316 * since the above code converts off to pages.
317 */
318 return print_mmap(tcp, tcp->u_arg, offset);
319}
320
321/* Params are passed directly, offset is in pages */
322int
323sys_mmap_pgoff(struct tcb *tcp)
324{
325 /* Try test/mmap_offset_decode.c */
326 unsigned long long offset;
327 offset = (unsigned long) tcp->u_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000328 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100329 return print_mmap(tcp, tcp->u_arg, offset);
330}
331
332/* Params are passed directly, offset is in 4k units */
333int
334sys_mmap_4koff(struct tcb *tcp)
335{
336 unsigned long long offset;
337 offset = (unsigned long) tcp->u_arg[5];
338 offset <<= 12;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000339 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000340}
341
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000342int
Denys Vlasenko12014262011-05-30 14:00:14 +0200343sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000344{
345 if (entering(tcp)) {
346 tprintf("%#lx, %lu",
347 tcp->u_arg[0], tcp->u_arg[1]);
348 }
349 return 0;
350}
351
352int
Denys Vlasenko12014262011-05-30 14:00:14 +0200353sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000354{
355 if (entering(tcp)) {
356 tprintf("%#lx, %lu, ",
357 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000358 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000359 }
360 return 0;
361}
362
Roland McGrathd9f816f2004-09-04 03:39:20 +0000363static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000364 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000365#ifdef MREMAP_FIXED
366 { MREMAP_FIXED, "MREMAP_FIXED" },
367#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000368 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000369};
370
371int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000372sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000373{
374 if (entering(tcp)) {
375 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
376 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000377 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000378#ifdef MREMAP_FIXED
379 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
380 (MREMAP_MAYMOVE | MREMAP_FIXED))
381 tprintf(", %#lx", tcp->u_arg[4]);
382#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000383 }
384 return RVAL_HEX;
385}
386
Roland McGrathf4021b12008-08-25 02:59:36 +0000387static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000388#ifdef MADV_NORMAL
389 { MADV_NORMAL, "MADV_NORMAL" },
390#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000391#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000392 { MADV_RANDOM, "MADV_RANDOM" },
393#endif
394#ifdef MADV_SEQUENTIAL
395 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
396#endif
397#ifdef MADV_WILLNEED
398 { MADV_WILLNEED, "MADV_WILLNEED" },
399#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000400#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000401 { MADV_DONTNEED, "MADV_DONTNEED" },
402#endif
403 { 0, NULL },
404};
405
Wichert Akkermanc7926982000-04-10 22:22:31 +0000406int
Denys Vlasenko12014262011-05-30 14:00:14 +0200407sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000408{
409 if (entering(tcp)) {
410 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000411 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000412 }
413 return 0;
414}
415
Roland McGrathd9f816f2004-09-04 03:39:20 +0000416static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000417#ifdef MCL_CURRENT
418 { MCL_CURRENT, "MCL_CURRENT" },
419#endif
420#ifdef MCL_FUTURE
421 { MCL_FUTURE, "MCL_FUTURE" },
422#endif
423 { 0, NULL}
424};
425
426int
Denys Vlasenko12014262011-05-30 14:00:14 +0200427sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000428{
429 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000430 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000431 }
432 return 0;
433}
434
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000435#ifdef MS_ASYNC
436
Roland McGrathd9f816f2004-09-04 03:39:20 +0000437static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000438#ifdef MS_SYNC
439 { MS_SYNC, "MS_SYNC" },
440#endif
John Hughesaca07f32001-10-16 18:12:27 +0000441 { MS_ASYNC, "MS_ASYNC" },
442 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000443 { 0, NULL },
444};
445
446int
Denys Vlasenko12014262011-05-30 14:00:14 +0200447sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000448{
449 if (entering(tcp)) {
450 /* addr */
451 tprintf("%#lx", tcp->u_arg[0]);
452 /* len */
453 tprintf(", %lu, ", tcp->u_arg[1]);
454 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000455 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000456 }
457 return 0;
458}
459
460#endif /* MS_ASYNC */
461
462#ifdef MC_SYNC
463
Roland McGrathd9f816f2004-09-04 03:39:20 +0000464static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000465 { MC_LOCK, "MC_LOCK" },
466 { MC_LOCKAS, "MC_LOCKAS" },
467 { MC_SYNC, "MC_SYNC" },
468 { MC_UNLOCK, "MC_UNLOCK" },
469 { MC_UNLOCKAS, "MC_UNLOCKAS" },
470 { 0, NULL },
471};
472
Roland McGrathd9f816f2004-09-04 03:39:20 +0000473static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000474 { MCL_CURRENT, "MCL_CURRENT" },
475 { MCL_FUTURE, "MCL_FUTURE" },
476 { 0, NULL },
477};
478
479int
Denys Vlasenko12014262011-05-30 14:00:14 +0200480sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000481{
482 int arg, function;
483
484 if (entering(tcp)) {
485 /* addr */
486 tprintf("%#lx", tcp->u_arg[0]);
487 /* len */
488 tprintf(", %lu, ", tcp->u_arg[1]);
489 /* function */
490 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000491 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000492 /* arg */
493 arg = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200494 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000495 switch (function) {
496 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000497 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000498 break;
499 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000500 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000501 break;
502 default:
503 tprintf("%#x", arg);
504 break;
505 }
506 }
507 return 0;
508}
509
510#endif /* MC_SYNC */
511
512int
Denys Vlasenko12014262011-05-30 14:00:14 +0200513sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000514{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000515 if (entering(tcp)) {
516 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
517 } else {
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200518 unsigned long i, len;
519 char *vec = NULL;
520
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000521 len = tcp->u_arg[1];
522 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000523 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000524 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
525 tprintf("%#lx", tcp->u_arg[2]);
526 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200527 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000528 for (i = 0; i < len; i++) {
529 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200530 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000531 break;
532 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200533 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000534 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200535 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000536 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200537 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000538 }
539 return 0;
540}
541
Denys Vlasenko84703742012-02-25 02:38:52 +0100542#if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000543int
Denys Vlasenko12014262011-05-30 14:00:14 +0200544sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000545{
546 if (exiting(tcp))
547 return RVAL_HEX;
548 return 0;
549}
Denys Vlasenko84703742012-02-25 02:38:52 +0100550#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000551
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100552#if defined(I386)
Roland McGrath909875b2002-12-22 03:34:36 +0000553void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000554print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000555{
556 tprintf("base_addr:%#08lx, "
557 "limit:%d, "
558 "seg_32bit:%d, "
559 "contents:%d, "
560 "read_exec_only:%d, "
561 "limit_in_pages:%d, "
562 "seg_not_present:%d, "
563 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000564 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000565 ldt_entry->limit,
566 ldt_entry->seg_32bit,
567 ldt_entry->contents,
568 ldt_entry->read_exec_only,
569 ldt_entry->limit_in_pages,
570 ldt_entry->seg_not_present,
571 ldt_entry->useable);
572}
573
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000574int
Denys Vlasenko12014262011-05-30 14:00:14 +0200575sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000576{
577 if (entering(tcp)) {
578 struct modify_ldt_ldt_s copy;
579 tprintf("%ld", tcp->u_arg[0]);
580 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200581 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000582 || umove(tcp, tcp->u_arg[1], &copy) == -1)
583 tprintf(", %lx", tcp->u_arg[1]);
584 else {
585 tprintf(", {entry_number:%d, ", copy.entry_number);
586 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200587 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000588 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000589 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000590 }
591 }
592 tprintf(", %lu", tcp->u_arg[2]);
593 }
594 return 0;
595}
Roland McGrath34e4a692002-12-15 23:58:17 +0000596
597int
Denys Vlasenko12014262011-05-30 14:00:14 +0200598sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000599{
600 struct modify_ldt_ldt_s copy;
601 if (entering(tcp)) {
602 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
603 if (copy.entry_number == -1)
604 tprintf("{entry_number:%d -> ",
605 copy.entry_number);
606 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200607 tprints("{entry_number:");
Roland McGrath34e4a692002-12-15 23:58:17 +0000608 }
609 } else {
610 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
611 tprintf("%d, ", copy.entry_number);
612 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200613 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000614 else {
615 print_ldt_entry(&copy);
616 }
617 } else {
618 tprintf("%lx", tcp->u_arg[0]);
619 }
620 }
621 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000622
Roland McGrath34e4a692002-12-15 23:58:17 +0000623}
624
625int
Denys Vlasenko12014262011-05-30 14:00:14 +0200626sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000627{
628 struct modify_ldt_ldt_s copy;
629 if (exiting(tcp)) {
630 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
631 tprintf("{entry_number:%d, ", copy.entry_number);
632 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200633 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000634 else {
635 print_ldt_entry(&copy);
636 }
637 } else {
638 tprintf("%lx", tcp->u_arg[0]);
639 }
640 }
641 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000642
Roland McGrath34e4a692002-12-15 23:58:17 +0000643}
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100644#endif /* I386 */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000645
Denys Vlasenko84703742012-02-25 02:38:52 +0100646#if defined(M68K)
Andreas Schwab58743222010-05-28 22:28:51 +0200647int
Denys Vlasenko12014262011-05-30 14:00:14 +0200648sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200649{
650 if (entering(tcp))
651 tprintf("%#lx", tcp->u_arg[0]);
652 return 0;
653
654}
655
656int
Denys Vlasenko12014262011-05-30 14:00:14 +0200657sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200658{
659 return RVAL_HEX;
660}
661#endif
662
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000663int
Denys Vlasenko12014262011-05-30 14:00:14 +0200664sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000665{
666 if (entering(tcp)) {
667 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000668 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000669 tprintf(", %lu, ", tcp->u_arg[3]);
670#ifdef MAP_TYPE
671 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
672 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
673#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000674 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000675#endif
676 }
677 return 0;
678}
Roland McGrathb10a3352004-10-07 18:53:12 +0000679
Roland McGrathb10a3352004-10-07 18:53:12 +0000680#define MPOL_DEFAULT 0
681#define MPOL_PREFERRED 1
682#define MPOL_BIND 2
683#define MPOL_INTERLEAVE 3
684
685#define MPOL_F_NODE (1<<0)
686#define MPOL_F_ADDR (1<<1)
687
688#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000689#define MPOL_MF_MOVE (1<<1)
690#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000691
Roland McGrathb10a3352004-10-07 18:53:12 +0000692static const struct xlat policies[] = {
693 { MPOL_DEFAULT, "MPOL_DEFAULT" },
694 { MPOL_PREFERRED, "MPOL_PREFERRED" },
695 { MPOL_BIND, "MPOL_BIND" },
696 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
697 { 0, NULL }
698};
699
700static const struct xlat mbindflags[] = {
701 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000702 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
703 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000704 { 0, NULL }
705};
706
707static const struct xlat mempolicyflags[] = {
708 { MPOL_F_NODE, "MPOL_F_NODE" },
709 { MPOL_F_ADDR, "MPOL_F_ADDR" },
710 { 0, NULL }
711};
712
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000713static const struct xlat move_pages_flags[] = {
714 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
715 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
716 { 0, NULL }
717};
718
Roland McGrathb10a3352004-10-07 18:53:12 +0000719static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200720get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000721{
Roland McGrathaa524c82005-06-01 19:22:06 +0000722 unsigned long nlongs, size, end;
723
724 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
725 size = nlongs * sizeof(long);
726 end = ptr + size;
727 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
728 && (end > ptr))) {
729 unsigned long n, cur, abbrev_end;
730 int failed = 0;
731
732 if (abbrev(tcp)) {
733 abbrev_end = ptr + max_strlen * sizeof(long);
734 if (abbrev_end < ptr)
735 abbrev_end = end;
736 } else {
737 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000738 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200739 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +0000740 for (cur = ptr; cur < end; cur += sizeof(long)) {
741 if (cur > ptr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200742 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000743 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200744 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000745 break;
746 }
747 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200748 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000749 failed = 1;
750 break;
751 }
752 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
753 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200754 tprints("}");
Roland McGrathaa524c82005-06-01 19:22:06 +0000755 if (failed)
756 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000757 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000758 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000759 tprintf(", %lu", maxnodes);
760}
761
762int
Denys Vlasenko12014262011-05-30 14:00:14 +0200763sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000764{
765 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000766 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000767 printxval(policies, tcp->u_arg[2], "MPOL_???");
768 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200769 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000770 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000771 }
772 return 0;
773}
774
775int
Denys Vlasenko12014262011-05-30 14:00:14 +0200776sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000777{
778 if (entering(tcp)) {
779 printxval(policies, tcp->u_arg[0], "MPOL_???");
780 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
781 }
782 return 0;
783}
784
785int
Denys Vlasenko12014262011-05-30 14:00:14 +0200786sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000787{
788 if (exiting(tcp)) {
789 int pol;
790 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200791 tprints("NULL");
Roland McGrathb10a3352004-10-07 18:53:12 +0000792 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
793 tprintf("%#lx", tcp->u_arg[0]);
794 else
795 printxval(policies, pol, "MPOL_???");
796 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
797 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000798 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000799 }
800 return 0;
801}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000802
803int
Dmitry V. Levin64d0e712012-03-11 22:44:14 +0000804sys_migrate_pages(struct tcb *tcp)
805{
806 if (entering(tcp)) {
807 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
808 get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0);
809 tprints(", ");
810 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0);
811 }
812 return 0;
813}
814
815int
Denys Vlasenko12014262011-05-30 14:00:14 +0200816sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000817{
818 if (entering(tcp)) {
819 unsigned long npages = tcp->u_arg[1];
820 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
821 if (tcp->u_arg[2] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200822 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000823 else {
824 int i;
825 long puser = tcp->u_arg[2];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200826 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000827 for (i = 0; i < npages; ++i) {
828 void *p;
829 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200830 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000831 if (umove(tcp, puser, &p) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200832 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000833 break;
834 }
835 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200836 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000837 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200838 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000839 }
840 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200841 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000842 else {
843 int i;
844 long nodeuser = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200845 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000846 for (i = 0; i < npages; ++i) {
847 int node;
848 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200849 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000850 if (umove(tcp, nodeuser, &node) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200851 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000852 break;
853 }
854 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200855 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000856 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200857 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000858 }
859 }
860 if (exiting(tcp)) {
861 unsigned long npages = tcp->u_arg[1];
862 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200863 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000864 else {
865 int i;
866 long statususer = tcp->u_arg[4];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200867 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000868 for (i = 0; i < npages; ++i) {
869 int status;
870 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200871 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000872 if (umove(tcp, statususer, &status) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200873 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000874 break;
875 }
876 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200877 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000878 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200879 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000880 }
881 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
882 }
883 return 0;
884}
Roland McGrath4a6f6522008-08-25 03:09:16 +0000885
Denys Vlasenko84703742012-02-25 02:38:52 +0100886#if defined(POWERPC)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000887int
Denys Vlasenko12014262011-05-30 14:00:14 +0200888sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000889{
890 if (entering(tcp)) {
891 unsigned long cur, end, abbrev_end, entries;
892 unsigned int entry;
893
894 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
895 entries = tcp->u_arg[1] >> 16;
896 if (!entries || !tcp->u_arg[2]) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200897 tprints("{}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000898 return 0;
899 }
900 cur = tcp->u_arg[2];
901 end = cur + (sizeof(int) * entries);
902 if (!verbose(tcp) || end < tcp->u_arg[2]) {
903 tprintf("%#lx", tcp->u_arg[2]);
904 return 0;
905 }
906 if (abbrev(tcp)) {
907 abbrev_end = cur + (sizeof(int) * max_strlen);
908 if (abbrev_end > end)
909 abbrev_end = end;
910 }
911 else
912 abbrev_end = end;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200913 tprints("{");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000914 for (; cur < end; cur += sizeof(int)) {
915 if (cur > tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200916 tprints(", ");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000917 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200918 tprints("...");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000919 break;
920 }
921 if (umove(tcp, cur, &entry) < 0) {
922 tprintf("??? [%#lx]", cur);
923 break;
924 }
925 else
926 tprintf("%#08x", entry);
927 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200928 tprints("}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000929 }
930
931 return 0;
932}
933#endif