SE mode: Make the direction anonymous mmaps move through memory configurable.
authorGabe Black <gblack@eecs.umich.edu>
Fri, 2 Oct 2009 08:32:00 +0000 (01:32 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Fri, 2 Oct 2009 08:32:00 +0000 (01:32 -0700)
src/kern/operatingsystem.hh
src/sim/syscall_emul.hh

index 47e64ffd93ef387a3a0d2c733cba5b200e2e17e6..6574e3c6bb93572cc7ed67da749c0e2afcb7cfcc 100644 (file)
@@ -122,6 +122,10 @@ class OperatingSystem {
 
     static int openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc);
 
+    static const bool mmapGrowsUp = true;
+
+    static bool mmapGrowsDown() { return false; }
+
 };  // class OperatingSystem
 
 
index c9ce4b14fb9054fb49721cbbc4a775663bced55e..e45a6c79755470086767cfaaf938ac6a393f373c 100644 (file)
@@ -978,9 +978,14 @@ mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
     }
 
     // pick next address from our "mmap region"
-    start = p->mmap_end;
+    if (OS::mmapGrowsDown()) {
+        start = p->mmap_end - length;
+        p->mmap_end = start;
+    } else {
+        start = p->mmap_end;
+        p->mmap_end += length;
+    }
     p->pTable->allocate(start, length);
-    p->mmap_end += length;
 
     if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
         warn("allowing mmap of file @ fd %d. "