blob: ce5ce51e5f2ad698e2c130c77b0230096b5444de [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.
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000031 */
32
33#include "defs.h"
Roland McGrath05cdd3c2004-03-02 06:16:59 +000034#include <asm/mman.h>
Wichert Akkerman2e2553a1999-05-09 00:29:58 +000035#include <sys/mman.h>
Denys Vlasenko1ba85432013-02-19 11:28:20 +010036
Dmitry V. Levinc76a3632013-03-05 14:58:24 +000037static unsigned long
38get_pagesize()
39{
40 static unsigned long pagesize;
41
42 if (!pagesize)
43 pagesize = sysconf(_SC_PAGESIZE);
44 return pagesize;
45}
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000046
47int
Denys Vlasenko12014262011-05-30 14:00:14 +020048sys_brk(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000049{
50 if (entering(tcp)) {
51 tprintf("%#lx", tcp->u_arg[0]);
52 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000053 return RVAL_HEX;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000054}
55
Roland McGrathd9f816f2004-09-04 03:39:20 +000056static const struct xlat mmap_prot[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000057 XLAT(PROT_NONE),
58 XLAT(PROT_READ),
59 XLAT(PROT_WRITE),
60 XLAT(PROT_EXEC),
Roland McGrath47eb0e22003-09-25 23:06:04 +000061#ifdef PROT_SEM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000062 XLAT(PROT_SEM),
Roland McGrath47eb0e22003-09-25 23:06:04 +000063#endif
64#ifdef PROT_GROWSDOWN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000065 XLAT(PROT_GROWSDOWN),
Roland McGrath47eb0e22003-09-25 23:06:04 +000066#endif
67#ifdef PROT_GROWSUP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000068 XLAT(PROT_GROWSUP),
Roland McGrath47eb0e22003-09-25 23:06:04 +000069#endif
Roland McGrath586d6ab2008-08-25 03:00:47 +000070#ifdef PROT_SAO
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000071 XLAT(PROT_SAO),
Roland McGrath586d6ab2008-08-25 03:00:47 +000072#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +000073 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000074};
75
Roland McGrathd9f816f2004-09-04 03:39:20 +000076static const struct xlat mmap_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000077 XLAT(MAP_SHARED),
78 XLAT(MAP_PRIVATE),
79 XLAT(MAP_FIXED),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000080#ifdef MAP_ANONYMOUS
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000081 XLAT(MAP_ANONYMOUS),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082#endif
Dmitry V. Levin71f1a132007-03-29 23:30:09 +000083#ifdef MAP_32BIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000084 XLAT(MAP_32BIT),
Dmitry V. Levin71f1a132007-03-29 23:30:09 +000085#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000086#ifdef MAP_RENAME
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000087 XLAT(MAP_RENAME),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000088#endif
89#ifdef MAP_NORESERVE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000090 XLAT(MAP_NORESERVE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000091#endif
Roland McGrath72c5b7b2003-03-05 04:08:00 +000092#ifdef MAP_POPULATE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000093 XLAT(MAP_POPULATE),
Roland McGrath72c5b7b2003-03-05 04:08:00 +000094#endif
95#ifdef MAP_NONBLOCK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +000096 XLAT(MAP_NONBLOCK),
Roland McGrath72c5b7b2003-03-05 04:08:00 +000097#endif
Wichert Akkerman8829a551999-06-11 13:18:40 +000098 /*
99 * XXX - this was introduced in SunOS 4.x to distinguish between
100 * the old pre-4.x "mmap()", which:
101 *
102 * only let you map devices with an "mmap" routine (e.g.,
103 * frame buffers) in;
104 *
105 * required you to specify the mapping address;
106 *
107 * returned 0 on success and -1 on failure;
108 *
109 * memory and which, and the 4.x "mmap()" which:
110 *
111 * can map plain files;
112 *
113 * can be asked to pick where to map the file;
114 *
115 * returns the address where it mapped the file on success
116 * and -1 on failure.
117 *
118 * It's not actually used in source code that calls "mmap()"; the
119 * "mmap()" routine adds it for you.
120 *
121 * It'd be nice to come up with some way of eliminating it from
122 * the flags, e.g. reporting calls *without* it as "old_mmap()"
123 * and calls with it as "mmap()".
124 */
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000125#ifdef _MAP_NEW
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000126 XLAT(_MAP_NEW),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000127#endif
128#ifdef MAP_GROWSDOWN
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000129 XLAT(MAP_GROWSDOWN),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000130#endif
131#ifdef MAP_DENYWRITE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000132 XLAT(MAP_DENYWRITE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000133#endif
134#ifdef MAP_EXECUTABLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000135 XLAT(MAP_EXECUTABLE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000136#endif
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000137#ifdef MAP_INHERIT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000138 XLAT(MAP_INHERIT),
Wichert Akkermanf5eeabb1999-11-18 17:09:47 +0000139#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000140#ifdef MAP_FILE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000141 XLAT(MAP_FILE),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000142#endif
143#ifdef MAP_LOCKED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000144 XLAT(MAP_LOCKED),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000145#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000146 /* FreeBSD ones */
Denys Vlasenko2897fb32012-03-17 01:29:40 +0100147#if defined(MAP_ANON) && (!defined(MAP_ANONYMOUS) || MAP_ANON != MAP_ANONYMOUS)
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000148 XLAT(MAP_ANON),
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000149#endif
150#ifdef MAP_HASSEMAPHORE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000151 XLAT(MAP_HASSEMAPHORE),
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000152#endif
153#ifdef MAP_STACK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000154 XLAT(MAP_STACK),
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000155#endif
Kirill A. Shutemovb5530a12014-01-02 13:15:32 +0200156#ifdef MAP_HUGETLB
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000157 XLAT(MAP_HUGETLB),
Kirill A. Shutemovb5530a12014-01-02 13:15:32 +0200158#endif
Bernhard Reutner-Fischer21ceeb42013-02-05 19:31:55 +0100159#if defined MAP_UNINITIALIZED && MAP_UNINITIALIZED > 0
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000160 XLAT(MAP_UNINITIALIZED),
Bernhard Reutner-Fischer21ceeb42013-02-05 19:31:55 +0100161#endif
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000162#ifdef MAP_NOSYNC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000163 XLAT(MAP_NOSYNC),
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000164#endif
165#ifdef MAP_NOCORE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000166 XLAT(MAP_NOCORE),
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000167#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000168 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000169};
170
Dmitry V. Levin31382132011-03-04 05:08:02 +0300171static int
Denys Vlasenko923255c2013-02-18 02:36:36 +0100172print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000173{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000174 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +0000176 if (!u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200177 tprints("NULL, ");
Wichert Akkerman8829a551999-06-11 13:18:40 +0000178 else
179 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000180 /* len */
181 tprintf("%lu, ", u_arg[1]);
182 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +0000183 printflags(mmap_prot, u_arg[2], "PROT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200184 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000185 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000186#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000187 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
188 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000189#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000190 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +0000191#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200192 tprints(", ");
Denys Vlasenko923255c2013-02-18 02:36:36 +0100193 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300194 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000195 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +0300196 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000197 }
198 return RVAL_HEX;
199}
200
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100201/* Syscall name<->function correspondence is messed up on many arches.
202 * For example:
203 * i386 has __NR_mmap == 90, and it is "old mmap", and
204 * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets".
205 * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets".
206 * Confused? Me too!
207 */
208
209/* Params are pointed to by u_arg[0], offset is in bytes */
210int
211sys_old_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000212{
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100213 long u_arg[6];
Denys Vlasenko72a58482011-08-19 16:01:51 +0200214#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000215 /*
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200216 * IA64 processes never call this routine, they only use the
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100217 * new 'sys_mmap' interface. Only IA32 processes come here.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000218 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200219 int i;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100220 unsigned narrow_arg[6];
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200221 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
222 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000223 for (i = 0; i < 6; i++)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100224 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100225#elif defined(X86_64)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100226 /* We are here only in personality 1 (i386) */
227 int i;
228 unsigned narrow_arg[6];
229 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
230 return 0;
231 for (i = 0; i < 6; ++i)
232 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100233#else
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200234 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000235 return 0;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100236#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100237 return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000238}
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000239
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100240#if defined(S390)
241/* Params are pointed to by u_arg[0], offset is in pages */
242int
243sys_old_mmap_pgoff(struct tcb *tcp)
244{
245 long u_arg[5];
246 int i;
247 unsigned narrow_arg[6];
248 unsigned long long offset;
249 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
250 return 0;
251 for (i = 0; i < 5; i++)
252 u_arg[i] = (unsigned long) narrow_arg[i];
253 offset = narrow_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000254 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100255 return print_mmap(tcp, u_arg, offset);
256}
257#endif
258
259/* Params are passed directly, offset is in bytes */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000260int
Denys Vlasenko12014262011-05-30 14:00:14 +0200261sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000262{
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100263 unsigned long long offset = (unsigned long) tcp->u_arg[5];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100264#if defined(LINUX_MIPSN32) || defined(X32)
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100265 /* Try test/x32_mmap.c */
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000266 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000267#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100268 /* Example of kernel-side handling of this variety of mmap:
269 * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls
270 * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes,
271 * since the above code converts off to pages.
272 */
273 return print_mmap(tcp, tcp->u_arg, offset);
274}
275
276/* Params are passed directly, offset is in pages */
277int
278sys_mmap_pgoff(struct tcb *tcp)
279{
280 /* Try test/mmap_offset_decode.c */
281 unsigned long long offset;
282 offset = (unsigned long) tcp->u_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000283 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100284 return print_mmap(tcp, tcp->u_arg, offset);
285}
286
287/* Params are passed directly, offset is in 4k units */
288int
289sys_mmap_4koff(struct tcb *tcp)
290{
291 unsigned long long offset;
292 offset = (unsigned long) tcp->u_arg[5];
293 offset <<= 12;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000294 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000295}
296
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000297int
Denys Vlasenko12014262011-05-30 14:00:14 +0200298sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000299{
300 if (entering(tcp)) {
301 tprintf("%#lx, %lu",
302 tcp->u_arg[0], tcp->u_arg[1]);
303 }
304 return 0;
305}
306
307int
Denys Vlasenko12014262011-05-30 14:00:14 +0200308sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000309{
310 if (entering(tcp)) {
311 tprintf("%#lx, %lu, ",
312 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000313 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000314 }
315 return 0;
316}
317
Roland McGrathd9f816f2004-09-04 03:39:20 +0000318static const struct xlat mremap_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000319 XLAT(MREMAP_MAYMOVE),
Chris Metcalfff3474a2009-12-24 23:19:19 +0000320#ifdef MREMAP_FIXED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000321 XLAT(MREMAP_FIXED),
Chris Metcalfff3474a2009-12-24 23:19:19 +0000322#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000323 XLAT_END
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000324};
325
326int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000327sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000328{
329 if (entering(tcp)) {
330 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
331 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000332 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000333#ifdef MREMAP_FIXED
334 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
335 (MREMAP_MAYMOVE | MREMAP_FIXED))
336 tprintf(", %#lx", tcp->u_arg[4]);
337#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000338 }
339 return RVAL_HEX;
340}
341
Roland McGrathf4021b12008-08-25 02:59:36 +0000342static const struct xlat madvise_cmds[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000343#ifdef MADV_NORMAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000344 XLAT(MADV_NORMAL),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000345#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000346#ifdef MADV_RANDOM
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000347 XLAT(MADV_RANDOM),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000348#endif
349#ifdef MADV_SEQUENTIAL
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000350 XLAT(MADV_SEQUENTIAL),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000351#endif
352#ifdef MADV_WILLNEED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000353 XLAT(MADV_WILLNEED),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000354#endif
Roland McGrathf4021b12008-08-25 02:59:36 +0000355#ifdef MADV_DONTNEED
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000356 XLAT(MADV_DONTNEED),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000357#endif
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000358#ifdef MADV_REMOVE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000359 XLAT(MADV_REMOVE),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000360#endif
361#ifdef MADV_DONTFORK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000362 XLAT(MADV_DONTFORK),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000363#endif
364#ifdef MADV_DOFORK
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000365 XLAT(MADV_DOFORK),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000366#endif
367#ifdef MADV_HWPOISON
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000368 XLAT(MADV_HWPOISON),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000369#endif
370#ifdef MADV_SOFT_OFFLINE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000371 XLAT(MADV_SOFT_OFFLINE),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000372#endif
373#ifdef MADV_MERGEABLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000374 XLAT(MADV_MERGEABLE),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000375#endif
376#ifdef MADV_UNMERGEABLE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000377 XLAT(MADV_UNMERGEABLE),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000378#endif
379#ifdef MADV_HUGEPAGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000380 XLAT(MADV_HUGEPAGE),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000381#endif
382#ifdef MADV_NOHUGEPAGE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000383 XLAT(MADV_NOHUGEPAGE),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000384#endif
385#ifdef MADV_DONTDUMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000386 XLAT(MADV_DONTDUMP),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000387#endif
388#ifdef MADV_DODUMP
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000389 XLAT(MADV_DODUMP),
Dmitry V. Levin3ec134b2013-03-14 18:55:26 +0000390#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000391 XLAT_END
Wichert Akkermanc7926982000-04-10 22:22:31 +0000392};
393
Wichert Akkermanc7926982000-04-10 22:22:31 +0000394int
Denys Vlasenko12014262011-05-30 14:00:14 +0200395sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000396{
397 if (entering(tcp)) {
398 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000399 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000400 }
401 return 0;
402}
403
Roland McGrathd9f816f2004-09-04 03:39:20 +0000404static const struct xlat mlockall_flags[] = {
Wichert Akkermanc7926982000-04-10 22:22:31 +0000405#ifdef MCL_CURRENT
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000406 XLAT(MCL_CURRENT),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000407#endif
408#ifdef MCL_FUTURE
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000409 XLAT(MCL_FUTURE),
Wichert Akkermanc7926982000-04-10 22:22:31 +0000410#endif
Dmitry V. Levin59452732014-02-05 02:20:51 +0000411 XLAT_END
Wichert Akkermanc7926982000-04-10 22:22:31 +0000412};
413
414int
Denys Vlasenko12014262011-05-30 14:00:14 +0200415sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000416{
417 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000418 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000419 }
420 return 0;
421}
422
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000423#ifdef MS_ASYNC
424
Roland McGrathd9f816f2004-09-04 03:39:20 +0000425static const struct xlat mctl_sync[] = {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000426#ifdef MS_SYNC
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000427 XLAT(MS_SYNC),
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000428#endif
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000429 XLAT(MS_ASYNC),
430 XLAT(MS_INVALIDATE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000431 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000432};
433
434int
Denys Vlasenko12014262011-05-30 14:00:14 +0200435sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000436{
437 if (entering(tcp)) {
438 /* addr */
439 tprintf("%#lx", tcp->u_arg[0]);
440 /* len */
441 tprintf(", %lu, ", tcp->u_arg[1]);
442 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000443 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000444 }
445 return 0;
446}
447
448#endif /* MS_ASYNC */
449
450#ifdef MC_SYNC
451
Roland McGrathd9f816f2004-09-04 03:39:20 +0000452static const struct xlat mctl_funcs[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000453 XLAT(MC_LOCK),
454 XLAT(MC_LOCKAS),
455 XLAT(MC_SYNC),
456 XLAT(MC_UNLOCK),
457 XLAT(MC_UNLOCKAS),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000458 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000459};
460
Roland McGrathd9f816f2004-09-04 03:39:20 +0000461static const struct xlat mctl_lockas[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000462 XLAT(MCL_CURRENT),
463 XLAT(MCL_FUTURE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000464 XLAT_END
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000465};
466
467int
Denys Vlasenko12014262011-05-30 14:00:14 +0200468sys_mctl(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000469{
470 int arg, function;
471
472 if (entering(tcp)) {
473 /* addr */
474 tprintf("%#lx", tcp->u_arg[0]);
475 /* len */
476 tprintf(", %lu, ", tcp->u_arg[1]);
477 /* function */
478 function = tcp->u_arg[2];
Roland McGrathb2dee132005-06-01 19:02:36 +0000479 printflags(mctl_funcs, function, "MC_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000480 /* arg */
481 arg = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200482 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000483 switch (function) {
484 case MC_SYNC:
Roland McGrathb2dee132005-06-01 19:02:36 +0000485 printflags(mctl_sync, arg, "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000486 break;
487 case MC_LOCKAS:
Roland McGrathb2dee132005-06-01 19:02:36 +0000488 printflags(mctl_lockas, arg, "MCL_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000489 break;
490 default:
491 tprintf("%#x", arg);
492 break;
493 }
494 }
495 return 0;
496}
497
498#endif /* MC_SYNC */
499
500int
Denys Vlasenko12014262011-05-30 14:00:14 +0200501sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000502{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000503 if (entering(tcp)) {
504 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
505 } else {
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200506 unsigned long i, len;
507 char *vec = NULL;
508
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000509 len = tcp->u_arg[1];
510 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000511 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000512 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
513 tprintf("%#lx", tcp->u_arg[2]);
514 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200515 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000516 for (i = 0; i < len; i++) {
517 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200518 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000519 break;
520 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200521 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000522 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200523 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000524 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200525 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000526 }
527 return 0;
528}
529
Denys Vlasenko84703742012-02-25 02:38:52 +0100530#if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000531int
Denys Vlasenko12014262011-05-30 14:00:14 +0200532sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000533{
534 if (exiting(tcp))
535 return RVAL_HEX;
536 return 0;
537}
Denys Vlasenko84703742012-02-25 02:38:52 +0100538#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000539
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000540int
Denys Vlasenko12014262011-05-30 14:00:14 +0200541sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000542{
543 if (entering(tcp)) {
544 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000545 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000546 tprintf(", %lu, ", tcp->u_arg[3]);
547#ifdef MAP_TYPE
548 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
549 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
550#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000551 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000552#endif
553 }
554 return 0;
555}
Roland McGrathb10a3352004-10-07 18:53:12 +0000556
Roland McGrathb10a3352004-10-07 18:53:12 +0000557#define MPOL_DEFAULT 0
558#define MPOL_PREFERRED 1
559#define MPOL_BIND 2
560#define MPOL_INTERLEAVE 3
561
562#define MPOL_F_NODE (1<<0)
563#define MPOL_F_ADDR (1<<1)
564
565#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000566#define MPOL_MF_MOVE (1<<1)
567#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000568
Roland McGrathb10a3352004-10-07 18:53:12 +0000569static const struct xlat policies[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000570 XLAT(MPOL_DEFAULT),
571 XLAT(MPOL_PREFERRED),
572 XLAT(MPOL_BIND),
573 XLAT(MPOL_INTERLEAVE),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000574 XLAT_END
Roland McGrathb10a3352004-10-07 18:53:12 +0000575};
576
577static const struct xlat mbindflags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000578 XLAT(MPOL_MF_STRICT),
579 XLAT(MPOL_MF_MOVE),
580 XLAT(MPOL_MF_MOVE_ALL),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000581 XLAT_END
Roland McGrathb10a3352004-10-07 18:53:12 +0000582};
583
584static const struct xlat mempolicyflags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000585 XLAT(MPOL_F_NODE),
586 XLAT(MPOL_F_ADDR),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000587 XLAT_END
Roland McGrathb10a3352004-10-07 18:53:12 +0000588};
589
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000590static const struct xlat move_pages_flags[] = {
Dmitry V. Levinbce0cc62014-02-05 01:33:50 +0000591 XLAT(MPOL_MF_MOVE),
592 XLAT(MPOL_MF_MOVE_ALL),
Dmitry V. Levin59452732014-02-05 02:20:51 +0000593 XLAT_END
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000594};
595
Roland McGrathb10a3352004-10-07 18:53:12 +0000596static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200597get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000598{
Roland McGrathaa524c82005-06-01 19:22:06 +0000599 unsigned long nlongs, size, end;
600
601 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
602 size = nlongs * sizeof(long);
603 end = ptr + size;
604 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
605 && (end > ptr))) {
606 unsigned long n, cur, abbrev_end;
607 int failed = 0;
608
609 if (abbrev(tcp)) {
610 abbrev_end = ptr + max_strlen * sizeof(long);
611 if (abbrev_end < ptr)
612 abbrev_end = end;
613 } else {
614 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000615 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200616 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +0000617 for (cur = ptr; cur < end; cur += sizeof(long)) {
618 if (cur > ptr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200619 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000620 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200621 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000622 break;
623 }
624 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200625 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000626 failed = 1;
627 break;
628 }
629 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
630 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200631 tprints("}");
Roland McGrathaa524c82005-06-01 19:22:06 +0000632 if (failed)
633 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000634 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000635 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000636 tprintf(", %lu", maxnodes);
637}
638
639int
Denys Vlasenko12014262011-05-30 14:00:14 +0200640sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000641{
642 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000643 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000644 printxval(policies, tcp->u_arg[2], "MPOL_???");
645 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200646 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000647 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000648 }
649 return 0;
650}
651
652int
Denys Vlasenko12014262011-05-30 14:00:14 +0200653sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000654{
655 if (entering(tcp)) {
656 printxval(policies, tcp->u_arg[0], "MPOL_???");
657 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
658 }
659 return 0;
660}
661
662int
Denys Vlasenko12014262011-05-30 14:00:14 +0200663sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000664{
665 if (exiting(tcp)) {
666 int pol;
667 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200668 tprints("NULL");
Roland McGrathb10a3352004-10-07 18:53:12 +0000669 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
670 tprintf("%#lx", tcp->u_arg[0]);
671 else
672 printxval(policies, pol, "MPOL_???");
673 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
674 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000675 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000676 }
677 return 0;
678}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000679
680int
Dmitry V. Levin64d0e712012-03-11 22:44:14 +0000681sys_migrate_pages(struct tcb *tcp)
682{
683 if (entering(tcp)) {
684 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
685 get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0);
686 tprints(", ");
687 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0);
688 }
689 return 0;
690}
691
692int
Denys Vlasenko12014262011-05-30 14:00:14 +0200693sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000694{
695 if (entering(tcp)) {
696 unsigned long npages = tcp->u_arg[1];
697 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
698 if (tcp->u_arg[2] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200699 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000700 else {
701 int i;
702 long puser = tcp->u_arg[2];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200703 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000704 for (i = 0; i < npages; ++i) {
705 void *p;
706 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200707 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000708 if (umove(tcp, puser, &p) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200709 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000710 break;
711 }
712 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200713 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000714 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200715 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000716 }
717 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200718 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000719 else {
720 int i;
721 long nodeuser = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200722 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000723 for (i = 0; i < npages; ++i) {
724 int node;
725 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200726 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000727 if (umove(tcp, nodeuser, &node) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200728 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000729 break;
730 }
731 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200732 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000733 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200734 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000735 }
736 }
737 if (exiting(tcp)) {
738 unsigned long npages = tcp->u_arg[1];
739 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200740 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000741 else {
742 int i;
743 long statususer = tcp->u_arg[4];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200744 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000745 for (i = 0; i < npages; ++i) {
746 int status;
747 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200748 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000749 if (umove(tcp, statususer, &status) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200750 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000751 break;
752 }
753 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200754 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000755 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200756 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000757 }
758 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
759 }
760 return 0;
761}
Roland McGrath4a6f6522008-08-25 03:09:16 +0000762
Denys Vlasenko84703742012-02-25 02:38:52 +0100763#if defined(POWERPC)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000764int
Denys Vlasenko12014262011-05-30 14:00:14 +0200765sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000766{
767 if (entering(tcp)) {
768 unsigned long cur, end, abbrev_end, entries;
769 unsigned int entry;
770
771 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
772 entries = tcp->u_arg[1] >> 16;
773 if (!entries || !tcp->u_arg[2]) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200774 tprints("{}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000775 return 0;
776 }
777 cur = tcp->u_arg[2];
778 end = cur + (sizeof(int) * entries);
779 if (!verbose(tcp) || end < tcp->u_arg[2]) {
780 tprintf("%#lx", tcp->u_arg[2]);
781 return 0;
782 }
783 if (abbrev(tcp)) {
784 abbrev_end = cur + (sizeof(int) * max_strlen);
785 if (abbrev_end > end)
786 abbrev_end = end;
787 }
788 else
789 abbrev_end = end;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200790 tprints("{");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000791 for (; cur < end; cur += sizeof(int)) {
792 if (cur > tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200793 tprints(", ");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000794 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200795 tprints("...");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000796 break;
797 }
798 if (umove(tcp, cur, &entry) < 0) {
799 tprintf("??? [%#lx]", cur);
800 break;
801 }
802 else
803 tprintf("%#08x", entry);
804 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200805 tprints("}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000806 }
807
808 return 0;
809}
810#endif