1999-02-19 03:21:36 +03:00
/*
* Copyright ( c ) 1991 , 1992 Paul Kranenburg < pk @ cs . few . eur . nl >
* Copyright ( c ) 1993 Branko Lankester < branko @ hacktic . nl >
* Copyright ( c ) 1993 , 1994 , 1995 , 1996 Rick Sladkey < jrs @ world . std . com >
1999-12-23 17:20:14 +03:00
* Copyright ( c ) 1996 - 1999 Wichert Akkerman < wichert @ cistron . nl >
2003-06-02 23:18:58 +04:00
* Copyright ( c ) 2000 PocketPenguins Inc . Linux for Hitachi SuperH
* port by Greg Banks < gbanks @ pocketpenguins . com >
2018-02-14 01:00:00 +03:00
* Copyright ( c ) 1999 - 2018 The strace developers .
1999-02-19 03:21:36 +03:00
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* 1. Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` ` AS IS ' ' AND ANY EXPRESS OR
* IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED .
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT , INDIRECT ,
* INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT
* NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
* DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*/
# include "defs.h"
2017-11-17 21:35:06 +03:00
# include <linux/mman.h>
1999-05-09 04:29:58 +04:00
# include <sys/mman.h>
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
2015-03-31 22:45:08 +03:00
unsigned long
get_pagesize ( void )
2013-03-05 18:58:24 +04:00
{
static unsigned long pagesize ;
if ( ! pagesize )
pagesize = sysconf ( _SC_PAGESIZE ) ;
return pagesize ;
}
1999-02-19 03:21:36 +03:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( brk )
1999-02-19 03:21:36 +03:00
{
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
printaddr ( tcp - > u_arg [ 0 ] ) ;
return RVAL_DECODED | RVAL_HEX ;
1999-02-19 03:21:36 +03:00
}
2014-04-26 03:30:54 +04:00
# include "xlat/mmap_prot.h"
# include "xlat/mmap_flags.h"
1999-02-19 03:21:36 +03:00
2017-11-17 21:35:06 +03:00
# ifndef MAP_HUGE_SHIFT
# define MAP_HUGE_SHIFT 26
# endif
# ifndef MAP_HUGE_MASK
# define MAP_HUGE_MASK 0x3f
# endif
2017-11-17 20:47:53 +03:00
static void
print_mmap_flags ( kernel_ulong_t flags )
{
printxval64 ( mmap_flags , flags & MAP_TYPE , " MAP_??? " ) ;
2017-11-17 21:35:06 +03:00
flags & = ~ MAP_TYPE ;
const unsigned int mask = MAP_HUGE_MASK < < MAP_HUGE_SHIFT ;
const unsigned int hugetlb_value = flags & mask ;
flags & = ~ mask ;
2018-03-10 07:38:10 +03:00
if ( flags ) {
tprints ( " | " ) ;
printflags64 ( mmap_flags , flags , NULL ) ;
}
2017-11-17 21:35:06 +03:00
if ( hugetlb_value )
tprintf ( " |%u<<MAP_HUGE_SHIFT " ,
hugetlb_value > > MAP_HUGE_SHIFT ) ;
2017-11-17 20:47:53 +03:00
}
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
static void
2016-12-26 13:26:03 +03:00
print_mmap ( struct tcb * tcp , kernel_ulong_t * u_arg , unsigned long long offset )
1999-02-19 03:21:36 +03:00
{
2016-12-26 13:26:03 +03:00
const kernel_ulong_t addr = u_arg [ 0 ] ;
const kernel_ulong_t len = u_arg [ 1 ] ;
const kernel_ulong_t prot = u_arg [ 2 ] ;
const kernel_ulong_t flags = u_arg [ 3 ] ;
2016-04-01 18:31:23 +03:00
const int fd = u_arg [ 4 ] ;
printaddr ( addr ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , " , len ) ;
2016-12-25 01:39:06 +03:00
printflags64 ( mmap_prot , prot , " PROT_??? " ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
tprints ( " , " ) ;
2017-11-17 20:47:53 +03:00
print_mmap_flags ( flags ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
tprints ( " , " ) ;
2016-04-01 18:31:23 +03:00
printfd ( tcp , fd ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
tprintf ( " , %#llx " , offset ) ;
1999-02-19 03:21:36 +03:00
}
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
/* Syscall name<->function correspondence is messed up on many arches.
* For example :
* i386 has __NR_mmap = = 90 , and it is " old mmap " , and
* also it has __NR_mmap2 = = 192 , which is a " new mmap with page offsets " .
* But x86_64 has just one __NR_mmap = = 9 , a " new mmap with byte offsets " .
* Confused ? Me too !
*/
2018-01-21 04:46:04 +03:00
# if HAVE_ARCH_OLD_MMAP
2018-01-17 04:18:45 +03:00
/* Params are pointed to by u_arg[0], offset is in bytes */
SYS_FUNC ( old_mmap )
{
2018-01-22 02:23:31 +03:00
kernel_ulong_t * args =
fetch_indirect_syscall_args ( tcp , tcp - > u_arg [ 0 ] , 6 ) ;
2018-01-17 04:18:45 +03:00
if ( args )
print_mmap ( tcp , args , args [ 5 ] ) ;
else
printaddr ( tcp - > u_arg [ 0 ] ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
return RVAL_DECODED | RVAL_HEX ;
1999-12-23 17:20:14 +03:00
}
2018-01-21 04:46:04 +03:00
# if HAVE_ARCH_OLD_MMAP_PGOFF
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
/* Params are pointed to by u_arg[0], offset is in pages */
2015-04-07 04:36:50 +03:00
SYS_FUNC ( old_mmap_pgoff )
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
{
2018-01-22 02:23:31 +03:00
kernel_ulong_t * args =
fetch_indirect_syscall_args ( tcp , tcp - > u_arg [ 0 ] , 6 ) ;
2018-01-17 04:18:45 +03:00
if ( args ) {
unsigned long long offset ;
offset = args [ 5 ] ;
offset * = get_pagesize ( ) ;
print_mmap ( tcp , args , offset ) ;
} else {
printaddr ( tcp - > u_arg [ 0 ] ) ;
}
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
return RVAL_DECODED | RVAL_HEX ;
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
}
Add compat support for s390x
By very popular demand.
While we are here, let's refactor the condition for old_mmap_pgoff into
an arch-specific one, as it is used more than in one place.
* NEWS: Mention this.
* strace.1.in (.SH "MULTIPLE PERSONALITY SUPPORT"): Likewise.
* configure.ac (case "$host_cpu" in) <s390x>: Set arch_m32 to s390, set
cc_flags_m32 to -m31.
(st_MPERS([m32])): Add s390x.
* defs.h [S390X]: Define NEED_UID16_PARSERS.
* linux/s390/arch_sigreturn.c [!S390_FRAME_PTR] (S390_FRAME_PTR): New
macro, define to s390_frame_ptr.
[!SIGNAL_FRAMESIZE] (SIGNAL_FRAMESIZE): New macro, define to
__SIGNAL_FRAMESIZE.
[!PTR_TYPE] (PTR_TYPE): New macro, define to unsigned long.
(arch_sigreturn): Use S390_FRAME_PTR, SIGNAL_FRAMESIZE, and PTR_TYPE
instead of s390_frame_ptr, __SIGNAL_FRAMESIZE, and pointer-sized type,
respectively.
* linux/s390/get_error.c [!ARCH_REGSET] (ARCH_REGSET): New macro, define
* to s390_regset.
(get_error): Use it instead of s390_regset.
* linux/s390/get_scno.c (arch_get_scno): Likewise.
* linux/s390/get_syscall_args.c (get_syscall_args): Likewise.
* linux/s390/set_error.c (arch_set_error, arch_set_success): Likewise.
* linux/s390/set_scno.c (arch_set_scno): Likewise.
* linux/s390x/arch_regs.c (psw_compat_t, s390_compat_regs,
s390x_regs_union, s390_frame_ptr, s390x_frame_ptr, s390x_io): New
variables.
(s390_regset, s390x_regset, ARCH_REGS_FOR_GETREGSET,
ARCH_IOVEC_FOR_GETREGSET, ARCH_PC_REG, ARCH_PERSONALITY_0_IOV_SIZE,
ARCH_PERSONALITY_1_IOV_SIZE): New macros.
* linux/s390x/arch_regs.h (s390_frame_ptr, s390x_frame_ptr): New
prototypes.
* linux/s390x/arch_rt_sigframe.c: Conditionalize on tcp->currpers.
* linux/s390x/arch_sigreturn.c: Likewise.
* linux/s390x/get_error.c: Likewise.
* linux/s390x/get_scno.c: Likewise.
* linux/s390x/get_syscall_args.c: Likewise.
* linux/s390x/set_error.c: Likewise.
* linux/s390x/set_scno.c: Likewise.
* linux/s390x/errnoent1.h: New file.
* linux/s390x/ioctls_arch1.h: Likewise.
* linux/s390x/ioctls_inc1.h: Likewise.
* linux/s390x/signalent1.h: Likewise.
* linux/s390x/syscallent1.h: Likewise.
* Makefile.am (EXTRA_DIST): Add new files added to linux/s390x.
* supported_personalities.h [S390X] (SUPPORTED_PERSONALITIES): Define
to 2.
* tests/strace-V.test: Add s390 to the list of architectures that have
m32 personality.
* linux/s390/arch_defs.h (HAVE_ARCH_OLD_MMAP_PGOFF): New macro.
* linux/s390x/arch_defs.h: Likewise.
* mem.c: Replace #ifdef S390 with #ifdef HAVE_ARCH_OLD_MMAP_PGOFF.
* pathtrace.c: Likewise.
2018-01-10 23:20:06 +03:00
# endif /* HAVE_ARCH_OLD_MMAP_PGOFF */
2018-01-17 04:18:45 +03:00
# endif /* HAVE_ARCH_OLD_MMAP */
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
/* Params are passed directly, offset is in bytes */
2015-04-07 04:36:50 +03:00
SYS_FUNC ( mmap )
1999-12-23 17:20:14 +03:00
{
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
/* Example of kernel-side handling of this variety of mmap:
* arch / x86 / kernel / sys_x86_64 . c : : SYSCALL_DEFINE6 ( mmap , . . . ) calls
* sys_mmap_pgoff ( . . . , off > > PAGE_SHIFT ) ; i . e . off is in bytes ,
* since the above code converts off to pages .
*/
2016-12-26 05:59:36 +03:00
print_mmap ( tcp , tcp - > u_arg , tcp - > u_arg [ 5 ] ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
return RVAL_DECODED | RVAL_HEX ;
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
}
/* Params are passed directly, offset is in pages */
2015-04-07 04:36:50 +03:00
SYS_FUNC ( mmap_pgoff )
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
{
/* Try test/mmap_offset_decode.c */
unsigned long long offset ;
2016-12-19 15:05:31 +03:00
offset = tcp - > u_arg [ 5 ] ;
2013-03-05 18:58:24 +04:00
offset * = get_pagesize ( ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
print_mmap ( tcp , tcp - > u_arg , offset ) ;
return RVAL_DECODED | RVAL_HEX ;
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
}
/* Params are passed directly, offset is in 4k units */
2015-04-07 04:36:50 +03:00
SYS_FUNC ( mmap_4koff )
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
{
unsigned long long offset ;
2016-12-19 15:05:31 +03:00
offset = tcp - > u_arg [ 5 ] ;
Clean up mmap decoding
Previous code merges too many similar, but different ways
of decoding mmap. For example, sys_old_mmap is "params in memory"
API... except SH[64], where it is "params in regs",
i.e. what sys_mmap ("new mmap") function does on other arches!
It's much simpler when every mmap handler has same API regardless
of arch. Where API means whether params are in regs or in memory,
and whether offset is in bytes, pages, or 4k blocks.
Then we just insert correct function pointers into
arch syscall tables.
It turns out there are four common mmap APIs over
all architectures which exist in Linux kernel,
and one outlier for S390.
A number of mmap decoders were plain wrong in arch tables.
For example, BFIN has no old_mmap. It returns ENOSYS.
I checked kernel sources for all arches nad fixed the tables.
There was dead code for x86_64 for old_mmap:
x86_64 has no old_mmap.
* mem.c: Refactor mmap functions so that we have five mmap syscall
handlers, each with the fixed API (not varying by arch).
* pathtrace.c (pathtrace_match): Adjust sys_func == mmap_func checks.
* linux/syscall.h: Declare new mmap syscall handler functions.
* linux/arm/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/avr32/syscallent.h: mmap is sys_mmap_pgoff.
* linux/bfin/syscallent.h: old_mmap is ENOSYS, mmap2 is sys_mmap_pgoff.
* linux/hppa/syscallent.h: mmap2 is sys_mmap_4koff.
* linux/i386/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/ia64/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/m68k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/microblaze/syscallent.h: old_mmap is sys_mmap, mmap2 is sys_mmap_pgoff.
* linux/mips/syscallent.h: mmap is sys_mmap_4kgoff.
* linux/or1k/syscallent.h: mmap2 is sys_mmap_pgoff.
* linux/powerpc/syscallent.h: mmap2 is sys_mmap_4kgoff.
* linux/s390/syscallent.h: mmap2 is sys_old_mmap_pgoff.
* linux/s390x/syscallent.h: mmap is sys_old_mmap and thus has 1 arg.
* linux/sh/syscallent.h: old_mmap2 is sys_mmap, mmap2 is sys_mmap_4koff.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent1.h: mmap is TD|TM.
* linux/tile/syscallent1.h: mmap2 is sys_mmap_4koff.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-02-19 14:28:20 +04:00
offset < < = 12 ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
print_mmap ( tcp , tcp - > u_arg , offset ) ;
return RVAL_DECODED | RVAL_HEX ;
1999-12-23 17:20:14 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( munmap )
1999-02-19 03:21:36 +03:00
{
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
printaddr ( tcp - > u_arg [ 0 ] ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu , tcp - > u_arg [ 1 ] ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
return RVAL_DECODED ;
1999-02-19 03:21:36 +03:00
}
2016-11-12 20:54:56 +03:00
static int
do_mprotect ( struct tcb * tcp , bool has_pkey )
1999-02-19 03:21:36 +03:00
{
2016-12-26 05:28:04 +03:00
printaddr ( tcp - > u_arg [ 0 ] ) ;
tprintf ( " , % " PRI_klu " , " , tcp - > u_arg [ 1 ] ) ;
printflags64 ( mmap_prot , tcp - > u_arg [ 2 ] , " PROT_??? " ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
2016-11-12 20:54:56 +03:00
if ( has_pkey )
tprintf ( " , %d " , ( int ) tcp - > u_arg [ 3 ] ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
return RVAL_DECODED ;
1999-02-19 03:21:36 +03:00
}
2016-11-12 20:54:56 +03:00
SYS_FUNC ( mprotect )
{
return do_mprotect ( tcp , false ) ;
}
SYS_FUNC ( pkey_mprotect )
{
return do_mprotect ( tcp , true ) ;
}
2014-04-26 03:30:54 +04:00
# include "xlat/mremap_flags.h"
1999-05-09 04:29:58 +04:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( mremap )
1999-05-09 04:29:58 +04:00
{
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
printaddr ( tcp - > u_arg [ 0 ] ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , % " PRI_klu " , " , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
2016-12-25 01:39:06 +03:00
printflags64 ( mremap_flags , tcp - > u_arg [ 3 ] , " MREMAP_??? " ) ;
2009-12-25 02:34:58 +03:00
# ifdef MREMAP_FIXED
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
if ( ( tcp - > u_arg [ 3 ] & ( MREMAP_MAYMOVE | MREMAP_FIXED ) ) = =
( MREMAP_MAYMOVE | MREMAP_FIXED ) ) {
tprints ( " , " ) ;
printaddr ( tcp - > u_arg [ 4 ] ) ;
1999-05-09 04:29:58 +04:00
}
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
# endif
return RVAL_DECODED | RVAL_HEX ;
1999-05-09 04:29:58 +04:00
}
2014-04-26 03:30:54 +04:00
# include "xlat/madvise_cmds.h"
2000-04-11 02:22:31 +04:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( madvise )
2000-04-11 02:22:31 +04:00
{
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
printaddr ( tcp - > u_arg [ 0 ] ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , " , tcp - > u_arg [ 1 ] ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
printxval ( madvise_cmds , tcp - > u_arg [ 2 ] , " MADV_??? " ) ;
return RVAL_DECODED ;
2000-04-11 02:22:31 +04:00
}
2014-04-26 03:30:54 +04:00
# include "xlat/mlockall_flags.h"
2000-04-11 02:22:31 +04:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( mlockall )
2000-04-11 02:22:31 +04:00
{
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
printflags ( mlockall_flags , tcp - > u_arg [ 0 ] , " MCL_??? " ) ;
return RVAL_DECODED ;
2000-04-11 02:22:31 +04:00
}
2014-04-26 03:30:54 +04:00
# include "xlat/mctl_sync.h"
1999-02-19 03:21:36 +03:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( msync )
1999-02-19 03:21:36 +03:00
{
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
/* addr */
printaddr ( tcp - > u_arg [ 0 ] ) ;
/* len */
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , " , tcp - > u_arg [ 1 ] ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
/* flags */
printflags ( mctl_sync , tcp - > u_arg [ 2 ] , " MS_??? " ) ;
return RVAL_DECODED ;
1999-02-19 03:21:36 +03:00
}
2015-11-15 05:35:57 +03:00
# include "xlat/mlock_flags.h"
SYS_FUNC ( mlock2 )
{
printaddr ( tcp - > u_arg [ 0 ] ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , " , tcp - > u_arg [ 1 ] ) ;
2015-11-15 05:35:57 +03:00
printflags ( mlock_flags , tcp - > u_arg [ 2 ] , " MLOCK_??? " ) ;
return RVAL_DECODED ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( mincore )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
mem.c: use printaddr and umove_or_printaddr
* mem.c (sys_brk, print_mmap, sys_munmap, sys_mprotect, sys_mremap,
sys_madvise, sys_msync, sys_mincore, sys_remap_file_pages, get_nodes,
sys_mbind, [POWERPC] sys_subpage_prot): Use printaddr.
(sys_get_mempolicy): Use printaddr and umove_or_printaddr.
2015-07-20 02:25:56 +03:00
printaddr ( tcp - > u_arg [ 0 ] ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , " , tcp - > u_arg [ 1 ] ) ;
1999-02-19 03:21:36 +03:00
} else {
2016-01-29 04:51:54 +03:00
const unsigned long page_size = get_pagesize ( ) ;
const unsigned long page_mask = page_size - 1 ;
unsigned long len = tcp - > u_arg [ 1 ] ;
unsigned char * vec = NULL ;
2011-08-31 16:00:02 +04:00
2016-01-29 04:51:54 +03:00
len = len / page_size + ( len & page_mask ? 1 : 0 ) ;
mem.c: use printaddr and umove_or_printaddr
* mem.c (sys_brk, print_mmap, sys_munmap, sys_mprotect, sys_mremap,
sys_madvise, sys_msync, sys_mincore, sys_remap_file_pages, get_nodes,
sys_mbind, [POWERPC] sys_subpage_prot): Use printaddr.
(sys_get_mempolicy): Use printaddr and umove_or_printaddr.
2015-07-20 02:25:56 +03:00
if ( syserror ( tcp ) | | ! verbose ( tcp ) | |
! tcp - > u_arg [ 2 ] | | ! ( vec = malloc ( len ) ) | |
umoven ( tcp , tcp - > u_arg [ 2 ] , len , vec ) < 0 )
printaddr ( tcp - > u_arg [ 2 ] ) ;
1999-02-19 03:21:36 +03:00
else {
2016-01-29 04:51:54 +03:00
unsigned long i ;
2011-09-01 12:00:28 +04:00
tprints ( " [ " ) ;
1999-02-19 03:21:36 +03:00
for ( i = 0 ; i < len ; i + + ) {
2016-11-28 04:28:53 +03:00
if ( i )
tprints ( " , " ) ;
1999-02-19 03:21:36 +03:00
if ( abbrev ( tcp ) & & i > = max_strlen ) {
2011-09-01 12:00:28 +04:00
tprints ( " ... " ) ;
1999-02-19 03:21:36 +03:00
break ;
}
2011-09-01 12:00:28 +04:00
tprints ( ( vec [ i ] & 1 ) ? " 1 " : " 0 " ) ;
1999-02-19 03:21:36 +03:00
}
2011-09-01 12:00:28 +04:00
tprints ( " ] " ) ;
1999-02-19 03:21:36 +03:00
}
2011-08-31 16:00:02 +04:00
free ( vec ) ;
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( remap_file_pages )
2003-03-05 07:08:00 +03:00
{
2016-12-26 13:26:03 +03:00
const kernel_ulong_t addr = tcp - > u_arg [ 0 ] ;
const kernel_ulong_t size = tcp - > u_arg [ 1 ] ;
const kernel_ulong_t prot = tcp - > u_arg [ 2 ] ;
const kernel_ulong_t pgoff = tcp - > u_arg [ 3 ] ;
const kernel_ulong_t flags = tcp - > u_arg [ 4 ] ;
2016-04-01 18:31:23 +03:00
printaddr ( addr ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , " , size ) ;
2016-12-25 01:39:06 +03:00
printflags64 ( mmap_prot , prot , " PROT_??? " ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , " , pgoff ) ;
2017-11-17 20:47:53 +03:00
print_mmap_flags ( flags ) ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
return RVAL_DECODED ;
2003-03-05 07:08:00 +03:00
}
2004-10-07 22:53:12 +04:00
2012-02-25 05:38:52 +04:00
# if defined(POWERPC)
2016-05-08 02:00:52 +03:00
static bool
print_protmap_entry ( struct tcb * tcp , void * elem_buf , size_t elem_size , void * data )
{
2017-06-18 01:23:09 +03:00
tprintf ( " %#08x " , * ( unsigned int * ) elem_buf ) ;
2016-05-08 02:00:52 +03:00
return true ;
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( subpage_prot )
2008-08-25 07:09:16 +04:00
{
2016-12-26 13:26:03 +03:00
kernel_ulong_t addr = tcp - > u_arg [ 0 ] ;
kernel_ulong_t len = tcp - > u_arg [ 1 ] ;
kernel_ulong_t nmemb = len > > 16 ;
kernel_ulong_t map = tcp - > u_arg [ 2 ] ;
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
2016-05-08 02:00:52 +03:00
printaddr ( addr ) ;
2016-12-26 13:16:35 +03:00
tprintf ( " , % " PRI_klu " , " , len ) ;
2016-05-08 02:00:52 +03:00
unsigned int entry ;
print_array ( tcp , map , nmemb , & entry , sizeof ( entry ) ,
umoven_or_printaddr , print_protmap_entry , 0 ) ;
2008-08-25 07:09:16 +04:00
mem.c: make use of RVAL_DECODED
* mem.c (print_mmap): Change to return void.
Update for RVAL_DECODED.
(sys_old_mmap, sys_old_mmap_pgoff, sys_mmap, sys_mmap_pgoff,
sys_mmap_4koff): Update callers. Update for RVAL_DECODED.
(sys_brk, sys_munmap, sys_mprotect, sys_mremap, sys_madvise,
sys_mlockall, sys_msync, sys_remap_file_pages, sys_mbind,
sys_set_mempolicy, sys_migrate_pages, [POWERPC] subpage_prot):
Update for RVAL_DECODED.
2015-07-20 02:37:40 +03:00
return RVAL_DECODED ;
2008-08-25 07:09:16 +04:00
}
# endif