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>
5 * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 #include <linux/mman.h>
40 #if defined(LINUX) && defined(I386)
44 #ifdef HAVE_LONG_LONG_OFF_T
46 * Ugly hacks for systems that have a long long off_t
48 #define sys_mmap64 sys_mmap
56 tprintf("%#lx", tcp->u_arg[0]);
70 tprintf("%lu", tcp->u_arg[0]);
75 static struct xlat mmap_prot[] = {
76 { PROT_NONE, "PROT_NONE", },
77 { PROT_READ, "PROT_READ" },
78 { PROT_WRITE, "PROT_WRITE" },
79 { PROT_EXEC, "PROT_EXEC" },
83 static struct xlat mmap_flags[] = {
84 { MAP_SHARED, "MAP_SHARED" },
85 { MAP_PRIVATE, "MAP_PRIVATE" },
86 { MAP_FIXED, "MAP_FIXED" },
88 { MAP_ANONYMOUS,"MAP_ANONYMOUS" },
91 { MAP_RENAME, "MAP_RENAME" },
94 { MAP_NORESERVE,"MAP_NORESERVE" },
97 { MAP_POPULATE, "MAP_POPULATE" },
100 { MAP_NONBLOCK, "MAP_NONBLOCK" },
103 * XXX - this was introduced in SunOS 4.x to distinguish between
104 * the old pre-4.x "mmap()", which:
106 * only let you map devices with an "mmap" routine (e.g.,
109 * required you to specify the mapping address;
111 * returned 0 on success and -1 on failure;
113 * memory and which, and the 4.x "mmap()" which:
115 * can map plain files;
117 * can be asked to pick where to map the file;
119 * returns the address where it mapped the file on success
122 * It's not actually used in source code that calls "mmap()"; the
123 * "mmap()" routine adds it for you.
125 * It'd be nice to come up with some way of eliminating it from
126 * the flags, e.g. reporting calls *without* it as "old_mmap()"
127 * and calls with it as "mmap()".
130 { _MAP_NEW, "_MAP_NEW" },
133 { MAP_GROWSDOWN,"MAP_GROWSDOWN" },
136 { MAP_DENYWRITE,"MAP_DENYWRITE" },
138 #ifdef MAP_EXECUTABLE
139 { MAP_EXECUTABLE,"MAP_EXECUTABLE"},
142 { MAP_INHERIT,"MAP_INHERIT" },
145 { MAP_FILE,"MAP_FILE"},
148 { MAP_LOCKED,"MAP_LOCKED"},
152 { MAP_ANON, "MAP_ANON" },
154 #ifdef MAP_HASSEMAPHORE
155 { MAP_HASSEMAPHORE, "MAP_HASSEMAPHORE" },
158 { MAP_STACK, "MAP_STACK" },
161 { MAP_NOSYNC, "MAP_NOSYNC" },
164 { MAP_NOCORE, "MAP_NOCORE" },
169 #if !HAVE_LONG_LONG_OFF_T
172 print_mmap(tcp,u_arg)
181 tprintf("%#lx, ", u_arg[0]);
183 tprintf("%lu, ", u_arg[1]);
185 printflags(mmap_prot, u_arg[2]);
189 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
190 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
192 printflags(mmap_flags, u_arg[3]);
194 /* fd (is always int, not long) */
195 tprintf(", %d, ", (int)u_arg[4]);
197 tprintf("%#lx", u_arg[5]);
203 int sys_old_mmap(tcp)
211 * IA64 processes never call this routine, they only use the
212 * new `sys_mmap' interface. This code converts the integer
213 * arguments that the IA32 process pushed onto the stack into
216 * Note that addresses with bit 31 set will be sign extended.
217 * Fortunately, those addresses are not currently being generated
218 * for IA32 processes so it's not a problem.
220 for (i = 0; i < 6; i++)
221 if (umove(tcp, tcp->u_arg[0] + (i * sizeof(int)), &v) == -1)
226 /* SH has always passed the args in registers */
229 u_arg[i] = tcp->u_arg[i];
231 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg, (char *) u_arg) == -1)
233 #endif // defined(IA64)
234 return print_mmap(tcp, u_arg);
243 return print_mmap(tcp, tcp->u_arg);
245 #endif /* !HAVE_LONG_LONG_OFF_T */
247 #if _LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T
254 long *u_arg = tcp->u_arg;
259 long *u_arg = tcp->u_arg;
265 if (umoven(tcp, tcp->u_arg[0], sizeof u_arg,
266 (char *) u_arg) == -1)
270 ALIGN64 (tcp, 5); /* FreeBSD wierdies */
273 tprintf("%#lx, ", u_arg[0]);
275 tprintf("%lu, ", u_arg[1]);
277 printflags(mmap_prot, u_arg[2]);
281 printxval(mmap_flags, u_arg[3] & MAP_TYPE, "MAP_???");
282 addflags(mmap_flags, u_arg[3] & ~MAP_TYPE);
284 printflags(mmap_flags, u_arg[3]);
287 tprintf(", %ld, ", u_arg[4]);
289 tprintf("%#llx", LONG_LONG(u_arg[5], u_arg[6]));
302 tcp->u_arg[0], tcp->u_arg[1]);
312 tprintf("%#lx, %lu, ",
313 tcp->u_arg[0], tcp->u_arg[1]);
314 if (!printflags(mmap_prot, tcp->u_arg[2]))
322 static struct xlat mremap_flags[] = {
323 { MREMAP_MAYMOVE, "MREMAP_MAYMOVE" },
332 tprintf("%#lx, %lu, %lu, ", tcp->u_arg[0], tcp->u_arg[1],
334 printflags(mremap_flags, tcp->u_arg[3]);
339 static struct xlat madvise_flags[] = {
341 { MADV_NORMAL, "MADV_NORMAL" },
344 { MADV_RANDOM, "MADV_RANDOM" },
346 #ifdef MADV_SEQUENTIAL
347 { MADV_SEQUENTIAL, "MADV_SEQUENTIAL" },
350 { MADV_WILLNEED, "MADV_WILLNEED" },
353 { MADV_DONTNEED, "MADV_DONTNEED" },
364 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
365 printflags(madvise_flags, tcp->u_arg[2]);
371 static struct xlat mlockall_flags[] = {
373 { MCL_CURRENT, "MCL_CURRENT" },
376 { MCL_FUTURE, "MCL_FUTURE" },
386 printflags(mlockall_flags, tcp->u_arg[0]);
396 static struct xlat mctl_sync[] = {
398 { MS_SYNC, "MS_SYNC" },
400 { MS_ASYNC, "MS_ASYNC" },
401 { MS_INVALIDATE,"MS_INVALIDATE" },
411 tprintf("%#lx", tcp->u_arg[0]);
413 tprintf(", %lu, ", tcp->u_arg[1]);
415 if (!printflags(mctl_sync, tcp->u_arg[2]))
421 #endif /* MS_ASYNC */
425 static struct xlat mctl_funcs[] = {
426 { MC_LOCK, "MC_LOCK" },
427 { MC_LOCKAS, "MC_LOCKAS" },
428 { MC_SYNC, "MC_SYNC" },
429 { MC_UNLOCK, "MC_UNLOCK" },
430 { MC_UNLOCKAS, "MC_UNLOCKAS" },
434 static struct xlat mctl_lockas[] = {
435 { MCL_CURRENT, "MCL_CURRENT" },
436 { MCL_FUTURE, "MCL_FUTURE" },
448 tprintf("%#lx", tcp->u_arg[0]);
450 tprintf(", %lu, ", tcp->u_arg[1]);
452 function = tcp->u_arg[2];
453 if (!printflags(mctl_funcs, function))
460 if (!printflags(mctl_sync, arg))
464 if (!printflags(mctl_lockas, arg))
485 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
488 if (syserror(tcp) || tcp->u_arg[2] == 0 ||
489 (vec = malloc((u_int)len)) == NULL ||
490 umoven(tcp, tcp->u_arg[2], len, vec) < 0)
491 tprintf("%#lx", tcp->u_arg[2]);
494 for (i = 0; i < len; i++) {
495 if (abbrev(tcp) && i >= max_strlen) {
499 tprintf((vec[i] & 1) ? "1" : "0");
518 #if defined(LINUX) && defined(__i386__)
520 print_ldt_entry (ldt_entry)
521 struct modify_ldt_ldt_s *ldt_entry;
523 tprintf("base_addr:%#08lx, "
527 "read_exec_only:%d, "
528 "limit_in_pages:%d, "
529 "seg_not_present:%d, "
531 ldt_entry->base_addr,
533 ldt_entry->seg_32bit,
535 ldt_entry->read_exec_only,
536 ldt_entry->limit_in_pages,
537 ldt_entry->seg_not_present,
546 struct modify_ldt_ldt_s copy;
547 tprintf("%ld", tcp->u_arg[0]);
548 if (tcp->u_arg[1] == 0
549 || tcp->u_arg[2] != sizeof (struct modify_ldt_ldt_s)
550 || umove(tcp, tcp->u_arg[1], ©) == -1)
551 tprintf(", %lx", tcp->u_arg[1]);
553 tprintf(", {entry_number:%d, ", copy.entry_number);
557 print_ldt_entry(©);
560 tprintf(", %lu", tcp->u_arg[2]);
566 sys_set_thread_area(tcp)
569 struct modify_ldt_ldt_s copy;
571 if (umove(tcp, tcp->u_arg[0], ©) != -1) {
572 if (copy.entry_number == -1)
573 tprintf("{entry_number:%d -> ",
576 tprintf("{entry_number:");
579 if (umove(tcp, tcp->u_arg[0], ©) != -1) {
580 tprintf("%d, ", copy.entry_number);
584 print_ldt_entry(©);
587 tprintf("%lx", tcp->u_arg[0]);
595 sys_get_thread_area(tcp)
598 struct modify_ldt_ldt_s copy;
600 if (umove(tcp, tcp->u_arg[0], ©) != -1) {
601 tprintf("{entry_number:%d, ", copy.entry_number);
605 print_ldt_entry(©);
608 tprintf("%lx", tcp->u_arg[0]);
614 #endif /* LINUX && __i386__ */
618 sys_remap_file_pages(tcp)
622 tprintf("%#lx, %lu, ", tcp->u_arg[0], tcp->u_arg[1]);
623 printflags(mmap_prot, tcp->u_arg[2]);
624 tprintf(", %lu, ", tcp->u_arg[3]);
626 printxval(mmap_flags, tcp->u_arg[4] & MAP_TYPE, "MAP_???");
627 addflags(mmap_flags, tcp->u_arg[4] & ~MAP_TYPE);
629 printflags(mmap_flags, tcp->u_arg[4]);