# Node ID a936f73348d9efdcec3609bfacd5b35308a8a94b # Parent aba7be5b02df24a9fa4802111bf8d1507d097045 diff --git a/src/arch/alpha/linux/linux.hh b/src/arch/alpha/linux/linux.hh --- a/src/arch/alpha/linux/linux.hh +++ b/src/arch/alpha/linux/linux.hh @@ -199,8 +199,6 @@ // For futex system call static const unsigned TGT_EAGAIN = 35; static const unsigned TGT_EWOULDBLOCK = TGT_EAGAIN; - - static bool mmapGrowsDown() { return false; } }; #endif // __ALPHA_ALPHA_LINUX_LINUX_HH__ diff --git a/src/arch/alpha/process.hh b/src/arch/alpha/process.hh --- a/src/arch/alpha/process.hh +++ b/src/arch/alpha/process.hh @@ -54,6 +54,10 @@ void setSyscallArg(ThreadContext *tc, int i, AlphaISA::IntReg val) override; void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value) override; + + // override default implementation in LiveProcess as the mmap + // region for Alpha platforms grows upward + virtual bool mmapGrowsDown() const override { return false; } }; /* No architectural page table defined for this ISA */ diff --git a/src/arch/alpha/process.cc b/src/arch/alpha/process.cc --- a/src/arch/alpha/process.cc +++ b/src/arch/alpha/process.cc @@ -57,7 +57,7 @@ // Set up region for mmaps. Tru64 seems to start just above 0 and // grow up from there. - mmap_start = mmap_end = 0x10000; + mmap_end = 0x10000; // Set pointer for next thread stack. Reserve 8M for main stack. next_thread_stack_base = stack_base - (8 * 1024 * 1024); diff --git a/src/arch/arm/linux/linux.hh b/src/arch/arm/linux/linux.hh --- a/src/arch/arm/linux/linux.hh +++ b/src/arch/arm/linux/linux.hh @@ -257,8 +257,6 @@ int32_t tms_cutime; //!< user time of children int32_t tms_cstime; //!< system time of children }; - - static bool mmapGrowsDown() { return true; } }; class ArmLinux64 : public Linux @@ -504,8 +502,6 @@ int64_t tms_cutime; //!< user time of children int64_t tms_cstime; //!< system time of children }; - - static bool mmapGrowsDown() { return true; } }; #endif diff --git a/src/arch/arm/process.cc b/src/arch/arm/process.cc --- a/src/arch/arm/process.cc +++ b/src/arch/arm/process.cc @@ -77,7 +77,7 @@ brk_point = roundUp(brk_point, PageBytes); // Set up region for mmaps. For now, start at bottom of kuseg space. - mmap_start = mmap_end = 0x40000000L; + mmap_end = 0x40000000L; } ArmLiveProcess64::ArmLiveProcess64(LiveProcessParams *params, @@ -94,7 +94,7 @@ brk_point = roundUp(brk_point, PageBytes); // Set up region for mmaps. For now, start at bottom of kuseg space. - mmap_start = mmap_end = 0x4000000000L; + mmap_end = 0x4000000000L; } void diff --git a/src/arch/mips/linux/linux.hh b/src/arch/mips/linux/linux.hh --- a/src/arch/mips/linux/linux.hh +++ b/src/arch/mips/linux/linux.hh @@ -195,8 +195,6 @@ uint32_t freehigh; /* Available high memory size */ uint32_t mem_unit; /* Memory unit size in bytes */ } tgt_sysinfo; - - static bool mmapGrowsDown() { return true; } }; #endif diff --git a/src/arch/mips/process.cc b/src/arch/mips/process.cc --- a/src/arch/mips/process.cc +++ b/src/arch/mips/process.cc @@ -61,7 +61,7 @@ brk_point = roundUp(brk_point, PageBytes); // Set up region for mmaps. Start it 1GB above the top of the heap. - mmap_start = mmap_end = brk_point + 0x40000000L; + mmap_end = brk_point + 0x40000000L; } void diff --git a/src/arch/power/linux/linux.hh b/src/arch/power/linux/linux.hh --- a/src/arch/power/linux/linux.hh +++ b/src/arch/power/linux/linux.hh @@ -214,8 +214,6 @@ return false; } } - - static bool mmapGrowsDown() { return true; } }; #endif // __ARCH_POWER_LINUX_LINUX_HH__ diff --git a/src/arch/power/process.cc b/src/arch/power/process.cc --- a/src/arch/power/process.cc +++ b/src/arch/power/process.cc @@ -59,7 +59,7 @@ brk_point = roundUp(brk_point, PageBytes); // Set up region for mmaps. For now, start at bottom of kuseg space. - mmap_start = mmap_end = 0x70000000L; + mmap_end = 0x70000000L; } void diff --git a/src/arch/sparc/linux/linux.hh b/src/arch/sparc/linux/linux.hh --- a/src/arch/sparc/linux/linux.hh +++ b/src/arch/sparc/linux/linux.hh @@ -184,8 +184,6 @@ return false; } } - - static bool mmapGrowsDown() { return true; } }; class Sparc32Linux : public SparcLinux @@ -233,8 +231,6 @@ /// Resource constants for getrlimit() (overide some generics). static const unsigned TGT_RLIMIT_NPROC = 7; static const unsigned TGT_RLIMIT_NOFILE = 6; - - static bool mmapGrowsDown() { return true; } }; #endif diff --git a/src/arch/sparc/process.hh b/src/arch/sparc/process.hh --- a/src/arch/sparc/process.hh +++ b/src/arch/sparc/process.hh @@ -82,7 +82,7 @@ stack_base = (Addr)0xf0000000ULL; // Set up region for mmaps. - mmap_start = mmap_end = 0x70000000; + mmap_end = 0x70000000; } void initState(); @@ -111,9 +111,8 @@ // downward, less the hole for the kernel address space. stack_base = (Addr)0x80000000000ULL; - // Set up region for mmaps. Tru64 seems to start just above 0 and - // grow up from there. - mmap_start = mmap_end = 0xfffff80000000000ULL; + // Set up region for mmaps. + mmap_end = 0xfffff80000000000ULL; } void initState(); diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh --- a/src/arch/x86/linux/linux.hh +++ b/src/arch/x86/linux/linux.hh @@ -167,8 +167,6 @@ uint64_t freehigh; /* Available high memory size */ uint64_t mem_unit; /* Memory unit size in bytes */ } tgt_sysinfo; - - static bool mmapGrowsDown() { return true; } }; class X86Linux32 : public Linux @@ -291,8 +289,6 @@ uint32_t freehigh; /* Available high memory size */ uint32_t mem_unit; /* Memory unit size in bytes */ } tgt_sysinfo; - - static bool mmapGrowsDown() { return true; } }; #endif diff --git a/src/arch/x86/process.cc b/src/arch/x86/process.cc --- a/src/arch/x86/process.cc +++ b/src/arch/x86/process.cc @@ -120,7 +120,7 @@ // We do not use any address space layout randomization in gem5 // therefore the random fields become zero; the smallest gap space was // chosen but gap could potentially be much larger. - mmap_start = mmap_end = (Addr)0x7FFFF7FFF000ULL; + mmap_end = (Addr)0x7FFFF7FFF000ULL; } void @@ -163,7 +163,7 @@ // We do not use any address space layout randomization in gem5 // therefore the random fields become zero; the smallest gap space was // chosen but gap could potentially be much larger. - mmap_start = mmap_end = (Addr)0xB7FFF000ULL; + mmap_end = (Addr)0xB7FFF000ULL; } SyscallDesc* diff --git a/src/gpu-compute/shader.cc b/src/gpu-compute/shader.cc --- a/src/gpu-compute/shader.cc +++ b/src/gpu-compute/shader.cc @@ -78,25 +78,24 @@ // round up length to the next page length = roundUp(length, TheISA::PageBytes); - if (X86Linux64::mmapGrowsDown()) { + Process *proc = gpuTc->getProcessPtr(); + + if (proc->mmapGrowsDown()) { DPRINTF(HSAIL, "GROWS DOWN"); - start = gpuTc->getProcessPtr()->mmap_end -length; - gpuTc->getProcessPtr()->mmap_end = start; + start = proc->mmap_end - length; + proc->mmap_end = start; } else { DPRINTF(HSAIL, "GROWS UP"); - start = gpuTc->getProcessPtr()->mmap_end; - gpuTc->getProcessPtr()->mmap_end += length; + start = proc->mmap_end; + proc->mmap_end += length; // assertion to make sure we don't overwrite the stack (it grows down) - assert(gpuTc->getProcessPtr()->mmap_end < - gpuTc->getProcessPtr()->stack_base - - gpuTc->getProcessPtr()->max_stack_size); - + assert(proc->mmap_end < proc->stack_base - proc->max_stack_size); } DPRINTF(HSAIL,"Shader::mmap start= %#x, %#x\n", start, length); - gpuTc->getProcessPtr()->allocateMem(start,length); + proc->allocateMem(start, length); return start; } diff --git a/src/kern/operatingsystem.hh b/src/kern/operatingsystem.hh --- a/src/kern/operatingsystem.hh +++ b/src/kern/operatingsystem.hh @@ -116,10 +116,6 @@ static int openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc); - static const bool mmapGrowsUp = true; - - static bool mmapGrowsDown() { return false; } - }; // class OperatingSystem #endif // __OPERATINGSYSTEM_HH__ diff --git a/src/sim/process.hh b/src/sim/process.hh --- a/src/sim/process.hh +++ b/src/sim/process.hh @@ -107,9 +107,13 @@ Addr next_thread_stack_base; // Base of region for mmaps (when user doesn't specify an address). - Addr mmap_start; Addr mmap_end; + // Does mmap region grow upward or downward from mmap_end? Most + // platforms grow downward, but a few (such as Alpha) grow upward + // instead, so they can override thie method to return false. + virtual bool mmapGrowsDown() const { return true; } + // Base of region for nxm data Addr nxm_start; Addr nxm_end; diff --git a/src/sim/process.cc b/src/sim/process.cc --- a/src/sim/process.cc +++ b/src/sim/process.cc @@ -182,7 +182,7 @@ fde_stderr->set(sim_fd, params->errout, O_WRONLY | O_CREAT | O_TRUNC, 0664, false); - mmap_start = mmap_end = 0; + mmap_end = 0; nxm_start = nxm_end = 0; // other parameters will be initialized when the program is loaded } @@ -412,7 +412,6 @@ SERIALIZE_SCALAR(stack_size); SERIALIZE_SCALAR(stack_min); SERIALIZE_SCALAR(next_thread_stack_base); - SERIALIZE_SCALAR(mmap_start); SERIALIZE_SCALAR(mmap_end); SERIALIZE_SCALAR(nxm_start); SERIALIZE_SCALAR(nxm_end); @@ -432,7 +431,6 @@ UNSERIALIZE_SCALAR(stack_size); UNSERIALIZE_SCALAR(stack_min); UNSERIALIZE_SCALAR(next_thread_stack_base); - UNSERIALIZE_SCALAR(mmap_start); UNSERIALIZE_SCALAR(mmap_end); UNSERIALIZE_SCALAR(nxm_start); UNSERIALIZE_SCALAR(nxm_end); diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh --- a/src/sim/syscall_emul.hh +++ b/src/sim/syscall_emul.hh @@ -1277,8 +1277,8 @@ // Extend global mmap region if necessary. Note that we ignore the // start address unless MAP_FIXED is specified. if (!(tgt_flags & OS::TGT_MAP_FIXED)) { - start = (OS::mmapGrowsDown) ? p->mmap_end - length : p->mmap_end; - p->mmap_end = (OS::mmapGrowsDown) ? start : p->mmap_end + length; + start = p->mmapGrowsDown() ? p->mmap_end - length : p->mmap_end; + p->mmap_end = p->mmapGrowsDown() ? start : p->mmap_end + length; } DPRINTF_SYSCALL(Verbose, " mmap range is 0x%x - 0x%x\n",