diff options
author | Brandon Potter <brandon.potter@amd.com> | 2016-03-17 10:24:17 -0700 |
---|---|---|
committer | Brandon Potter <brandon.potter@amd.com> | 2016-03-17 10:24:17 -0700 |
commit | a04fac976f02377237bb827d46854b669ebc2397 (patch) | |
tree | 2f2a5e55e16b2c05e4d94e302081bb977e864a36 /src/arch/alpha | |
parent | 3fa311e5acd58ce720014dd964728c2fa414ca6a (diff) | |
download | gem5-a04fac976f02377237bb827d46854b669ebc2397.tar.xz |
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.
Diffstat (limited to 'src/arch/alpha')
-rw-r--r-- | src/arch/alpha/linux/linux.cc | 30 | ||||
-rw-r--r-- | src/arch/alpha/linux/linux.hh | 21 | ||||
-rw-r--r-- | src/arch/alpha/tru64/tru64.cc | 22 | ||||
-rw-r--r-- | src/arch/alpha/tru64/tru64.hh | 24 |
4 files changed, 91 insertions, 6 deletions
diff --git a/src/arch/alpha/linux/linux.cc b/src/arch/alpha/linux/linux.cc index b86b92c2e..7b747f127 100644 --- a/src/arch/alpha/linux/linux.cc +++ b/src/arch/alpha/linux/linux.cc @@ -28,10 +28,11 @@ * Authors: Korey Sewell */ -#include <fcntl.h> - #include "arch/alpha/linux/linux.hh" +#include <fcntl.h> +#include <sys/mman.h> + // open(2) flags translation table SyscallFlagTransTable AlphaLinux::openFlagTable[] = { #ifdef _MSC_VER @@ -99,3 +100,28 @@ SyscallFlagTransTable AlphaLinux::openFlagTable[] = { const int AlphaLinux::NUM_OPEN_FLAGS = (sizeof(AlphaLinux::openFlagTable)/sizeof(AlphaLinux::openFlagTable[0])); + +// mmap(2) flags translation table +SyscallFlagTransTable AlphaLinux::mmapFlagTable[] = { + { AlphaLinux::TGT_MAP_SHARED, MAP_SHARED }, + { AlphaLinux::TGT_MAP_PRIVATE, MAP_PRIVATE }, + { AlphaLinux::TGT_MAP_ANON, MAP_ANON }, + { AlphaLinux::TGT_MAP_DENYWRITE, MAP_DENYWRITE }, + { AlphaLinux::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, + { AlphaLinux::TGT_MAP_FILE, MAP_FILE }, + { AlphaLinux::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, + { AlphaLinux::TGT_MAP_HUGETLB, MAP_HUGETLB }, + { AlphaLinux::TGT_MAP_LOCKED, MAP_LOCKED }, + { AlphaLinux::TGT_MAP_NONBLOCK, MAP_NONBLOCK }, + { AlphaLinux::TGT_MAP_NORESERVE, MAP_NORESERVE }, + { AlphaLinux::TGT_MAP_POPULATE, MAP_POPULATE }, +#ifdef MAP_STACK + { AlphaLinux::TGT_MAP_STACK, MAP_STACK }, +#endif + { AlphaLinux::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, + { AlphaLinux::TGT_MAP_FIXED, MAP_FIXED }, +}; + +const unsigned AlphaLinux::NUM_MMAP_FLAGS = + sizeof(AlphaLinux::mmapFlagTable) / + sizeof(AlphaLinux::mmapFlagTable[0]); diff --git a/src/arch/alpha/linux/linux.hh b/src/arch/alpha/linux/linux.hh index 7864c6414..409ad4dd1 100644 --- a/src/arch/alpha/linux/linux.hh +++ b/src/arch/alpha/linux/linux.hh @@ -104,8 +104,25 @@ class AlphaLinux : public Linux //@} /// For mmap(). - static const unsigned TGT_MAP_ANONYMOUS = 0x10; - static const unsigned TGT_MAP_FIXED = 0x100; + static SyscallFlagTransTable mmapFlagTable[]; + + static const unsigned TGT_MAP_SHARED = 0x000001; + static const unsigned TGT_MAP_PRIVATE = 0x000002; + static const unsigned TGT_MAP_ANON = 0x000010; + static const unsigned TGT_MAP_DENYWRITE = 0x002000; + static const unsigned TGT_MAP_EXECUTABLE = 0x004000; + static const unsigned TGT_MAP_FILE = 0x000000; + static const unsigned TGT_MAP_GROWSDOWN = 0x001000; + static const unsigned TGT_MAP_HUGETLB = 0x100000; + static const unsigned TGT_MAP_LOCKED = 0x008000; + static const unsigned TGT_MAP_NONBLOCK = 0x040000; + static const unsigned TGT_MAP_NORESERVE = 0x010000; + static const unsigned TGT_MAP_POPULATE = 0x020000; + static const unsigned TGT_MAP_STACK = 0x080000; + static const unsigned TGT_MAP_ANONYMOUS = 0x000010; + static const unsigned TGT_MAP_FIXED = 0x000100; + + static const unsigned NUM_MMAP_FLAGS; //@{ /// For getsysinfo(). diff --git a/src/arch/alpha/tru64/tru64.cc b/src/arch/alpha/tru64/tru64.cc index 1854a02f1..1fd589f66 100644 --- a/src/arch/alpha/tru64/tru64.cc +++ b/src/arch/alpha/tru64/tru64.cc @@ -68,5 +68,27 @@ SyscallFlagTransTable AlphaTru64::openFlagTable[] = { const int AlphaTru64::NUM_OPEN_FLAGS = (sizeof(AlphaTru64::openFlagTable)/sizeof(AlphaTru64::openFlagTable[0])); +// mmap(2) flags translation table +SyscallFlagTransTable AlphaTru64::mmapFlagTable[] = { + { TGT_MAP_SHARED, MAP_SHARED }, + { TGT_MAP_PRIVATE, MAP_PRIVATE }, + { TGT_MAP_32BIT, MAP_32BIT}, + { TGT_MAP_ANON, MAP_ANON }, + { TGT_MAP_DENYWRITE, MAP_DENYWRITE }, + { TGT_MAP_EXECUTABLE, MAP_EXECUTABLE }, + { TGT_MAP_FILE, MAP_FILE }, + { TGT_MAP_GROWSDOWN, MAP_GROWSDOWN }, + { TGT_MAP_HUGETLB, MAP_HUGETLB }, + { TGT_MAP_LOCKED, MAP_LOCKED }, + { TGT_MAP_NONBLOCK, MAP_NONBLOCK }, + { TGT_MAP_NORESERVE, MAP_NORESERVE }, + { TGT_MAP_POPULATE, MAP_POPULATE }, + { TGT_MAP_STACK, MAP_STACK }, + { TGT_MAP_ANONYMOUS, MAP_ANONYMOUS }, + { TGT_MAP_FIXED, MAP_FIXED }, +}; +const unsigned AlphaTru64::NUM_MMAP_FLAGS = + sizeof(AlphaTru64::mmapFlagTable) / + sizeof(AlphaTru64::mmapFlagTable[0]); diff --git a/src/arch/alpha/tru64/tru64.hh b/src/arch/alpha/tru64/tru64.hh index 92d6db842..e8ac3c7e8 100644 --- a/src/arch/alpha/tru64/tru64.hh +++ b/src/arch/alpha/tru64/tru64.hh @@ -63,8 +63,28 @@ class AlphaTru64 : public Tru64 //@} /// For mmap(). - static const unsigned TGT_MAP_ANONYMOUS = 0x10; - static const unsigned TGT_MAP_FIXED = 0x100; + static SyscallFlagTransTable mmapFlagTable[]; + + static const unsigned TGT_MAP_SHARED = 0x00001; + static const unsigned TGT_MAP_PRIVATE = 0x00002; + static const unsigned TGT_MAP_32BIT = 0x00040; + 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 = 0x00100; + static const unsigned TGT_MAP_HUGETLB = 0x40000; + static const unsigned TGT_MAP_LOCKED = 0x02000; + static const unsigned TGT_MAP_NONBLOCK = 0x10000; + static const unsigned TGT_MAP_NORESERVE = 0x04000; + 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 NUM_MMAP_FLAGS; + + //@{ //@{ /// For getsysinfo(). |