From a04fac976f02377237bb827d46854b669ebc2397 Mon Sep 17 00:00:00 2001 From: Brandon Potter Date: Thu, 17 Mar 2016 10:24:17 -0700 Subject: syscall_emul: extend mmap system call to support file backed mmaps For O3, which has a stat that counts reg reads, there is an additional reg read per mmap() call since there's an arg we no longer ignore. Otherwise, stats should not be affected. --- src/arch/sparc/linux/linux.cc | 34 ++++++++++++++++++++++++++++++++-- src/arch/sparc/linux/linux.hh | 23 +++++++++++++++++++++-- 2 files changed, 53 insertions(+), 4 deletions(-) (limited to 'src/arch/sparc/linux') diff --git a/src/arch/sparc/linux/linux.cc b/src/arch/sparc/linux/linux.cc index 2f91cf81d..dbc7e9691 100644 --- a/src/arch/sparc/linux/linux.cc +++ b/src/arch/sparc/linux/linux.cc @@ -28,10 +28,11 @@ * Authors: Gabe Black */ -#include - #include "arch/sparc/linux/linux.hh" +#include +#include + // open(2) flags translation table SyscallFlagTransTable SparcLinux::openFlagTable[] = { #ifdef _MSC_VER @@ -95,3 +96,32 @@ SyscallFlagTransTable SparcLinux::openFlagTable[] = { const int SparcLinux::NUM_OPEN_FLAGS = (sizeof(SparcLinux::openFlagTable)/sizeof(SparcLinux::openFlagTable[0])); +// mmap(2) flags translation table +SyscallFlagTransTable SparcLinux::mmapFlagTable[] = { + { SparcLinux::TGT_MAP_SHARED, MAP_SHARED }, + { SparcLinux::TGT_MAP_PRIVATE, MAP_PRIVATE }, + { SparcLinux::TGT_MAP_ANON, MAP_ANON }, + { SparcLinux::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, + { SparcLinux::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, + { SparcLinux::TGT_MAP_FILE, MAP_FILE }, + { SparcLinux::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, + { SparcLinux::TGT_MAP_HUGETLB, MAP_HUGETLB }, + { SparcLinux::TGT_MAP_LOCKED, MAP_LOCKED }, + { SparcLinux::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, + { SparcLinux::TGT_MAP_NORESERVE, MAP_NORESERVE }, + { SparcLinux::TGT_MAP_POPULATE, MAP_POPULATE }, +#ifdef MAP_STACK + { SparcLinux::TGT_MAP_STACK, MAP_STACK }, +#endif + { SparcLinux::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, + { SparcLinux::TGT_MAP_FIXED, MAP_FIXED }, +#ifdef MAP_INHERIT + { SparcLinux::TGT_MAP_INHERIT, MAP_INHERIT }, +#endif + { SparcLinux::TGT_MAP_POPULATE, MAP_POPULATE }, +}; + +const unsigned SparcLinux::NUM_MMAP_FLAGS = + sizeof(SparcLinux::mmapFlagTable) / + sizeof(SparcLinux::mmapFlagTable[0]); + diff --git a/src/arch/sparc/linux/linux.hh b/src/arch/sparc/linux/linux.hh index 138f178b7..d0631f82b 100644 --- a/src/arch/sparc/linux/linux.hh +++ b/src/arch/sparc/linux/linux.hh @@ -118,8 +118,27 @@ class SparcLinux : public Linux static const int NUM_OPEN_FLAGS; - static const unsigned TGT_MAP_ANONYMOUS = 0x20; - static const unsigned TGT_MAP_FIXED = 0x10; + /// For mmap(). + static SyscallFlagTransTable mmapFlagTable[]; + + static const unsigned TGT_MAP_SHARED = 0x00001; + static const unsigned TGT_MAP_PRIVATE = 0x00002; + static const unsigned TGT_MAP_ANON = 0x00020; + static const unsigned TGT_MAP_DENYWRITE = 0x00800; + static const unsigned TGT_MAP_EXECUTABLE = 0x01000; + static const unsigned TGT_MAP_FILE = 0x00000; + static const unsigned TGT_MAP_GROWSDOWN = 0x00200; + static const unsigned TGT_MAP_HUGETLB = 0x40000; + static const unsigned TGT_MAP_LOCKED = 0x00100; + static const unsigned TGT_MAP_NONBLOCK = 0x10000; + static const unsigned TGT_MAP_NORESERVE = 0x00040; + static const unsigned TGT_MAP_POPULATE = 0x08000; + static const unsigned TGT_MAP_STACK = 0x20000; + static const unsigned TGT_MAP_ANONYMOUS = 0x00020; + static const unsigned TGT_MAP_FIXED = 0x00010; + static const unsigned TGT_MAP_INHERIT = 0x00080; + + static const unsigned NUM_MMAP_FLAGS; typedef struct { int64_t uptime; /* Seconds since boot */ -- cgit v1.2.3