blob: de9b6bbe38a152fb5490751a5996eea812150067 [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.
31 *
32 * $Id$
33 */
34
35#include "defs.h"
36
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000037#ifdef LINUX
Roland McGrath05cdd3c2004-03-02 06:16:59 +000038#include <asm/mman.h>
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000039#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000040#include <sys/mman.h>
Wichert Akkerman5daa0281999-03-15 19:49:42 +000041
Roland McGrath909875b2002-12-22 03:34:36 +000042#if defined(LINUX) && defined(I386)
Denys Vlasenko72a58482011-08-19 16:01:51 +020043# include <asm/ldt.h>
Roland McGrath7decfb22004-03-01 22:10:52 +000044# ifdef HAVE_STRUCT_USER_DESC
45# define modify_ldt_ldt_s user_desc
46# endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047#endif
Roland McGrathf5a47772003-06-26 22:40:42 +000048#if defined(LINUX) && defined(SH64)
Denys Vlasenko72a58482011-08-19 16:01:51 +020049# include <asm/page.h> /* for PAGE_SHIFT */
Roland McGrathe1e584b2003-06-02 19:18:58 +000050#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051
John Hughes70623be2001-03-08 13:59:00 +000052#ifdef HAVE_LONG_LONG_OFF_T
53/*
54 * Ugly hacks for systems that have a long long off_t
55 */
56#define sys_mmap64 sys_mmap
57#endif
58
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000059int
Denys Vlasenko12014262011-05-30 14:00:14 +020060sys_brk(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000061{
62 if (entering(tcp)) {
63 tprintf("%#lx", tcp->u_arg[0]);
64 }
Wichert Akkerman5daa0281999-03-15 19:49:42 +000065#ifdef LINUX
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000066 return RVAL_HEX;
67#else
68 return 0;
69#endif
70}
71
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +000072#if defined(FREEBSD) || defined(SUNOS4)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000073int
Denys Vlasenko12014262011-05-30 14:00:14 +020074sys_sbrk(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000075{
76 if (entering(tcp)) {
77 tprintf("%lu", tcp->u_arg[0]);
78 }
79 return RVAL_HEX;
80}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +000081#endif /* FREEBSD || SUNOS4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082
Roland McGrathd9f816f2004-09-04 03:39:20 +000083static const struct xlat mmap_prot[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000084 { PROT_NONE, "PROT_NONE", },
85 { PROT_READ, "PROT_READ" },
86 { PROT_WRITE, "PROT_WRITE" },
87 { PROT_EXEC, "PROT_EXEC" },
Roland McGrath47eb0e22003-09-25 23:06:04 +000088#ifdef PROT_SEM
89 { PROT_SEM, "PROT_SEM" },
90#endif
91#ifdef PROT_GROWSDOWN
92 { PROT_GROWSDOWN,"PROT_GROWSDOWN"},
93#endif
94#ifdef PROT_GROWSUP
95 { PROT_GROWSUP, "PROT_GROWSUP" },
96#endif
Roland McGrath586d6ab2008-08-25 03:00:47 +000097#ifdef PROT_SAO
98 { PROT_SAO, "PROT_SAO" },
99#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000100 { 0, NULL },
101};
102
Roland McGrathd9f816f2004-09-04 03:39:20 +0000103static const struct xlat mmap_flags[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000104 { MAP_SHARED, "MAP_SHARED" },
105 { MAP_PRIVATE, "MAP_PRIVATE" },
106 { MAP_FIXED, "MAP_FIXED" },
107#ifdef MAP_ANONYMOUS
108 { MAP_ANONYMOUS,"MAP_ANONYMOUS" },
109#endif
Dmitry V. Levin71f1a132007-03-29 23:30:09 +0000110#ifdef MAP_32BIT
111 { MAP_32BIT, "MAP_32BIT" },
112#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000113#ifdef MAP_RENAME
114 { MAP_RENAME, "MAP_RENAME" },
115#endif
116#ifdef MAP_NORESERVE
117 { MAP_NORESERVE,"MAP_NORESERVE" },
118#endif
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000119#ifdef MAP_POPULATE
120 { MAP_POPULATE, "MAP_POPULATE" },
121#endif
122#ifdef MAP_NONBLOCK
123 { MAP_NONBLOCK, "MAP_NONBLOCK" },
124#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +0000125 /*
126 * XXX - this was introduced in SunOS 4.x to distinguish between
127 * the old pre-4.x "mmap()", which:
128 *
129 * only let you map devices with an "mmap" routine (e.g.,
130 * frame buffers) in;
131 *
132 * required you to specify the mapping address;
133 *
134 * returned 0 on success and -1 on failure;
135 *
136 * memory and which, and the 4.x "mmap()" which:
137 *
138 * can map plain files;
139 *
140 * can be asked to pick where to map the file;
141 *
142 * returns the address where it mapped the file on success
143 * and -1 on failure.
144 *
145 * It's not actually used in source code that calls "mmap()"; the
146 * "mmap()" routine adds it for you.
147 *
148 * It'd be nice to come up with some way of eliminating it from
149 * the flags, e.g. reporting calls *without* it as "old_mmap()"
150 * and calls with it as "mmap()".
151 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000152#ifdef _MAP_NEW
153 { _MAP_NEW, "_MAP_NEW" },
154#endif
155#ifdef MAP_GROWSDOWN
156 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
157#endif
158#ifdef MAP_DENYWRITE
159 { MAP_DENYWRITE,"MAP_DENYWRITE" },
160#endif
161#ifdef MAP_EXECUTABLE
162 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
163#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000164#ifdef MAP_INHERIT
165 { MAP_INHERIT,"MAP_INHERIT" },
166#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000167#ifdef MAP_FILE
168 { MAP_FILE,"MAP_FILE"},
169#endif
170#ifdef MAP_LOCKED
171 { MAP_LOCKED,"MAP_LOCKED"},
172#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000173 /* FreeBSD ones */
174#ifdef MAP_ANON
175 { MAP_ANON, "MAP_ANON" },
176#endif
177#ifdef MAP_HASSEMAPHORE
178 { MAP_HASSEMAPHORE, "MAP_HASSEMAPHORE" },
179#endif
180#ifdef MAP_STACK
181 { MAP_STACK, "MAP_STACK" },
182#endif
183#ifdef MAP_NOSYNC
184 { MAP_NOSYNC, "MAP_NOSYNC" },
185#endif
186#ifdef MAP_NOCORE
187 { MAP_NOCORE, "MAP_NOCORE" },
188#endif
Chris Metcalfc8c66982009-12-28 10:00:15 -0500189#ifdef TILE
190 { MAP_CACHE_NO_LOCAL, "MAP_CACHE_NO_LOCAL" },
191 { MAP_CACHE_NO_L2, "MAP_CACHE_NO_L2" },
192 { MAP_CACHE_NO_L1, "MAP_CACHE_NO_L1" },
193#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000194 { 0, NULL },
195};
196
Chris Metcalfc8c66982009-12-28 10:00:15 -0500197#ifdef TILE
Denys Vlasenko72a58482011-08-19 16:01:51 +0200198static int
199addtileflags(long flags)
Chris Metcalfc8c66982009-12-28 10:00:15 -0500200{
201 long home = flags & _MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
202 flags &= ~_MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
203
204 if (flags & _MAP_CACHE_INCOHERENT) {
205 flags &= ~_MAP_CACHE_INCOHERENT;
206 if (home == MAP_CACHE_HOME_NONE) {
207 tprintf("|MAP_CACHE_INCOHERENT");
208 return flags;
209 }
210 tprintf("|_MAP_CACHE_INCOHERENT");
211 }
212
213 switch (home) {
214 case 0: break;
215 case MAP_CACHE_HOME_HERE: tprintf("|MAP_CACHE_HOME_HERE"); break;
216 case MAP_CACHE_HOME_NONE: tprintf("|MAP_CACHE_HOME_NONE"); break;
217 case MAP_CACHE_HOME_SINGLE: tprintf("|MAP_CACHE_HOME_SINGLE"); break;
218 case MAP_CACHE_HOME_TASK: tprintf("|MAP_CACHE_HOME_TASK"); break;
219 case MAP_CACHE_HOME_HASH: tprintf("|MAP_CACHE_HOME_HASH"); break;
220 default:
221 tprintf("|MAP_CACHE_HOME(%d)",
222 (home >> _MAP_CACHE_HOME_SHIFT) );
223 break;
224 }
225
226 return flags;
227}
228#endif
229
John Hughes70623be2001-03-08 13:59:00 +0000230#if !HAVE_LONG_LONG_OFF_T
Dmitry V. Levin31382132011-03-04 05:08:02 +0300231static int
232print_mmap(struct tcb *tcp, long *u_arg, long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000233{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000234 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000235 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +0000236 if (!u_arg[0])
237 tprintf("NULL, ");
238 else
239 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000240 /* len */
241 tprintf("%lu, ", u_arg[1]);
242 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000243 printflags(mmap_prot, u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000244 tprintf(", ");
245 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000246#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000247 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500248#ifdef TILE
249 addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE));
250#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000251 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Chris Metcalfc8c66982009-12-28 10:00:15 -0500252#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000253#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000254 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000255#endif
Dmitry V. Levin31382132011-03-04 05:08:02 +0300256 /* fd */
257 tprintf(", ");
258 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300260 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000261 }
262 return RVAL_HEX;
263}
264
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000265#ifdef LINUX
Denys Vlasenko12014262011-05-30 14:00:14 +0200266int sys_old_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000267{
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000268 long u_arg[6];
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000269
Denys Vlasenko72a58482011-08-19 16:01:51 +0200270#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000271 int i, v;
272 /*
273 * IA64 processes never call this routine, they only use the
274 * new `sys_mmap' interface. This code converts the integer
275 * arguments that the IA32 process pushed onto the stack into
276 * longs.
277 *
278 * Note that addresses with bit 31 set will be sign extended.
279 * Fortunately, those addresses are not currently being generated
280 * for IA32 processes so it's not a problem.
281 */
282 for (i = 0; i < 6; i++)
283 if (umove(tcp, tcp->u_arg[0] + (i * sizeof(int)), &v) == -1)
284 return 0;
285 else
286 u_arg[i] = v;
Roland McGrathf5a47772003-06-26 22:40:42 +0000287#elif defined(SH) || defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000288 /* SH has always passed the args in registers */
289 int i;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200290 for (i = 0; i < 6; i++)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000291 u_arg[i] = tcp->u_arg[i];
Roland McGrath6b1d43e2003-03-31 01:05:01 +0000292#else
Roland McGrath520e21f2005-07-05 09:50:18 +0000293# if defined(X86_64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000294 if (current_personality == 1) {
295 int i;
296 for (i = 0; i < 6; ++i) {
297 unsigned int val;
298 if (umove(tcp, tcp->u_arg[0] + i * 4, &val) == -1)
299 return 0;
300 u_arg[i] = val;
301 }
302 }
303 else
Roland McGrath520e21f2005-07-05 09:50:18 +0000304# endif
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000305 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1)
306 return 0;
Denys Vlasenko72a58482011-08-19 16:01:51 +0200307#endif /* !IA64 && !SH[64] */
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000308 return print_mmap(tcp, u_arg, u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000309}
Denys Vlasenko72a58482011-08-19 16:01:51 +0200310#endif /* LINUX */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000311
312int
Denys Vlasenko12014262011-05-30 14:00:14 +0200313sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000314{
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000315 long long offset = tcp->u_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000316
Roland McGrathf5a47772003-06-26 22:40:42 +0000317#if defined(LINUX) && defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000318 /*
319 * Old mmap differs from new mmap in specifying the
320 * offset in units of bytes rather than pages. We
321 * pretend it's in byte units so the user only ever
322 * sees bytes in the printout.
323 */
324 offset <<= PAGE_SHIFT;
Roland McGrathe1e584b2003-06-02 19:18:58 +0000325#endif
Roland McGrath542c2c62008-05-20 01:11:56 +0000326#if defined(LINUX_MIPSN32)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000327 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000328#endif
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000329 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000330}
John Hughes70623be2001-03-08 13:59:00 +0000331#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000332
John Hughes70623be2001-03-08 13:59:00 +0000333#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000334int
Dmitry V. Levin31382132011-03-04 05:08:02 +0300335sys_mmap64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000336{
John Hughesbdf48f52001-03-06 15:08:09 +0000337 if (entering(tcp)) {
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200338#if !defined(LINUX) || defined(ALPHA)
339 long *u_arg = tcp->u_arg;
340#else
341 long u_arg[7];
John Hughesbdf48f52001-03-06 15:08:09 +0000342 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
343 (char *) u_arg) == -1)
344 return 0;
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200345#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000346 /* addr */
347 tprintf("%#lx, ", u_arg[0]);
348 /* len */
349 tprintf("%lu, ", u_arg[1]);
350 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000351 printflags(mmap_prot, u_arg[2], "PROT_???");
John Hughesbdf48f52001-03-06 15:08:09 +0000352 tprintf(", ");
353 /* flags */
John Hughes5a826b82001-03-07 13:21:24 +0000354#ifdef MAP_TYPE
John Hughesbdf48f52001-03-06 15:08:09 +0000355 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
356 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
John Hughes5a826b82001-03-07 13:21:24 +0000357#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000358 printflags(mmap_flags, u_arg[3], "MAP_???");
John Hughes5a826b82001-03-07 13:21:24 +0000359#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000360 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300361 tprintf(", ");
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200362 /* BUG?! should be u_arg[4] (without tcp->)? */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300363 printfd(tcp, tcp->u_arg[4]);
John Hughesbdf48f52001-03-06 15:08:09 +0000364 /* offset */
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200365 /* BUG?! on non-ALPHA linux, offset will be not in tcp->u_arg,
366 * but in local u_arg, but printllval prints tcp->u_arg! */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300367 printllval(tcp, ", %#llx", 5);
John Hughesbdf48f52001-03-06 15:08:09 +0000368 }
369 return RVAL_HEX;
370}
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200371#endif /* _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T */
John Hughesbdf48f52001-03-06 15:08:09 +0000372
Roland McGrath909875b2002-12-22 03:34:36 +0000373
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000374int
Denys Vlasenko12014262011-05-30 14:00:14 +0200375sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000376{
377 if (entering(tcp)) {
378 tprintf("%#lx, %lu",
379 tcp->u_arg[0], tcp->u_arg[1]);
380 }
381 return 0;
382}
383
384int
Denys Vlasenko12014262011-05-30 14:00:14 +0200385sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000386{
387 if (entering(tcp)) {
388 tprintf("%#lx, %lu, ",
389 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000390 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000391 }
392 return 0;
393}
394
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000395#ifdef LINUX
396
Roland McGrathd9f816f2004-09-04 03:39:20 +0000397static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000398 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000399#ifdef MREMAP_FIXED
400 { MREMAP_FIXED, "MREMAP_FIXED" },
401#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000402 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000403};
404
405int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000406sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000407{
408 if (entering(tcp)) {
409 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
410 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000411 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000412#ifdef MREMAP_FIXED
413 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
414 (MREMAP_MAYMOVE | MREMAP_FIXED))
415 tprintf(", %#lx", tcp->u_arg[4]);
416#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000417 }
418 return RVAL_HEX;
419}
420
Roland McGrathf4021b12008-08-25 02:59:36 +0000421static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000422#ifdef MADV_NORMAL
423 { MADV_NORMAL, "MADV_NORMAL" },
424#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000425#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000426 { MADV_RANDOM, "MADV_RANDOM" },
427#endif
428#ifdef MADV_SEQUENTIAL
429 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
430#endif
431#ifdef MADV_WILLNEED
432 { MADV_WILLNEED, "MADV_WILLNEED" },
433#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000434#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000435 { MADV_DONTNEED, "MADV_DONTNEED" },
436#endif
437 { 0, NULL },
438};
439
440
441int
Denys Vlasenko12014262011-05-30 14:00:14 +0200442sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000443{
444 if (entering(tcp)) {
445 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000446 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000447 }
448 return 0;
449}
450
451
Roland McGrathd9f816f2004-09-04 03:39:20 +0000452static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000453#ifdef MCL_CURRENT
454 { MCL_CURRENT, "MCL_CURRENT" },
455#endif
456#ifdef MCL_FUTURE
457 { MCL_FUTURE, "MCL_FUTURE" },
458#endif
459 { 0, NULL}
460};
461
462int
Denys Vlasenko12014262011-05-30 14:00:14 +0200463sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000464{
465 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000466 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000467 }
468 return 0;
469}
470
471
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000472#endif /* LINUX */
473
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000474#ifdef MS_ASYNC
475
Roland McGrathd9f816f2004-09-04 03:39:20 +0000476static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000477#ifdef MS_SYNC
478 { MS_SYNC, "MS_SYNC" },
479#endif
John Hughesaca07f32001-10-16 18:12:27 +0000480 { MS_ASYNC, "MS_ASYNC" },
481 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000482 { 0, NULL },
483};
484
485int
Denys Vlasenko12014262011-05-30 14:00:14 +0200486sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000487{
488 if (entering(tcp)) {
489 /* addr */
490 tprintf("%#lx", tcp->u_arg[0]);
491 /* len */
492 tprintf(", %lu, ", tcp->u_arg[1]);
493 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000494 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000495 }
496 return 0;
497}
498
499#endif /* MS_ASYNC */
500
501#ifdef MC_SYNC
502
Roland McGrathd9f816f2004-09-04 03:39:20 +0000503static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000504 { MC_LOCK, "MC_LOCK" },
505 { MC_LOCKAS, "MC_LOCKAS" },
506 { MC_SYNC, "MC_SYNC" },
507 { MC_UNLOCK, "MC_UNLOCK" },
508 { MC_UNLOCKAS, "MC_UNLOCKAS" },
509 { 0, NULL },
510};
511
Roland McGrathd9f816f2004-09-04 03:39:20 +0000512static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000513 { MCL_CURRENT, "MCL_CURRENT" },
514 { MCL_FUTURE, "MCL_FUTURE" },
515 { 0, NULL },
516};
517
518int
Denys Vlasenko12014262011-05-30 14:00:14 +0200519sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000520{
521 int arg, function;
522
523 if (entering(tcp)) {
524 /* addr */
525 tprintf("%#lx", tcp->u_arg[0]);
526 /* len */
527 tprintf(", %lu, ", tcp->u_arg[1]);
528 /* function */
529 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000530 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000531 /* arg */
532 arg = tcp->u_arg[3];
533 tprintf(", ");
534 switch (function) {
535 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000536 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000537 break;
538 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000539 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000540 break;
541 default:
542 tprintf("%#x", arg);
543 break;
544 }
545 }
546 return 0;
547}
548
549#endif /* MC_SYNC */
550
551int
Denys Vlasenko12014262011-05-30 14:00:14 +0200552sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000553{
Roland McGrath46100d02005-06-01 18:55:42 +0000554 unsigned long i, len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000555 char *vec = NULL;
556
557 if (entering(tcp)) {
558 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
559 } else {
560 len = tcp->u_arg[1];
561 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000562 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000563 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
564 tprintf("%#lx", tcp->u_arg[2]);
565 else {
566 tprintf("[");
567 for (i = 0; i < len; i++) {
568 if (abbrev(tcp) && i >= max_strlen) {
569 tprintf("...");
570 break;
571 }
572 tprintf((vec[i] & 1) ? "1" : "0");
573 }
574 tprintf("]");
575 }
576 if (vec)
577 free(vec);
578 }
579 return 0;
580}
581
Roland McGrathda6c92c2007-09-12 01:26:29 +0000582#if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000583int
Denys Vlasenko12014262011-05-30 14:00:14 +0200584sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000585{
586 if (exiting(tcp))
587 return RVAL_HEX;
588 return 0;
589}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +0000590#endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000591
592#if defined(LINUX) && defined(__i386__)
Roland McGrath909875b2002-12-22 03:34:36 +0000593void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000594print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000595{
596 tprintf("base_addr:%#08lx, "
597 "limit:%d, "
598 "seg_32bit:%d, "
599 "contents:%d, "
600 "read_exec_only:%d, "
601 "limit_in_pages:%d, "
602 "seg_not_present:%d, "
603 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000604 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000605 ldt_entry->limit,
606 ldt_entry->seg_32bit,
607 ldt_entry->contents,
608 ldt_entry->read_exec_only,
609 ldt_entry->limit_in_pages,
610 ldt_entry->seg_not_present,
611 ldt_entry->useable);
612}
613
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000614int
Denys Vlasenko12014262011-05-30 14:00:14 +0200615sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000616{
617 if (entering(tcp)) {
618 struct modify_ldt_ldt_s copy;
619 tprintf("%ld", tcp->u_arg[0]);
620 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200621 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000622 || umove(tcp, tcp->u_arg[1], &copy) == -1)
623 tprintf(", %lx", tcp->u_arg[1]);
624 else {
625 tprintf(", {entry_number:%d, ", copy.entry_number);
626 if (!verbose(tcp))
627 tprintf("...}");
628 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000629 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000630 }
631 }
632 tprintf(", %lu", tcp->u_arg[2]);
633 }
634 return 0;
635}
Roland McGrath34e4a692002-12-15 23:58:17 +0000636
637int
Denys Vlasenko12014262011-05-30 14:00:14 +0200638sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000639{
640 struct modify_ldt_ldt_s copy;
641 if (entering(tcp)) {
642 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
643 if (copy.entry_number == -1)
644 tprintf("{entry_number:%d -> ",
645 copy.entry_number);
646 else
647 tprintf("{entry_number:");
648 }
649 } else {
650 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
651 tprintf("%d, ", copy.entry_number);
652 if (!verbose(tcp))
653 tprintf("...}");
654 else {
655 print_ldt_entry(&copy);
656 }
657 } else {
658 tprintf("%lx", tcp->u_arg[0]);
659 }
660 }
661 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000662
Roland McGrath34e4a692002-12-15 23:58:17 +0000663}
664
665int
Denys Vlasenko12014262011-05-30 14:00:14 +0200666sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000667{
668 struct modify_ldt_ldt_s copy;
669 if (exiting(tcp)) {
670 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
671 tprintf("{entry_number:%d, ", copy.entry_number);
672 if (!verbose(tcp))
673 tprintf("...}");
674 else {
675 print_ldt_entry(&copy);
676 }
677 } else {
678 tprintf("%lx", tcp->u_arg[0]);
679 }
680 }
681 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000682
Roland McGrath34e4a692002-12-15 23:58:17 +0000683}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000684#endif /* LINUX && __i386__ */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000685
Andreas Schwab58743222010-05-28 22:28:51 +0200686#if defined(LINUX) && defined(M68K)
687
688int
Denys Vlasenko12014262011-05-30 14:00:14 +0200689sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200690{
691 if (entering(tcp))
692 tprintf("%#lx", tcp->u_arg[0]);
693 return 0;
694
695}
696
697int
Denys Vlasenko12014262011-05-30 14:00:14 +0200698sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200699{
700 return RVAL_HEX;
701}
702#endif
703
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000704#if defined(LINUX)
705int
Denys Vlasenko12014262011-05-30 14:00:14 +0200706sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000707{
708 if (entering(tcp)) {
709 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000710 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000711 tprintf(", %lu, ", tcp->u_arg[3]);
712#ifdef MAP_TYPE
713 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
714 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
715#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000716 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000717#endif
718 }
719 return 0;
720}
Roland McGrathb10a3352004-10-07 18:53:12 +0000721
722
723#define MPOL_DEFAULT 0
724#define MPOL_PREFERRED 1
725#define MPOL_BIND 2
726#define MPOL_INTERLEAVE 3
727
728#define MPOL_F_NODE (1<<0)
729#define MPOL_F_ADDR (1<<1)
730
731#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000732#define MPOL_MF_MOVE (1<<1)
733#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000734
735
736static const struct xlat policies[] = {
737 { MPOL_DEFAULT, "MPOL_DEFAULT" },
738 { MPOL_PREFERRED, "MPOL_PREFERRED" },
739 { MPOL_BIND, "MPOL_BIND" },
740 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
741 { 0, NULL }
742};
743
744static const struct xlat mbindflags[] = {
745 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000746 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
747 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000748 { 0, NULL }
749};
750
751static const struct xlat mempolicyflags[] = {
752 { MPOL_F_NODE, "MPOL_F_NODE" },
753 { MPOL_F_ADDR, "MPOL_F_ADDR" },
754 { 0, NULL }
755};
756
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000757static const struct xlat move_pages_flags[] = {
758 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
759 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
760 { 0, NULL }
761};
762
Roland McGrathb10a3352004-10-07 18:53:12 +0000763
764static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200765get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000766{
Roland McGrathaa524c82005-06-01 19:22:06 +0000767 unsigned long nlongs, size, end;
768
769 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
770 size = nlongs * sizeof(long);
771 end = ptr + size;
772 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
773 && (end > ptr))) {
774 unsigned long n, cur, abbrev_end;
775 int failed = 0;
776
777 if (abbrev(tcp)) {
778 abbrev_end = ptr + max_strlen * sizeof(long);
779 if (abbrev_end < ptr)
780 abbrev_end = end;
781 } else {
782 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000783 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000784 tprintf(", {");
785 for (cur = ptr; cur < end; cur += sizeof(long)) {
786 if (cur > ptr)
787 tprintf(", ");
788 if (cur >= abbrev_end) {
789 tprintf("...");
790 break;
791 }
792 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
793 tprintf("?");
794 failed = 1;
795 break;
796 }
797 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
798 }
799 tprintf("}");
800 if (failed)
801 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000802 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000803 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000804 tprintf(", %lu", maxnodes);
805}
806
807int
Denys Vlasenko12014262011-05-30 14:00:14 +0200808sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000809{
810 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000811 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000812 printxval(policies, tcp->u_arg[2], "MPOL_???");
813 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
814 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000815 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000816 }
817 return 0;
818}
819
820int
Denys Vlasenko12014262011-05-30 14:00:14 +0200821sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000822{
823 if (entering(tcp)) {
824 printxval(policies, tcp->u_arg[0], "MPOL_???");
825 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
826 }
827 return 0;
828}
829
830int
Denys Vlasenko12014262011-05-30 14:00:14 +0200831sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000832{
833 if (exiting(tcp)) {
834 int pol;
835 if (tcp->u_arg[0] == 0)
836 tprintf("NULL");
837 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
838 tprintf("%#lx", tcp->u_arg[0]);
839 else
840 printxval(policies, pol, "MPOL_???");
841 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
842 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000843 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000844 }
845 return 0;
846}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000847
848int
Denys Vlasenko12014262011-05-30 14:00:14 +0200849sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000850{
851 if (entering(tcp)) {
852 unsigned long npages = tcp->u_arg[1];
853 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
854 if (tcp->u_arg[2] == 0)
855 tprintf("NULL, ");
856 else {
857 int i;
858 long puser = tcp->u_arg[2];
859 tprintf("{");
860 for (i = 0; i < npages; ++i) {
861 void *p;
862 if (i > 0)
863 tprintf(", ");
864 if (umove(tcp, puser, &p) < 0) {
865 tprintf("???");
866 break;
867 }
868 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200869 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000870 }
871 tprintf("}, ");
872 }
873 if (tcp->u_arg[3] == 0)
874 tprintf("NULL, ");
875 else {
876 int i;
877 long nodeuser = tcp->u_arg[3];
878 tprintf("{");
879 for (i = 0; i < npages; ++i) {
880 int node;
881 if (i > 0)
882 tprintf(", ");
883 if (umove(tcp, nodeuser, &node) < 0) {
884 tprintf("???");
885 break;
886 }
887 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200888 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000889 }
890 tprintf("}, ");
891 }
892 }
893 if (exiting(tcp)) {
894 unsigned long npages = tcp->u_arg[1];
895 if (tcp->u_arg[4] == 0)
896 tprintf("NULL, ");
897 else {
898 int i;
899 long statususer = tcp->u_arg[4];
900 tprintf("{");
901 for (i = 0; i < npages; ++i) {
902 int status;
903 if (i > 0)
904 tprintf(", ");
905 if (umove(tcp, statususer, &status) < 0) {
906 tprintf("???");
907 break;
908 }
909 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200910 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000911 }
912 tprintf("}, ");
913 }
914 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
915 }
916 return 0;
917}
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000918#endif
Roland McGrath4a6f6522008-08-25 03:09:16 +0000919
920#if defined(LINUX) && defined(POWERPC)
921int
Denys Vlasenko12014262011-05-30 14:00:14 +0200922sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000923{
924 if (entering(tcp)) {
925 unsigned long cur, end, abbrev_end, entries;
926 unsigned int entry;
927
928 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
929 entries = tcp->u_arg[1] >> 16;
930 if (!entries || !tcp->u_arg[2]) {
931 tprintf("{}");
932 return 0;
933 }
934 cur = tcp->u_arg[2];
935 end = cur + (sizeof(int) * entries);
936 if (!verbose(tcp) || end < tcp->u_arg[2]) {
937 tprintf("%#lx", tcp->u_arg[2]);
938 return 0;
939 }
940 if (abbrev(tcp)) {
941 abbrev_end = cur + (sizeof(int) * max_strlen);
942 if (abbrev_end > end)
943 abbrev_end = end;
944 }
945 else
946 abbrev_end = end;
947 tprintf("{");
948 for (; cur < end; cur += sizeof(int)) {
949 if (cur > tcp->u_arg[2])
950 tprintf(", ");
951 if (cur >= abbrev_end) {
952 tprintf("...");
953 break;
954 }
955 if (umove(tcp, cur, &entry) < 0) {
956 tprintf("??? [%#lx]", cur);
957 break;
958 }
959 else
960 tprintf("%#08x", entry);
961 }
962 tprintf("}");
963 }
964
965 return 0;
966}
967#endif