blob: 7fdd384eeaba69e6ad87d8d2a9cf586d00cfee1c [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) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200207 tprints("|MAP_CACHE_INCOHERENT");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500208 return flags;
209 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200210 tprints("|_MAP_CACHE_INCOHERENT");
Chris Metcalfc8c66982009-12-28 10:00:15 -0500211 }
212
213 switch (home) {
214 case 0: break;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200215 case MAP_CACHE_HOME_HERE: tprints("|MAP_CACHE_HOME_HERE"); break;
216 case MAP_CACHE_HOME_NONE: tprints("|MAP_CACHE_HOME_NONE"); break;
217 case MAP_CACHE_HOME_SINGLE: tprints("|MAP_CACHE_HOME_SINGLE"); break;
218 case MAP_CACHE_HOME_TASK: tprints("|MAP_CACHE_HOME_TASK"); break;
219 case MAP_CACHE_HOME_HASH: tprints("|MAP_CACHE_HOME_HASH"); break;
Chris Metcalfc8c66982009-12-28 10:00:15 -0500220 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])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200237 tprints("NULL, ");
Wichert Akkerman8829a551999-06-11 13:18:40 +0000238 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_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200244 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000245 /* 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 */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200257 tprints(", ");
Dmitry V. Levin31382132011-03-04 05:08:02 +0300258 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
Denys Vlasenkod5e66c42011-08-23 17:51:58 +0200337/* TODO: comment which arches use this routine.
338 * For one, does ALPHA on Linux use this??
339 * From code it seems that it might use 7 or 8 registers,
340 * which is strange - Linux syscalls can pass maximum of 6 parameters!
341 */
John Hughesbdf48f52001-03-06 15:08:09 +0000342int
Dmitry V. Levin31382132011-03-04 05:08:02 +0300343sys_mmap64(struct tcb *tcp)
John Hughesbdf48f52001-03-06 15:08:09 +0000344{
John Hughesbdf48f52001-03-06 15:08:09 +0000345 if (entering(tcp)) {
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200346#if !defined(LINUX) || defined(ALPHA)
347 long *u_arg = tcp->u_arg;
348#else
349 long u_arg[7];
John Hughesbdf48f52001-03-06 15:08:09 +0000350 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
351 (char *) u_arg) == -1)
352 return 0;
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200353#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000354 /* addr */
H.J. Lud0cd4432012-02-03 10:07:42 -0800355 if (!u_arg[0])
356 tprints("NULL, ");
357 else
358 tprintf("%#lx, ", u_arg[0]);
John Hughesbdf48f52001-03-06 15:08:09 +0000359 /* len */
360 tprintf("%lu, ", u_arg[1]);
361 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000362 printflags(mmap_prot, u_arg[2], "PROT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200363 tprints(", ");
John Hughesbdf48f52001-03-06 15:08:09 +0000364 /* flags */
John Hughes5a826b82001-03-07 13:21:24 +0000365#ifdef MAP_TYPE
John Hughesbdf48f52001-03-06 15:08:09 +0000366 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
367 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
John Hughes5a826b82001-03-07 13:21:24 +0000368#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000369 printflags(mmap_flags, u_arg[3], "MAP_???");
John Hughes5a826b82001-03-07 13:21:24 +0000370#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000371 /* fd */
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200372 tprints(", ");
Denys Vlasenkod5e66c42011-08-23 17:51:58 +0200373 printfd(tcp, u_arg[4]);
John Hughesbdf48f52001-03-06 15:08:09 +0000374 /* offset */
Denys Vlasenkod5e66c42011-08-23 17:51:58 +0200375#if !defined(LINUX) || defined(ALPHA)
Dmitry V. Levin31382132011-03-04 05:08:02 +0300376 printllval(tcp, ", %#llx", 5);
Denys Vlasenkod5e66c42011-08-23 17:51:58 +0200377#else
378 /* NOTE: not verified that [5] and [6] should be used.
379 * It's possible that long long is 64-bit aligned in memory
380 * and we need to use [6] and [7] here instead:
381 */
382 tprintf(", %#llx", LONG_LONG(u_arg[5], u_arg[6]));
383#endif
John Hughesbdf48f52001-03-06 15:08:09 +0000384 }
385 return RVAL_HEX;
386}
Denys Vlasenko31f9cb62011-08-19 16:11:07 +0200387#endif /* _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T */
John Hughesbdf48f52001-03-06 15:08:09 +0000388
Roland McGrath909875b2002-12-22 03:34:36 +0000389
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000390int
Denys Vlasenko12014262011-05-30 14:00:14 +0200391sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000392{
393 if (entering(tcp)) {
394 tprintf("%#lx, %lu",
395 tcp->u_arg[0], tcp->u_arg[1]);
396 }
397 return 0;
398}
399
400int
Denys Vlasenko12014262011-05-30 14:00:14 +0200401sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000402{
403 if (entering(tcp)) {
404 tprintf("%#lx, %lu, ",
405 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000406 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000407 }
408 return 0;
409}
410
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000411#ifdef LINUX
412
Roland McGrathd9f816f2004-09-04 03:39:20 +0000413static const struct xlat mremap_flags[] = {
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000414 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
Chris Metcalfff3474a2009-12-24 23:19:19 +0000415#ifdef MREMAP_FIXED
416 { MREMAP_FIXED, "MREMAP_FIXED" },
417#endif
Wichert Akkerman5ae21ea2000-05-01 01:53:59 +0000418 { 0, NULL }
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000419};
420
421int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000422sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000423{
424 if (entering(tcp)) {
425 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
426 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000427 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000428#ifdef MREMAP_FIXED
429 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
430 (MREMAP_MAYMOVE | MREMAP_FIXED))
431 tprintf(", %#lx", tcp->u_arg[4]);
432#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000433 }
434 return RVAL_HEX;
435}
436
Roland McGrathf4021b12008-08-25 02:59:36 +0000437static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000438#ifdef MADV_NORMAL
439 { MADV_NORMAL, "MADV_NORMAL" },
440#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000441#ifdef MADV_RANDOM
Wichert Akkermanc7926982000-04-10 22:22:31 +0000442 { MADV_RANDOM, "MADV_RANDOM" },
443#endif
444#ifdef MADV_SEQUENTIAL
445 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
446#endif
447#ifdef MADV_WILLNEED
448 { MADV_WILLNEED, "MADV_WILLNEED" },
449#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000450#ifdef MADV_DONTNEED
Wichert Akkermanc7926982000-04-10 22:22:31 +0000451 { MADV_DONTNEED, "MADV_DONTNEED" },
452#endif
453 { 0, NULL },
454};
455
456
457int
Denys Vlasenko12014262011-05-30 14:00:14 +0200458sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000459{
460 if (entering(tcp)) {
461 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000462 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000463 }
464 return 0;
465}
466
467
Roland McGrathd9f816f2004-09-04 03:39:20 +0000468static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000469#ifdef MCL_CURRENT
470 { MCL_CURRENT, "MCL_CURRENT" },
471#endif
472#ifdef MCL_FUTURE
473 { MCL_FUTURE, "MCL_FUTURE" },
474#endif
475 { 0, NULL}
476};
477
478int
Denys Vlasenko12014262011-05-30 14:00:14 +0200479sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000480{
481 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000482 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000483 }
484 return 0;
485}
486
487
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000488#endif /* LINUX */
489
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000490#ifdef MS_ASYNC
491
Roland McGrathd9f816f2004-09-04 03:39:20 +0000492static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000493#ifdef MS_SYNC
494 { MS_SYNC, "MS_SYNC" },
495#endif
John Hughesaca07f32001-10-16 18:12:27 +0000496 { MS_ASYNC, "MS_ASYNC" },
497 { MS_INVALIDATE,"MS_INVALIDATE" },
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000498 { 0, NULL },
499};
500
501int
Denys Vlasenko12014262011-05-30 14:00:14 +0200502sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000503{
504 if (entering(tcp)) {
505 /* addr */
506 tprintf("%#lx", tcp->u_arg[0]);
507 /* len */
508 tprintf(", %lu, ", tcp->u_arg[1]);
509 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000510 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000511 }
512 return 0;
513}
514
515#endif /* MS_ASYNC */
516
517#ifdef MC_SYNC
518
Roland McGrathd9f816f2004-09-04 03:39:20 +0000519static const struct xlat mctl_funcs[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000520 { MC_LOCK, "MC_LOCK" },
521 { MC_LOCKAS, "MC_LOCKAS" },
522 { MC_SYNC, "MC_SYNC" },
523 { MC_UNLOCK, "MC_UNLOCK" },
524 { MC_UNLOCKAS, "MC_UNLOCKAS" },
525 { 0, NULL },
526};
527
Roland McGrathd9f816f2004-09-04 03:39:20 +0000528static const struct xlat mctl_lockas[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000529 { MCL_CURRENT, "MCL_CURRENT" },
530 { MCL_FUTURE, "MCL_FUTURE" },
531 { 0, NULL },
532};
533
534int
Denys Vlasenko12014262011-05-30 14:00:14 +0200535sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000536{
537 int arg, function;
538
539 if (entering(tcp)) {
540 /* addr */
541 tprintf("%#lx", tcp->u_arg[0]);
542 /* len */
543 tprintf(", %lu, ", tcp->u_arg[1]);
544 /* function */
545 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000546 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000547 /* arg */
548 arg = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200549 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000550 switch (function) {
551 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000552 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000553 break;
554 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000555 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000556 break;
557 default:
558 tprintf("%#x", arg);
559 break;
560 }
561 }
562 return 0;
563}
564
565#endif /* MC_SYNC */
566
567int
Denys Vlasenko12014262011-05-30 14:00:14 +0200568sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000569{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000570 if (entering(tcp)) {
571 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
572 } else {
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200573 unsigned long i, len;
574 char *vec = NULL;
575
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000576 len = tcp->u_arg[1];
577 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000578 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000579 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
580 tprintf("%#lx", tcp->u_arg[2]);
581 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200582 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000583 for (i = 0; i < len; i++) {
584 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200585 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000586 break;
587 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200588 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000589 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200590 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000591 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200592 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000593 }
594 return 0;
595}
596
Roland McGrathda6c92c2007-09-12 01:26:29 +0000597#if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000598int
Denys Vlasenko12014262011-05-30 14:00:14 +0200599sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000600{
601 if (exiting(tcp))
602 return RVAL_HEX;
603 return 0;
604}
Dmitry V. Levinb9fe0112006-12-13 16:59:44 +0000605#endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000606
607#if defined(LINUX) && defined(__i386__)
Roland McGrath909875b2002-12-22 03:34:36 +0000608void
Denys Vlasenko1f458252009-01-23 16:10:22 +0000609print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry)
Roland McGrath34e4a692002-12-15 23:58:17 +0000610{
611 tprintf("base_addr:%#08lx, "
612 "limit:%d, "
613 "seg_32bit:%d, "
614 "contents:%d, "
615 "read_exec_only:%d, "
616 "limit_in_pages:%d, "
617 "seg_not_present:%d, "
618 "useable:%d}",
Denys Vlasenko1f458252009-01-23 16:10:22 +0000619 (long) ldt_entry->base_addr,
Roland McGrath34e4a692002-12-15 23:58:17 +0000620 ldt_entry->limit,
621 ldt_entry->seg_32bit,
622 ldt_entry->contents,
623 ldt_entry->read_exec_only,
624 ldt_entry->limit_in_pages,
625 ldt_entry->seg_not_present,
626 ldt_entry->useable);
627}
628
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000629int
Denys Vlasenko12014262011-05-30 14:00:14 +0200630sys_modify_ldt(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000631{
632 if (entering(tcp)) {
633 struct modify_ldt_ldt_s copy;
634 tprintf("%ld", tcp->u_arg[0]);
635 if (tcp->u_arg[1] == 0
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200636 || tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000637 || umove(tcp, tcp->u_arg[1], &copy) == -1)
638 tprintf(", %lx", tcp->u_arg[1]);
639 else {
640 tprintf(", {entry_number:%d, ", copy.entry_number);
641 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200642 tprints("...}");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000643 else {
Roland McGrath34e4a692002-12-15 23:58:17 +0000644 print_ldt_entry(&copy);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000645 }
646 }
647 tprintf(", %lu", tcp->u_arg[2]);
648 }
649 return 0;
650}
Roland McGrath34e4a692002-12-15 23:58:17 +0000651
652int
Denys Vlasenko12014262011-05-30 14:00:14 +0200653sys_set_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000654{
655 struct modify_ldt_ldt_s copy;
656 if (entering(tcp)) {
657 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
658 if (copy.entry_number == -1)
659 tprintf("{entry_number:%d -> ",
660 copy.entry_number);
661 else
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200662 tprints("{entry_number:");
Roland McGrath34e4a692002-12-15 23:58:17 +0000663 }
664 } else {
665 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
666 tprintf("%d, ", copy.entry_number);
667 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200668 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000669 else {
670 print_ldt_entry(&copy);
671 }
672 } else {
673 tprintf("%lx", tcp->u_arg[0]);
674 }
675 }
676 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000677
Roland McGrath34e4a692002-12-15 23:58:17 +0000678}
679
680int
Denys Vlasenko12014262011-05-30 14:00:14 +0200681sys_get_thread_area(struct tcb *tcp)
Roland McGrath34e4a692002-12-15 23:58:17 +0000682{
683 struct modify_ldt_ldt_s copy;
684 if (exiting(tcp)) {
685 if (umove(tcp, tcp->u_arg[0], &copy) != -1) {
686 tprintf("{entry_number:%d, ", copy.entry_number);
687 if (!verbose(tcp))
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200688 tprints("...}");
Roland McGrath34e4a692002-12-15 23:58:17 +0000689 else {
690 print_ldt_entry(&copy);
691 }
692 } else {
693 tprintf("%lx", tcp->u_arg[0]);
694 }
695 }
696 return 0;
Roland McGrath909875b2002-12-22 03:34:36 +0000697
Roland McGrath34e4a692002-12-15 23:58:17 +0000698}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000699#endif /* LINUX && __i386__ */
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000700
Andreas Schwab58743222010-05-28 22:28:51 +0200701#if defined(LINUX) && defined(M68K)
702
703int
Denys Vlasenko12014262011-05-30 14:00:14 +0200704sys_set_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200705{
706 if (entering(tcp))
707 tprintf("%#lx", tcp->u_arg[0]);
708 return 0;
709
710}
711
712int
Denys Vlasenko12014262011-05-30 14:00:14 +0200713sys_get_thread_area(struct tcb *tcp)
Andreas Schwab58743222010-05-28 22:28:51 +0200714{
715 return RVAL_HEX;
716}
717#endif
718
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000719#if defined(LINUX)
720int
Denys Vlasenko12014262011-05-30 14:00:14 +0200721sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000722{
723 if (entering(tcp)) {
724 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000725 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000726 tprintf(", %lu, ", tcp->u_arg[3]);
727#ifdef MAP_TYPE
728 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
729 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
730#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000731 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000732#endif
733 }
734 return 0;
735}
Roland McGrathb10a3352004-10-07 18:53:12 +0000736
737
738#define MPOL_DEFAULT 0
739#define MPOL_PREFERRED 1
740#define MPOL_BIND 2
741#define MPOL_INTERLEAVE 3
742
743#define MPOL_F_NODE (1<<0)
744#define MPOL_F_ADDR (1<<1)
745
746#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000747#define MPOL_MF_MOVE (1<<1)
748#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000749
750
751static const struct xlat policies[] = {
752 { MPOL_DEFAULT, "MPOL_DEFAULT" },
753 { MPOL_PREFERRED, "MPOL_PREFERRED" },
754 { MPOL_BIND, "MPOL_BIND" },
755 { MPOL_INTERLEAVE, "MPOL_INTERLEAVE" },
756 { 0, NULL }
757};
758
759static const struct xlat mbindflags[] = {
760 { MPOL_MF_STRICT, "MPOL_MF_STRICT" },
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000761 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
762 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
Roland McGrathb10a3352004-10-07 18:53:12 +0000763 { 0, NULL }
764};
765
766static const struct xlat mempolicyflags[] = {
767 { MPOL_F_NODE, "MPOL_F_NODE" },
768 { MPOL_F_ADDR, "MPOL_F_ADDR" },
769 { 0, NULL }
770};
771
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000772static const struct xlat move_pages_flags[] = {
773 { MPOL_MF_MOVE, "MPOL_MF_MOVE" },
774 { MPOL_MF_MOVE_ALL, "MPOL_MF_MOVE_ALL" },
775 { 0, NULL }
776};
777
Roland McGrathb10a3352004-10-07 18:53:12 +0000778
779static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200780get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000781{
Roland McGrathaa524c82005-06-01 19:22:06 +0000782 unsigned long nlongs, size, end;
783
784 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
785 size = nlongs * sizeof(long);
786 end = ptr + size;
787 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
788 && (end > ptr))) {
789 unsigned long n, cur, abbrev_end;
790 int failed = 0;
791
792 if (abbrev(tcp)) {
793 abbrev_end = ptr + max_strlen * sizeof(long);
794 if (abbrev_end < ptr)
795 abbrev_end = end;
796 } else {
797 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000798 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200799 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +0000800 for (cur = ptr; cur < end; cur += sizeof(long)) {
801 if (cur > ptr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200802 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000803 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200804 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000805 break;
806 }
807 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200808 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000809 failed = 1;
810 break;
811 }
812 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
813 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200814 tprints("}");
Roland McGrathaa524c82005-06-01 19:22:06 +0000815 if (failed)
816 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000817 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000818 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000819 tprintf(", %lu", maxnodes);
820}
821
822int
Denys Vlasenko12014262011-05-30 14:00:14 +0200823sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000824{
825 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000826 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000827 printxval(policies, tcp->u_arg[2], "MPOL_???");
828 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200829 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000830 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000831 }
832 return 0;
833}
834
835int
Denys Vlasenko12014262011-05-30 14:00:14 +0200836sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000837{
838 if (entering(tcp)) {
839 printxval(policies, tcp->u_arg[0], "MPOL_???");
840 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
841 }
842 return 0;
843}
844
845int
Denys Vlasenko12014262011-05-30 14:00:14 +0200846sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000847{
848 if (exiting(tcp)) {
849 int pol;
850 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200851 tprints("NULL");
Roland McGrathb10a3352004-10-07 18:53:12 +0000852 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
853 tprintf("%#lx", tcp->u_arg[0]);
854 else
855 printxval(policies, pol, "MPOL_???");
856 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
857 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000858 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000859 }
860 return 0;
861}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000862
863int
Denys Vlasenko12014262011-05-30 14:00:14 +0200864sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000865{
866 if (entering(tcp)) {
867 unsigned long npages = tcp->u_arg[1];
868 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
869 if (tcp->u_arg[2] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200870 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000871 else {
872 int i;
873 long puser = tcp->u_arg[2];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200874 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000875 for (i = 0; i < npages; ++i) {
876 void *p;
877 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200878 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000879 if (umove(tcp, puser, &p) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200880 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000881 break;
882 }
883 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200884 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000885 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200886 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000887 }
888 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200889 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000890 else {
891 int i;
892 long nodeuser = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200893 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000894 for (i = 0; i < npages; ++i) {
895 int node;
896 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200897 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000898 if (umove(tcp, nodeuser, &node) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200899 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000900 break;
901 }
902 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200903 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000904 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200905 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000906 }
907 }
908 if (exiting(tcp)) {
909 unsigned long npages = tcp->u_arg[1];
910 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200911 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000912 else {
913 int i;
914 long statususer = tcp->u_arg[4];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200915 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000916 for (i = 0; i < npages; ++i) {
917 int status;
918 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200919 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000920 if (umove(tcp, statususer, &status) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200921 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000922 break;
923 }
924 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200925 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000926 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200927 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000928 }
929 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
930 }
931 return 0;
932}
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000933#endif
Roland McGrath4a6f6522008-08-25 03:09:16 +0000934
935#if defined(LINUX) && defined(POWERPC)
936int
Denys Vlasenko12014262011-05-30 14:00:14 +0200937sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000938{
939 if (entering(tcp)) {
940 unsigned long cur, end, abbrev_end, entries;
941 unsigned int entry;
942
943 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
944 entries = tcp->u_arg[1] >> 16;
945 if (!entries || !tcp->u_arg[2]) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200946 tprints("{}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000947 return 0;
948 }
949 cur = tcp->u_arg[2];
950 end = cur + (sizeof(int) * entries);
951 if (!verbose(tcp) || end < tcp->u_arg[2]) {
952 tprintf("%#lx", tcp->u_arg[2]);
953 return 0;
954 }
955 if (abbrev(tcp)) {
956 abbrev_end = cur + (sizeof(int) * max_strlen);
957 if (abbrev_end > end)
958 abbrev_end = end;
959 }
960 else
961 abbrev_end = end;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200962 tprints("{");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000963 for (; cur < end; cur += sizeof(int)) {
964 if (cur > tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200965 tprints(", ");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000966 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200967 tprints("...");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000968 break;
969 }
970 if (umove(tcp, cur, &entry) < 0) {
971 tprintf("??? [%#lx]", cur);
972 break;
973 }
974 else
975 tprintf("%#08x", entry);
976 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200977 tprints("}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000978 }
979
980 return 0;
981}
982#endif