syscall_emul: move mmapGrowsDown() to LiveProcess
[gem5.git] / src / arch / x86 / process.cc
index 5a00ce78c1841ee50e88327e5f7e3787daea81c5..f0b8370c047ac9c27dc0319bcdf177e999d3a827 100644 (file)
@@ -80,6 +80,7 @@ static const int ArgumentReg32[] = {
     INTREG_EDX,
     INTREG_ESI,
     INTREG_EDI,
+    INTREG_EBP
 };
 static const int NumArgumentRegs32 = sizeof(ArgumentReg) / sizeof(const int);
 
@@ -113,7 +114,7 @@ X86_64LiveProcess::X86_64LiveProcess(LiveProcessParams *params,
 
     // Set up region for mmaps. This was determined empirically and may not
     // always be correct.
-    mmap_start = mmap_end = (Addr)0x2aaaaaaab000ULL;
+    mmap_end = (Addr)0x2aaaaaaab000ULL;
 }
 
 void
@@ -150,7 +151,7 @@ I386LiveProcess::I386LiveProcess(LiveProcessParams *params,
 
     // Set up region for mmaps. This was determined empirically and may not
     // always be correct.
-    mmap_start = mmap_end = (Addr)0xf7ffe000ULL;
+    mmap_end = (Addr)0xf7ffe000ULL;
 }
 
 SyscallDesc*
@@ -552,7 +553,7 @@ X86_64LiveProcess::initState()
             dataAttr.system = 1;
 
             //Initialize the segment registers.
-            for(int seg = 0; seg < NUM_SEGMENTREGS; seg++) {
+            for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) {
                 tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0);
                 tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0);
                 tc->setMiscRegNoEffect(MISCREG_SEG_ATTR(seg), dataAttr);
@@ -612,7 +613,7 @@ I386LiveProcess::initState()
 
     argsInit(sizeof(uint32_t), PageBytes);
 
-    /* 
+    /*
      * Set up a GDT for this process. The whole GDT wouldn't really be for
      * this process, but the only parts we care about are.
      */
@@ -663,7 +664,7 @@ I386LiveProcess::initState()
         dataAttr.system = 1;
 
         //Initialize the segment registers.
-        for(int seg = 0; seg < NUM_SEGMENTREGS; seg++) {
+        for (int seg = 0; seg < NUM_SEGMENTREGS; seg++) {
             tc->setMiscRegNoEffect(MISCREG_SEG_BASE(seg), 0);
             tc->setMiscRegNoEffect(MISCREG_SEG_EFF_BASE(seg), 0);
             tc->setMiscRegNoEffect(MISCREG_SEG_ATTR(seg), dataAttr);
@@ -735,7 +736,7 @@ X86LiveProcess::argsInit(int pageSize,
     std::vector<auxv_t> auxv = extraAuxvs;
 
     string filename;
-    if(argv.size() < 1)
+    if (argv.size() < 1)
         filename = "";
     else
         filename = argv[0];
@@ -983,8 +984,10 @@ X86LiveProcess::argsInit(int pageSize,
     }
     //Write out the terminating zeroed auxilliary vector
     const uint64_t zero = 0;
-    initVirtMem.writeBlob(auxv_array_base + 2 * intSize * auxv.size(),
-            (uint8_t*)&zero, 2 * intSize);
+    initVirtMem.writeBlob(auxv_array_base + auxv.size() * 2 * intSize,
+                          (uint8_t*)&zero, intSize);
+    initVirtMem.writeBlob(auxv_array_base + (auxv.size() * 2 + 1) * intSize,
+                          (uint8_t*)&zero, intSize);
 
     initVirtMem.writeString(aux_data_base, platform.c_str());