From f6cd7a4bb7ee66b58f88fbdc6bdc4faa6a559952 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Thu, 17 Mar 2016 10:29:32 -0700 Subject: syscall_emul: move mmapGrowsDown() to LiveProcess The mmapGrowsDown() method was a static method on the OperatingSystem class (and derived classes), which worked OK for the templated syscall emulation methods, but made it hard to access elsewhere. This patch moves the method to be a virtual function on the LiveProcess method, where it can be overridden for specific platforms (for now, Alpha). This patch also changes the value of mmapGrowsDown() from being false by default and true only on X86Linux32 to being true by default and false only on Alpha, which seems closer to reality (though in reality most people use ASLR and this doesn't really matter anymore). In the process, also got rid of the unused mmap_start field on LiveProcess and OperatingSystem mmapGrowsUp variable. --- src/gpu-compute/shader.cc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/gpu-compute') diff --git a/src/gpu-compute/shader.cc b/src/gpu-compute/shader.cc index e8d7946ff..31aa1e4cf 100644 --- a/src/gpu-compute/shader.cc +++ b/src/gpu-compute/shader.cc @@ -78,25 +78,24 @@ Shader::mmap(int length) // 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; } -- cgit v1.2.3