blob: 6f22922d623e3e871c01933413cabe0be9ad9aed [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
43#include <sys/user.h> /* for PAGE_SHIFT */
Denys Vlasenko84703742012-02-25 02:38:52 +010044#if defined(SH64)
Denys Vlasenko1ba85432013-02-19 11:28:20 +010045# include <asm/page.h> /* for PAGE_SHIFT */
46#endif
47#if !defined(PAGE_SHIFT)
48# warning Failed to get PAGE_SHIFT, assuming 12
49# define PAGE_SHIFT 12
Roland McGrathe1e584b2003-06-02 19:18:58 +000050#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051
52int
Denys Vlasenko12014262011-05-30 14:00:14 +020053sys_brk(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000054{
55 if (entering(tcp)) {
56 tprintf("%#lx", tcp->u_arg[0]);
57 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000058 return RVAL_HEX;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000059}
60
Roland McGrathd9f816f2004-09-04 03:39:20 +000061static const struct xlat mmap_prot[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000062 { PROT_NONE, "PROT_NONE", },
63 { PROT_READ, "PROT_READ" },
64 { PROT_WRITE, "PROT_WRITE" },
65 { PROT_EXEC, "PROT_EXEC" },
Roland McGrath47eb0e22003-09-25 23:06:04 +000066#ifdef PROT_SEM
67 { PROT_SEM, "PROT_SEM" },
68#endif
69#ifdef PROT_GROWSDOWN
70 { PROT_GROWSDOWN,"PROT_GROWSDOWN"},
71#endif
72#ifdef PROT_GROWSUP
73 { PROT_GROWSUP, "PROT_GROWSUP" },
74#endif
Roland McGrath586d6ab2008-08-25 03:00:47 +000075#ifdef PROT_SAO
76 { PROT_SAO, "PROT_SAO" },
77#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000078 { 0, NULL },
79};
80
Roland McGrathd9f816f2004-09-04 03:39:20 +000081static const struct xlat mmap_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082 { MAP_SHARED, "MAP_SHARED" },
83 { MAP_PRIVATE, "MAP_PRIVATE" },
84 { MAP_FIXED, "MAP_FIXED" },
85#ifdef MAP_ANONYMOUS
86 { MAP_ANONYMOUS,"MAP_ANONYMOUS" },
87#endif
Dmitry V. Levin71f1a132007-03-29 23:30:09 +000088#ifdef MAP_32BIT
89 { MAP_32BIT, "MAP_32BIT" },
90#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000091#ifdef MAP_RENAME
92 { MAP_RENAME, "MAP_RENAME" },
93#endif
94#ifdef MAP_NORESERVE
95 { MAP_NORESERVE,"MAP_NORESERVE" },
96#endif
Roland McGrath72c5b7b2003-03-05 04:08:00 +000097#ifdef MAP_POPULATE
98 { MAP_POPULATE, "MAP_POPULATE" },
99#endif
100#ifdef MAP_NONBLOCK
101 { MAP_NONBLOCK, "MAP_NONBLOCK" },
102#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000103 /*
104 * XXX - this was introduced in SunOS 4.x to distinguish between
105 * the old pre-4.x "mmap()", which:
106 *
107 * only let you map devices with an "mmap" routine (e.g.,
108 * frame buffers) in;
109 *
110 * required you to specify the mapping address;
111 *
112 * returned 0 on success and -1 on failure;
113 *
114 * memory and which, and the 4.x "mmap()" which:
115 *
116 * can map plain files;
117 *
118 * can be asked to pick where to map the file;
119 *
120 * returns the address where it mapped the file on success
121 * and -1 on failure.
122 *
123 * It's not actually used in source code that calls "mmap()"; the
124 * "mmap()" routine adds it for you.
125 *
126 * It'd be nice to come up with some way of eliminating it from
127 * the flags, e.g. reporting calls *without* it as "old_mmap()"
128 * and calls with it as "mmap()".
129 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000130#ifdef _MAP_NEW
131 { _MAP_NEW, "_MAP_NEW" },
132#endif
133#ifdef MAP_GROWSDOWN
134 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
135#endif
136#ifdef MAP_DENYWRITE
137 { MAP_DENYWRITE,"MAP_DENYWRITE" },
138#endif
139#ifdef MAP_EXECUTABLE
140 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
141#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000142#ifdef MAP_INHERIT
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100143 { MAP_INHERIT, "MAP_INHERIT" },
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000144#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000145#ifdef MAP_FILE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100146 { MAP_FILE, "MAP_FILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000147#endif
148#ifdef MAP_LOCKED
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100149 { MAP_LOCKED, "MAP_LOCKED" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000150#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000151 /* FreeBSD ones */
Denys Vlasenko2897fb32012-03-17 01:29:40 +0100152#if defined(MAP_ANON) && (!defined(MAP_ANONYMOUS) || MAP_ANON != MAP_ANONYMOUS)
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100153 { MAP_ANON, "MAP_ANON" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000154#endif
155#ifdef MAP_HASSEMAPHORE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100156 { MAP_HASSEMAPHORE,"MAP_HASSEMAPHORE"},
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000157#endif
158#ifdef MAP_STACK
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100159 { MAP_STACK, "MAP_STACK" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000160#endif
Bernhard Reutner-Fischer21ceeb42013-02-05 19:31:55 +0100161#if defined MAP_UNINITIALIZED && MAP_UNINITIALIZED > 0
162 { MAP_UNINITIALIZED,"MAP_UNINITIALIZED"},
163#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000164#ifdef MAP_NOSYNC
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100165 { MAP_NOSYNC, "MAP_NOSYNC" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000166#endif
167#ifdef MAP_NOCORE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100168 { MAP_NOCORE, "MAP_NOCORE" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000169#endif
Chris Metcalfc8c66982009-12-28 10:00:15 -0500170#ifdef TILE
171 { MAP_CACHE_NO_LOCAL, "MAP_CACHE_NO_LOCAL" },
172 { MAP_CACHE_NO_L2, "MAP_CACHE_NO_L2" },
173 { MAP_CACHE_NO_L1, "MAP_CACHE_NO_L1" },
174#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175 { 0, NULL },
176};
177
Chris Metcalfc8c66982009-12-28 10:00:15 -0500178#ifdef TILE
Denys Vlasenko72a58482011-08-19 16:01:51 +0200179static int
180addtileflags(long flags)
Chris Metcalfc8c66982009-12-28 10:00:15 -0500181{
182 long home = flags & _MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
183 flags &= ~_MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
184
185 if (flags & _MAP_CACHE_INCOHERENT) {
186 flags &= ~_MAP_CACHE_INCOHERENT;
187 if (home == MAP_CACHE_HOME_NONE) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200188 tprints("|MAP_CACHE_INCOHERENT");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500189 return flags;
190 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200191 tprints("|_MAP_CACHE_INCOHERENT");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500192 }
193
194 switch (home) {
195 case 0: break;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200196 case MAP_CACHE_HOME_HERE: tprints("|MAP_CACHE_HOME_HERE"); break;
197 case MAP_CACHE_HOME_NONE: tprints("|MAP_CACHE_HOME_NONE"); break;
198 case MAP_CACHE_HOME_SINGLE: tprints("|MAP_CACHE_HOME_SINGLE"); break;
199 case MAP_CACHE_HOME_TASK: tprints("|MAP_CACHE_HOME_TASK"); break;
200 case MAP_CACHE_HOME_HASH: tprints("|MAP_CACHE_HOME_HASH"); break;
Chris Metcalfc8c66982009-12-28 10:00:15 -0500201 default:
Chris Metcalf0b99a8a2013-02-05 17:48:33 +0100202 tprintf("|MAP_CACHE_HOME(%ld)",
Chris Metcalfc8c66982009-12-28 10:00:15 -0500203 (home >> _MAP_CACHE_HOME_SHIFT) );
204 break;
205 }
206
207 return flags;
208}
209#endif
210
Dmitry V. Levin31382132011-03-04 05:08:02 +0300211static int
Denys Vlasenko923255c2013-02-18 02:36:36 +0100212print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000213{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000214 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000215 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +0000216 if (!u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200217 tprints("NULL, ");
Wichert Akkerman8829a551999-06-11 13:18:40 +0000218 else
219 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000220 /* len */
221 tprintf("%lu, ", u_arg[1]);
222 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000223 printflags(mmap_prot, u_arg[2], "PROT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200224 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000225 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000226#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000227 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
Denys Vlasenko923255c2013-02-18 02:36:36 +0100228# ifdef TILE
Chris Metcalfc8c66982009-12-28 10:00:15 -0500229 addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE));
Denys Vlasenko923255c2013-02-18 02:36:36 +0100230# else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000231 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Denys Vlasenko923255c2013-02-18 02:36:36 +0100232# endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000233#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000234 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000235#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200236 tprints(", ");
Denys Vlasenko923255c2013-02-18 02:36:36 +0100237 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300238 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000239 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300240 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000241 }
242 return RVAL_HEX;
243}
244
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100245/* Syscall name<->function correspondence is messed up on many arches.
246 * For example:
247 * i386 has __NR_mmap == 90, and it is "old mmap", and
248 * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets".
249 * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets".
250 * Confused? Me too!
251 */
252
253/* Params are pointed to by u_arg[0], offset is in bytes */
254int
255sys_old_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000256{
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100257 long u_arg[6];
Denys Vlasenko72a58482011-08-19 16:01:51 +0200258#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000259 /*
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200260 * IA64 processes never call this routine, they only use the
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100261 * new 'sys_mmap' interface. Only IA32 processes come here.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000262 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200263 int i;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100264 unsigned narrow_arg[6];
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200265 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
266 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000267 for (i = 0; i < 6; i++)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100268 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100269#elif defined(X86_64)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100270 /* We are here only in personality 1 (i386) */
271 int i;
272 unsigned narrow_arg[6];
273 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
274 return 0;
275 for (i = 0; i < 6; ++i)
276 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100277#else
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200278 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000279 return 0;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100280#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100281 return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000282}
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000283
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100284#if defined(S390)
285/* Params are pointed to by u_arg[0], offset is in pages */
286int
287sys_old_mmap_pgoff(struct tcb *tcp)
288{
289 long u_arg[5];
290 int i;
291 unsigned narrow_arg[6];
292 unsigned long long offset;
293 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
294 return 0;
295 for (i = 0; i < 5; i++)
296 u_arg[i] = (unsigned long) narrow_arg[i];
297 offset = narrow_arg[5];
298 offset <<= PAGE_SHIFT;
299 return print_mmap(tcp, u_arg, offset);
300}
301#endif
302
303/* Params are passed directly, offset is in bytes */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000304int
Denys Vlasenko12014262011-05-30 14:00:14 +0200305sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000306{
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100307 unsigned long long offset = (unsigned long) tcp->u_arg[5];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100308#if defined(LINUX_MIPSN32) || defined(X32)
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100309 /* Try test/x32_mmap.c */
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000310 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000311#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100312 /* Example of kernel-side handling of this variety of mmap:
313 * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls
314 * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes,
315 * since the above code converts off to pages.
316 */
317 return print_mmap(tcp, tcp->u_arg, offset);
318}
319
320/* Params are passed directly, offset is in pages */
321int
322sys_mmap_pgoff(struct tcb *tcp)
323{
324 /* Try test/mmap_offset_decode.c */
325 unsigned long long offset;
326 offset = (unsigned long) tcp->u_arg[5];
327 offset <<= PAGE_SHIFT;
328 return print_mmap(tcp, tcp->u_arg, offset);
329}
330
331/* Params are passed directly, offset is in 4k units */
332int
333sys_mmap_4koff(struct tcb *tcp)
334{
335 unsigned long long offset;
336 offset = (unsigned long) tcp->u_arg[5];
337 offset <<= 12;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000338 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000339}
340
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000341int
Denys Vlasenko12014262011-05-30 14:00:14 +0200342sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000343{
344 if (entering(tcp)) {
345 tprintf("%#lx, %lu",
346 tcp->u_arg[0], tcp->u_arg[1]);
347 }
348 return 0;
349}
350
351int
Denys Vlasenko12014262011-05-30 14:00:14 +0200352sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000353{
354 if (entering(tcp)) {
355 tprintf("%#lx, %lu, ",
356 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000357 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000358 }
359 return 0;
360}
361
Roland McGrathd9f816f2004-09-04 03:39:20 +0000362static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000363 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000364#ifdef MREMAP_FIXED
365 { MREMAP_FIXED, "MREMAP_FIXED" },
366#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000367 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000368};
369
370int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000371sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000372{
373 if (entering(tcp)) {
374 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
375 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000376 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000377#ifdef MREMAP_FIXED
378 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
379 (MREMAP_MAYMOVE | MREMAP_FIXED))
380 tprintf(", %#lx", tcp->u_arg[4]);
381#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000382 }
383 return RVAL_HEX;
384}
385
Roland McGrathf4021b12008-08-25 02:59:36 +0000386static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000387#ifdef MADV_NORMAL
388 { MADV_NORMAL, "MADV_NORMAL" },
389#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000390#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000391 { MADV_RANDOM, "MADV_RANDOM" },
392#endif
393#ifdef MADV_SEQUENTIAL
394 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
395#endif
396#ifdef MADV_WILLNEED
397 { MADV_WILLNEED, "MADV_WILLNEED" },
398#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000399#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000400 { MADV_DONTNEED, "MADV_DONTNEED" },
401#endif
402 { 0, NULL },
403};
404
Wichert Akkermanc7926982000-04-10 22:22:31 +0000405int
Denys Vlasenko12014262011-05-30 14:00:14 +0200406sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000407{
408 if (entering(tcp)) {
409 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000410 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000411 }
412 return 0;
413}
414
Roland McGrathd9f816f2004-09-04 03:39:20 +0000415static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000416#ifdef MCL_CURRENT
417 { MCL_CURRENT, "MCL_CURRENT" },
418#endif
419#ifdef MCL_FUTURE
420 { MCL_FUTURE, "MCL_FUTURE" },
421#endif
422 { 0, NULL}
423};
424
425int
Denys Vlasenko12014262011-05-30 14:00:14 +0200426sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000427{
428 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000429 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000430 }
431 return 0;
432}
433
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000434#ifdef MS_ASYNC
435
Roland McGrathd9f816f2004-09-04 03:39:20 +0000436static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000437#ifdef MS_SYNC
438 { MS_SYNC, "MS_SYNC" },
439#endif
John Hughesaca07f32001-10-16 18:12:27 +0000440 { MS_ASYNC, "MS_ASYNC" },
441 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000442 { 0, NULL },
443};
444
445int
Denys Vlasenko12014262011-05-30 14:00:14 +0200446sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000447{
448 if (entering(tcp)) {
449 /* addr */
450 tprintf("%#lx", tcp->u_arg[0]);
451 /* len */
452 tprintf(", %lu, ", tcp->u_arg[1]);
453 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000454 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000455 }
456 return 0;
457}
458
459#endif /* MS_ASYNC */
460
461#ifdef MC_SYNC
462
Roland McGrathd9f816f2004-09-04 03:39:20 +0000463static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000464 { MC_LOCK, "MC_LOCK" },
465 { MC_LOCKAS, "MC_LOCKAS" },
466 { MC_SYNC, "MC_SYNC" },
467 { MC_UNLOCK, "MC_UNLOCK" },
468 { MC_UNLOCKAS, "MC_UNLOCKAS" },
469 { 0, NULL },
470};
471
Roland McGrathd9f816f2004-09-04 03:39:20 +0000472static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000473 { MCL_CURRENT, "MCL_CURRENT" },
474 { MCL_FUTURE, "MCL_FUTURE" },
475 { 0, NULL },
476};
477
478int
Denys Vlasenko12014262011-05-30 14:00:14 +0200479sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000480{
481 int arg, function;
482
483 if (entering(tcp)) {
484 /* addr */
485 tprintf("%#lx", tcp->u_arg[0]);
486 /* len */
487 tprintf(", %lu, ", tcp->u_arg[1]);
488 /* function */
489 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000490 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000491 /* arg */
492 arg = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200493 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000494 switch (function) {
495 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000496 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000497 break;
498 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000499 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000500 break;
501 default:
502 tprintf("%#x", arg);
503 break;
504 }
505 }
506 return 0;
507}
508
509#endif /* MC_SYNC */
510
511int
Denys Vlasenko12014262011-05-30 14:00:14 +0200512sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000513{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000514 if (entering(tcp)) {
515 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
516 } else {
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200517 unsigned long i, len;
518 char *vec = NULL;
519
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000520 len = tcp->u_arg[1];
521 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000522 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000523 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
524 tprintf("%#lx", tcp->u_arg[2]);
525 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200526 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000527 for (i = 0; i < len; i++) {
528 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200529 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000530 break;
531 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200532 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000533 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200534 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000535 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200536 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000537 }
538 return 0;
539}
540
Denys Vlasenko84703742012-02-25 02:38:52 +0100541#if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000542int
Denys Vlasenko12014262011-05-30 14:00:14 +0200543sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000544{
545 if (exiting(tcp))
546 return RVAL_HEX;
547 return 0;
548}
Denys Vlasenko84703742012-02-25 02:38:52 +0100549#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000550
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100551#if defined(I386)
Roland McGrath909875b2002-12-22 03:34:36 +0000552void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000553print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000554{
555 tprintf("base_addr:%#08lx, "
556 "limit:%d, "
557 "seg_32bit:%d, "
558 "contents:%d, "
559 "read_exec_only:%d, "
560 "limit_in_pages:%d, "
561 "seg_not_present:%d, "
562 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000563 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000564 ldt_entry->limit,
565 ldt_entry->seg_32bit,
566 ldt_entry->contents,
567 ldt_entry->read_exec_only,
568 ldt_entry->limit_in_pages,
569 ldt_entry->seg_not_present,
570 ldt_entry->useable);
571}
572
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000573int
Denys Vlasenko12014262011-05-30 14:00:14 +0200574sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000575{
576 if (entering(tcp)) {
577 struct modify_ldt_ldt_s copy;
578 tprintf("%ld", tcp->u_arg[0]);
579 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200580 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000581 || umove(tcp, tcp->u_arg[1], &copy) == -1)
582 tprintf(", %lx", tcp->u_arg[1]);
583 else {
584 tprintf(", {entry_number:%d, ", copy.entry_number);
585 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200586 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000587 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000588 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000589 }
590 }
591 tprintf(", %lu", tcp->u_arg[2]);
592 }
593 return 0;
594}
Roland McGrath34e4a692002-12-15 23:58:17 +0000595
596int
Denys Vlasenko12014262011-05-30 14:00:14 +0200597sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000598{
599 struct modify_ldt_ldt_s copy;
600 if (entering(tcp)) {
601 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
602 if (copy.entry_number == -1)
603 tprintf("{entry_number:%d -> ",
604 copy.entry_number);
605 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200606 tprints("{entry_number:");
Roland McGrath34e4a692002-12-15 23:58:17 +0000607 }
608 } else {
609 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
610 tprintf("%d, ", copy.entry_number);
611 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200612 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000613 else {
614 print_ldt_entry(&copy);
615 }
616 } else {
617 tprintf("%lx", tcp->u_arg[0]);
618 }
619 }
620 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000621
Roland McGrath34e4a692002-12-15 23:58:17 +0000622}
623
624int
Denys Vlasenko12014262011-05-30 14:00:14 +0200625sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000626{
627 struct modify_ldt_ldt_s copy;
628 if (exiting(tcp)) {
629 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
630 tprintf("{entry_number:%d, ", copy.entry_number);
631 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200632 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000633 else {
634 print_ldt_entry(&copy);
635 }
636 } else {
637 tprintf("%lx", tcp->u_arg[0]);
638 }
639 }
640 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000641
Roland McGrath34e4a692002-12-15 23:58:17 +0000642}
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100643#endif /* I386 */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000644
Denys Vlasenko84703742012-02-25 02:38:52 +0100645#if defined(M68K)
Andreas Schwab58743222010-05-28 22:28:51 +0200646int
Denys Vlasenko12014262011-05-30 14:00:14 +0200647sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200648{
649 if (entering(tcp))
650 tprintf("%#lx", tcp->u_arg[0]);
651 return 0;
652
653}
654
655int
Denys Vlasenko12014262011-05-30 14:00:14 +0200656sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200657{
658 return RVAL_HEX;
659}
660#endif
661
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000662int
Denys Vlasenko12014262011-05-30 14:00:14 +0200663sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000664{
665 if (entering(tcp)) {
666 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000667 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000668 tprintf(", %lu, ", tcp->u_arg[3]);
669#ifdef MAP_TYPE
670 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
671 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
672#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000673 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000674#endif
675 }
676 return 0;
677}
Roland McGrathb10a3352004-10-07 18:53:12 +0000678
Roland McGrathb10a3352004-10-07 18:53:12 +0000679#define MPOL_DEFAULT 0
680#define MPOL_PREFERRED 1
681#define MPOL_BIND 2
682#define MPOL_INTERLEAVE 3
683
684#define MPOL_F_NODE (1<<0)
685#define MPOL_F_ADDR (1<<1)
686
687#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000688#define MPOL_MF_MOVE (1<<1)
689#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000690
Roland McGrathb10a3352004-10-07 18:53:12 +0000691static const struct xlat policies[] = {
692 { MPOL_DEFAULT, "MPOL_DEFAULT" },
693 { MPOL_PREFERRED, "MPOL_PREFERRED" },
694 { MPOL_BIND, "MPOL_BIND" },
695 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
696 { 0, NULL }
697};
698
699static const struct xlat mbindflags[] = {
700 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000701 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
702 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000703 { 0, NULL }
704};
705
706static const struct xlat mempolicyflags[] = {
707 { MPOL_F_NODE, "MPOL_F_NODE" },
708 { MPOL_F_ADDR, "MPOL_F_ADDR" },
709 { 0, NULL }
710};
711
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000712static const struct xlat move_pages_flags[] = {
713 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
714 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
715 { 0, NULL }
716};
717
Roland McGrathb10a3352004-10-07 18:53:12 +0000718static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200719get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000720{
Roland McGrathaa524c82005-06-01 19:22:06 +0000721 unsigned long nlongs, size, end;
722
723 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
724 size = nlongs * sizeof(long);
725 end = ptr + size;
726 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
727 && (end > ptr))) {
728 unsigned long n, cur, abbrev_end;
729 int failed = 0;
730
731 if (abbrev(tcp)) {
732 abbrev_end = ptr + max_strlen * sizeof(long);
733 if (abbrev_end < ptr)
734 abbrev_end = end;
735 } else {
736 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000737 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200738 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +0000739 for (cur = ptr; cur < end; cur += sizeof(long)) {
740 if (cur > ptr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200741 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000742 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200743 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000744 break;
745 }
746 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200747 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000748 failed = 1;
749 break;
750 }
751 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
752 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200753 tprints("}");
Roland McGrathaa524c82005-06-01 19:22:06 +0000754 if (failed)
755 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000756 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000757 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000758 tprintf(", %lu", maxnodes);
759}
760
761int
Denys Vlasenko12014262011-05-30 14:00:14 +0200762sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000763{
764 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000765 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000766 printxval(policies, tcp->u_arg[2], "MPOL_???");
767 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200768 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000769 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000770 }
771 return 0;
772}
773
774int
Denys Vlasenko12014262011-05-30 14:00:14 +0200775sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000776{
777 if (entering(tcp)) {
778 printxval(policies, tcp->u_arg[0], "MPOL_???");
779 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
780 }
781 return 0;
782}
783
784int
Denys Vlasenko12014262011-05-30 14:00:14 +0200785sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000786{
787 if (exiting(tcp)) {
788 int pol;
789 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200790 tprints("NULL");
Roland McGrathb10a3352004-10-07 18:53:12 +0000791 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
792 tprintf("%#lx", tcp->u_arg[0]);
793 else
794 printxval(policies, pol, "MPOL_???");
795 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
796 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000797 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000798 }
799 return 0;
800}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000801
802int
Dmitry V. Levin64d0e712012-03-11 22:44:14 +0000803sys_migrate_pages(struct tcb *tcp)
804{
805 if (entering(tcp)) {
806 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
807 get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0);
808 tprints(", ");
809 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0);
810 }
811 return 0;
812}
813
814int
Denys Vlasenko12014262011-05-30 14:00:14 +0200815sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000816{
817 if (entering(tcp)) {
818 unsigned long npages = tcp->u_arg[1];
819 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
820 if (tcp->u_arg[2] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200821 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000822 else {
823 int i;
824 long puser = tcp->u_arg[2];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200825 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000826 for (i = 0; i < npages; ++i) {
827 void *p;
828 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200829 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000830 if (umove(tcp, puser, &p) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200831 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000832 break;
833 }
834 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200835 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000836 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200837 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000838 }
839 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200840 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000841 else {
842 int i;
843 long nodeuser = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200844 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000845 for (i = 0; i < npages; ++i) {
846 int node;
847 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200848 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000849 if (umove(tcp, nodeuser, &node) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200850 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000851 break;
852 }
853 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200854 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000855 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200856 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000857 }
858 }
859 if (exiting(tcp)) {
860 unsigned long npages = tcp->u_arg[1];
861 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200862 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000863 else {
864 int i;
865 long statususer = tcp->u_arg[4];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200866 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000867 for (i = 0; i < npages; ++i) {
868 int status;
869 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200870 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000871 if (umove(tcp, statususer, &status) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200872 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000873 break;
874 }
875 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200876 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000877 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200878 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000879 }
880 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
881 }
882 return 0;
883}
Roland McGrath4a6f6522008-08-25 03:09:16 +0000884
Denys Vlasenko84703742012-02-25 02:38:52 +0100885#if defined(POWERPC)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000886int
Denys Vlasenko12014262011-05-30 14:00:14 +0200887sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000888{
889 if (entering(tcp)) {
890 unsigned long cur, end, abbrev_end, entries;
891 unsigned int entry;
892
893 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
894 entries = tcp->u_arg[1] >> 16;
895 if (!entries || !tcp->u_arg[2]) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200896 tprints("{}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000897 return 0;
898 }
899 cur = tcp->u_arg[2];
900 end = cur + (sizeof(int) * entries);
901 if (!verbose(tcp) || end < tcp->u_arg[2]) {
902 tprintf("%#lx", tcp->u_arg[2]);
903 return 0;
904 }
905 if (abbrev(tcp)) {
906 abbrev_end = cur + (sizeof(int) * max_strlen);
907 if (abbrev_end > end)
908 abbrev_end = end;
909 }
910 else
911 abbrev_end = end;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200912 tprints("{");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000913 for (; cur < end; cur += sizeof(int)) {
914 if (cur > tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200915 tprints(", ");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000916 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200917 tprints("...");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000918 break;
919 }
920 if (umove(tcp, cur, &entry) < 0) {
921 tprintf("??? [%#lx]", cur);
922 break;
923 }
924 else
925 tprintf("%#08x", entry);
926 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200927 tprints("}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000928 }
929
930 return 0;
931}
932#endif