blob: 55943f133cdb0e2b90377a44e3682034491467fb [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
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000056#include "xlat/mmap_prot.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000057#include "xlat/mmap_flags.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000058
Dmitry V. Levin31382132011-03-04 05:08:02 +030059static int
Denys Vlasenko923255c2013-02-18 02:36:36 +010060print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000061{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000062 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000063 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +000064 if (!u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020065 tprints("NULL, ");
Wichert Akkerman8829a551999-06-11 13:18:40 +000066 else
67 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000068 /* len */
69 tprintf("%lu, ", u_arg[1]);
70 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +000071 printflags(mmap_prot, u_arg[2], "PROT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020072 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000073 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000074#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000075 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
76 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000077#else
Roland McGrathb2dee132005-06-01 19:02:36 +000078 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000079#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020080 tprints(", ");
Denys Vlasenko923255c2013-02-18 02:36:36 +010081 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +030082 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000083 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +030084 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000085 }
86 return RVAL_HEX;
87}
88
Denys Vlasenko1ba85432013-02-19 11:28:20 +010089/* Syscall name<->function correspondence is messed up on many arches.
90 * For example:
91 * i386 has __NR_mmap == 90, and it is "old mmap", and
92 * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets".
93 * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets".
94 * Confused? Me too!
95 */
96
97/* Params are pointed to by u_arg[0], offset is in bytes */
98int
99sys_old_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000100{
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100101 long u_arg[6];
Denys Vlasenko72a58482011-08-19 16:01:51 +0200102#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000103 /*
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200104 * IA64 processes never call this routine, they only use the
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100105 * new 'sys_mmap' interface. Only IA32 processes come here.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000106 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200107 int i;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100108 unsigned narrow_arg[6];
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200109 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
110 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000111 for (i = 0; i < 6; i++)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100112 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100113#elif defined(X86_64)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100114 /* We are here only in personality 1 (i386) */
115 int i;
116 unsigned narrow_arg[6];
117 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
118 return 0;
119 for (i = 0; i < 6; ++i)
120 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100121#else
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200122 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000123 return 0;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100124#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100125 return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000126}
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000127
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100128#if defined(S390)
129/* Params are pointed to by u_arg[0], offset is in pages */
130int
131sys_old_mmap_pgoff(struct tcb *tcp)
132{
133 long u_arg[5];
134 int i;
135 unsigned narrow_arg[6];
136 unsigned long long offset;
137 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), (char *) narrow_arg) == -1)
138 return 0;
139 for (i = 0; i < 5; i++)
140 u_arg[i] = (unsigned long) narrow_arg[i];
141 offset = narrow_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000142 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100143 return print_mmap(tcp, u_arg, offset);
144}
145#endif
146
147/* Params are passed directly, offset is in bytes */
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000148int
Denys Vlasenko12014262011-05-30 14:00:14 +0200149sys_mmap(struct tcb *tcp)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000150{
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100151 unsigned long long offset = (unsigned long) tcp->u_arg[5];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100152#if defined(LINUX_MIPSN32) || defined(X32)
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100153 /* Try test/x32_mmap.c */
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000154 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000155#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100156 /* Example of kernel-side handling of this variety of mmap:
157 * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls
158 * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes,
159 * since the above code converts off to pages.
160 */
161 return print_mmap(tcp, tcp->u_arg, offset);
162}
163
164/* Params are passed directly, offset is in pages */
165int
166sys_mmap_pgoff(struct tcb *tcp)
167{
168 /* Try test/mmap_offset_decode.c */
169 unsigned long long offset;
170 offset = (unsigned long) tcp->u_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000171 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100172 return print_mmap(tcp, tcp->u_arg, offset);
173}
174
175/* Params are passed directly, offset is in 4k units */
176int
177sys_mmap_4koff(struct tcb *tcp)
178{
179 unsigned long long offset;
180 offset = (unsigned long) tcp->u_arg[5];
181 offset <<= 12;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000182 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000183}
184
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000185int
Denys Vlasenko12014262011-05-30 14:00:14 +0200186sys_munmap(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000187{
188 if (entering(tcp)) {
189 tprintf("%#lx, %lu",
190 tcp->u_arg[0], tcp->u_arg[1]);
191 }
192 return 0;
193}
194
195int
Denys Vlasenko12014262011-05-30 14:00:14 +0200196sys_mprotect(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000197{
198 if (entering(tcp)) {
199 tprintf("%#lx, %lu, ",
200 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000201 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000202 }
203 return 0;
204}
205
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000206#include "xlat/mremap_flags.h"
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000207
208int
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000209sys_mremap(struct tcb *tcp)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000210{
211 if (entering(tcp)) {
212 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
213 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000214 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000215#ifdef MREMAP_FIXED
216 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
217 (MREMAP_MAYMOVE | MREMAP_FIXED))
218 tprintf(", %#lx", tcp->u_arg[4]);
219#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000220 }
221 return RVAL_HEX;
222}
223
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000224#include "xlat/madvise_cmds.h"
Wichert Akkermanc7926982000-04-10 22:22:31 +0000225
Wichert Akkermanc7926982000-04-10 22:22:31 +0000226int
Denys Vlasenko12014262011-05-30 14:00:14 +0200227sys_madvise(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000228{
229 if (entering(tcp)) {
230 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000231 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000232 }
233 return 0;
234}
235
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000236#include "xlat/mlockall_flags.h"
Wichert Akkermanc7926982000-04-10 22:22:31 +0000237
238int
Denys Vlasenko12014262011-05-30 14:00:14 +0200239sys_mlockall(struct tcb *tcp)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000240{
241 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000242 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000243 }
244 return 0;
245}
246
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000247#include "xlat/mctl_sync.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000248
249int
Denys Vlasenko12014262011-05-30 14:00:14 +0200250sys_msync(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000251{
252 if (entering(tcp)) {
253 /* addr */
254 tprintf("%#lx", tcp->u_arg[0]);
255 /* len */
256 tprintf(", %lu, ", tcp->u_arg[1]);
257 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000258 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259 }
260 return 0;
261}
262
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000263int
Denys Vlasenko12014262011-05-30 14:00:14 +0200264sys_mincore(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000265{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000266 if (entering(tcp)) {
267 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
268 } else {
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200269 unsigned long i, len;
270 char *vec = NULL;
271
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000272 len = tcp->u_arg[1];
273 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000274 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000275 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
276 tprintf("%#lx", tcp->u_arg[2]);
277 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200278 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000279 for (i = 0; i < len; i++) {
280 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200281 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000282 break;
283 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200284 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000285 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200286 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000287 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200288 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000289 }
290 return 0;
291}
292
Denys Vlasenko84703742012-02-25 02:38:52 +0100293#if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000294int
Denys Vlasenko12014262011-05-30 14:00:14 +0200295sys_getpagesize(struct tcb *tcp)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000296{
297 if (exiting(tcp))
298 return RVAL_HEX;
299 return 0;
300}
Denys Vlasenko84703742012-02-25 02:38:52 +0100301#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000302
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000303int
Denys Vlasenko12014262011-05-30 14:00:14 +0200304sys_remap_file_pages(struct tcb *tcp)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000305{
306 if (entering(tcp)) {
307 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000308 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000309 tprintf(", %lu, ", tcp->u_arg[3]);
310#ifdef MAP_TYPE
311 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
312 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
313#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000314 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000315#endif
316 }
317 return 0;
318}
Roland McGrathb10a3352004-10-07 18:53:12 +0000319
Roland McGrathb10a3352004-10-07 18:53:12 +0000320#define MPOL_DEFAULT 0
321#define MPOL_PREFERRED 1
322#define MPOL_BIND 2
323#define MPOL_INTERLEAVE 3
324
325#define MPOL_F_NODE (1<<0)
326#define MPOL_F_ADDR (1<<1)
327
328#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000329#define MPOL_MF_MOVE (1<<1)
330#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000331
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000332#include "xlat/policies.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000333#include "xlat/mbindflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000334#include "xlat/mempolicyflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000335#include "xlat/move_pages_flags.h"
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000336
Roland McGrathb10a3352004-10-07 18:53:12 +0000337static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200338get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000339{
Roland McGrathaa524c82005-06-01 19:22:06 +0000340 unsigned long nlongs, size, end;
341
342 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
343 size = nlongs * sizeof(long);
344 end = ptr + size;
345 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
346 && (end > ptr))) {
347 unsigned long n, cur, abbrev_end;
348 int failed = 0;
349
350 if (abbrev(tcp)) {
351 abbrev_end = ptr + max_strlen * sizeof(long);
352 if (abbrev_end < ptr)
353 abbrev_end = end;
354 } else {
355 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000356 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200357 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +0000358 for (cur = ptr; cur < end; cur += sizeof(long)) {
359 if (cur > ptr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200360 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000361 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200362 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000363 break;
364 }
365 if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200366 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000367 failed = 1;
368 break;
369 }
370 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
371 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200372 tprints("}");
Roland McGrathaa524c82005-06-01 19:22:06 +0000373 if (failed)
374 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000375 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000376 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000377 tprintf(", %lu", maxnodes);
378}
379
380int
Denys Vlasenko12014262011-05-30 14:00:14 +0200381sys_mbind(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000382{
383 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000384 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000385 printxval(policies, tcp->u_arg[2], "MPOL_???");
386 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200387 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000388 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000389 }
390 return 0;
391}
392
393int
Denys Vlasenko12014262011-05-30 14:00:14 +0200394sys_set_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000395{
396 if (entering(tcp)) {
397 printxval(policies, tcp->u_arg[0], "MPOL_???");
398 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
399 }
400 return 0;
401}
402
403int
Denys Vlasenko12014262011-05-30 14:00:14 +0200404sys_get_mempolicy(struct tcb *tcp)
Roland McGrathb10a3352004-10-07 18:53:12 +0000405{
406 if (exiting(tcp)) {
407 int pol;
408 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200409 tprints("NULL");
Roland McGrathb10a3352004-10-07 18:53:12 +0000410 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
411 tprintf("%#lx", tcp->u_arg[0]);
412 else
413 printxval(policies, pol, "MPOL_???");
414 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
415 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000416 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000417 }
418 return 0;
419}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000420
421int
Dmitry V. Levin64d0e712012-03-11 22:44:14 +0000422sys_migrate_pages(struct tcb *tcp)
423{
424 if (entering(tcp)) {
425 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
426 get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0);
427 tprints(", ");
428 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0);
429 }
430 return 0;
431}
432
433int
Denys Vlasenko12014262011-05-30 14:00:14 +0200434sys_move_pages(struct tcb *tcp)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000435{
436 if (entering(tcp)) {
437 unsigned long npages = tcp->u_arg[1];
438 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
439 if (tcp->u_arg[2] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200440 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000441 else {
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +0000442 unsigned int i;
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000443 long puser = tcp->u_arg[2];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200444 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000445 for (i = 0; i < npages; ++i) {
446 void *p;
447 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200448 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000449 if (umove(tcp, puser, &p) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200450 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000451 break;
452 }
453 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200454 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000455 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200456 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000457 }
458 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200459 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000460 else {
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +0000461 unsigned int i;
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000462 long nodeuser = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200463 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000464 for (i = 0; i < npages; ++i) {
465 int node;
466 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200467 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000468 if (umove(tcp, nodeuser, &node) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200469 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000470 break;
471 }
472 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200473 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000474 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200475 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000476 }
477 }
478 if (exiting(tcp)) {
479 unsigned long npages = tcp->u_arg[1];
480 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200481 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000482 else {
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +0000483 unsigned int i;
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000484 long statususer = tcp->u_arg[4];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200485 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000486 for (i = 0; i < npages; ++i) {
487 int status;
488 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200489 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000490 if (umove(tcp, statususer, &status) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200491 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000492 break;
493 }
494 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200495 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000496 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200497 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000498 }
499 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
500 }
501 return 0;
502}
Roland McGrath4a6f6522008-08-25 03:09:16 +0000503
Denys Vlasenko84703742012-02-25 02:38:52 +0100504#if defined(POWERPC)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000505int
Denys Vlasenko12014262011-05-30 14:00:14 +0200506sys_subpage_prot(struct tcb *tcp)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000507{
508 if (entering(tcp)) {
509 unsigned long cur, end, abbrev_end, entries;
510 unsigned int entry;
511
512 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
513 entries = tcp->u_arg[1] >> 16;
514 if (!entries || !tcp->u_arg[2]) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200515 tprints("{}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000516 return 0;
517 }
518 cur = tcp->u_arg[2];
519 end = cur + (sizeof(int) * entries);
520 if (!verbose(tcp) || end < tcp->u_arg[2]) {
521 tprintf("%#lx", tcp->u_arg[2]);
522 return 0;
523 }
524 if (abbrev(tcp)) {
525 abbrev_end = cur + (sizeof(int) * max_strlen);
526 if (abbrev_end > end)
527 abbrev_end = end;
528 }
529 else
530 abbrev_end = end;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200531 tprints("{");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000532 for (; cur < end; cur += sizeof(int)) {
533 if (cur > tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200534 tprints(", ");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000535 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200536 tprints("...");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000537 break;
538 }
539 if (umove(tcp, cur, &entry) < 0) {
540 tprintf("??? [%#lx]", cur);
541 break;
542 }
543 else
544 tprintf("%#08x", entry);
545 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200546 tprints("}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000547 }
548
549 return 0;
550}
551#endif