blob: 322b7eb76b5f0cb71ac16b6a7a76813ca5412d51 [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. Levinea1fea62015-03-31 19:45:08 +000037unsigned long
38get_pagesize(void)
Dmitry V. Levinc76a3632013-03-05 14:58:24 +000039{
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
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000047SYS_FUNC(brk)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000048{
49 if (entering(tcp)) {
50 tprintf("%#lx", tcp->u_arg[0]);
51 }
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000052 return RVAL_HEX;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000053}
54
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000055#include "xlat/mmap_prot.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +000056#include "xlat/mmap_flags.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057
Dmitry V. Levin31382132011-03-04 05:08:02 +030058static int
Denys Vlasenko923255c2013-02-18 02:36:36 +010059print_mmap(struct tcb *tcp, long *u_arg, unsigned long long offset)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000060{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000061 if (entering(tcp)) {
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000062 /* addr */
Wichert Akkerman8829a551999-06-11 13:18:40 +000063 if (!u_arg[0])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020064 tprints("NULL, ");
Wichert Akkerman8829a551999-06-11 13:18:40 +000065 else
66 tprintf("%#lx, ", u_arg[0]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000067 /* len */
68 tprintf("%lu, ", u_arg[1]);
69 /* prot */
Roland McGrathb2dee132005-06-01 19:02:36 +000070 printflags(mmap_prot, u_arg[2], "PROT_???");
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020071 tprints(", ");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000072 /* flags */
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000073#ifdef MAP_TYPE
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000074 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
75 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000076#else
Roland McGrathb2dee132005-06-01 19:02:36 +000077 printflags(mmap_flags, u_arg[3], "MAP_???");
Wichert Akkermanbf79f2e2000-09-01 21:03:06 +000078#endif
Denys Vlasenko60fe8c12011-09-01 10:00:28 +020079 tprints(", ");
Denys Vlasenko923255c2013-02-18 02:36:36 +010080 /* fd */
Dmitry V. Levin31382132011-03-04 05:08:02 +030081 printfd(tcp, u_arg[4]);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000082 /* offset */
Dmitry V. Levin31382132011-03-04 05:08:02 +030083 tprintf(", %#llx", offset);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000084 }
85 return RVAL_HEX;
86}
87
Denys Vlasenko1ba85432013-02-19 11:28:20 +010088/* Syscall name<->function correspondence is messed up on many arches.
89 * For example:
90 * i386 has __NR_mmap == 90, and it is "old mmap", and
91 * also it has __NR_mmap2 == 192, which is a "new mmap with page offsets".
92 * But x86_64 has just one __NR_mmap == 9, a "new mmap with byte offsets".
93 * Confused? Me too!
94 */
95
96/* Params are pointed to by u_arg[0], offset is in bytes */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +000097SYS_FUNC(old_mmap)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +000098{
Denys Vlasenko1ba85432013-02-19 11:28:20 +010099 long u_arg[6];
Denys Vlasenko72a58482011-08-19 16:01:51 +0200100#if defined(IA64)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000101 /*
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200102 * IA64 processes never call this routine, they only use the
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100103 * new 'sys_mmap' interface. Only IA32 processes come here.
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000104 */
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200105 int i;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100106 unsigned narrow_arg[6];
Denys Vlasenko7e69ed92015-03-21 19:50:53 +0100107 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), narrow_arg) == -1)
Denys Vlasenko9aa97962011-08-19 17:07:38 +0200108 return 0;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000109 for (i = 0; i < 6; i++)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100110 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100111#elif defined(X86_64)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100112 /* We are here only in personality 1 (i386) */
113 int i;
114 unsigned narrow_arg[6];
Denys Vlasenko7e69ed92015-03-21 19:50:53 +0100115 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), narrow_arg) == -1)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100116 return 0;
117 for (i = 0; i < 6; ++i)
118 u_arg[i] = (unsigned long) narrow_arg[i];
Denys Vlasenko923255c2013-02-18 02:36:36 +0100119#else
Denys Vlasenko7e69ed92015-03-21 19:50:53 +0100120 if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), u_arg) == -1)
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000121 return 0;
Denys Vlasenko923255c2013-02-18 02:36:36 +0100122#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100123 return print_mmap(tcp, u_arg, (unsigned long) u_arg[5]);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000124}
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000125
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100126#if defined(S390)
127/* Params are pointed to by u_arg[0], offset is in pages */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000128SYS_FUNC(old_mmap_pgoff)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100129{
130 long u_arg[5];
131 int i;
132 unsigned narrow_arg[6];
133 unsigned long long offset;
Denys Vlasenko7e69ed92015-03-21 19:50:53 +0100134 if (umoven(tcp, tcp->u_arg[0], sizeof(narrow_arg), narrow_arg) == -1)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100135 return 0;
136 for (i = 0; i < 5; i++)
137 u_arg[i] = (unsigned long) narrow_arg[i];
138 offset = narrow_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000139 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100140 return print_mmap(tcp, u_arg, offset);
141}
142#endif
143
144/* Params are passed directly, offset is in bytes */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000145SYS_FUNC(mmap)
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000146{
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100147 unsigned long long offset = (unsigned long) tcp->u_arg[5];
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100148#if defined(LINUX_MIPSN32) || defined(X32)
Denys Vlasenko8dedb0d2013-02-18 03:13:07 +0100149 /* Try test/x32_mmap.c */
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000150 offset = tcp->ext_arg[5];
Roland McGrath542c2c62008-05-20 01:11:56 +0000151#endif
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100152 /* Example of kernel-side handling of this variety of mmap:
153 * arch/x86/kernel/sys_x86_64.c::SYSCALL_DEFINE6(mmap, ...) calls
154 * sys_mmap_pgoff(..., off >> PAGE_SHIFT); i.e. off is in bytes,
155 * since the above code converts off to pages.
156 */
157 return print_mmap(tcp, tcp->u_arg, offset);
158}
159
160/* Params are passed directly, offset is in pages */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000161SYS_FUNC(mmap_pgoff)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100162{
163 /* Try test/mmap_offset_decode.c */
164 unsigned long long offset;
165 offset = (unsigned long) tcp->u_arg[5];
Dmitry V. Levinc76a3632013-03-05 14:58:24 +0000166 offset *= get_pagesize();
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100167 return print_mmap(tcp, tcp->u_arg, offset);
168}
169
170/* Params are passed directly, offset is in 4k units */
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000171SYS_FUNC(mmap_4koff)
Denys Vlasenko1ba85432013-02-19 11:28:20 +0100172{
173 unsigned long long offset;
174 offset = (unsigned long) tcp->u_arg[5];
175 offset <<= 12;
Denys Vlasenkoadedb512008-12-30 18:47:55 +0000176 return print_mmap(tcp, tcp->u_arg, offset);
Wichert Akkerman4dc8a2a1999-12-23 14:20:14 +0000177}
178
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000179SYS_FUNC(munmap)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000180{
181 if (entering(tcp)) {
182 tprintf("%#lx, %lu",
183 tcp->u_arg[0], tcp->u_arg[1]);
184 }
185 return 0;
186}
187
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000188SYS_FUNC(mprotect)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000189{
190 if (entering(tcp)) {
191 tprintf("%#lx, %lu, ",
192 tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000193 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000194 }
195 return 0;
196}
197
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000198#include "xlat/mremap_flags.h"
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000199
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000200SYS_FUNC(mremap)
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000201{
202 if (entering(tcp)) {
203 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
204 tcp->u_arg[2]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000205 printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???");
Dmitry V. Levinfdc45592009-12-24 23:34:58 +0000206#ifdef MREMAP_FIXED
207 if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) ==
208 (MREMAP_MAYMOVE | MREMAP_FIXED))
209 tprintf(", %#lx", tcp->u_arg[4]);
210#endif
Wichert Akkerman2e2553a1999-05-09 00:29:58 +0000211 }
212 return RVAL_HEX;
213}
214
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000215#include "xlat/madvise_cmds.h"
Wichert Akkermanc7926982000-04-10 22:22:31 +0000216
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000217SYS_FUNC(madvise)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000218{
219 if (entering(tcp)) {
220 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathf4021b12008-08-25 02:59:36 +0000221 printxval(madvise_cmds, tcp->u_arg[2], "MADV_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000222 }
223 return 0;
224}
225
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000226#include "xlat/mlockall_flags.h"
Wichert Akkermanc7926982000-04-10 22:22:31 +0000227
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000228SYS_FUNC(mlockall)
Wichert Akkermanc7926982000-04-10 22:22:31 +0000229{
230 if (entering(tcp)) {
Roland McGrathb2dee132005-06-01 19:02:36 +0000231 printflags(mlockall_flags, tcp->u_arg[0], "MCL_???");
Wichert Akkermanc7926982000-04-10 22:22:31 +0000232 }
233 return 0;
234}
235
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000236#include "xlat/mctl_sync.h"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000237
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000238SYS_FUNC(msync)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000239{
240 if (entering(tcp)) {
241 /* addr */
242 tprintf("%#lx", tcp->u_arg[0]);
243 /* len */
244 tprintf(", %lu, ", tcp->u_arg[1]);
245 /* flags */
Roland McGrathb2dee132005-06-01 19:02:36 +0000246 printflags(mctl_sync, tcp->u_arg[2], "MS_???");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000247 }
248 return 0;
249}
250
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000251SYS_FUNC(mincore)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000252{
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000253 if (entering(tcp)) {
254 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
255 } else {
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200256 unsigned long i, len;
257 char *vec = NULL;
258
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000259 len = tcp->u_arg[1];
260 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
Roland McGrath46100d02005-06-01 18:55:42 +0000261 (vec = malloc(len)) == NULL ||
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000262 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
263 tprintf("%#lx", tcp->u_arg[2]);
264 else {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200265 tprints("[");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000266 for (i = 0; i < len; i++) {
267 if (abbrev(tcp) && i >= max_strlen) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200268 tprints("...");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000269 break;
270 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200271 tprints((vec[i] & 1) ? "1" : "0");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000272 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200273 tprints("]");
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000274 }
Denys Vlasenko1d46ba52011-08-31 14:00:02 +0200275 free(vec);
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000276 }
277 return 0;
278}
279
Denys Vlasenko84703742012-02-25 02:38:52 +0100280#if defined(ALPHA) || defined(IA64) || defined(SPARC) || defined(SPARC64)
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000281SYS_FUNC(getpagesize)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000282{
283 if (exiting(tcp))
284 return RVAL_HEX;
285 return 0;
286}
Denys Vlasenko84703742012-02-25 02:38:52 +0100287#endif
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000288
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000289SYS_FUNC(remap_file_pages)
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000290{
291 if (entering(tcp)) {
292 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000293 printflags(mmap_prot, tcp->u_arg[2], "PROT_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000294 tprintf(", %lu, ", tcp->u_arg[3]);
295#ifdef MAP_TYPE
296 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
297 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
298#else
Roland McGrathb2dee132005-06-01 19:02:36 +0000299 printflags(mmap_flags, tcp->u_arg[4], "MAP_???");
Roland McGrath72c5b7b2003-03-05 04:08:00 +0000300#endif
301 }
302 return 0;
303}
Roland McGrathb10a3352004-10-07 18:53:12 +0000304
Roland McGrathb10a3352004-10-07 18:53:12 +0000305#define MPOL_DEFAULT 0
306#define MPOL_PREFERRED 1
307#define MPOL_BIND 2
308#define MPOL_INTERLEAVE 3
309
310#define MPOL_F_NODE (1<<0)
311#define MPOL_F_ADDR (1<<1)
312
313#define MPOL_MF_STRICT (1<<0)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000314#define MPOL_MF_MOVE (1<<1)
315#define MPOL_MF_MOVE_ALL (1<<2)
Roland McGrathb10a3352004-10-07 18:53:12 +0000316
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000317#include "xlat/policies.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000318#include "xlat/mbindflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000319#include "xlat/mempolicyflags.h"
Dmitry V. Levin0ed617b2014-04-25 23:30:54 +0000320#include "xlat/move_pages_flags.h"
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000321
Roland McGrathb10a3352004-10-07 18:53:12 +0000322static void
Denys Vlasenko12014262011-05-30 14:00:14 +0200323get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err)
Roland McGrathb10a3352004-10-07 18:53:12 +0000324{
Roland McGrathaa524c82005-06-01 19:22:06 +0000325 unsigned long nlongs, size, end;
326
327 nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long));
328 size = nlongs * sizeof(long);
329 end = ptr + size;
330 if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes)
331 && (end > ptr))) {
332 unsigned long n, cur, abbrev_end;
333 int failed = 0;
334
335 if (abbrev(tcp)) {
336 abbrev_end = ptr + max_strlen * sizeof(long);
337 if (abbrev_end < ptr)
338 abbrev_end = end;
339 } else {
340 abbrev_end = end;
Roland McGrathb10a3352004-10-07 18:53:12 +0000341 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200342 tprints(", {");
Roland McGrathaa524c82005-06-01 19:22:06 +0000343 for (cur = ptr; cur < end; cur += sizeof(long)) {
344 if (cur > ptr)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200345 tprints(", ");
Roland McGrathaa524c82005-06-01 19:22:06 +0000346 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200347 tprints("...");
Roland McGrathaa524c82005-06-01 19:22:06 +0000348 break;
349 }
Denys Vlasenko7e69ed92015-03-21 19:50:53 +0100350 if (umoven(tcp, cur, sizeof(n), &n) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200351 tprints("?");
Roland McGrathaa524c82005-06-01 19:22:06 +0000352 failed = 1;
353 break;
354 }
355 tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n);
356 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200357 tprints("}");
Roland McGrathaa524c82005-06-01 19:22:06 +0000358 if (failed)
359 tprintf(" %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000360 } else
Roland McGrathaa524c82005-06-01 19:22:06 +0000361 tprintf(", %#lx", ptr);
Roland McGrathb10a3352004-10-07 18:53:12 +0000362 tprintf(", %lu", maxnodes);
363}
364
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000365SYS_FUNC(mbind)
Roland McGrathb10a3352004-10-07 18:53:12 +0000366{
367 if (entering(tcp)) {
Chris Metcalfc5fd1d92009-12-24 23:19:35 +0000368 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
Roland McGrathb10a3352004-10-07 18:53:12 +0000369 printxval(policies, tcp->u_arg[2], "MPOL_???");
370 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0);
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200371 tprints(", ");
Roland McGrathb2dee132005-06-01 19:02:36 +0000372 printflags(mbindflags, tcp->u_arg[5], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000373 }
374 return 0;
375}
376
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000377SYS_FUNC(set_mempolicy)
Roland McGrathb10a3352004-10-07 18:53:12 +0000378{
379 if (entering(tcp)) {
380 printxval(policies, tcp->u_arg[0], "MPOL_???");
381 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0);
382 }
383 return 0;
384}
385
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000386SYS_FUNC(get_mempolicy)
Roland McGrathb10a3352004-10-07 18:53:12 +0000387{
388 if (exiting(tcp)) {
389 int pol;
390 if (tcp->u_arg[0] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200391 tprints("NULL");
Roland McGrathb10a3352004-10-07 18:53:12 +0000392 else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0)
393 tprintf("%#lx", tcp->u_arg[0]);
394 else
395 printxval(policies, pol, "MPOL_???");
396 get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp));
397 tprintf(", %#lx, ", tcp->u_arg[3]);
Roland McGrathb2dee132005-06-01 19:02:36 +0000398 printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???");
Roland McGrathb10a3352004-10-07 18:53:12 +0000399 }
400 return 0;
401}
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000402
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000403SYS_FUNC(migrate_pages)
Dmitry V. Levin64d0e712012-03-11 22:44:14 +0000404{
405 if (entering(tcp)) {
406 tprintf("%ld, ", (long) (pid_t) tcp->u_arg[0]);
407 get_nodes(tcp, tcp->u_arg[2], tcp->u_arg[1], 0);
408 tprints(", ");
409 get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[1], 0);
410 }
411 return 0;
412}
413
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000414SYS_FUNC(move_pages)
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000415{
416 if (entering(tcp)) {
417 unsigned long npages = tcp->u_arg[1];
418 tprintf("%ld, %lu, ", tcp->u_arg[0], npages);
419 if (tcp->u_arg[2] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200420 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000421 else {
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +0000422 unsigned int i;
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000423 long puser = tcp->u_arg[2];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200424 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000425 for (i = 0; i < npages; ++i) {
426 void *p;
427 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200428 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000429 if (umove(tcp, puser, &p) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200430 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000431 break;
432 }
433 tprintf("%p", p);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200434 puser += sizeof(void *);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000435 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200436 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000437 }
438 if (tcp->u_arg[3] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200439 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000440 else {
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +0000441 unsigned int i;
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000442 long nodeuser = tcp->u_arg[3];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200443 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000444 for (i = 0; i < npages; ++i) {
445 int node;
446 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200447 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000448 if (umove(tcp, nodeuser, &node) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200449 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000450 break;
451 }
452 tprintf("%#x", node);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200453 nodeuser += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000454 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200455 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000456 }
457 }
458 if (exiting(tcp)) {
459 unsigned long npages = tcp->u_arg[1];
460 if (tcp->u_arg[4] == 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200461 tprints("NULL, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000462 else {
Dmitry V. Levin3ed5d022014-09-10 13:46:04 +0000463 unsigned int i;
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000464 long statususer = tcp->u_arg[4];
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200465 tprints("{");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000466 for (i = 0; i < npages; ++i) {
467 int status;
468 if (i > 0)
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200469 tprints(", ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000470 if (umove(tcp, statususer, &status) < 0) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200471 tprints("???");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000472 break;
473 }
474 tprintf("%#x", status);
Denys Vlasenkob63256e2011-06-07 12:13:24 +0200475 statususer += sizeof(int);
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000476 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200477 tprints("}, ");
Roland McGrath2c00a4a2007-07-24 01:52:58 +0000478 }
479 printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???");
480 }
481 return 0;
482}
Roland McGrath4a6f6522008-08-25 03:09:16 +0000483
Denys Vlasenko84703742012-02-25 02:38:52 +0100484#if defined(POWERPC)
Dmitry V. Levina0bd3742015-04-07 01:36:50 +0000485SYS_FUNC(subpage_prot)
Roland McGrath4a6f6522008-08-25 03:09:16 +0000486{
487 if (entering(tcp)) {
488 unsigned long cur, end, abbrev_end, entries;
489 unsigned int entry;
490
491 tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]);
492 entries = tcp->u_arg[1] >> 16;
493 if (!entries || !tcp->u_arg[2]) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200494 tprints("{}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000495 return 0;
496 }
497 cur = tcp->u_arg[2];
498 end = cur + (sizeof(int) * entries);
Dmitry V. Levin3b64d992015-01-14 07:17:11 +0000499 if (!verbose(tcp) || end < (unsigned long) tcp->u_arg[2]) {
Roland McGrath4a6f6522008-08-25 03:09:16 +0000500 tprintf("%#lx", tcp->u_arg[2]);
501 return 0;
502 }
503 if (abbrev(tcp)) {
504 abbrev_end = cur + (sizeof(int) * max_strlen);
505 if (abbrev_end > end)
506 abbrev_end = end;
507 }
508 else
509 abbrev_end = end;
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200510 tprints("{");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000511 for (; cur < end; cur += sizeof(int)) {
Dmitry V. Levin3b64d992015-01-14 07:17:11 +0000512 if (cur > (unsigned long) tcp->u_arg[2])
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200513 tprints(", ");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000514 if (cur >= abbrev_end) {
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200515 tprints("...");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000516 break;
517 }
518 if (umove(tcp, cur, &entry) < 0) {
519 tprintf("??? [%#lx]", cur);
520 break;
521 }
522 else
523 tprintf("%#08x", entry);
524 }
Denys Vlasenko60fe8c12011-09-01 10:00:28 +0200525 tprints("}");
Roland McGrath4a6f6522008-08-25 03:09:16 +0000526 }
527
528 return 0;
529}
530#endif