blob: 56c20cc5edb29dede1a4d0ef27edc4c4cfcc9303 [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)
Wichert Akkerman8bc6cfd1999-04-21 15:57:38 +000043#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)
Roland McGrathe1e584b2003-06-02 19:18:58 +000049#include <asm/page.h> /* for PAGE_SHIFT */
50#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
198static
199int
200addtileflags(flags)
201long flags;
202{
203 long home = flags & _MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
204 flags &= ~_MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK);
205
206 if (flags & _MAP_CACHE_INCOHERENT) {
207 flags &= ~_MAP_CACHE_INCOHERENT;
208 if (home == MAP_CACHE_HOME_NONE) {
209 tprintf("|MAP_CACHE_INCOHERENT");
210 return flags;
211 }
212 tprintf("|_MAP_CACHE_INCOHERENT");
213 }
214
215 switch (home) {
216 case 0: break;
217 case MAP_CACHE_HOME_HERE: tprintf("|MAP_CACHE_HOME_HERE"); break;
218 case MAP_CACHE_HOME_NONE: tprintf("|MAP_CACHE_HOME_NONE"); break;
219 case MAP_CACHE_HOME_SINGLE: tprintf("|MAP_CACHE_HOME_SINGLE"); break;
220 case MAP_CACHE_HOME_TASK: tprintf("|MAP_CACHE_HOME_TASK"); break;
221 case MAP_CACHE_HOME_HASH: tprintf("|MAP_CACHE_HOME_HASH"); break;
222 default:
223 tprintf("|MAP_CACHE_HOME(%d)",
224 (home >> _MAP_CACHE_HOME_SHIFT) );
225 break;
226 }
227
228 return flags;
229}
230#endif
231
John Hughes70623be2001-03-08 13:59:00 +0000232#if !HAVE_LONG_LONG_OFF_T
Dmitry V. Levin31382132011-03-04 05:08:02 +0300233static int
234print_mmap(struct tcb *tcp, long *u_arg, long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000235{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000236 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000237 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +0000238 if (!u_arg[0])
239 tprintf("NULL, ");
240 else
241 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000242 /* len */
243 tprintf("%lu, ", u_arg[1]);
244 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000245 printflags(mmap_prot, u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000246 tprintf(", ");
247 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000248#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000249 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500250#ifdef TILE
251 addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE));
252#else
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000253 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Chris Metcalfc8c66982009-12-28 10:00:15 -0500254#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000255#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000256 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000257#endif
Dmitry V. Levin31382132011-03-04 05:08:02 +0300258 /* fd */
259 tprintf(", ");
260 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000261 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300262 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000263 }
264 return RVAL_HEX;
265}
266
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000267#ifdef LINUX
Denys Vlasenko12014262011-05-30 14:00:14 +0200268int sys_old_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000269{
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000270 long u_arg[6];
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000271
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000272#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000273 int i, v;
274 /*
275 * IA64 processes never call this routine, they only use the
276 * new `sys_mmap' interface. This code converts the integer
277 * arguments that the IA32 process pushed onto the stack into
278 * longs.
279 *
280 * Note that addresses with bit 31 set will be sign extended.
281 * Fortunately, those addresses are not currently being generated
282 * for IA32 processes so it's not a problem.
283 */
284 for (i = 0; i < 6; i++)
285 if (umove(tcp, tcp->u_arg[0] + (i * sizeof(int)), &v) == -1)
286 return 0;
287 else
288 u_arg[i] = v;
Roland McGrathf5a47772003-06-26 22:40:42 +0000289#elif defined(SH) || defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000290 /* SH has always passed the args in registers */
291 int i;
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200292 for (i = 0; i < 6; i++)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000293 u_arg[i] = tcp->u_arg[i];
Roland McGrath6b1d43e2003-03-31 01:05:01 +0000294#else
Roland McGrath520e21f2005-07-05 09:50:18 +0000295# if defined(X86_64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000296 if (current_personality == 1) {
297 int i;
298 for (i = 0; i < 6; ++i) {
299 unsigned int val;
300 if (umove(tcp, tcp->u_arg[0] + i * 4, &val) == -1)
301 return 0;
302 u_arg[i] = val;
303 }
304 }
305 else
Roland McGrath520e21f2005-07-05 09:50:18 +0000306# endif
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000307 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1)
308 return 0;
Wichert Akkerman8b1b40c2000-02-03 21:58:30 +0000309#endif // defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000310 return print_mmap(tcp, u_arg, u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000311}
312#endif
313
314int
Denys Vlasenko12014262011-05-30 14:00:14 +0200315sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000316{
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000317 long long offset = tcp->u_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000318
Roland McGrathf5a47772003-06-26 22:40:42 +0000319#if defined(LINUX) && defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000320 /*
321 * Old mmap differs from new mmap in specifying the
322 * offset in units of bytes rather than pages. We
323 * pretend it's in byte units so the user only ever
324 * sees bytes in the printout.
325 */
326 offset <<= PAGE_SHIFT;
Roland McGrathe1e584b2003-06-02 19:18:58 +0000327#endif
Roland McGrath542c2c62008-05-20 01:11:56 +0000328#if defined(LINUX_MIPSN32)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000329 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000330#endif
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000331 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000332}
John Hughes70623be2001-03-08 13:59:00 +0000333#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000334
John Hughes70623be2001-03-08 13:59:00 +0000335#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000336int
Dmitry V. Levin31382132011-03-04 05:08:02 +0300337sys_mmap64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000338{
339#ifdef linux
340#ifdef ALPHA
341 long *u_arg = tcp->u_arg;
342#else /* !ALPHA */
343 long u_arg[7];
344#endif /* !ALPHA */
345#else /* !linux */
346 long *u_arg = tcp->u_arg;
347#endif /* !linux */
348
349 if (entering(tcp)) {
350#ifdef linux
351#ifndef ALPHA
352 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
353 (char *) u_arg) == -1)
354 return 0;
355#endif /* ALPHA */
356#endif /* linux */
357
358 /* addr */
359 tprintf("%#lx, ", u_arg[0]);
360 /* len */
361 tprintf("%lu, ", u_arg[1]);
362 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000363 printflags(mmap_prot, u_arg[2], "PROT_???");
John Hughesbdf48f52001-03-06 15:08:09 +0000364 tprintf(", ");
365 /* flags */
John Hughes5a826b82001-03-07 13:21:24 +0000366#ifdef MAP_TYPE
John Hughesbdf48f52001-03-06 15:08:09 +0000367 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
368 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
John Hughes5a826b82001-03-07 13:21:24 +0000369#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000370 printflags(mmap_flags, u_arg[3], "MAP_???");
John Hughes5a826b82001-03-07 13:21:24 +0000371#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000372 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300373 tprintf(", ");
374 printfd(tcp, tcp->u_arg[4]);
John Hughesbdf48f52001-03-06 15:08:09 +0000375 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300376 printllval(tcp, ", %#llx", 5);
John Hughesbdf48f52001-03-06 15:08:09 +0000377 }
378 return RVAL_HEX;
379}
380#endif
381
Roland McGrath909875b2002-12-22 03:34:36 +0000382
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000383int
Denys Vlasenko12014262011-05-30 14:00:14 +0200384sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000385{
386 if (entering(tcp)) {
387 tprintf("%#lx, %lu",
388 tcp->u_arg[0], tcp->u_arg[1]);
389 }
390 return 0;
391}
392
393int
Denys Vlasenko12014262011-05-30 14:00:14 +0200394sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000395{
396 if (entering(tcp)) {
397 tprintf("%#lx, %lu, ",
398 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000399 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000400 }
401 return 0;
402}
403
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000404#ifdef LINUX
405
Roland McGrathd9f816f2004-09-04 03:39:20 +0000406static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000407 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000408#ifdef MREMAP_FIXED
409 { MREMAP_FIXED, "MREMAP_FIXED" },
410#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000411 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000412};
413
414int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000415sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000416{
417 if (entering(tcp)) {
418 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
419 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000420 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000421#ifdef MREMAP_FIXED
422 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
423 (MREMAP_MAYMOVE | MREMAP_FIXED))
424 tprintf(", %#lx", tcp->u_arg[4]);
425#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000426 }
427 return RVAL_HEX;
428}
429
Roland McGrathf4021b12008-08-25 02:59:36 +0000430static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000431#ifdef MADV_NORMAL
432 { MADV_NORMAL, "MADV_NORMAL" },
433#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000434#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000435 { MADV_RANDOM, "MADV_RANDOM" },
436#endif
437#ifdef MADV_SEQUENTIAL
438 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
439#endif
440#ifdef MADV_WILLNEED
441 { MADV_WILLNEED, "MADV_WILLNEED" },
442#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000443#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000444 { MADV_DONTNEED, "MADV_DONTNEED" },
445#endif
446 { 0, NULL },
447};
448
449
450int
Denys Vlasenko12014262011-05-30 14:00:14 +0200451sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000452{
453 if (entering(tcp)) {
454 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000455 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000456 }
457 return 0;
458}
459
460
Roland McGrathd9f816f2004-09-04 03:39:20 +0000461static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000462#ifdef MCL_CURRENT
463 { MCL_CURRENT, "MCL_CURRENT" },
464#endif
465#ifdef MCL_FUTURE
466 { MCL_FUTURE, "MCL_FUTURE" },
467#endif
468 { 0, NULL}
469};
470
471int
Denys Vlasenko12014262011-05-30 14:00:14 +0200472sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000473{
474 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000475 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000476 }
477 return 0;
478}
479
480
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000481#endif /* LINUX */
482
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000483#ifdef MS_ASYNC
484
Roland McGrathd9f816f2004-09-04 03:39:20 +0000485static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000486#ifdef MS_SYNC
487 { MS_SYNC, "MS_SYNC" },
488#endif
John Hughesaca07f32001-10-16 18:12:27 +0000489 { MS_ASYNC, "MS_ASYNC" },
490 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000491 { 0, NULL },
492};
493
494int
Denys Vlasenko12014262011-05-30 14:00:14 +0200495sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000496{
497 if (entering(tcp)) {
498 /* addr */
499 tprintf("%#lx", tcp->u_arg[0]);
500 /* len */
501 tprintf(", %lu, ", tcp->u_arg[1]);
502 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000503 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000504 }
505 return 0;
506}
507
508#endif /* MS_ASYNC */
509
510#ifdef MC_SYNC
511
Roland McGrathd9f816f2004-09-04 03:39:20 +0000512static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000513 { MC_LOCK, "MC_LOCK" },
514 { MC_LOCKAS, "MC_LOCKAS" },
515 { MC_SYNC, "MC_SYNC" },
516 { MC_UNLOCK, "MC_UNLOCK" },
517 { MC_UNLOCKAS, "MC_UNLOCKAS" },
518 { 0, NULL },
519};
520
Roland McGrathd9f816f2004-09-04 03:39:20 +0000521static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000522 { MCL_CURRENT, "MCL_CURRENT" },
523 { MCL_FUTURE, "MCL_FUTURE" },
524 { 0, NULL },
525};
526
527int
Denys Vlasenko12014262011-05-30 14:00:14 +0200528sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000529{
530 int arg, function;
531
532 if (entering(tcp)) {
533 /* addr */
534 tprintf("%#lx", tcp->u_arg[0]);
535 /* len */
536 tprintf(", %lu, ", tcp->u_arg[1]);
537 /* function */
538 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000539 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000540 /* arg */
541 arg = tcp->u_arg[3];
542 tprintf(", ");
543 switch (function) {
544 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000545 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000546 break;
547 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000548 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000549 break;
550 default:
551 tprintf("%#x", arg);
552 break;
553 }
554 }
555 return 0;
556}
557
558#endif /* MC_SYNC */
559
560int
Denys Vlasenko12014262011-05-30 14:00:14 +0200561sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000562{
Roland McGrath46100d02005-06-01 18:55:42 +0000563 unsigned long i, len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000564 char *vec = NULL;
565
566 if (entering(tcp)) {
567 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
568 } else {
569 len = tcp->u_arg[1];
570 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000571 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000572 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
573 tprintf("%#lx", tcp->u_arg[2]);
574 else {
575 tprintf("[");
576 for (i = 0; i < len; i++) {
577 if (abbrev(tcp) && i >= max_strlen) {
578 tprintf("...");
579 break;
580 }
581 tprintf((vec[i] & 1) ? "1" : "0");
582 }
583 tprintf("]");
584 }
585 if (vec)
586 free(vec);
587 }
588 return 0;
589}
590
Roland McGrathda6c92c2007-09-12 01:26:29 +0000591#if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000592int
Denys Vlasenko12014262011-05-30 14:00:14 +0200593sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000594{
595 if (exiting(tcp))
596 return RVAL_HEX;
597 return 0;
598}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +0000599#endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000600
601#if defined(LINUX) && defined(__i386__)
Roland McGrath909875b2002-12-22 03:34:36 +0000602void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000603print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000604{
605 tprintf("base_addr:%#08lx, "
606 "limit:%d, "
607 "seg_32bit:%d, "
608 "contents:%d, "
609 "read_exec_only:%d, "
610 "limit_in_pages:%d, "
611 "seg_not_present:%d, "
612 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000613 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000614 ldt_entry->limit,
615 ldt_entry->seg_32bit,
616 ldt_entry->contents,
617 ldt_entry->read_exec_only,
618 ldt_entry->limit_in_pages,
619 ldt_entry->seg_not_present,
620 ldt_entry->useable);
621}
622
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000623int
Denys Vlasenko12014262011-05-30 14:00:14 +0200624sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000625{
626 if (entering(tcp)) {
627 struct modify_ldt_ldt_s copy;
628 tprintf("%ld", tcp->u_arg[0]);
629 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200630 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000631 || umove(tcp, tcp->u_arg[1], &copy) == -1)
632 tprintf(", %lx", tcp->u_arg[1]);
633 else {
634 tprintf(", {entry_number:%d, ", copy.entry_number);
635 if (!verbose(tcp))
636 tprintf("...}");
637 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000638 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000639 }
640 }
641 tprintf(", %lu", tcp->u_arg[2]);
642 }
643 return 0;
644}
Roland McGrath34e4a692002-12-15 23:58:17 +0000645
646int
Denys Vlasenko12014262011-05-30 14:00:14 +0200647sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000648{
649 struct modify_ldt_ldt_s copy;
650 if (entering(tcp)) {
651 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
652 if (copy.entry_number == -1)
653 tprintf("{entry_number:%d -> ",
654 copy.entry_number);
655 else
656 tprintf("{entry_number:");
657 }
658 } else {
659 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
660 tprintf("%d, ", copy.entry_number);
661 if (!verbose(tcp))
662 tprintf("...}");
663 else {
664 print_ldt_entry(&copy);
665 }
666 } else {
667 tprintf("%lx", tcp->u_arg[0]);
668 }
669 }
670 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000671
Roland McGrath34e4a692002-12-15 23:58:17 +0000672}
673
674int
Denys Vlasenko12014262011-05-30 14:00:14 +0200675sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000676{
677 struct modify_ldt_ldt_s copy;
678 if (exiting(tcp)) {
679 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
680 tprintf("{entry_number:%d, ", copy.entry_number);
681 if (!verbose(tcp))
682 tprintf("...}");
683 else {
684 print_ldt_entry(&copy);
685 }
686 } else {
687 tprintf("%lx", tcp->u_arg[0]);
688 }
689 }
690 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000691
Roland McGrath34e4a692002-12-15 23:58:17 +0000692}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000693#endif /* LINUX && __i386__ */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000694
Andreas Schwab58743222010-05-28 22:28:51 +0200695#if defined(LINUX) && defined(M68K)
696
697int
Denys Vlasenko12014262011-05-30 14:00:14 +0200698sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200699{
700 if (entering(tcp))
701 tprintf("%#lx", tcp->u_arg[0]);
702 return 0;
703
704}
705
706int
Denys Vlasenko12014262011-05-30 14:00:14 +0200707sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200708{
709 return RVAL_HEX;
710}
711#endif
712
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000713#if defined(LINUX)
714int
Denys Vlasenko12014262011-05-30 14:00:14 +0200715sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000716{
717 if (entering(tcp)) {
718 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000719 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000720 tprintf(", %lu, ", tcp->u_arg[3]);
721#ifdef MAP_TYPE
722 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
723 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
724#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000725 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000726#endif
727 }
728 return 0;
729}
Roland McGrathb10a3352004-10-07 18:53:12 +0000730
731
732#define MPOL_DEFAULT 0
733#define MPOL_PREFERRED 1
734#define MPOL_BIND 2
735#define MPOL_INTERLEAVE 3
736
737#define MPOL_F_NODE (1<<0)
738#define MPOL_F_ADDR (1<<1)
739
740#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000741#define MPOL_MF_MOVE (1<<1)
742#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000743
744
745static const struct xlat policies[] = {
746 { MPOL_DEFAULT, "MPOL_DEFAULT" },
747 { MPOL_PREFERRED, "MPOL_PREFERRED" },
748 { MPOL_BIND, "MPOL_BIND" },
749 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
750 { 0, NULL }
751};
752
753static const struct xlat mbindflags[] = {
754 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000755 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
756 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000757 { 0, NULL }
758};
759
760static const struct xlat mempolicyflags[] = {
761 { MPOL_F_NODE, "MPOL_F_NODE" },
762 { MPOL_F_ADDR, "MPOL_F_ADDR" },
763 { 0, NULL }
764};
765
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000766static const struct xlat move_pages_flags[] = {
767 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
768 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
769 { 0, NULL }
770};
771
Roland McGrathb10a3352004-10-07 18:53:12 +0000772
773static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200774get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000775{
Roland McGrathaa524c82005-06-01 19:22:06 +0000776 unsigned long nlongs, size, end;
777
778 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
779 size = nlongs * sizeof(long);
780 end = ptr + size;
781 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
782 && (end > ptr))) {
783 unsigned long n, cur, abbrev_end;
784 int failed = 0;
785
786 if (abbrev(tcp)) {
787 abbrev_end = ptr + max_strlen * sizeof(long);
788 if (abbrev_end < ptr)
789 abbrev_end = end;
790 } else {
791 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000792 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000793 tprintf(", {");
794 for (cur = ptr; cur < end; cur += sizeof(long)) {
795 if (cur > ptr)
796 tprintf(", ");
797 if (cur >= abbrev_end) {
798 tprintf("...");
799 break;
800 }
801 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
802 tprintf("?");
803 failed = 1;
804 break;
805 }
806 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
807 }
808 tprintf("}");
809 if (failed)
810 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000811 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000812 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000813 tprintf(", %lu", maxnodes);
814}
815
816int
Denys Vlasenko12014262011-05-30 14:00:14 +0200817sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000818{
819 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000820 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000821 printxval(policies, tcp->u_arg[2], "MPOL_???");
822 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
823 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000824 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000825 }
826 return 0;
827}
828
829int
Denys Vlasenko12014262011-05-30 14:00:14 +0200830sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000831{
832 if (entering(tcp)) {
833 printxval(policies, tcp->u_arg[0], "MPOL_???");
834 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
835 }
836 return 0;
837}
838
839int
Denys Vlasenko12014262011-05-30 14:00:14 +0200840sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000841{
842 if (exiting(tcp)) {
843 int pol;
844 if (tcp->u_arg[0] == 0)
845 tprintf("NULL");
846 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
847 tprintf("%#lx", tcp->u_arg[0]);
848 else
849 printxval(policies, pol, "MPOL_???");
850 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
851 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000852 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000853 }
854 return 0;
855}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000856
857int
Denys Vlasenko12014262011-05-30 14:00:14 +0200858sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000859{
860 if (entering(tcp)) {
861 unsigned long npages = tcp->u_arg[1];
862 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
863 if (tcp->u_arg[2] == 0)
864 tprintf("NULL, ");
865 else {
866 int i;
867 long puser = tcp->u_arg[2];
868 tprintf("{");
869 for (i = 0; i < npages; ++i) {
870 void *p;
871 if (i > 0)
872 tprintf(", ");
873 if (umove(tcp, puser, &p) < 0) {
874 tprintf("???");
875 break;
876 }
877 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200878 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000879 }
880 tprintf("}, ");
881 }
882 if (tcp->u_arg[3] == 0)
883 tprintf("NULL, ");
884 else {
885 int i;
886 long nodeuser = tcp->u_arg[3];
887 tprintf("{");
888 for (i = 0; i < npages; ++i) {
889 int node;
890 if (i > 0)
891 tprintf(", ");
892 if (umove(tcp, nodeuser, &node) < 0) {
893 tprintf("???");
894 break;
895 }
896 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200897 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000898 }
899 tprintf("}, ");
900 }
901 }
902 if (exiting(tcp)) {
903 unsigned long npages = tcp->u_arg[1];
904 if (tcp->u_arg[4] == 0)
905 tprintf("NULL, ");
906 else {
907 int i;
908 long statususer = tcp->u_arg[4];
909 tprintf("{");
910 for (i = 0; i < npages; ++i) {
911 int status;
912 if (i > 0)
913 tprintf(", ");
914 if (umove(tcp, statususer, &status) < 0) {
915 tprintf("???");
916 break;
917 }
918 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200919 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000920 }
921 tprintf("}, ");
922 }
923 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
924 }
925 return 0;
926}
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000927#endif
Roland McGrath4a6f6522008-08-25 03:09:16 +0000928
929#if defined(LINUX) && defined(POWERPC)
930int
Denys Vlasenko12014262011-05-30 14:00:14 +0200931sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000932{
933 if (entering(tcp)) {
934 unsigned long cur, end, abbrev_end, entries;
935 unsigned int entry;
936
937 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
938 entries = tcp->u_arg[1] >> 16;
939 if (!entries || !tcp->u_arg[2]) {
940 tprintf("{}");
941 return 0;
942 }
943 cur = tcp->u_arg[2];
944 end = cur + (sizeof(int) * entries);
945 if (!verbose(tcp) || end < tcp->u_arg[2]) {
946 tprintf("%#lx", tcp->u_arg[2]);
947 return 0;
948 }
949 if (abbrev(tcp)) {
950 abbrev_end = cur + (sizeof(int) * max_strlen);
951 if (abbrev_end > end)
952 abbrev_end = end;
953 }
954 else
955 abbrev_end = end;
956 tprintf("{");
957 for (; cur < end; cur += sizeof(int)) {
958 if (cur > tcp->u_arg[2])
959 tprintf(", ");
960 if (cur >= abbrev_end) {
961 tprintf("...");
962 break;
963 }
964 if (umove(tcp, cur, &entry) < 0) {
965 tprintf("??? [%#lx]", cur);
966 break;
967 }
968 else
969 tprintf("%#08x", entry);
970 }
971 tprintf("}");
972 }
973
974 return 0;
975}
976#endif