blob: f0ccfc79727a47bb2c78736645c5aa905d7a783b [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{
337#ifdef linux
338#ifdef ALPHA
339 long *u_arg = tcp->u_arg;
340#else /* !ALPHA */
341 long u_arg[7];
342#endif /* !ALPHA */
343#else /* !linux */
344 long *u_arg = tcp->u_arg;
345#endif /* !linux */
346
347 if (entering(tcp)) {
348#ifdef linux
349#ifndef ALPHA
350 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
351 (char *) u_arg) == -1)
352 return 0;
353#endif /* ALPHA */
354#endif /* linux */
355
356 /* addr */
357 tprintf("%#lx, ", u_arg[0]);
358 /* len */
359 tprintf("%lu, ", u_arg[1]);
360 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000361 printflags(mmap_prot, u_arg[2], "PROT_???");
John Hughesbdf48f52001-03-06 15:08:09 +0000362 tprintf(", ");
363 /* flags */
John Hughes5a826b82001-03-07 13:21:24 +0000364#ifdef MAP_TYPE
John Hughesbdf48f52001-03-06 15:08:09 +0000365 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
366 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
John Hughes5a826b82001-03-07 13:21:24 +0000367#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000368 printflags(mmap_flags, u_arg[3], "MAP_???");
John Hughes5a826b82001-03-07 13:21:24 +0000369#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000370 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300371 tprintf(", ");
372 printfd(tcp, tcp->u_arg[4]);
John Hughesbdf48f52001-03-06 15:08:09 +0000373 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300374 printllval(tcp, ", %#llx", 5);
John Hughesbdf48f52001-03-06 15:08:09 +0000375 }
376 return RVAL_HEX;
377}
378#endif
379
Roland McGrath909875b2002-12-22 03:34:36 +0000380
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000381int
Denys Vlasenko12014262011-05-30 14:00:14 +0200382sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000383{
384 if (entering(tcp)) {
385 tprintf("%#lx, %lu",
386 tcp->u_arg[0], tcp->u_arg[1]);
387 }
388 return 0;
389}
390
391int
Denys Vlasenko12014262011-05-30 14:00:14 +0200392sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000393{
394 if (entering(tcp)) {
395 tprintf("%#lx, %lu, ",
396 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000397 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000398 }
399 return 0;
400}
401
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000402#ifdef LINUX
403
Roland McGrathd9f816f2004-09-04 03:39:20 +0000404static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000405 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000406#ifdef MREMAP_FIXED
407 { MREMAP_FIXED, "MREMAP_FIXED" },
408#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000409 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000410};
411
412int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000413sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000414{
415 if (entering(tcp)) {
416 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
417 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000418 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000419#ifdef MREMAP_FIXED
420 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
421 (MREMAP_MAYMOVE | MREMAP_FIXED))
422 tprintf(", %#lx", tcp->u_arg[4]);
423#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000424 }
425 return RVAL_HEX;
426}
427
Roland McGrathf4021b12008-08-25 02:59:36 +0000428static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000429#ifdef MADV_NORMAL
430 { MADV_NORMAL, "MADV_NORMAL" },
431#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000432#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000433 { MADV_RANDOM, "MADV_RANDOM" },
434#endif
435#ifdef MADV_SEQUENTIAL
436 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
437#endif
438#ifdef MADV_WILLNEED
439 { MADV_WILLNEED, "MADV_WILLNEED" },
440#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000441#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000442 { MADV_DONTNEED, "MADV_DONTNEED" },
443#endif
444 { 0, NULL },
445};
446
447
448int
Denys Vlasenko12014262011-05-30 14:00:14 +0200449sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000450{
451 if (entering(tcp)) {
452 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000453 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000454 }
455 return 0;
456}
457
458
Roland McGrathd9f816f2004-09-04 03:39:20 +0000459static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000460#ifdef MCL_CURRENT
461 { MCL_CURRENT, "MCL_CURRENT" },
462#endif
463#ifdef MCL_FUTURE
464 { MCL_FUTURE, "MCL_FUTURE" },
465#endif
466 { 0, NULL}
467};
468
469int
Denys Vlasenko12014262011-05-30 14:00:14 +0200470sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000471{
472 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000473 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000474 }
475 return 0;
476}
477
478
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000479#endif /* LINUX */
480
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000481#ifdef MS_ASYNC
482
Roland McGrathd9f816f2004-09-04 03:39:20 +0000483static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000484#ifdef MS_SYNC
485 { MS_SYNC, "MS_SYNC" },
486#endif
John Hughesaca07f32001-10-16 18:12:27 +0000487 { MS_ASYNC, "MS_ASYNC" },
488 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000489 { 0, NULL },
490};
491
492int
Denys Vlasenko12014262011-05-30 14:00:14 +0200493sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000494{
495 if (entering(tcp)) {
496 /* addr */
497 tprintf("%#lx", tcp->u_arg[0]);
498 /* len */
499 tprintf(", %lu, ", tcp->u_arg[1]);
500 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000501 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000502 }
503 return 0;
504}
505
506#endif /* MS_ASYNC */
507
508#ifdef MC_SYNC
509
Roland McGrathd9f816f2004-09-04 03:39:20 +0000510static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000511 { MC_LOCK, "MC_LOCK" },
512 { MC_LOCKAS, "MC_LOCKAS" },
513 { MC_SYNC, "MC_SYNC" },
514 { MC_UNLOCK, "MC_UNLOCK" },
515 { MC_UNLOCKAS, "MC_UNLOCKAS" },
516 { 0, NULL },
517};
518
Roland McGrathd9f816f2004-09-04 03:39:20 +0000519static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000520 { MCL_CURRENT, "MCL_CURRENT" },
521 { MCL_FUTURE, "MCL_FUTURE" },
522 { 0, NULL },
523};
524
525int
Denys Vlasenko12014262011-05-30 14:00:14 +0200526sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000527{
528 int arg, function;
529
530 if (entering(tcp)) {
531 /* addr */
532 tprintf("%#lx", tcp->u_arg[0]);
533 /* len */
534 tprintf(", %lu, ", tcp->u_arg[1]);
535 /* function */
536 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000537 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000538 /* arg */
539 arg = tcp->u_arg[3];
540 tprintf(", ");
541 switch (function) {
542 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000543 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000544 break;
545 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000546 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000547 break;
548 default:
549 tprintf("%#x", arg);
550 break;
551 }
552 }
553 return 0;
554}
555
556#endif /* MC_SYNC */
557
558int
Denys Vlasenko12014262011-05-30 14:00:14 +0200559sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000560{
Roland McGrath46100d02005-06-01 18:55:42 +0000561 unsigned long i, len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000562 char *vec = NULL;
563
564 if (entering(tcp)) {
565 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
566 } else {
567 len = tcp->u_arg[1];
568 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000569 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000570 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
571 tprintf("%#lx", tcp->u_arg[2]);
572 else {
573 tprintf("[");
574 for (i = 0; i < len; i++) {
575 if (abbrev(tcp) && i >= max_strlen) {
576 tprintf("...");
577 break;
578 }
579 tprintf((vec[i] & 1) ? "1" : "0");
580 }
581 tprintf("]");
582 }
583 if (vec)
584 free(vec);
585 }
586 return 0;
587}
588
Roland McGrathda6c92c2007-09-12 01:26:29 +0000589#if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000590int
Denys Vlasenko12014262011-05-30 14:00:14 +0200591sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000592{
593 if (exiting(tcp))
594 return RVAL_HEX;
595 return 0;
596}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +0000597#endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000598
599#if defined(LINUX) && defined(__i386__)
Roland McGrath909875b2002-12-22 03:34:36 +0000600void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000601print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000602{
603 tprintf("base_addr:%#08lx, "
604 "limit:%d, "
605 "seg_32bit:%d, "
606 "contents:%d, "
607 "read_exec_only:%d, "
608 "limit_in_pages:%d, "
609 "seg_not_present:%d, "
610 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000611 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000612 ldt_entry->limit,
613 ldt_entry->seg_32bit,
614 ldt_entry->contents,
615 ldt_entry->read_exec_only,
616 ldt_entry->limit_in_pages,
617 ldt_entry->seg_not_present,
618 ldt_entry->useable);
619}
620
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000621int
Denys Vlasenko12014262011-05-30 14:00:14 +0200622sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000623{
624 if (entering(tcp)) {
625 struct modify_ldt_ldt_s copy;
626 tprintf("%ld", tcp->u_arg[0]);
627 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200628 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000629 || umove(tcp, tcp->u_arg[1], &copy) == -1)
630 tprintf(", %lx", tcp->u_arg[1]);
631 else {
632 tprintf(", {entry_number:%d, ", copy.entry_number);
633 if (!verbose(tcp))
634 tprintf("...}");
635 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000636 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000637 }
638 }
639 tprintf(", %lu", tcp->u_arg[2]);
640 }
641 return 0;
642}
Roland McGrath34e4a692002-12-15 23:58:17 +0000643
644int
Denys Vlasenko12014262011-05-30 14:00:14 +0200645sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000646{
647 struct modify_ldt_ldt_s copy;
648 if (entering(tcp)) {
649 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
650 if (copy.entry_number == -1)
651 tprintf("{entry_number:%d -> ",
652 copy.entry_number);
653 else
654 tprintf("{entry_number:");
655 }
656 } else {
657 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
658 tprintf("%d, ", copy.entry_number);
659 if (!verbose(tcp))
660 tprintf("...}");
661 else {
662 print_ldt_entry(&copy);
663 }
664 } else {
665 tprintf("%lx", tcp->u_arg[0]);
666 }
667 }
668 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000669
Roland McGrath34e4a692002-12-15 23:58:17 +0000670}
671
672int
Denys Vlasenko12014262011-05-30 14:00:14 +0200673sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000674{
675 struct modify_ldt_ldt_s copy;
676 if (exiting(tcp)) {
677 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
678 tprintf("{entry_number:%d, ", copy.entry_number);
679 if (!verbose(tcp))
680 tprintf("...}");
681 else {
682 print_ldt_entry(&copy);
683 }
684 } else {
685 tprintf("%lx", tcp->u_arg[0]);
686 }
687 }
688 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000689
Roland McGrath34e4a692002-12-15 23:58:17 +0000690}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000691#endif /* LINUX && __i386__ */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000692
Andreas Schwab58743222010-05-28 22:28:51 +0200693#if defined(LINUX) && defined(M68K)
694
695int
Denys Vlasenko12014262011-05-30 14:00:14 +0200696sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200697{
698 if (entering(tcp))
699 tprintf("%#lx", tcp->u_arg[0]);
700 return 0;
701
702}
703
704int
Denys Vlasenko12014262011-05-30 14:00:14 +0200705sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200706{
707 return RVAL_HEX;
708}
709#endif
710
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000711#if defined(LINUX)
712int
Denys Vlasenko12014262011-05-30 14:00:14 +0200713sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000714{
715 if (entering(tcp)) {
716 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000717 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000718 tprintf(", %lu, ", tcp->u_arg[3]);
719#ifdef MAP_TYPE
720 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
721 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
722#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000723 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000724#endif
725 }
726 return 0;
727}
Roland McGrathb10a3352004-10-07 18:53:12 +0000728
729
730#define MPOL_DEFAULT 0
731#define MPOL_PREFERRED 1
732#define MPOL_BIND 2
733#define MPOL_INTERLEAVE 3
734
735#define MPOL_F_NODE (1<<0)
736#define MPOL_F_ADDR (1<<1)
737
738#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000739#define MPOL_MF_MOVE (1<<1)
740#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000741
742
743static const struct xlat policies[] = {
744 { MPOL_DEFAULT, "MPOL_DEFAULT" },
745 { MPOL_PREFERRED, "MPOL_PREFERRED" },
746 { MPOL_BIND, "MPOL_BIND" },
747 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
748 { 0, NULL }
749};
750
751static const struct xlat mbindflags[] = {
752 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000753 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
754 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000755 { 0, NULL }
756};
757
758static const struct xlat mempolicyflags[] = {
759 { MPOL_F_NODE, "MPOL_F_NODE" },
760 { MPOL_F_ADDR, "MPOL_F_ADDR" },
761 { 0, NULL }
762};
763
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000764static const struct xlat move_pages_flags[] = {
765 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
766 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
767 { 0, NULL }
768};
769
Roland McGrathb10a3352004-10-07 18:53:12 +0000770
771static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200772get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000773{
Roland McGrathaa524c82005-06-01 19:22:06 +0000774 unsigned long nlongs, size, end;
775
776 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
777 size = nlongs * sizeof(long);
778 end = ptr + size;
779 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
780 && (end > ptr))) {
781 unsigned long n, cur, abbrev_end;
782 int failed = 0;
783
784 if (abbrev(tcp)) {
785 abbrev_end = ptr + max_strlen * sizeof(long);
786 if (abbrev_end < ptr)
787 abbrev_end = end;
788 } else {
789 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000790 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000791 tprintf(", {");
792 for (cur = ptr; cur < end; cur += sizeof(long)) {
793 if (cur > ptr)
794 tprintf(", ");
795 if (cur >= abbrev_end) {
796 tprintf("...");
797 break;
798 }
799 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
800 tprintf("?");
801 failed = 1;
802 break;
803 }
804 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
805 }
806 tprintf("}");
807 if (failed)
808 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000809 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000810 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000811 tprintf(", %lu", maxnodes);
812}
813
814int
Denys Vlasenko12014262011-05-30 14:00:14 +0200815sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000816{
817 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000818 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000819 printxval(policies, tcp->u_arg[2], "MPOL_???");
820 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
821 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000822 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000823 }
824 return 0;
825}
826
827int
Denys Vlasenko12014262011-05-30 14:00:14 +0200828sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000829{
830 if (entering(tcp)) {
831 printxval(policies, tcp->u_arg[0], "MPOL_???");
832 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
833 }
834 return 0;
835}
836
837int
Denys Vlasenko12014262011-05-30 14:00:14 +0200838sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000839{
840 if (exiting(tcp)) {
841 int pol;
842 if (tcp->u_arg[0] == 0)
843 tprintf("NULL");
844 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
845 tprintf("%#lx", tcp->u_arg[0]);
846 else
847 printxval(policies, pol, "MPOL_???");
848 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
849 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000850 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000851 }
852 return 0;
853}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000854
855int
Denys Vlasenko12014262011-05-30 14:00:14 +0200856sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000857{
858 if (entering(tcp)) {
859 unsigned long npages = tcp->u_arg[1];
860 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
861 if (tcp->u_arg[2] == 0)
862 tprintf("NULL, ");
863 else {
864 int i;
865 long puser = tcp->u_arg[2];
866 tprintf("{");
867 for (i = 0; i < npages; ++i) {
868 void *p;
869 if (i > 0)
870 tprintf(", ");
871 if (umove(tcp, puser, &p) < 0) {
872 tprintf("???");
873 break;
874 }
875 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200876 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000877 }
878 tprintf("}, ");
879 }
880 if (tcp->u_arg[3] == 0)
881 tprintf("NULL, ");
882 else {
883 int i;
884 long nodeuser = tcp->u_arg[3];
885 tprintf("{");
886 for (i = 0; i < npages; ++i) {
887 int node;
888 if (i > 0)
889 tprintf(", ");
890 if (umove(tcp, nodeuser, &node) < 0) {
891 tprintf("???");
892 break;
893 }
894 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200895 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000896 }
897 tprintf("}, ");
898 }
899 }
900 if (exiting(tcp)) {
901 unsigned long npages = tcp->u_arg[1];
902 if (tcp->u_arg[4] == 0)
903 tprintf("NULL, ");
904 else {
905 int i;
906 long statususer = tcp->u_arg[4];
907 tprintf("{");
908 for (i = 0; i < npages; ++i) {
909 int status;
910 if (i > 0)
911 tprintf(", ");
912 if (umove(tcp, statususer, &status) < 0) {
913 tprintf("???");
914 break;
915 }
916 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200917 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000918 }
919 tprintf("}, ");
920 }
921 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
922 }
923 return 0;
924}
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000925#endif
Roland McGrath4a6f6522008-08-25 03:09:16 +0000926
927#if defined(LINUX) && defined(POWERPC)
928int
Denys Vlasenko12014262011-05-30 14:00:14 +0200929sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000930{
931 if (entering(tcp)) {
932 unsigned long cur, end, abbrev_end, entries;
933 unsigned int entry;
934
935 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
936 entries = tcp->u_arg[1] >> 16;
937 if (!entries || !tcp->u_arg[2]) {
938 tprintf("{}");
939 return 0;
940 }
941 cur = tcp->u_arg[2];
942 end = cur + (sizeof(int) * entries);
943 if (!verbose(tcp) || end < tcp->u_arg[2]) {
944 tprintf("%#lx", tcp->u_arg[2]);
945 return 0;
946 }
947 if (abbrev(tcp)) {
948 abbrev_end = cur + (sizeof(int) * max_strlen);
949 if (abbrev_end > end)
950 abbrev_end = end;
951 }
952 else
953 abbrev_end = end;
954 tprintf("{");
955 for (; cur < end; cur += sizeof(int)) {
956 if (cur > tcp->u_arg[2])
957 tprintf(", ");
958 if (cur >= abbrev_end) {
959 tprintf("...");
960 break;
961 }
962 if (umove(tcp, cur, &entry) < 0) {
963 tprintf("??? [%#lx]", cur);
964 break;
965 }
966 else
967 tprintf("%#08x", entry);
968 }
969 tprintf("}");
970 }
971
972 return 0;
973}
974#endif