blob: b67a1b6509208c57ba4a9b517429007855f9d7ef [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 Vlasenko84703742012-02-25 02:38:52 +010042#if defined(SH64)
Denys Vlasenko72a58482011-08-19 16:01:51 +020043# include <asm/page.h> /* for PAGE_SHIFT */
Roland McGrathe1e584b2003-06-02 19:18:58 +000044#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000045
46int
Denys Vlasenko12014262011-05-30 14:00:14 +020047sys_brk(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000048{
49 if (entering(tcp)) {
50 tprintf("%#lx", tcp->u_arg[0]);
51 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052 return RVAL_HEX;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000053}
54
Roland McGrathd9f816f2004-09-04 03:39:20 +000055static const struct xlat mmap_prot[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000056 { PROT_NONE, "PROT_NONE", },
57 { PROT_READ, "PROT_READ" },
58 { PROT_WRITE, "PROT_WRITE" },
59 { PROT_EXEC, "PROT_EXEC" },
Roland McGrath47eb0e22003-09-25 23:06:04 +000060#ifdef PROT_SEM
61 { PROT_SEM, "PROT_SEM" },
62#endif
63#ifdef PROT_GROWSDOWN
64 { PROT_GROWSDOWN,"PROT_GROWSDOWN"},
65#endif
66#ifdef PROT_GROWSUP
67 { PROT_GROWSUP, "PROT_GROWSUP" },
68#endif
Roland McGrath586d6ab2008-08-25 03:00:47 +000069#ifdef PROT_SAO
70 { PROT_SAO, "PROT_SAO" },
71#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000072 { 0, NULL },
73};
74
Roland McGrathd9f816f2004-09-04 03:39:20 +000075static const struct xlat mmap_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000076 { MAP_SHARED, "MAP_SHARED" },
77 { MAP_PRIVATE, "MAP_PRIVATE" },
78 { MAP_FIXED, "MAP_FIXED" },
79#ifdef MAP_ANONYMOUS
80 { MAP_ANONYMOUS,"MAP_ANONYMOUS" },
81#endif
Dmitry V. Levin71f1a132007-03-29 23:30:09 +000082#ifdef MAP_32BIT
83 { MAP_32BIT, "MAP_32BIT" },
84#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000085#ifdef MAP_RENAME
86 { MAP_RENAME, "MAP_RENAME" },
87#endif
88#ifdef MAP_NORESERVE
89 { MAP_NORESERVE,"MAP_NORESERVE" },
90#endif
Roland McGrath72c5b7b2003-03-05 04:08:00 +000091#ifdef MAP_POPULATE
92 { MAP_POPULATE, "MAP_POPULATE" },
93#endif
94#ifdef MAP_NONBLOCK
95 { MAP_NONBLOCK, "MAP_NONBLOCK" },
96#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +000097 /*
98 * XXX - this was introduced in SunOS 4.x to distinguish between
99 * the old pre-4.x "mmap()", which:
100 *
101 * only let you map devices with an "mmap" routine (e.g.,
102 * frame buffers) in;
103 *
104 * required you to specify the mapping address;
105 *
106 * returned 0 on success and -1 on failure;
107 *
108 * memory and which, and the 4.x "mmap()" which:
109 *
110 * can map plain files;
111 *
112 * can be asked to pick where to map the file;
113 *
114 * returns the address where it mapped the file on success
115 * and -1 on failure.
116 *
117 * It's not actually used in source code that calls "mmap()"; the
118 * "mmap()" routine adds it for you.
119 *
120 * It'd be nice to come up with some way of eliminating it from
121 * the flags, e.g. reporting calls *without* it as "old_mmap()"
122 * and calls with it as "mmap()".
123 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000124#ifdef _MAP_NEW
125 { _MAP_NEW, "_MAP_NEW" },
126#endif
127#ifdef MAP_GROWSDOWN
128 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
129#endif
130#ifdef MAP_DENYWRITE
131 { MAP_DENYWRITE,"MAP_DENYWRITE" },
132#endif
133#ifdef MAP_EXECUTABLE
134 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
135#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000136#ifdef MAP_INHERIT
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100137 { MAP_INHERIT, "MAP_INHERIT" },
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000138#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000139#ifdef MAP_FILE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100140 { MAP_FILE, "MAP_FILE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000141#endif
142#ifdef MAP_LOCKED
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100143 { MAP_LOCKED, "MAP_LOCKED" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000144#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000145 /* FreeBSD ones */
Denys Vlasenko2897fb32012-03-17 01:29:40 +0100146#if defined(MAP_ANON) && (!defined(MAP_ANONYMOUS) || MAP_ANON != MAP_ANONYMOUS)
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100147 { MAP_ANON, "MAP_ANON" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000148#endif
149#ifdef MAP_HASSEMAPHORE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100150 { MAP_HASSEMAPHORE,"MAP_HASSEMAPHORE"},
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000151#endif
152#ifdef MAP_STACK
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100153 { MAP_STACK, "MAP_STACK" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000154#endif
Bernhard Reutner-Fischer21ceeb42013-02-05 19:31:55 +0100155#if defined MAP_UNINITIALIZED && MAP_UNINITIALIZED > 0
156 { MAP_UNINITIALIZED,"MAP_UNINITIALIZED"},
157#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000158#ifdef MAP_NOSYNC
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100159 { MAP_NOSYNC, "MAP_NOSYNC" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000160#endif
161#ifdef MAP_NOCORE
Denys Vlasenko3e3490a2012-03-17 01:27:37 +0100162 { MAP_NOCORE, "MAP_NOCORE" },
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000163#endif
Chris Metcalfc8c66982009-12-28 10:00:15 -0500164#ifdef TILE
165 { MAP_CACHE_NO_LOCAL, "MAP_CACHE_NO_LOCAL" },
166 { MAP_CACHE_NO_L2, "MAP_CACHE_NO_L2" },
167 { MAP_CACHE_NO_L1, "MAP_CACHE_NO_L1" },
168#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000169 { 0, NULL },
170};
171
Chris Metcalfc8c66982009-12-28 10:00:15 -0500172#ifdef TILE
Denys Vlasenko72a58482011-08-19 16:01:51 +0200173static int
174addtileflags(long flags)
Chris Metcalfc8c66982009-12-28 10:00:15 -0500175{
176 long home = flags & _MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
177 flags &= ~_MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
178
179 if (flags & _MAP_CACHE_INCOHERENT) {
180 flags &= ~_MAP_CACHE_INCOHERENT;
181 if (home == MAP_CACHE_HOME_NONE) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200182 tprints("|MAP_CACHE_INCOHERENT");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500183 return flags;
184 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200185 tprints("|_MAP_CACHE_INCOHERENT");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500186 }
187
188 switch (home) {
189 case 0: break;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200190 case MAP_CACHE_HOME_HERE: tprints("|MAP_CACHE_HOME_HERE"); break;
191 case MAP_CACHE_HOME_NONE: tprints("|MAP_CACHE_HOME_NONE"); break;
192 case MAP_CACHE_HOME_SINGLE: tprints("|MAP_CACHE_HOME_SINGLE"); break;
193 case MAP_CACHE_HOME_TASK: tprints("|MAP_CACHE_HOME_TASK"); break;
194 case MAP_CACHE_HOME_HASH: tprints("|MAP_CACHE_HOME_HASH"); break;
Chris Metcalfc8c66982009-12-28 10:00:15 -0500195 default:
Chris Metcalf0b99a8a2013-02-05 17:48:33 +0100196 tprintf("|MAP_CACHE_HOME(%ld)",
Chris Metcalfc8c66982009-12-28 10:00:15 -0500197 (home >> _MAP_CACHE_HOME_SHIFT) );
198 break;
199 }
200
201 return flags;
202}
203#endif
204
Dmitry V. Levin31382132011-03-04 05:08:02 +0300205static int
Denys Vlasenko923255c2013-02-18 02:36:36 +0100206print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000207{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000208 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000209 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +0000210 if (!u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200211 tprints("NULL, ");
Wichert Akkerman8829a551999-06-11 13:18:40 +0000212 else
213 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000214 /* len */
215 tprintf("%lu, ", u_arg[1]);
216 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000217 printflags(mmap_prot, u_arg[2], "PROT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200218 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000219 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000220#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000221 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
Denys Vlasenko923255c2013-02-18 02:36:36 +0100222# ifdef TILE
Chris Metcalfc8c66982009-12-28 10:00:15 -0500223 addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE));
Denys Vlasenko923255c2013-02-18 02:36:36 +0100224# else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000225 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Denys Vlasenko923255c2013-02-18 02:36:36 +0100226# endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000227#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000228 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000229#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200230 tprints(", ");
Denys Vlasenko923255c2013-02-18 02:36:36 +0100231 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300232 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000233 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300234 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000235 }
236 return RVAL_HEX;
237}
238
Denys Vlasenko12014262011-05-30 14:00:14 +0200239int sys_old_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000240{
Denys Vlasenko72a58482011-08-19 16:01:51 +0200241#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000242 /*
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200243 * IA64 processes never call this routine, they only use the
244 * new `sys_mmap' interface.
245 * For IA32 processes, this code converts the integer arguments
246 * that they pushed onto the stack, into longs.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000247 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200248 int i;
249 long u_arg[6];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100250 unsigned narrow_arg[6];
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200251 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
252 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000253 for (i = 0; i < 6; i++)
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200254 u_arg[i] = narrow_arg[i];
Roland McGrathf5a47772003-06-26 22:40:42 +0000255#elif defined(SH) || defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000256 /* SH has always passed the args in registers */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200257 long *u_arg = tcp->u_arg;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100258#elif defined(X86_64)
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200259 long u_arg[6];
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000260 if (current_personality == 1) {
261 int i;
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200262 unsigned narrow_arg[6];
263 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
264 return 0;
265 for (i = 0; i < 6; ++i)
266 u_arg[i] = narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100267 } else {
268 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
269 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000270 }
Denys Vlasenko923255c2013-02-18 02:36:36 +0100271#else
272 long u_arg[6];
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200273 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000274 return 0;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100275#endif
276 return print_mmap(tcp, u_arg, (unsigned long)u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000277}
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000278
279int
Denys Vlasenko12014262011-05-30 14:00:14 +0200280sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000281{
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100282 unsigned long long offset = (unsigned long) tcp->u_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000283
Denys Vlasenko84703742012-02-25 02:38:52 +0100284#if defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000285 /*
286 * Old mmap differs from new mmap in specifying the
287 * offset in units of bytes rather than pages. We
288 * pretend it's in byte units so the user only ever
289 * sees bytes in the printout.
290 */
291 offset <<= PAGE_SHIFT;
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100292#elif defined(I386)
293 /* Try test/mmap_offset_decode.c */
294 offset <<= 12; /* 4096 byte pages */
295#elif defined(LINUX_MIPSN32) || defined(X32)
296 /* Try test/x32_mmap.c */
297 /* At least for X32 it definitely should not be page-shifted! */
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000298 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000299#endif
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000300 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000301}
302
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000303int
Denys Vlasenko12014262011-05-30 14:00:14 +0200304sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000305{
306 if (entering(tcp)) {
307 tprintf("%#lx, %lu",
308 tcp->u_arg[0], tcp->u_arg[1]);
309 }
310 return 0;
311}
312
313int
Denys Vlasenko12014262011-05-30 14:00:14 +0200314sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000315{
316 if (entering(tcp)) {
317 tprintf("%#lx, %lu, ",
318 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000319 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000320 }
321 return 0;
322}
323
Roland McGrathd9f816f2004-09-04 03:39:20 +0000324static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000325 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000326#ifdef MREMAP_FIXED
327 { MREMAP_FIXED, "MREMAP_FIXED" },
328#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000329 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000330};
331
332int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000333sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000334{
335 if (entering(tcp)) {
336 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
337 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000338 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000339#ifdef MREMAP_FIXED
340 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
341 (MREMAP_MAYMOVE | MREMAP_FIXED))
342 tprintf(", %#lx", tcp->u_arg[4]);
343#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000344 }
345 return RVAL_HEX;
346}
347
Roland McGrathf4021b12008-08-25 02:59:36 +0000348static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000349#ifdef MADV_NORMAL
350 { MADV_NORMAL, "MADV_NORMAL" },
351#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000352#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000353 { MADV_RANDOM, "MADV_RANDOM" },
354#endif
355#ifdef MADV_SEQUENTIAL
356 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
357#endif
358#ifdef MADV_WILLNEED
359 { MADV_WILLNEED, "MADV_WILLNEED" },
360#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000361#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000362 { MADV_DONTNEED, "MADV_DONTNEED" },
363#endif
364 { 0, NULL },
365};
366
Wichert Akkermanc7926982000-04-10 22:22:31 +0000367int
Denys Vlasenko12014262011-05-30 14:00:14 +0200368sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000369{
370 if (entering(tcp)) {
371 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000372 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000373 }
374 return 0;
375}
376
Roland McGrathd9f816f2004-09-04 03:39:20 +0000377static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000378#ifdef MCL_CURRENT
379 { MCL_CURRENT, "MCL_CURRENT" },
380#endif
381#ifdef MCL_FUTURE
382 { MCL_FUTURE, "MCL_FUTURE" },
383#endif
384 { 0, NULL}
385};
386
387int
Denys Vlasenko12014262011-05-30 14:00:14 +0200388sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000389{
390 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000391 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000392 }
393 return 0;
394}
395
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000396#ifdef MS_ASYNC
397
Roland McGrathd9f816f2004-09-04 03:39:20 +0000398static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000399#ifdef MS_SYNC
400 { MS_SYNC, "MS_SYNC" },
401#endif
John Hughesaca07f32001-10-16 18:12:27 +0000402 { MS_ASYNC, "MS_ASYNC" },
403 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000404 { 0, NULL },
405};
406
407int
Denys Vlasenko12014262011-05-30 14:00:14 +0200408sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000409{
410 if (entering(tcp)) {
411 /* addr */
412 tprintf("%#lx", tcp->u_arg[0]);
413 /* len */
414 tprintf(", %lu, ", tcp->u_arg[1]);
415 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000416 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000417 }
418 return 0;
419}
420
421#endif /* MS_ASYNC */
422
423#ifdef MC_SYNC
424
Roland McGrathd9f816f2004-09-04 03:39:20 +0000425static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000426 { MC_LOCK, "MC_LOCK" },
427 { MC_LOCKAS, "MC_LOCKAS" },
428 { MC_SYNC, "MC_SYNC" },
429 { MC_UNLOCK, "MC_UNLOCK" },
430 { MC_UNLOCKAS, "MC_UNLOCKAS" },
431 { 0, NULL },
432};
433
Roland McGrathd9f816f2004-09-04 03:39:20 +0000434static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000435 { MCL_CURRENT, "MCL_CURRENT" },
436 { MCL_FUTURE, "MCL_FUTURE" },
437 { 0, NULL },
438};
439
440int
Denys Vlasenko12014262011-05-30 14:00:14 +0200441sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000442{
443 int arg, function;
444
445 if (entering(tcp)) {
446 /* addr */
447 tprintf("%#lx", tcp->u_arg[0]);
448 /* len */
449 tprintf(", %lu, ", tcp->u_arg[1]);
450 /* function */
451 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000452 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000453 /* arg */
454 arg = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200455 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000456 switch (function) {
457 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000458 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000459 break;
460 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000461 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000462 break;
463 default:
464 tprintf("%#x", arg);
465 break;
466 }
467 }
468 return 0;
469}
470
471#endif /* MC_SYNC */
472
473int
Denys Vlasenko12014262011-05-30 14:00:14 +0200474sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000475{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000476 if (entering(tcp)) {
477 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
478 } else {
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200479 unsigned long i, len;
480 char *vec = NULL;
481
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000482 len = tcp->u_arg[1];
483 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000484 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000485 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
486 tprintf("%#lx", tcp->u_arg[2]);
487 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200488 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000489 for (i = 0; i < len; i++) {
490 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200491 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000492 break;
493 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200494 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000495 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200496 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000497 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200498 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000499 }
500 return 0;
501}
502
Denys Vlasenko84703742012-02-25 02:38:52 +0100503#if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000504int
Denys Vlasenko12014262011-05-30 14:00:14 +0200505sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000506{
507 if (exiting(tcp))
508 return RVAL_HEX;
509 return 0;
510}
Denys Vlasenko84703742012-02-25 02:38:52 +0100511#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000512
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100513#if defined(I386)
Roland McGrath909875b2002-12-22 03:34:36 +0000514void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000515print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000516{
517 tprintf("base_addr:%#08lx, "
518 "limit:%d, "
519 "seg_32bit:%d, "
520 "contents:%d, "
521 "read_exec_only:%d, "
522 "limit_in_pages:%d, "
523 "seg_not_present:%d, "
524 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000525 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000526 ldt_entry->limit,
527 ldt_entry->seg_32bit,
528 ldt_entry->contents,
529 ldt_entry->read_exec_only,
530 ldt_entry->limit_in_pages,
531 ldt_entry->seg_not_present,
532 ldt_entry->useable);
533}
534
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000535int
Denys Vlasenko12014262011-05-30 14:00:14 +0200536sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000537{
538 if (entering(tcp)) {
539 struct modify_ldt_ldt_s copy;
540 tprintf("%ld", tcp->u_arg[0]);
541 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200542 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000543 || umove(tcp, tcp->u_arg[1], &copy) == -1)
544 tprintf(", %lx", tcp->u_arg[1]);
545 else {
546 tprintf(", {entry_number:%d, ", copy.entry_number);
547 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200548 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000549 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000550 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000551 }
552 }
553 tprintf(", %lu", tcp->u_arg[2]);
554 }
555 return 0;
556}
Roland McGrath34e4a692002-12-15 23:58:17 +0000557
558int
Denys Vlasenko12014262011-05-30 14:00:14 +0200559sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000560{
561 struct modify_ldt_ldt_s copy;
562 if (entering(tcp)) {
563 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
564 if (copy.entry_number == -1)
565 tprintf("{entry_number:%d -> ",
566 copy.entry_number);
567 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200568 tprints("{entry_number:");
Roland McGrath34e4a692002-12-15 23:58:17 +0000569 }
570 } else {
571 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
572 tprintf("%d, ", copy.entry_number);
573 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200574 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000575 else {
576 print_ldt_entry(&copy);
577 }
578 } else {
579 tprintf("%lx", tcp->u_arg[0]);
580 }
581 }
582 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000583
Roland McGrath34e4a692002-12-15 23:58:17 +0000584}
585
586int
Denys Vlasenko12014262011-05-30 14:00:14 +0200587sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000588{
589 struct modify_ldt_ldt_s copy;
590 if (exiting(tcp)) {
591 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
592 tprintf("{entry_number:%d, ", copy.entry_number);
593 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200594 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000595 else {
596 print_ldt_entry(&copy);
597 }
598 } else {
599 tprintf("%lx", tcp->u_arg[0]);
600 }
601 }
602 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000603
Roland McGrath34e4a692002-12-15 23:58:17 +0000604}
Denys Vlasenkoc36c3522012-02-25 02:47:15 +0100605#endif /* I386 */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000606
Denys Vlasenko84703742012-02-25 02:38:52 +0100607#if defined(M68K)
Andreas Schwab58743222010-05-28 22:28:51 +0200608int
Denys Vlasenko12014262011-05-30 14:00:14 +0200609sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200610{
611 if (entering(tcp))
612 tprintf("%#lx", tcp->u_arg[0]);
613 return 0;
614
615}
616
617int
Denys Vlasenko12014262011-05-30 14:00:14 +0200618sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200619{
620 return RVAL_HEX;
621}
622#endif
623
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000624int
Denys Vlasenko12014262011-05-30 14:00:14 +0200625sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000626{
627 if (entering(tcp)) {
628 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000629 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000630 tprintf(", %lu, ", tcp->u_arg[3]);
631#ifdef MAP_TYPE
632 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
633 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
634#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000635 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000636#endif
637 }
638 return 0;
639}
Roland McGrathb10a3352004-10-07 18:53:12 +0000640
Roland McGrathb10a3352004-10-07 18:53:12 +0000641#define MPOL_DEFAULT 0
642#define MPOL_PREFERRED 1
643#define MPOL_BIND 2
644#define MPOL_INTERLEAVE 3
645
646#define MPOL_F_NODE (1<<0)
647#define MPOL_F_ADDR (1<<1)
648
649#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000650#define MPOL_MF_MOVE (1<<1)
651#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000652
Roland McGrathb10a3352004-10-07 18:53:12 +0000653static const struct xlat policies[] = {
654 { MPOL_DEFAULT, "MPOL_DEFAULT" },
655 { MPOL_PREFERRED, "MPOL_PREFERRED" },
656 { MPOL_BIND, "MPOL_BIND" },
657 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
658 { 0, NULL }
659};
660
661static const struct xlat mbindflags[] = {
662 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000663 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
664 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000665 { 0, NULL }
666};
667
668static const struct xlat mempolicyflags[] = {
669 { MPOL_F_NODE, "MPOL_F_NODE" },
670 { MPOL_F_ADDR, "MPOL_F_ADDR" },
671 { 0, NULL }
672};
673
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000674static const struct xlat move_pages_flags[] = {
675 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
676 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
677 { 0, NULL }
678};
679
Roland McGrathb10a3352004-10-07 18:53:12 +0000680static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200681get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000682{
Roland McGrathaa524c82005-06-01 19:22:06 +0000683 unsigned long nlongs, size, end;
684
685 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
686 size = nlongs * sizeof(long);
687 end = ptr + size;
688 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
689 && (end > ptr))) {
690 unsigned long n, cur, abbrev_end;
691 int failed = 0;
692
693 if (abbrev(tcp)) {
694 abbrev_end = ptr + max_strlen * sizeof(long);
695 if (abbrev_end < ptr)
696 abbrev_end = end;
697 } else {
698 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000699 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200700 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +0000701 for (cur = ptr; cur < end; cur += sizeof(long)) {
702 if (cur > ptr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200703 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000704 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200705 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000706 break;
707 }
708 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200709 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000710 failed = 1;
711 break;
712 }
713 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
714 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200715 tprints("}");
Roland McGrathaa524c82005-06-01 19:22:06 +0000716 if (failed)
717 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000718 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000719 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000720 tprintf(", %lu", maxnodes);
721}
722
723int
Denys Vlasenko12014262011-05-30 14:00:14 +0200724sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000725{
726 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000727 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000728 printxval(policies, tcp->u_arg[2], "MPOL_???");
729 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200730 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000731 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000732 }
733 return 0;
734}
735
736int
Denys Vlasenko12014262011-05-30 14:00:14 +0200737sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000738{
739 if (entering(tcp)) {
740 printxval(policies, tcp->u_arg[0], "MPOL_???");
741 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
742 }
743 return 0;
744}
745
746int
Denys Vlasenko12014262011-05-30 14:00:14 +0200747sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000748{
749 if (exiting(tcp)) {
750 int pol;
751 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200752 tprints("NULL");
Roland McGrathb10a3352004-10-07 18:53:12 +0000753 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
754 tprintf("%#lx", tcp->u_arg[0]);
755 else
756 printxval(policies, pol, "MPOL_???");
757 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
758 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000759 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000760 }
761 return 0;
762}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000763
764int
Dmitry V. Levin64d0e712012-03-11 22:44:14 +0000765sys_migrate_pages(struct tcb *tcp)
766{
767 if (entering(tcp)) {
768 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
769 get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0);
770 tprints(", ");
771 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0);
772 }
773 return 0;
774}
775
776int
Denys Vlasenko12014262011-05-30 14:00:14 +0200777sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000778{
779 if (entering(tcp)) {
780 unsigned long npages = tcp->u_arg[1];
781 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
782 if (tcp->u_arg[2] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200783 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000784 else {
785 int i;
786 long puser = tcp->u_arg[2];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200787 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000788 for (i = 0; i < npages; ++i) {
789 void *p;
790 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200791 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000792 if (umove(tcp, puser, &p) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200793 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000794 break;
795 }
796 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200797 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000798 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200799 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000800 }
801 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200802 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000803 else {
804 int i;
805 long nodeuser = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200806 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000807 for (i = 0; i < npages; ++i) {
808 int node;
809 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200810 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000811 if (umove(tcp, nodeuser, &node) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200812 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000813 break;
814 }
815 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200816 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000817 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200818 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000819 }
820 }
821 if (exiting(tcp)) {
822 unsigned long npages = tcp->u_arg[1];
823 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200824 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000825 else {
826 int i;
827 long statususer = tcp->u_arg[4];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200828 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000829 for (i = 0; i < npages; ++i) {
830 int status;
831 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200832 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000833 if (umove(tcp, statususer, &status) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200834 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000835 break;
836 }
837 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200838 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000839 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200840 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000841 }
842 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
843 }
844 return 0;
845}
Roland McGrath4a6f6522008-08-25 03:09:16 +0000846
Denys Vlasenko84703742012-02-25 02:38:52 +0100847#if defined(POWERPC)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000848int
Denys Vlasenko12014262011-05-30 14:00:14 +0200849sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000850{
851 if (entering(tcp)) {
852 unsigned long cur, end, abbrev_end, entries;
853 unsigned int entry;
854
855 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
856 entries = tcp->u_arg[1] >> 16;
857 if (!entries || !tcp->u_arg[2]) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200858 tprints("{}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000859 return 0;
860 }
861 cur = tcp->u_arg[2];
862 end = cur + (sizeof(int) * entries);
863 if (!verbose(tcp) || end < tcp->u_arg[2]) {
864 tprintf("%#lx", tcp->u_arg[2]);
865 return 0;
866 }
867 if (abbrev(tcp)) {
868 abbrev_end = cur + (sizeof(int) * max_strlen);
869 if (abbrev_end > end)
870 abbrev_end = end;
871 }
872 else
873 abbrev_end = end;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200874 tprints("{");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000875 for (; cur < end; cur += sizeof(int)) {
876 if (cur > tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200877 tprints(", ");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000878 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200879 tprints("...");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000880 break;
881 }
882 if (umove(tcp, cur, &entry) < 0) {
883 tprintf("??? [%#lx]", cur);
884 break;
885 }
886 else
887 tprintf("%#08x", entry);
888 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200889 tprints("}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000890 }
891
892 return 0;
893}
894#endif