blob: 7ae8b5cc3e602c8c44d89298318e47a6fdbec73d [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 Vlasenko72a58482011-08-19 16:01:51 +0200268#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000269 /*
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200270 * IA64 processes never call this routine, they only use the
271 * new `sys_mmap' interface.
272 * For IA32 processes, this code converts the integer arguments
273 * that they pushed onto the stack, into longs.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000274 *
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200275 * Note that addresses with bit 31 set will be sign extended.
276 * Fortunately, those addresses are not currently being generated
277 * for IA32 processes so it's not a problem.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000278 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200279 int i;
280 long u_arg[6];
281 int narrow_arg[6];
282 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
283 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000284 for (i = 0; i < 6; i++)
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200285 u_arg[i] = narrow_arg[i];
Roland McGrathf5a47772003-06-26 22:40:42 +0000286#elif defined(SH) || defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000287 /* SH has always passed the args in registers */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200288 long *u_arg = tcp->u_arg;
Roland McGrath6b1d43e2003-03-31 01:05:01 +0000289#else
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200290 long u_arg[6];
Roland McGrath520e21f2005-07-05 09:50:18 +0000291# if defined(X86_64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000292 if (current_personality == 1) {
293 int i;
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200294 unsigned narrow_arg[6];
295 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
296 return 0;
297 for (i = 0; i < 6; ++i)
298 u_arg[i] = narrow_arg[i];
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000299 }
300 else
Roland McGrath520e21f2005-07-05 09:50:18 +0000301# endif
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200302 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000303 return 0;
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200304#endif /* other architectures */
305
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000306 return print_mmap(tcp, u_arg, u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000307}
Denys Vlasenko72a58482011-08-19 16:01:51 +0200308#endif /* LINUX */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000309
310int
Denys Vlasenko12014262011-05-30 14:00:14 +0200311sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000312{
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000313 long long offset = tcp->u_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000314
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200315 /* FIXME: why only SH64? i386 mmap2 syscall ends up
316 * in this function, but does not convert offset
317 * from pages to bytes. See test/mmap_offset_decode.c
318 * Why SH64 and i386 are handled differently?
319 */
Roland McGrathf5a47772003-06-26 22:40:42 +0000320#if defined(LINUX) && defined(SH64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000321 /*
322 * Old mmap differs from new mmap in specifying the
323 * offset in units of bytes rather than pages. We
324 * pretend it's in byte units so the user only ever
325 * sees bytes in the printout.
326 */
327 offset <<= PAGE_SHIFT;
Roland McGrathe1e584b2003-06-02 19:18:58 +0000328#endif
Roland McGrath542c2c62008-05-20 01:11:56 +0000329#if defined(LINUX_MIPSN32)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000330 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000331#endif
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000332 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000333}
John Hughes70623be2001-03-08 13:59:00 +0000334#endif /* !HAVE_LONG_LONG_OFF_T */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000335
John Hughes70623be2001-03-08 13:59:00 +0000336#if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
John Hughesbdf48f52001-03-06 15:08:09 +0000337int
Dmitry V. Levin31382132011-03-04 05:08:02 +0300338sys_mmap64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000339{
John Hughesbdf48f52001-03-06 15:08:09 +0000340 if (entering(tcp)) {
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200341#if !defined(LINUX) || defined(ALPHA)
342 long *u_arg = tcp->u_arg;
343#else
344 long u_arg[7];
John Hughesbdf48f52001-03-06 15:08:09 +0000345 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
346 (char *) u_arg) == -1)
347 return 0;
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200348#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000349 /* addr */
350 tprintf("%#lx, ", u_arg[0]);
351 /* len */
352 tprintf("%lu, ", u_arg[1]);
353 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000354 printflags(mmap_prot, u_arg[2], "PROT_???");
John Hughesbdf48f52001-03-06 15:08:09 +0000355 tprintf(", ");
356 /* flags */
John Hughes5a826b82001-03-07 13:21:24 +0000357#ifdef MAP_TYPE
John Hughesbdf48f52001-03-06 15:08:09 +0000358 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
359 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
John Hughes5a826b82001-03-07 13:21:24 +0000360#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000361 printflags(mmap_flags, u_arg[3], "MAP_???");
John Hughes5a826b82001-03-07 13:21:24 +0000362#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000363 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300364 tprintf(", ");
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200365 /* BUG?! should be u_arg[4] (without tcp->)? */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300366 printfd(tcp, tcp->u_arg[4]);
John Hughesbdf48f52001-03-06 15:08:09 +0000367 /* offset */
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200368 /* BUG?! on non-ALPHA linux, offset will be not in tcp->u_arg,
369 * but in local u_arg, but printllval prints tcp->u_arg! */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300370 printllval(tcp, ", %#llx", 5);
John Hughesbdf48f52001-03-06 15:08:09 +0000371 }
372 return RVAL_HEX;
373}
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200374#endif /* _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T */
John Hughesbdf48f52001-03-06 15:08:09 +0000375
Roland McGrath909875b2002-12-22 03:34:36 +0000376
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000377int
Denys Vlasenko12014262011-05-30 14:00:14 +0200378sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000379{
380 if (entering(tcp)) {
381 tprintf("%#lx, %lu",
382 tcp->u_arg[0], tcp->u_arg[1]);
383 }
384 return 0;
385}
386
387int
Denys Vlasenko12014262011-05-30 14:00:14 +0200388sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000389{
390 if (entering(tcp)) {
391 tprintf("%#lx, %lu, ",
392 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000393 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000394 }
395 return 0;
396}
397
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000398#ifdef LINUX
399
Roland McGrathd9f816f2004-09-04 03:39:20 +0000400static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000401 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000402#ifdef MREMAP_FIXED
403 { MREMAP_FIXED, "MREMAP_FIXED" },
404#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000405 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000406};
407
408int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000409sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000410{
411 if (entering(tcp)) {
412 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
413 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000414 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000415#ifdef MREMAP_FIXED
416 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
417 (MREMAP_MAYMOVE | MREMAP_FIXED))
418 tprintf(", %#lx", tcp->u_arg[4]);
419#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000420 }
421 return RVAL_HEX;
422}
423
Roland McGrathf4021b12008-08-25 02:59:36 +0000424static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000425#ifdef MADV_NORMAL
426 { MADV_NORMAL, "MADV_NORMAL" },
427#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000428#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000429 { MADV_RANDOM, "MADV_RANDOM" },
430#endif
431#ifdef MADV_SEQUENTIAL
432 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
433#endif
434#ifdef MADV_WILLNEED
435 { MADV_WILLNEED, "MADV_WILLNEED" },
436#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000437#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000438 { MADV_DONTNEED, "MADV_DONTNEED" },
439#endif
440 { 0, NULL },
441};
442
443
444int
Denys Vlasenko12014262011-05-30 14:00:14 +0200445sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000446{
447 if (entering(tcp)) {
448 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000449 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000450 }
451 return 0;
452}
453
454
Roland McGrathd9f816f2004-09-04 03:39:20 +0000455static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000456#ifdef MCL_CURRENT
457 { MCL_CURRENT, "MCL_CURRENT" },
458#endif
459#ifdef MCL_FUTURE
460 { MCL_FUTURE, "MCL_FUTURE" },
461#endif
462 { 0, NULL}
463};
464
465int
Denys Vlasenko12014262011-05-30 14:00:14 +0200466sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000467{
468 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000469 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000470 }
471 return 0;
472}
473
474
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000475#endif /* LINUX */
476
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000477#ifdef MS_ASYNC
478
Roland McGrathd9f816f2004-09-04 03:39:20 +0000479static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000480#ifdef MS_SYNC
481 { MS_SYNC, "MS_SYNC" },
482#endif
John Hughesaca07f32001-10-16 18:12:27 +0000483 { MS_ASYNC, "MS_ASYNC" },
484 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000485 { 0, NULL },
486};
487
488int
Denys Vlasenko12014262011-05-30 14:00:14 +0200489sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000490{
491 if (entering(tcp)) {
492 /* addr */
493 tprintf("%#lx", tcp->u_arg[0]);
494 /* len */
495 tprintf(", %lu, ", tcp->u_arg[1]);
496 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000497 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000498 }
499 return 0;
500}
501
502#endif /* MS_ASYNC */
503
504#ifdef MC_SYNC
505
Roland McGrathd9f816f2004-09-04 03:39:20 +0000506static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000507 { MC_LOCK, "MC_LOCK" },
508 { MC_LOCKAS, "MC_LOCKAS" },
509 { MC_SYNC, "MC_SYNC" },
510 { MC_UNLOCK, "MC_UNLOCK" },
511 { MC_UNLOCKAS, "MC_UNLOCKAS" },
512 { 0, NULL },
513};
514
Roland McGrathd9f816f2004-09-04 03:39:20 +0000515static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000516 { MCL_CURRENT, "MCL_CURRENT" },
517 { MCL_FUTURE, "MCL_FUTURE" },
518 { 0, NULL },
519};
520
521int
Denys Vlasenko12014262011-05-30 14:00:14 +0200522sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000523{
524 int arg, function;
525
526 if (entering(tcp)) {
527 /* addr */
528 tprintf("%#lx", tcp->u_arg[0]);
529 /* len */
530 tprintf(", %lu, ", tcp->u_arg[1]);
531 /* function */
532 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000533 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000534 /* arg */
535 arg = tcp->u_arg[3];
536 tprintf(", ");
537 switch (function) {
538 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000539 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000540 break;
541 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000542 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000543 break;
544 default:
545 tprintf("%#x", arg);
546 break;
547 }
548 }
549 return 0;
550}
551
552#endif /* MC_SYNC */
553
554int
Denys Vlasenko12014262011-05-30 14:00:14 +0200555sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000556{
Roland McGrath46100d02005-06-01 18:55:42 +0000557 unsigned long i, len;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000558 char *vec = NULL;
559
560 if (entering(tcp)) {
561 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
562 } else {
563 len = tcp->u_arg[1];
564 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000565 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000566 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
567 tprintf("%#lx", tcp->u_arg[2]);
568 else {
569 tprintf("[");
570 for (i = 0; i < len; i++) {
571 if (abbrev(tcp) && i >= max_strlen) {
572 tprintf("...");
573 break;
574 }
575 tprintf((vec[i] & 1) ? "1" : "0");
576 }
577 tprintf("]");
578 }
579 if (vec)
580 free(vec);
581 }
582 return 0;
583}
584
Roland McGrathda6c92c2007-09-12 01:26:29 +0000585#if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000586int
Denys Vlasenko12014262011-05-30 14:00:14 +0200587sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000588{
589 if (exiting(tcp))
590 return RVAL_HEX;
591 return 0;
592}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +0000593#endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000594
595#if defined(LINUX) && defined(__i386__)
Roland McGrath909875b2002-12-22 03:34:36 +0000596void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000597print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000598{
599 tprintf("base_addr:%#08lx, "
600 "limit:%d, "
601 "seg_32bit:%d, "
602 "contents:%d, "
603 "read_exec_only:%d, "
604 "limit_in_pages:%d, "
605 "seg_not_present:%d, "
606 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000607 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000608 ldt_entry->limit,
609 ldt_entry->seg_32bit,
610 ldt_entry->contents,
611 ldt_entry->read_exec_only,
612 ldt_entry->limit_in_pages,
613 ldt_entry->seg_not_present,
614 ldt_entry->useable);
615}
616
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000617int
Denys Vlasenko12014262011-05-30 14:00:14 +0200618sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000619{
620 if (entering(tcp)) {
621 struct modify_ldt_ldt_s copy;
622 tprintf("%ld", tcp->u_arg[0]);
623 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200624 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000625 || umove(tcp, tcp->u_arg[1], &copy) == -1)
626 tprintf(", %lx", tcp->u_arg[1]);
627 else {
628 tprintf(", {entry_number:%d, ", copy.entry_number);
629 if (!verbose(tcp))
630 tprintf("...}");
631 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000632 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000633 }
634 }
635 tprintf(", %lu", tcp->u_arg[2]);
636 }
637 return 0;
638}
Roland McGrath34e4a692002-12-15 23:58:17 +0000639
640int
Denys Vlasenko12014262011-05-30 14:00:14 +0200641sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000642{
643 struct modify_ldt_ldt_s copy;
644 if (entering(tcp)) {
645 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
646 if (copy.entry_number == -1)
647 tprintf("{entry_number:%d -> ",
648 copy.entry_number);
649 else
650 tprintf("{entry_number:");
651 }
652 } else {
653 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
654 tprintf("%d, ", copy.entry_number);
655 if (!verbose(tcp))
656 tprintf("...}");
657 else {
658 print_ldt_entry(&copy);
659 }
660 } else {
661 tprintf("%lx", tcp->u_arg[0]);
662 }
663 }
664 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000665
Roland McGrath34e4a692002-12-15 23:58:17 +0000666}
667
668int
Denys Vlasenko12014262011-05-30 14:00:14 +0200669sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000670{
671 struct modify_ldt_ldt_s copy;
672 if (exiting(tcp)) {
673 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
674 tprintf("{entry_number:%d, ", copy.entry_number);
675 if (!verbose(tcp))
676 tprintf("...}");
677 else {
678 print_ldt_entry(&copy);
679 }
680 } else {
681 tprintf("%lx", tcp->u_arg[0]);
682 }
683 }
684 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000685
Roland McGrath34e4a692002-12-15 23:58:17 +0000686}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000687#endif /* LINUX && __i386__ */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000688
Andreas Schwab58743222010-05-28 22:28:51 +0200689#if defined(LINUX) && defined(M68K)
690
691int
Denys Vlasenko12014262011-05-30 14:00:14 +0200692sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200693{
694 if (entering(tcp))
695 tprintf("%#lx", tcp->u_arg[0]);
696 return 0;
697
698}
699
700int
Denys Vlasenko12014262011-05-30 14:00:14 +0200701sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200702{
703 return RVAL_HEX;
704}
705#endif
706
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000707#if defined(LINUX)
708int
Denys Vlasenko12014262011-05-30 14:00:14 +0200709sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000710{
711 if (entering(tcp)) {
712 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000713 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000714 tprintf(", %lu, ", tcp->u_arg[3]);
715#ifdef MAP_TYPE
716 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
717 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
718#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000719 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000720#endif
721 }
722 return 0;
723}
Roland McGrathb10a3352004-10-07 18:53:12 +0000724
725
726#define MPOL_DEFAULT 0
727#define MPOL_PREFERRED 1
728#define MPOL_BIND 2
729#define MPOL_INTERLEAVE 3
730
731#define MPOL_F_NODE (1<<0)
732#define MPOL_F_ADDR (1<<1)
733
734#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000735#define MPOL_MF_MOVE (1<<1)
736#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000737
738
739static const struct xlat policies[] = {
740 { MPOL_DEFAULT, "MPOL_DEFAULT" },
741 { MPOL_PREFERRED, "MPOL_PREFERRED" },
742 { MPOL_BIND, "MPOL_BIND" },
743 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
744 { 0, NULL }
745};
746
747static const struct xlat mbindflags[] = {
748 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000749 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
750 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000751 { 0, NULL }
752};
753
754static const struct xlat mempolicyflags[] = {
755 { MPOL_F_NODE, "MPOL_F_NODE" },
756 { MPOL_F_ADDR, "MPOL_F_ADDR" },
757 { 0, NULL }
758};
759
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000760static const struct xlat move_pages_flags[] = {
761 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
762 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
763 { 0, NULL }
764};
765
Roland McGrathb10a3352004-10-07 18:53:12 +0000766
767static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200768get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000769{
Roland McGrathaa524c82005-06-01 19:22:06 +0000770 unsigned long nlongs, size, end;
771
772 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
773 size = nlongs * sizeof(long);
774 end = ptr + size;
775 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
776 && (end > ptr))) {
777 unsigned long n, cur, abbrev_end;
778 int failed = 0;
779
780 if (abbrev(tcp)) {
781 abbrev_end = ptr + max_strlen * sizeof(long);
782 if (abbrev_end < ptr)
783 abbrev_end = end;
784 } else {
785 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000786 }
Roland McGrathaa524c82005-06-01 19:22:06 +0000787 tprintf(", {");
788 for (cur = ptr; cur < end; cur += sizeof(long)) {
789 if (cur > ptr)
790 tprintf(", ");
791 if (cur >= abbrev_end) {
792 tprintf("...");
793 break;
794 }
795 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
796 tprintf("?");
797 failed = 1;
798 break;
799 }
800 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
801 }
802 tprintf("}");
803 if (failed)
804 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000805 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000806 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000807 tprintf(", %lu", maxnodes);
808}
809
810int
Denys Vlasenko12014262011-05-30 14:00:14 +0200811sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000812{
813 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000814 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000815 printxval(policies, tcp->u_arg[2], "MPOL_???");
816 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
817 tprintf(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000818 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000819 }
820 return 0;
821}
822
823int
Denys Vlasenko12014262011-05-30 14:00:14 +0200824sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000825{
826 if (entering(tcp)) {
827 printxval(policies, tcp->u_arg[0], "MPOL_???");
828 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
829 }
830 return 0;
831}
832
833int
Denys Vlasenko12014262011-05-30 14:00:14 +0200834sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000835{
836 if (exiting(tcp)) {
837 int pol;
838 if (tcp->u_arg[0] == 0)
839 tprintf("NULL");
840 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
841 tprintf("%#lx", tcp->u_arg[0]);
842 else
843 printxval(policies, pol, "MPOL_???");
844 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
845 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000846 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000847 }
848 return 0;
849}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000850
851int
Denys Vlasenko12014262011-05-30 14:00:14 +0200852sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000853{
854 if (entering(tcp)) {
855 unsigned long npages = tcp->u_arg[1];
856 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
857 if (tcp->u_arg[2] == 0)
858 tprintf("NULL, ");
859 else {
860 int i;
861 long puser = tcp->u_arg[2];
862 tprintf("{");
863 for (i = 0; i < npages; ++i) {
864 void *p;
865 if (i > 0)
866 tprintf(", ");
867 if (umove(tcp, puser, &p) < 0) {
868 tprintf("???");
869 break;
870 }
871 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200872 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000873 }
874 tprintf("}, ");
875 }
876 if (tcp->u_arg[3] == 0)
877 tprintf("NULL, ");
878 else {
879 int i;
880 long nodeuser = tcp->u_arg[3];
881 tprintf("{");
882 for (i = 0; i < npages; ++i) {
883 int node;
884 if (i > 0)
885 tprintf(", ");
886 if (umove(tcp, nodeuser, &node) < 0) {
887 tprintf("???");
888 break;
889 }
890 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200891 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000892 }
893 tprintf("}, ");
894 }
895 }
896 if (exiting(tcp)) {
897 unsigned long npages = tcp->u_arg[1];
898 if (tcp->u_arg[4] == 0)
899 tprintf("NULL, ");
900 else {
901 int i;
902 long statususer = tcp->u_arg[4];
903 tprintf("{");
904 for (i = 0; i < npages; ++i) {
905 int status;
906 if (i > 0)
907 tprintf(", ");
908 if (umove(tcp, statususer, &status) < 0) {
909 tprintf("???");
910 break;
911 }
912 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200913 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000914 }
915 tprintf("}, ");
916 }
917 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
918 }
919 return 0;
920}
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000921#endif
Roland McGrath4a6f6522008-08-25 03:09:16 +0000922
923#if defined(LINUX) && defined(POWERPC)
924int
Denys Vlasenko12014262011-05-30 14:00:14 +0200925sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000926{
927 if (entering(tcp)) {
928 unsigned long cur, end, abbrev_end, entries;
929 unsigned int entry;
930
931 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
932 entries = tcp->u_arg[1] >> 16;
933 if (!entries || !tcp->u_arg[2]) {
934 tprintf("{}");
935 return 0;
936 }
937 cur = tcp->u_arg[2];
938 end = cur + (sizeof(int) * entries);
939 if (!verbose(tcp) || end < tcp->u_arg[2]) {
940 tprintf("%#lx", tcp->u_arg[2]);
941 return 0;
942 }
943 if (abbrev(tcp)) {
944 abbrev_end = cur + (sizeof(int) * max_strlen);
945 if (abbrev_end > end)
946 abbrev_end = end;
947 }
948 else
949 abbrev_end = end;
950 tprintf("{");
951 for (; cur < end; cur += sizeof(int)) {
952 if (cur > tcp->u_arg[2])
953 tprintf(", ");
954 if (cur >= abbrev_end) {
955 tprintf("...");
956 break;
957 }
958 if (umove(tcp, cur, &entry) < 0) {
959 tprintf("??? [%#lx]", cur);
960 break;
961 }
962 else
963 tprintf("%#08x", entry);
964 }
965 tprintf("}");
966 }
967
968 return 0;
969}
970#endif