summaryrefslogtreecommitdiff
path: root/src/arch/power/linux
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2016-03-17 10:24:17 -0700
committerBrandon Potter <brandon.potter@amd.com>2016-03-17 10:24:17 -0700
commita04fac976f02377237bb827d46854b669ebc2397 (patch)
tree2f2a5e55e16b2c05e4d94e302081bb977e864a36 /src/arch/power/linux
parent3fa311e5acd58ce720014dd964728c2fa414ca6a (diff)
downloadgem5-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/power/linux')
-rw-r--r--src/arch/power/linux/linux.cc30
-rw-r--r--src/arch/power/linux/linux.hh21
2 files changed, 47 insertions, 4 deletions
diff --git a/src/arch/power/linux/linux.cc b/src/arch/power/linux/linux.cc
index f73dd063b..6382ca72a 100644
--- a/src/arch/power/linux/linux.cc
+++ b/src/arch/power/linux/linux.cc
@@ -29,10 +29,11 @@
* Authors: Timothy M. Jones
*/
-#include <fcntl.h>
-
#include "arch/power/linux/linux.hh"
+#include <fcntl.h>
+#include <sys/mman.h>
+
// open(2) flags translation table
SyscallFlagTransTable PowerLinux::openFlagTable[] = {
#ifdef _MSC_VER
@@ -105,3 +106,28 @@ SyscallFlagTransTable PowerLinux::openFlagTable[] = {
const int PowerLinux::NUM_OPEN_FLAGS =
(sizeof(PowerLinux::openFlagTable)/sizeof(PowerLinux::openFlagTable[0]));
+// mmap(2) flags translation table
+SyscallFlagTransTable PowerLinux::mmapFlagTable[] = {
+ { PowerLinux::TGT_MAP_SHARED, MAP_SHARED },
+ { PowerLinux::TGT_MAP_PRIVATE, MAP_PRIVATE },
+ { PowerLinux::TGT_MAP_ANON, MAP_ANON },
+ { PowerLinux::TGT_MAP_DENYWRITE, MAP_DENYWRITE },
+ { PowerLinux::TGT_MAP_EXECUTABLE, MAP_EXECUTABLE },
+ { PowerLinux::TGT_MAP_FILE, MAP_FILE },
+ { PowerLinux::TGT_MAP_GROWSDOWN, MAP_GROWSDOWN },
+ { PowerLinux::TGT_MAP_HUGETLB, MAP_HUGETLB },
+ { PowerLinux::TGT_MAP_LOCKED, MAP_LOCKED },
+ { PowerLinux::TGT_MAP_NONBLOCK, MAP_NONBLOCK },
+ { PowerLinux::TGT_MAP_NORESERVE, MAP_NORESERVE },
+ { PowerLinux::TGT_MAP_POPULATE, MAP_POPULATE },
+#ifdef MAP_STACK
+ { PowerLinux::TGT_MAP_STACK, MAP_STACK },
+#endif
+ { PowerLinux::TGT_MAP_ANONYMOUS, MAP_ANONYMOUS },
+ { PowerLinux::TGT_MAP_FIXED, MAP_FIXED },
+};
+
+const unsigned PowerLinux::NUM_MMAP_FLAGS =
+ sizeof(PowerLinux::mmapFlagTable) /
+ sizeof(PowerLinux::mmapFlagTable[0]);
+
diff --git a/src/arch/power/linux/linux.hh b/src/arch/power/linux/linux.hh
index 656f4402e..55634800e 100644
--- a/src/arch/power/linux/linux.hh
+++ b/src/arch/power/linux/linux.hh
@@ -164,8 +164,25 @@ class PowerLinux : public Linux
//@}
/// For mmap().
- static const unsigned TGT_MAP_ANONYMOUS = 0x20;
- static const unsigned TGT_MAP_FIXED = 0x10;
+ 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 = 0x00100;
+ static const unsigned TGT_MAP_HUGETLB = 0x40000;
+ static const unsigned TGT_MAP_LOCKED = 0x00080;
+ 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 NUM_MMAP_FLAGS;
//@{
/// ioctl() command codes.