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 >
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"
2004-03-02 09:16:59 +03:00
# include <asm/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
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
2013-02-18 05:36:36 +04:00
print_mmap ( struct tcb * tcp , long * u_arg , unsigned long long offset )
1999-02-19 03:21:36 +03:00
{
2016-04-01 18:31:23 +03:00
const unsigned long addr = u_arg [ 0 ] ;
const unsigned long len = u_arg [ 1 ] ;
const unsigned long prot = u_arg [ 2 ] ;
const unsigned long flags = u_arg [ 3 ] ;
const int fd = u_arg [ 4 ] ;
printaddr ( addr ) ;
tprintf ( " , %lu, " , len ) ;
printflags ( 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 ( " , " ) ;
2000-09-02 01:03:06 +04:00
# ifdef MAP_TYPE
2016-04-01 18:31:23 +03:00
printxval ( mmap_flags , flags & MAP_TYPE , " MAP_??? " ) ;
addflags ( mmap_flags , flags & ~ MAP_TYPE ) ;
2000-09-02 01:03:06 +04:00
# else
2016-04-01 18:31:23 +03:00
printflags ( mmap_flags , flags , " MAP_??? " ) ;
2000-09-02 01:03:06 +04:00
# endif
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 !
*/
2016-04-23 02:36:26 +03:00
# if defined AARCH64 || defined ARM \
| | defined I386 | | defined X86_64 | | defined X32 \
| | defined M68K \
| | defined S390 | | defined S390X
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 bytes */
2015-04-07 04:36:50 +03:00
SYS_FUNC ( old_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
long u_arg [ 6 ] ;
2016-04-23 02:47:46 +03:00
# if defined AARCH64 || defined X86_64
/* We are here only in a 32-bit personality. */
2016-04-23 02:41:36 +03:00
unsigned int narrow_arg [ 6 ] ;
if ( umove_or_printaddr ( tcp , tcp - > u_arg [ 0 ] , & narrow_arg ) )
return RVAL_DECODED | RVAL_HEX ;
unsigned int i ;
for ( i = 0 ; i < 6 ; i + + )
u_arg [ i ] = narrow_arg [ i ] ;
2016-04-23 02:36:26 +03:00
# else
2016-04-23 02:41:36 +03:00
if ( umove_or_printaddr ( tcp , tcp - > u_arg [ 0 ] , & u_arg ) )
return RVAL_DECODED | RVAL_HEX ;
2016-04-23 02:36:26 +03:00
# endif
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 , u_arg , ( unsigned long ) u_arg [ 5 ] ) ;
return RVAL_DECODED | RVAL_HEX ;
1999-12-23 17:20:14 +03:00
}
2016-04-23 02:36:26 +03:00
# endif /* old_mmap architectures */
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
# if defined(S390)
/* 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
{
long u_arg [ 5 ] ;
int i ;
unsigned narrow_arg [ 6 ] ;
unsigned long long offset ;
2015-03-21 21:50:53 +03:00
if ( umoven ( tcp , tcp - > u_arg [ 0 ] , sizeof ( narrow_arg ) , narrow_arg ) = = - 1 )
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
return 0 ;
for ( i = 0 ; i < 5 ; i + + )
u_arg [ i ] = ( unsigned long ) narrow_arg [ i ] ;
offset = narrow_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 , 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
}
# endif
/* 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
{
2013-02-18 06:13:07 +04:00
unsigned long long offset = ( unsigned long ) 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
# if defined(LINUX_MIPSN32) || defined(X32)
2013-02-18 06:13:07 +04:00
/* Try test/x32_mmap.c */
2008-12-30 21:47:55 +03:00
offset = tcp - > ext_arg [ 5 ] ;
2003-06-02 23:18:58 +04:00
# endif
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 .
*/
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 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 ;
offset = ( unsigned long ) 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 ;
offset = ( unsigned long ) tcp - > u_arg [ 5 ] ;
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 ] ) ;
tprintf ( " , %lu " , tcp - > u_arg [ 1 ] ) ;
return RVAL_DECODED ;
1999-02-19 03:21:36 +03:00
}
2015-04-07 04:36:50 +03:00
SYS_FUNC ( mprotect )
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 ] ) ;
tprintf ( " , %lu, " , tcp - > u_arg [ 1 ] ) ;
printflags ( mmap_prot , tcp - > u_arg [ 2 ] , " PROT_??? " ) ;
return RVAL_DECODED ;
1999-02-19 03:21:36 +03:00
}
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 ] ) ;
tprintf ( " , %lu, %lu, " , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
printflags ( 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 ] ) ;
tprintf ( " , %lu, " , tcp - > u_arg [ 1 ] ) ;
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 */
tprintf ( " , %lu, " , tcp - > u_arg [ 1 ] ) ;
/* 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 ] ) ;
tprintf ( " , %lu, " , tcp - > u_arg [ 1 ] ) ;
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 ] ) ;
tprintf ( " , %lu, " , 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 + + ) {
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-07-21 18:55:09 +03:00
# if defined ALPHA || defined IA64 || defined M68K \
| | defined SPARC | | defined SPARC64
2015-04-07 04:36:50 +03:00
SYS_FUNC ( getpagesize )
1999-02-19 03:21:36 +03:00
{
2016-01-08 22:20:05 +03:00
return RVAL_DECODED | RVAL_HEX ;
1999-02-19 03:21:36 +03:00
}
2012-02-25 05:38:52 +04:00
# endif
1999-02-19 03:21:36 +03:00
2015-04-07 04:36:50 +03:00
SYS_FUNC ( remap_file_pages )
2003-03-05 07:08:00 +03:00
{
2016-04-01 18:31:23 +03:00
const unsigned long addr = tcp - > u_arg [ 0 ] ;
const unsigned long size = tcp - > u_arg [ 1 ] ;
const unsigned long prot = tcp - > u_arg [ 2 ] ;
const unsigned long pgoff = tcp - > u_arg [ 3 ] ;
const unsigned long flags = tcp - > u_arg [ 4 ] ;
printaddr ( addr ) ;
tprintf ( " , %lu, " , size ) ;
printflags ( mmap_prot , prot , " PROT_??? " ) ;
tprintf ( " , %lu, " , pgoff ) ;
2003-03-05 07:08:00 +03:00
# ifdef MAP_TYPE
2016-04-01 18:31:23 +03:00
printxval ( mmap_flags , flags & MAP_TYPE , " MAP_??? " ) ;
addflags ( mmap_flags , flags & ~ MAP_TYPE ) ;
2003-03-05 07:08:00 +03:00
# else
2016-04-01 18:31:23 +03:00
printflags ( mmap_flags , flags , " MAP_??? " ) ;
2003-03-05 07:08:00 +03:00
# endif
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)
2015-04-07 04:36:50 +03:00
SYS_FUNC ( subpage_prot )
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
unsigned long cur , end , abbrev_end , entries ;
unsigned int entry ;
printaddr ( tcp - > u_arg [ 0 ] ) ;
tprints ( " , " ) ;
printaddr ( tcp - > u_arg [ 1 ] ) ;
tprints ( " , " ) ;
entries = tcp - > u_arg [ 1 ] > > 16 ;
if ( ! entries | | ! tcp - > u_arg [ 2 ] ) {
tprints ( " {} " ) ;
return 0 ;
}
cur = tcp - > u_arg [ 2 ] ;
end = cur + ( sizeof ( int ) * entries ) ;
if ( ! verbose ( tcp ) | | end < ( unsigned long ) tcp - > u_arg [ 2 ] ) {
printaddr ( tcp - > u_arg [ 2 ] ) ;
return 0 ;
}
if ( abbrev ( tcp ) ) {
abbrev_end = cur + ( sizeof ( int ) * max_strlen ) ;
if ( abbrev_end > end )
abbrev_end = end ;
}
else
abbrev_end = end ;
tprints ( " { " ) ;
for ( ; cur < end ; cur + = sizeof ( int ) ) {
if ( cur > ( unsigned long ) tcp - > u_arg [ 2 ] )
tprints ( " , " ) ;
if ( cur > = abbrev_end ) {
tprints ( " ... " ) ;
break ;
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
if ( umove ( tcp , cur , & entry ) < 0 ) {
tprintf ( " ??? [%#lx] " , cur ) ;
break ;
2008-08-25 07:09:16 +04:00
}
else
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 ( " %#08x " , entry ) ;
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
tprints ( " } " ) ;
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