| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* | 
 | 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 Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 |  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> | 
| Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 6 |  * Copyright (c) 2000 PocketPenguins Inc.  Linux for Hitachi SuperH | 
 | 7 |  *                    port by Greg Banks <gbanks@pocketpenguins.com> | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 8 |  * 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 Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 37 | #ifdef LINUX | 
| Roland McGrath | 05cdd3c | 2004-03-02 06:16:59 +0000 | [diff] [blame] | 38 | #include <asm/mman.h> | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 39 | #endif | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 40 | #include <sys/mman.h> | 
| Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 41 |  | 
| Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 42 | #if defined(LINUX) && defined(I386) | 
| Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 43 | # include <asm/ldt.h> | 
| Roland McGrath | 7decfb2 | 2004-03-01 22:10:52 +0000 | [diff] [blame] | 44 | # ifdef HAVE_STRUCT_USER_DESC | 
 | 45 | #  define modify_ldt_ldt_s user_desc | 
 | 46 | # endif | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | #endif | 
| Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 48 | #if defined(LINUX) && defined(SH64) | 
| Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 49 | # include <asm/page.h>	    /* for PAGE_SHIFT */ | 
| Roland McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 50 | #endif | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 51 |  | 
| John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 52 | #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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 59 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 60 | sys_brk(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 61 | { | 
 | 62 | 	if (entering(tcp)) { | 
 | 63 | 		tprintf("%#lx", tcp->u_arg[0]); | 
 | 64 | 	} | 
| Wichert Akkerman | 5daa028 | 1999-03-15 19:49:42 +0000 | [diff] [blame] | 65 | #ifdef LINUX | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 66 | 	return RVAL_HEX; | 
 | 67 | #else | 
 | 68 | 	return 0; | 
 | 69 | #endif | 
 | 70 | } | 
 | 71 |  | 
| Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 72 | #if defined(FREEBSD) || defined(SUNOS4) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 73 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 74 | sys_sbrk(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 75 | { | 
 | 76 | 	if (entering(tcp)) { | 
 | 77 | 		tprintf("%lu", tcp->u_arg[0]); | 
 | 78 | 	} | 
 | 79 | 	return RVAL_HEX; | 
 | 80 | } | 
| Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 81 | #endif /* FREEBSD || SUNOS4 */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 82 |  | 
| Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 83 | static const struct xlat mmap_prot[] = { | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 84 | 	{ PROT_NONE,	"PROT_NONE",	}, | 
 | 85 | 	{ PROT_READ,	"PROT_READ"	}, | 
 | 86 | 	{ PROT_WRITE,	"PROT_WRITE"	}, | 
 | 87 | 	{ PROT_EXEC,	"PROT_EXEC"	}, | 
| Roland McGrath | 47eb0e2 | 2003-09-25 23:06:04 +0000 | [diff] [blame] | 88 | #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 McGrath | 586d6ab | 2008-08-25 03:00:47 +0000 | [diff] [blame] | 97 | #ifdef PROT_SAO | 
 | 98 | 	{ PROT_SAO,	"PROT_SAO"	}, | 
 | 99 | #endif | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 100 | 	{ 0,		NULL		}, | 
 | 101 | }; | 
 | 102 |  | 
| Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 103 | static const struct xlat mmap_flags[] = { | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 104 | 	{ 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. Levin | 71f1a13 | 2007-03-29 23:30:09 +0000 | [diff] [blame] | 110 | #ifdef MAP_32BIT | 
 | 111 | 	{ MAP_32BIT,	"MAP_32BIT"	}, | 
 | 112 | #endif | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 113 | #ifdef MAP_RENAME | 
 | 114 | 	{ MAP_RENAME,	"MAP_RENAME"	}, | 
 | 115 | #endif | 
 | 116 | #ifdef MAP_NORESERVE | 
 | 117 | 	{ MAP_NORESERVE,"MAP_NORESERVE"	}, | 
 | 118 | #endif | 
| Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 119 | #ifdef MAP_POPULATE | 
 | 120 | 	{ MAP_POPULATE, "MAP_POPULATE" }, | 
 | 121 | #endif | 
 | 122 | #ifdef MAP_NONBLOCK | 
 | 123 | 	{ MAP_NONBLOCK, "MAP_NONBLOCK" }, | 
 | 124 | #endif | 
| Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 125 | 	/* | 
 | 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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 152 | #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 Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 164 | #ifdef MAP_INHERIT | 
 | 165 | 	{ MAP_INHERIT,"MAP_INHERIT"	}, | 
 | 166 | #endif | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 167 | #ifdef MAP_FILE | 
 | 168 | 	{ MAP_FILE,"MAP_FILE"}, | 
 | 169 | #endif | 
 | 170 | #ifdef MAP_LOCKED | 
 | 171 | 	{ MAP_LOCKED,"MAP_LOCKED"}, | 
 | 172 | #endif | 
| Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 173 | 	/* 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 Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 189 | #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 Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 194 | 	{ 0,		NULL		}, | 
 | 195 | }; | 
 | 196 |  | 
| Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 197 | #ifdef TILE | 
| Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 198 | static int | 
 | 199 | addtileflags(long flags) | 
| Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 200 | { | 
 | 201 | 	long home = flags & _MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK); | 
 | 202 | 	flags &= ~_MAP_CACHE_MKHOME(_MAP_CACHE_HOME_MASK); | 
 | 203 |  | 
 | 204 | 	if (flags & _MAP_CACHE_INCOHERENT) { | 
 | 205 | 		flags &= ~_MAP_CACHE_INCOHERENT; | 
 | 206 | 		if (home == MAP_CACHE_HOME_NONE) { | 
 | 207 | 			tprintf("|MAP_CACHE_INCOHERENT"); | 
 | 208 | 			return flags; | 
 | 209 | 		} | 
 | 210 | 		tprintf("|_MAP_CACHE_INCOHERENT"); | 
 | 211 | 	} | 
 | 212 |  | 
 | 213 | 	switch (home) { | 
 | 214 | 	case 0:	break; | 
 | 215 | 	case MAP_CACHE_HOME_HERE: tprintf("|MAP_CACHE_HOME_HERE"); break; | 
 | 216 | 	case MAP_CACHE_HOME_NONE: tprintf("|MAP_CACHE_HOME_NONE"); break; | 
 | 217 | 	case MAP_CACHE_HOME_SINGLE: tprintf("|MAP_CACHE_HOME_SINGLE"); break; | 
 | 218 | 	case MAP_CACHE_HOME_TASK: tprintf("|MAP_CACHE_HOME_TASK"); break; | 
 | 219 | 	case MAP_CACHE_HOME_HASH: tprintf("|MAP_CACHE_HOME_HASH"); break; | 
 | 220 | 	default: | 
 | 221 | 		tprintf("|MAP_CACHE_HOME(%d)", | 
 | 222 | 			(home >> _MAP_CACHE_HOME_SHIFT) ); | 
 | 223 | 		break; | 
 | 224 | 	} | 
 | 225 |  | 
 | 226 | 	return flags; | 
 | 227 | } | 
 | 228 | #endif | 
 | 229 |  | 
| John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 230 | #if !HAVE_LONG_LONG_OFF_T | 
| Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 231 | static int | 
 | 232 | print_mmap(struct tcb *tcp, long *u_arg, long long offset) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 233 | { | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 234 | 	if (entering(tcp)) { | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 235 | 		/* addr */ | 
| Wichert Akkerman | 8829a55 | 1999-06-11 13:18:40 +0000 | [diff] [blame] | 236 | 		if (!u_arg[0]) | 
 | 237 | 			tprintf("NULL, "); | 
 | 238 | 		else | 
 | 239 | 			tprintf("%#lx, ", u_arg[0]); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 240 | 		/* len */ | 
 | 241 | 		tprintf("%lu, ", u_arg[1]); | 
 | 242 | 		/* prot */ | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 243 | 		printflags(mmap_prot, u_arg[2], "PROT_???"); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 244 | 		tprintf(", "); | 
 | 245 | 		/* flags */ | 
| Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 246 | #ifdef MAP_TYPE | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 247 | 		printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); | 
| Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 248 | #ifdef TILE | 
 | 249 | 		addflags(mmap_flags, addtileflags(u_arg[3] & ~MAP_TYPE)); | 
 | 250 | #else | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 251 | 		addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); | 
| Chris Metcalf | c8c6698 | 2009-12-28 10:00:15 -0500 | [diff] [blame] | 252 | #endif | 
| Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 253 | #else | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 254 | 		printflags(mmap_flags, u_arg[3], "MAP_???"); | 
| Wichert Akkerman | bf79f2e | 2000-09-01 21:03:06 +0000 | [diff] [blame] | 255 | #endif | 
| Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 256 | 		/* fd */ | 
 | 257 | 		tprintf(", "); | 
 | 258 | 		printfd(tcp, u_arg[4]); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 259 | 		/* offset */ | 
| Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 260 | 		tprintf(", %#llx", offset); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 261 | 	} | 
 | 262 | 	return RVAL_HEX; | 
 | 263 | } | 
 | 264 |  | 
| Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 265 | #ifdef LINUX | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 266 | int sys_old_mmap(struct tcb *tcp) | 
| Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 267 | { | 
| Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 268 | #if defined(IA64) | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 269 | 	/* | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 270 | 	 * 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 Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 274 | 	 * | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 275 | 	 * 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 Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 278 | 	 */ | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 279 | 	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 Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 284 | 	for (i = 0; i < 6; i++) | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 285 | 		u_arg[i] = narrow_arg[i]; | 
| Roland McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 286 | #elif defined(SH) || defined(SH64) | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 287 | 	/* SH has always passed the args in registers */ | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 288 | 	long *u_arg = tcp->u_arg; | 
| Roland McGrath | 6b1d43e | 2003-03-31 01:05:01 +0000 | [diff] [blame] | 289 | #else | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 290 | 	long u_arg[6]; | 
| Roland McGrath | 520e21f | 2005-07-05 09:50:18 +0000 | [diff] [blame] | 291 | # if defined(X86_64) | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 292 | 	if (current_personality == 1) { | 
 | 293 | 		int i; | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 294 | 		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 Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 299 | 	} | 
 | 300 | 	else | 
| Roland McGrath | 520e21f | 2005-07-05 09:50:18 +0000 | [diff] [blame] | 301 | # endif | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 302 | 	if (umoven(tcp, tcp->u_arg[0], sizeof(u_arg), (char *) u_arg) == -1) | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 303 | 		return 0; | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 304 | #endif /* other architectures */ | 
 | 305 |  | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 306 | 	return print_mmap(tcp, u_arg, u_arg[5]); | 
| Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 307 | } | 
| Denys Vlasenko | 72a5848 | 2011-08-19 16:01:51 +0200 | [diff] [blame] | 308 | #endif /* LINUX */ | 
| Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 309 |  | 
 | 310 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 311 | sys_mmap(struct tcb *tcp) | 
| Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 312 | { | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 313 | 	long long offset = tcp->u_arg[5]; | 
| Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 314 |  | 
| Denys Vlasenko | 9aa9796 | 2011-08-19 17:07:38 +0200 | [diff] [blame] | 315 | 	/* 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 McGrath | f5a4777 | 2003-06-26 22:40:42 +0000 | [diff] [blame] | 320 | #if defined(LINUX) && defined(SH64) | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 321 | 	/* | 
 | 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 McGrath | e1e584b | 2003-06-02 19:18:58 +0000 | [diff] [blame] | 328 | #endif | 
| Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 329 | #if defined(LINUX_MIPSN32) | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 330 | 	offset = tcp->ext_arg[5]; | 
| Roland McGrath | 542c2c6 | 2008-05-20 01:11:56 +0000 | [diff] [blame] | 331 | #endif | 
| Denys Vlasenko | adedb51 | 2008-12-30 18:47:55 +0000 | [diff] [blame] | 332 | 	return print_mmap(tcp, tcp->u_arg, offset); | 
| Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 333 | } | 
| John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 334 | #endif /* !HAVE_LONG_LONG_OFF_T */ | 
| Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 335 |  | 
| John Hughes | 70623be | 2001-03-08 13:59:00 +0000 | [diff] [blame] | 336 | #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 337 | int | 
| Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 338 | sys_mmap64(struct tcb *tcp) | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 339 | { | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 340 | 	if (entering(tcp)) { | 
| Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 341 | #if !defined(LINUX) || defined(ALPHA) | 
 | 342 | 		long *u_arg = tcp->u_arg; | 
 | 343 | #else | 
 | 344 | 		long u_arg[7]; | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 345 | 		if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, | 
 | 346 | 				(char *) u_arg) == -1) | 
 | 347 | 			return 0; | 
| Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 348 | #endif | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 349 | 		/* addr */ | 
 | 350 | 		tprintf("%#lx, ", u_arg[0]); | 
 | 351 | 		/* len */ | 
 | 352 | 		tprintf("%lu, ", u_arg[1]); | 
 | 353 | 		/* prot */ | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 354 | 		printflags(mmap_prot, u_arg[2], "PROT_???"); | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 355 | 		tprintf(", "); | 
 | 356 | 		/* flags */ | 
| John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 357 | #ifdef MAP_TYPE | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 358 | 		printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???"); | 
 | 359 | 		addflags(mmap_flags, u_arg[3] & ~MAP_TYPE); | 
| John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 360 | #else | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 361 | 		printflags(mmap_flags, u_arg[3], "MAP_???"); | 
| John Hughes | 5a826b8 | 2001-03-07 13:21:24 +0000 | [diff] [blame] | 362 | #endif | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 363 | 		/* fd */ | 
| Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 364 | 		tprintf(", "); | 
| Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 365 | 	/* BUG?! should be u_arg[4] (without tcp->)? */ | 
| Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 366 | 		printfd(tcp, tcp->u_arg[4]); | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 367 | 		/* offset */ | 
| Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 368 | 	/* BUG?! on non-ALPHA linux, offset will be not in tcp->u_arg, | 
 | 369 | 	 * but in local u_arg, but printllval prints tcp->u_arg! */ | 
| Dmitry V. Levin | 3138213 | 2011-03-04 05:08:02 +0300 | [diff] [blame] | 370 | 		printllval(tcp, ", %#llx", 5); | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 371 | 	} | 
 | 372 | 	return RVAL_HEX; | 
 | 373 | } | 
| Denys Vlasenko | 31f9cb6 | 2011-08-19 16:11:07 +0200 | [diff] [blame] | 374 | #endif /* _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T */ | 
| John Hughes | bdf48f5 | 2001-03-06 15:08:09 +0000 | [diff] [blame] | 375 |  | 
| Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 376 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 377 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 378 | sys_munmap(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 379 | { | 
 | 380 | 	if (entering(tcp)) { | 
 | 381 | 		tprintf("%#lx, %lu", | 
 | 382 | 			tcp->u_arg[0], tcp->u_arg[1]); | 
 | 383 | 	} | 
 | 384 | 	return 0; | 
 | 385 | } | 
 | 386 |  | 
 | 387 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 388 | sys_mprotect(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 389 | { | 
 | 390 | 	if (entering(tcp)) { | 
 | 391 | 		tprintf("%#lx, %lu, ", | 
 | 392 | 			tcp->u_arg[0], tcp->u_arg[1]); | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 393 | 		printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 394 | 	} | 
 | 395 | 	return 0; | 
 | 396 | } | 
 | 397 |  | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 398 | #ifdef LINUX | 
 | 399 |  | 
| Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 400 | static const struct xlat mremap_flags[] = { | 
| Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 401 | 	{ MREMAP_MAYMOVE,	"MREMAP_MAYMOVE"	}, | 
| Chris Metcalf | ff3474a | 2009-12-24 23:19:19 +0000 | [diff] [blame] | 402 | #ifdef MREMAP_FIXED | 
 | 403 | 	{ MREMAP_FIXED,		"MREMAP_FIXED"		}, | 
 | 404 | #endif | 
| Wichert Akkerman | 5ae21ea | 2000-05-01 01:53:59 +0000 | [diff] [blame] | 405 | 	{ 0,			NULL			} | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 406 | }; | 
 | 407 |  | 
 | 408 | int | 
| Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 409 | sys_mremap(struct tcb *tcp) | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 410 | { | 
 | 411 | 	if (entering(tcp)) { | 
 | 412 | 		tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1], | 
 | 413 | 			tcp->u_arg[2]); | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 414 | 		printflags(mremap_flags, tcp->u_arg[3], "MREMAP_???"); | 
| Dmitry V. Levin | fdc4559 | 2009-12-24 23:34:58 +0000 | [diff] [blame] | 415 | #ifdef MREMAP_FIXED | 
 | 416 | 		if ((tcp->u_arg[3] & (MREMAP_MAYMOVE | MREMAP_FIXED)) == | 
 | 417 | 		    (MREMAP_MAYMOVE | MREMAP_FIXED)) | 
 | 418 | 			tprintf(", %#lx", tcp->u_arg[4]); | 
 | 419 | #endif | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 420 | 	} | 
 | 421 | 	return RVAL_HEX; | 
 | 422 | } | 
 | 423 |  | 
| Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 424 | static const struct xlat madvise_cmds[] = { | 
| Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 425 | #ifdef MADV_NORMAL | 
 | 426 | 	{ MADV_NORMAL,		"MADV_NORMAL" }, | 
 | 427 | #endif | 
| Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 428 | #ifdef MADV_RANDOM | 
| Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 429 | 	{ MADV_RANDOM,		"MADV_RANDOM" }, | 
 | 430 | #endif | 
 | 431 | #ifdef MADV_SEQUENTIAL | 
 | 432 | 	{ MADV_SEQUENTIAL,	"MADV_SEQUENTIAL" }, | 
 | 433 | #endif | 
 | 434 | #ifdef MADV_WILLNEED | 
 | 435 | 	{ MADV_WILLNEED,	"MADV_WILLNEED" }, | 
 | 436 | #endif | 
| Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 437 | #ifdef MADV_DONTNEED | 
| Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 438 | 	{ MADV_DONTNEED,	"MADV_DONTNEED" }, | 
 | 439 | #endif | 
 | 440 | 	{ 0,			NULL }, | 
 | 441 | }; | 
 | 442 |  | 
 | 443 |  | 
 | 444 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 445 | sys_madvise(struct tcb *tcp) | 
| Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 446 | { | 
 | 447 | 	if (entering(tcp)) { | 
 | 448 | 		tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); | 
| Roland McGrath | f4021b1 | 2008-08-25 02:59:36 +0000 | [diff] [blame] | 449 | 		printxval(madvise_cmds, tcp->u_arg[2], "MADV_???"); | 
| Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 450 | 	} | 
 | 451 | 	return 0; | 
 | 452 | } | 
 | 453 |  | 
 | 454 |  | 
| Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 455 | static const struct xlat mlockall_flags[] = { | 
| Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 456 | #ifdef MCL_CURRENT | 
 | 457 | 	{ MCL_CURRENT,	"MCL_CURRENT" }, | 
 | 458 | #endif | 
 | 459 | #ifdef MCL_FUTURE | 
 | 460 | 	{ MCL_FUTURE,	"MCL_FUTURE" }, | 
 | 461 | #endif | 
 | 462 | 	{ 0,		NULL} | 
 | 463 | }; | 
 | 464 |  | 
 | 465 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 466 | sys_mlockall(struct tcb *tcp) | 
| Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 467 | { | 
 | 468 | 	if (entering(tcp)) { | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 469 | 		printflags(mlockall_flags, tcp->u_arg[0], "MCL_???"); | 
| Wichert Akkerman | c792698 | 2000-04-10 22:22:31 +0000 | [diff] [blame] | 470 | 	} | 
 | 471 | 	return 0; | 
 | 472 | } | 
 | 473 |  | 
 | 474 |  | 
| Wichert Akkerman | 2e2553a | 1999-05-09 00:29:58 +0000 | [diff] [blame] | 475 | #endif /* LINUX */ | 
 | 476 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 477 | #ifdef MS_ASYNC | 
 | 478 |  | 
| Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 479 | static const struct xlat mctl_sync[] = { | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 480 | #ifdef MS_SYNC | 
 | 481 | 	{ MS_SYNC,	"MS_SYNC"	}, | 
 | 482 | #endif | 
| John Hughes | aca07f3 | 2001-10-16 18:12:27 +0000 | [diff] [blame] | 483 | 	{ MS_ASYNC,	"MS_ASYNC"	}, | 
 | 484 | 	{ MS_INVALIDATE,"MS_INVALIDATE"	}, | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 485 | 	{ 0,		NULL		}, | 
 | 486 | }; | 
 | 487 |  | 
 | 488 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 489 | sys_msync(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 490 | { | 
 | 491 | 	if (entering(tcp)) { | 
 | 492 | 		/* addr */ | 
 | 493 | 		tprintf("%#lx", tcp->u_arg[0]); | 
 | 494 | 		/* len */ | 
 | 495 | 		tprintf(", %lu, ", tcp->u_arg[1]); | 
 | 496 | 		/* flags */ | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 497 | 		printflags(mctl_sync, tcp->u_arg[2], "MS_???"); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 498 | 	} | 
 | 499 | 	return 0; | 
 | 500 | } | 
 | 501 |  | 
 | 502 | #endif /* MS_ASYNC */ | 
 | 503 |  | 
 | 504 | #ifdef MC_SYNC | 
 | 505 |  | 
| Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 506 | static const struct xlat mctl_funcs[] = { | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 507 | 	{ MC_LOCK,	"MC_LOCK"	}, | 
 | 508 | 	{ MC_LOCKAS,	"MC_LOCKAS"	}, | 
 | 509 | 	{ MC_SYNC,	"MC_SYNC"	}, | 
 | 510 | 	{ MC_UNLOCK,	"MC_UNLOCK"	}, | 
 | 511 | 	{ MC_UNLOCKAS,	"MC_UNLOCKAS"	}, | 
 | 512 | 	{ 0,		NULL		}, | 
 | 513 | }; | 
 | 514 |  | 
| Roland McGrath | d9f816f | 2004-09-04 03:39:20 +0000 | [diff] [blame] | 515 | static const struct xlat mctl_lockas[] = { | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 516 | 	{ MCL_CURRENT,	"MCL_CURRENT"	}, | 
 | 517 | 	{ MCL_FUTURE,	"MCL_FUTURE"	}, | 
 | 518 | 	{ 0,		NULL		}, | 
 | 519 | }; | 
 | 520 |  | 
 | 521 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 522 | sys_mctl(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 523 | { | 
 | 524 | 	int arg, function; | 
 | 525 |  | 
 | 526 | 	if (entering(tcp)) { | 
 | 527 | 		/* addr */ | 
 | 528 | 		tprintf("%#lx", tcp->u_arg[0]); | 
 | 529 | 		/* len */ | 
 | 530 | 		tprintf(", %lu, ", tcp->u_arg[1]); | 
 | 531 | 		/* function */ | 
 | 532 | 		function = tcp->u_arg[2]; | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 533 | 		printflags(mctl_funcs, function, "MC_???"); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 534 | 		/* arg */ | 
 | 535 | 		arg = tcp->u_arg[3]; | 
 | 536 | 		tprintf(", "); | 
 | 537 | 		switch (function) { | 
 | 538 | 		case MC_SYNC: | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 539 | 			printflags(mctl_sync, arg, "MS_???"); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 540 | 			break; | 
 | 541 | 		case MC_LOCKAS: | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 542 | 			printflags(mctl_lockas, arg, "MCL_???"); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 543 | 			break; | 
 | 544 | 		default: | 
 | 545 | 			tprintf("%#x", arg); | 
 | 546 | 			break; | 
 | 547 | 		} | 
 | 548 | 	} | 
 | 549 | 	return 0; | 
 | 550 | } | 
 | 551 |  | 
 | 552 | #endif /* MC_SYNC */ | 
 | 553 |  | 
 | 554 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 555 | sys_mincore(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 556 | { | 
| Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 557 | 	unsigned long i, len; | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 558 | 	char *vec = NULL; | 
 | 559 |  | 
 | 560 | 	if (entering(tcp)) { | 
 | 561 | 		tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); | 
 | 562 | 	} else { | 
 | 563 | 		len = tcp->u_arg[1]; | 
 | 564 | 		if (syserror(tcp) || tcp->u_arg[2] == 0 || | 
| Roland McGrath | 46100d0 | 2005-06-01 18:55:42 +0000 | [diff] [blame] | 565 | 			(vec = malloc(len)) == NULL || | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 566 | 			umoven(tcp, tcp->u_arg[2], len, vec) < 0) | 
 | 567 | 			tprintf("%#lx", tcp->u_arg[2]); | 
 | 568 | 		else { | 
 | 569 | 			tprintf("["); | 
 | 570 | 			for (i = 0; i < len; i++) { | 
 | 571 | 				if (abbrev(tcp) && i >= max_strlen) { | 
 | 572 | 					tprintf("..."); | 
 | 573 | 					break; | 
 | 574 | 				} | 
 | 575 | 				tprintf((vec[i] & 1) ? "1" : "0"); | 
 | 576 | 			} | 
 | 577 | 			tprintf("]"); | 
 | 578 | 		} | 
 | 579 | 		if (vec) | 
 | 580 | 			free(vec); | 
 | 581 | 	} | 
 | 582 | 	return 0; | 
 | 583 | } | 
 | 584 |  | 
| Roland McGrath | da6c92c | 2007-09-12 01:26:29 +0000 | [diff] [blame] | 585 | #if defined(ALPHA) || defined(FREEBSD) || defined(IA64) || defined(SUNOS4) || defined(SVR4) || defined(SPARC) || defined(SPARC64) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 586 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 587 | sys_getpagesize(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 588 | { | 
 | 589 | 	if (exiting(tcp)) | 
 | 590 | 		return RVAL_HEX; | 
 | 591 | 	return 0; | 
 | 592 | } | 
| Dmitry V. Levin | b9fe011 | 2006-12-13 16:59:44 +0000 | [diff] [blame] | 593 | #endif /* ALPHA || FREEBSD || IA64 || SUNOS4 || SVR4 */ | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 594 |  | 
 | 595 | #if defined(LINUX) && defined(__i386__) | 
| Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 596 | void | 
| Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 597 | print_ldt_entry(struct modify_ldt_ldt_s *ldt_entry) | 
| Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 598 | { | 
 | 599 | 	tprintf("base_addr:%#08lx, " | 
 | 600 | 		"limit:%d, " | 
 | 601 | 		"seg_32bit:%d, " | 
 | 602 | 		"contents:%d, " | 
 | 603 | 		"read_exec_only:%d, " | 
 | 604 | 		"limit_in_pages:%d, " | 
 | 605 | 		"seg_not_present:%d, " | 
 | 606 | 		"useable:%d}", | 
| Denys Vlasenko | 1f45825 | 2009-01-23 16:10:22 +0000 | [diff] [blame] | 607 | 		(long) ldt_entry->base_addr, | 
| Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 608 | 		ldt_entry->limit, | 
 | 609 | 		ldt_entry->seg_32bit, | 
 | 610 | 		ldt_entry->contents, | 
 | 611 | 		ldt_entry->read_exec_only, | 
 | 612 | 		ldt_entry->limit_in_pages, | 
 | 613 | 		ldt_entry->seg_not_present, | 
 | 614 | 		ldt_entry->useable); | 
 | 615 | } | 
 | 616 |  | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 617 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 618 | sys_modify_ldt(struct tcb *tcp) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 619 | { | 
 | 620 | 	if (entering(tcp)) { | 
 | 621 | 		struct modify_ldt_ldt_s copy; | 
 | 622 | 		tprintf("%ld", tcp->u_arg[0]); | 
 | 623 | 		if (tcp->u_arg[1] == 0 | 
| Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 624 | 				|| tcp->u_arg[2] != sizeof(struct modify_ldt_ldt_s) | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 625 | 				|| umove(tcp, tcp->u_arg[1], ©) == -1) | 
 | 626 | 			tprintf(", %lx", tcp->u_arg[1]); | 
 | 627 | 		else { | 
 | 628 | 			tprintf(", {entry_number:%d, ", copy.entry_number); | 
 | 629 | 			if (!verbose(tcp)) | 
 | 630 | 				tprintf("...}"); | 
 | 631 | 			else { | 
| Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 632 | 				print_ldt_entry(©); | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 633 | 			} | 
 | 634 | 		} | 
 | 635 | 		tprintf(", %lu", tcp->u_arg[2]); | 
 | 636 | 	} | 
 | 637 | 	return 0; | 
 | 638 | } | 
| Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 639 |  | 
 | 640 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 641 | sys_set_thread_area(struct tcb *tcp) | 
| Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 642 | { | 
 | 643 | 	struct modify_ldt_ldt_s copy; | 
 | 644 | 	if (entering(tcp)) { | 
 | 645 | 		if (umove(tcp, tcp->u_arg[0], ©) != -1) { | 
 | 646 | 			if (copy.entry_number == -1) | 
 | 647 | 				tprintf("{entry_number:%d -> ", | 
 | 648 | 					copy.entry_number); | 
 | 649 | 			else | 
 | 650 | 				tprintf("{entry_number:"); | 
 | 651 | 		} | 
 | 652 | 	} else { | 
 | 653 | 		if (umove(tcp, tcp->u_arg[0], ©) != -1) { | 
 | 654 | 			tprintf("%d, ", copy.entry_number); | 
 | 655 | 			if (!verbose(tcp)) | 
 | 656 | 				tprintf("...}"); | 
 | 657 | 			else { | 
 | 658 | 				print_ldt_entry(©); | 
 | 659 | 			} | 
 | 660 | 		} else { | 
 | 661 | 			tprintf("%lx", tcp->u_arg[0]); | 
 | 662 | 		} | 
 | 663 | 	} | 
 | 664 | 	return 0; | 
| Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 665 |  | 
| Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 666 | } | 
 | 667 |  | 
 | 668 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 669 | sys_get_thread_area(struct tcb *tcp) | 
| Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 670 | { | 
 | 671 | 	struct modify_ldt_ldt_s copy; | 
 | 672 | 	if (exiting(tcp)) { | 
 | 673 | 		if (umove(tcp, tcp->u_arg[0], ©) != -1) { | 
 | 674 | 			tprintf("{entry_number:%d, ", copy.entry_number); | 
 | 675 | 			if (!verbose(tcp)) | 
 | 676 | 				tprintf("...}"); | 
 | 677 | 			else { | 
 | 678 | 				print_ldt_entry(©); | 
 | 679 | 			} | 
 | 680 | 		} else { | 
 | 681 | 			tprintf("%lx", tcp->u_arg[0]); | 
 | 682 | 		} | 
 | 683 | 	} | 
 | 684 | 	return 0; | 
| Roland McGrath | 909875b | 2002-12-22 03:34:36 +0000 | [diff] [blame] | 685 |  | 
| Roland McGrath | 34e4a69 | 2002-12-15 23:58:17 +0000 | [diff] [blame] | 686 | } | 
| Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 687 | #endif /* LINUX && __i386__ */ | 
| Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 688 |  | 
| Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 689 | #if defined(LINUX) && defined(M68K) | 
 | 690 |  | 
 | 691 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 692 | sys_set_thread_area(struct tcb *tcp) | 
| Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 693 | { | 
 | 694 | 	if (entering(tcp)) | 
 | 695 | 		tprintf("%#lx", tcp->u_arg[0]); | 
 | 696 | 	return 0; | 
 | 697 |  | 
 | 698 | } | 
 | 699 |  | 
 | 700 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 701 | sys_get_thread_area(struct tcb *tcp) | 
| Andreas Schwab | 5874322 | 2010-05-28 22:28:51 +0200 | [diff] [blame] | 702 | { | 
 | 703 | 	return RVAL_HEX; | 
 | 704 | } | 
 | 705 | #endif | 
 | 706 |  | 
| Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 707 | #if defined(LINUX) | 
 | 708 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 709 | sys_remap_file_pages(struct tcb *tcp) | 
| Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 710 | { | 
 | 711 | 	if (entering(tcp)) { | 
 | 712 | 		tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 713 | 		printflags(mmap_prot, tcp->u_arg[2], "PROT_???"); | 
| Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 714 | 		tprintf(", %lu, ", tcp->u_arg[3]); | 
 | 715 | #ifdef MAP_TYPE | 
 | 716 | 		printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???"); | 
 | 717 | 		addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE); | 
 | 718 | #else | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 719 | 		printflags(mmap_flags, tcp->u_arg[4], "MAP_???"); | 
| Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 720 | #endif | 
 | 721 | 	} | 
 | 722 | 	return 0; | 
 | 723 | } | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 724 |  | 
 | 725 |  | 
 | 726 | #define MPOL_DEFAULT    0 | 
 | 727 | #define MPOL_PREFERRED  1 | 
 | 728 | #define MPOL_BIND       2 | 
 | 729 | #define MPOL_INTERLEAVE 3 | 
 | 730 |  | 
 | 731 | #define MPOL_F_NODE     (1<<0) | 
 | 732 | #define MPOL_F_ADDR     (1<<1) | 
 | 733 |  | 
 | 734 | #define MPOL_MF_STRICT  (1<<0) | 
| Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 735 | #define MPOL_MF_MOVE	(1<<1) | 
 | 736 | #define MPOL_MF_MOVE_ALL (1<<2) | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 737 |  | 
 | 738 |  | 
 | 739 | static const struct xlat policies[] = { | 
 | 740 | 	{ MPOL_DEFAULT,		"MPOL_DEFAULT"		}, | 
 | 741 | 	{ MPOL_PREFERRED,	"MPOL_PREFERRED"	}, | 
 | 742 | 	{ MPOL_BIND,		"MPOL_BIND"		}, | 
 | 743 | 	{ MPOL_INTERLEAVE,	"MPOL_INTERLEAVE"	}, | 
 | 744 | 	{ 0,			NULL			} | 
 | 745 | }; | 
 | 746 |  | 
 | 747 | static const struct xlat mbindflags[] = { | 
 | 748 | 	{ MPOL_MF_STRICT,	"MPOL_MF_STRICT"	}, | 
| Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 749 | 	{ MPOL_MF_MOVE,		"MPOL_MF_MOVE"		}, | 
 | 750 | 	{ MPOL_MF_MOVE_ALL,	"MPOL_MF_MOVE_ALL"	}, | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 751 | 	{ 0,			NULL			} | 
 | 752 | }; | 
 | 753 |  | 
 | 754 | static const struct xlat mempolicyflags[] = { | 
 | 755 | 	{ MPOL_F_NODE,		"MPOL_F_NODE"		}, | 
 | 756 | 	{ MPOL_F_ADDR,		"MPOL_F_ADDR"		}, | 
 | 757 | 	{ 0,			NULL			} | 
 | 758 | }; | 
 | 759 |  | 
| Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 760 | static const struct xlat move_pages_flags[] = { | 
 | 761 | 	{ MPOL_MF_MOVE,		"MPOL_MF_MOVE"		}, | 
 | 762 | 	{ MPOL_MF_MOVE_ALL,	"MPOL_MF_MOVE_ALL"	}, | 
 | 763 | 	{ 0,			NULL			} | 
 | 764 | }; | 
 | 765 |  | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 766 |  | 
 | 767 | static void | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 768 | get_nodes(struct tcb *tcp, unsigned long ptr, unsigned long maxnodes, int err) | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 769 | { | 
| Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 770 | 	unsigned long nlongs, size, end; | 
 | 771 |  | 
 | 772 | 	nlongs = (maxnodes + 8 * sizeof(long) - 1) / (8 * sizeof(long)); | 
 | 773 | 	size = nlongs * sizeof(long); | 
 | 774 | 	end = ptr + size; | 
 | 775 | 	if (nlongs == 0 || ((err || verbose(tcp)) && (size * 8 == maxnodes) | 
 | 776 | 			    && (end > ptr))) { | 
 | 777 | 		unsigned long n, cur, abbrev_end; | 
 | 778 | 		int failed = 0; | 
 | 779 |  | 
 | 780 | 		if (abbrev(tcp)) { | 
 | 781 | 			abbrev_end = ptr + max_strlen * sizeof(long); | 
 | 782 | 			if (abbrev_end < ptr) | 
 | 783 | 				abbrev_end = end; | 
 | 784 | 		} else { | 
 | 785 | 			abbrev_end = end; | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 786 | 		} | 
| Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 787 | 		tprintf(", {"); | 
 | 788 | 		for (cur = ptr; cur < end; cur += sizeof(long)) { | 
 | 789 | 			if (cur > ptr) | 
 | 790 | 				tprintf(", "); | 
 | 791 | 			if (cur >= abbrev_end) { | 
 | 792 | 				tprintf("..."); | 
 | 793 | 				break; | 
 | 794 | 			} | 
 | 795 | 			if (umoven(tcp, cur, sizeof(n), (char *) &n) < 0) { | 
 | 796 | 				tprintf("?"); | 
 | 797 | 				failed = 1; | 
 | 798 | 				break; | 
 | 799 | 			} | 
 | 800 | 			tprintf("%#0*lx", (int) sizeof(long) * 2 + 2, n); | 
 | 801 | 		} | 
 | 802 | 		tprintf("}"); | 
 | 803 | 		if (failed) | 
 | 804 | 			tprintf(" %#lx", ptr); | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 805 | 	} else | 
| Roland McGrath | aa524c8 | 2005-06-01 19:22:06 +0000 | [diff] [blame] | 806 | 		tprintf(", %#lx", ptr); | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 807 | 	tprintf(", %lu", maxnodes); | 
 | 808 | } | 
 | 809 |  | 
 | 810 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 811 | sys_mbind(struct tcb *tcp) | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 812 | { | 
 | 813 | 	if (entering(tcp)) { | 
| Chris Metcalf | c5fd1d9 | 2009-12-24 23:19:35 +0000 | [diff] [blame] | 814 | 		tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]); | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 815 | 		printxval(policies, tcp->u_arg[2], "MPOL_???"); | 
 | 816 | 		get_nodes(tcp, tcp->u_arg[3], tcp->u_arg[4], 0); | 
 | 817 | 		tprintf(", "); | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 818 | 		printflags(mbindflags, tcp->u_arg[5], "MPOL_???"); | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 819 | 	} | 
 | 820 | 	return 0; | 
 | 821 | } | 
 | 822 |  | 
 | 823 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 824 | sys_set_mempolicy(struct tcb *tcp) | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 825 | { | 
 | 826 | 	if (entering(tcp)) { | 
 | 827 | 		printxval(policies, tcp->u_arg[0], "MPOL_???"); | 
 | 828 | 		get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], 0); | 
 | 829 | 	} | 
 | 830 | 	return 0; | 
 | 831 | } | 
 | 832 |  | 
 | 833 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 834 | sys_get_mempolicy(struct tcb *tcp) | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 835 | { | 
 | 836 | 	if (exiting(tcp)) { | 
 | 837 | 		int pol; | 
 | 838 | 		if (tcp->u_arg[0] == 0) | 
 | 839 | 			tprintf("NULL"); | 
 | 840 | 		else if (syserror(tcp) || umove(tcp, tcp->u_arg[0], &pol) < 0) | 
 | 841 | 			tprintf("%#lx", tcp->u_arg[0]); | 
 | 842 | 		else | 
 | 843 | 			printxval(policies, pol, "MPOL_???"); | 
 | 844 | 		get_nodes(tcp, tcp->u_arg[1], tcp->u_arg[2], syserror(tcp)); | 
 | 845 | 		tprintf(", %#lx, ", tcp->u_arg[3]); | 
| Roland McGrath | b2dee13 | 2005-06-01 19:02:36 +0000 | [diff] [blame] | 846 | 		printflags(mempolicyflags, tcp->u_arg[4], "MPOL_???"); | 
| Roland McGrath | b10a335 | 2004-10-07 18:53:12 +0000 | [diff] [blame] | 847 | 	} | 
 | 848 | 	return 0; | 
 | 849 | } | 
| Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 850 |  | 
 | 851 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 852 | sys_move_pages(struct tcb *tcp) | 
| Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 853 | { | 
 | 854 | 	if (entering(tcp)) { | 
 | 855 | 		unsigned long npages = tcp->u_arg[1]; | 
 | 856 | 		tprintf("%ld, %lu, ", tcp->u_arg[0], npages); | 
 | 857 | 		if (tcp->u_arg[2] == 0) | 
 | 858 | 			tprintf("NULL, "); | 
 | 859 | 		else { | 
 | 860 | 			int i; | 
 | 861 | 			long puser = tcp->u_arg[2]; | 
 | 862 | 			tprintf("{"); | 
 | 863 | 			for (i = 0; i < npages; ++i) { | 
 | 864 | 				void *p; | 
 | 865 | 				if (i > 0) | 
 | 866 | 					tprintf(", "); | 
 | 867 | 				if (umove(tcp, puser, &p) < 0) { | 
 | 868 | 					tprintf("???"); | 
 | 869 | 					break; | 
 | 870 | 				} | 
 | 871 | 				tprintf("%p", p); | 
| Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 872 | 				puser += sizeof(void *); | 
| Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 873 | 			} | 
 | 874 | 			tprintf("}, "); | 
 | 875 | 		} | 
 | 876 | 		if (tcp->u_arg[3] == 0) | 
 | 877 | 			tprintf("NULL, "); | 
 | 878 | 		else { | 
 | 879 | 			int i; | 
 | 880 | 			long nodeuser = tcp->u_arg[3]; | 
 | 881 | 			tprintf("{"); | 
 | 882 | 			for (i = 0; i < npages; ++i) { | 
 | 883 | 				int node; | 
 | 884 | 				if (i > 0) | 
 | 885 | 					tprintf(", "); | 
 | 886 | 				if (umove(tcp, nodeuser, &node) < 0) { | 
 | 887 | 					tprintf("???"); | 
 | 888 | 					break; | 
 | 889 | 				} | 
 | 890 | 				tprintf("%#x", node); | 
| Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 891 | 				nodeuser += sizeof(int); | 
| Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 892 | 			} | 
 | 893 | 			tprintf("}, "); | 
 | 894 | 		} | 
 | 895 | 	} | 
 | 896 | 	if (exiting(tcp)) { | 
 | 897 | 		unsigned long npages = tcp->u_arg[1]; | 
 | 898 | 		if (tcp->u_arg[4] == 0) | 
 | 899 | 			tprintf("NULL, "); | 
 | 900 | 		else { | 
 | 901 | 			int i; | 
 | 902 | 			long statususer = tcp->u_arg[4]; | 
 | 903 | 			tprintf("{"); | 
 | 904 | 			for (i = 0; i < npages; ++i) { | 
 | 905 | 				int status; | 
 | 906 | 				if (i > 0) | 
 | 907 | 					tprintf(", "); | 
 | 908 | 				if (umove(tcp, statususer, &status) < 0) { | 
 | 909 | 					tprintf("???"); | 
 | 910 | 					break; | 
 | 911 | 				} | 
 | 912 | 				tprintf("%#x", status); | 
| Denys Vlasenko | b63256e | 2011-06-07 12:13:24 +0200 | [diff] [blame] | 913 | 				statususer += sizeof(int); | 
| Roland McGrath | 2c00a4a | 2007-07-24 01:52:58 +0000 | [diff] [blame] | 914 | 			} | 
 | 915 | 			tprintf("}, "); | 
 | 916 | 		} | 
 | 917 | 		printflags(move_pages_flags, tcp->u_arg[5], "MPOL_???"); | 
 | 918 | 	} | 
 | 919 | 	return 0; | 
 | 920 | } | 
| Roland McGrath | 72c5b7b | 2003-03-05 04:08:00 +0000 | [diff] [blame] | 921 | #endif | 
| Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 922 |  | 
 | 923 | #if defined(LINUX) && defined(POWERPC) | 
 | 924 | int | 
| Denys Vlasenko | 1201426 | 2011-05-30 14:00:14 +0200 | [diff] [blame] | 925 | sys_subpage_prot(struct tcb *tcp) | 
| Roland McGrath | 4a6f652 | 2008-08-25 03:09:16 +0000 | [diff] [blame] | 926 | { | 
 | 927 | 	if (entering(tcp)) { | 
 | 928 | 		unsigned long cur, end, abbrev_end, entries; | 
 | 929 | 		unsigned int entry; | 
 | 930 |  | 
 | 931 | 		tprintf("%#lx, %#lx, ", tcp->u_arg[0], tcp->u_arg[1]); | 
 | 932 | 		entries = tcp->u_arg[1] >> 16; | 
 | 933 | 		if (!entries || !tcp->u_arg[2]) { | 
 | 934 | 			tprintf("{}"); | 
 | 935 | 			return 0; | 
 | 936 | 		} | 
 | 937 | 		cur = tcp->u_arg[2]; | 
 | 938 | 		end = cur + (sizeof(int) * entries); | 
 | 939 | 		if (!verbose(tcp) || end < tcp->u_arg[2]) { | 
 | 940 | 			tprintf("%#lx", tcp->u_arg[2]); | 
 | 941 | 			return 0; | 
 | 942 | 		} | 
 | 943 | 		if (abbrev(tcp)) { | 
 | 944 | 			abbrev_end = cur + (sizeof(int) * max_strlen); | 
 | 945 | 			if (abbrev_end > end) | 
 | 946 | 				abbrev_end = end; | 
 | 947 | 		} | 
 | 948 | 		else | 
 | 949 | 			abbrev_end = end; | 
 | 950 | 		tprintf("{"); | 
 | 951 | 		for (; cur < end; cur += sizeof(int)) { | 
 | 952 | 			if (cur > tcp->u_arg[2]) | 
 | 953 | 				tprintf(", "); | 
 | 954 | 			if (cur >= abbrev_end) { | 
 | 955 | 				tprintf("..."); | 
 | 956 | 				break; | 
 | 957 | 			} | 
 | 958 | 			if (umove(tcp, cur, &entry) < 0) { | 
 | 959 | 				tprintf("??? [%#lx]", cur); | 
 | 960 | 				break; | 
 | 961 | 			} | 
 | 962 | 			else | 
 | 963 | 				tprintf("%#08x", entry); | 
 | 964 | 		} | 
 | 965 | 		tprintf("}"); | 
 | 966 | 	} | 
 | 967 |  | 
 | 968 | 	return 0; | 
 | 969 | } | 
 | 970 | #endif |