summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.hh
diff options
context:
space:
mode:
authorBrandon Potter <Brandon.Potter@amd.com>2017-03-01 13:07:43 -0600
committerBrandon Potter <Brandon.Potter@amd.com>2017-03-09 19:19:38 +0000
commit43418e7f81099072fb7d56dae11110ae1d858162 (patch)
tree0d624abfdd331b0edffcafc274c08695d0cca97b /src/sim/syscall_emul.hh
parent71dd6c2c17a465b7705f53469cd2c89f16ede4b7 (diff)
downloadgem5-43418e7f81099072fb7d56dae11110ae1d858162.tar.xz
syscall-emul: Move memState into its own file
The Process class is full of implementation details and structures related to SE Mode. This changeset factors out an internal class from Process and moves it into a separate file. The purpose behind doing this is to clean up the code and make it a bit more modular. Change-Id: Ic6941a1657751e8d51d5b6b1dcc04f1195884280 Reviewed-on: https://gem5-review.googlesource.com/2263 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/sim/syscall_emul.hh')
-rw-r--r--src/sim/syscall_emul.hh27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 8a34c3415..8cca6ebcb 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -885,11 +885,14 @@ mremapFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
new_length = roundUp(new_length, TheISA::PageBytes);
if (new_length > old_length) {
- if ((start + old_length) == process->memState->mmapEnd &&
+ std::shared_ptr<MemState> mem_state = process->memState;
+ Addr mmap_end = mem_state->getMmapEnd();
+
+ if ((start + old_length) == mmap_end &&
(!use_provided_address || provided_address == start)) {
uint64_t diff = new_length - old_length;
- process->allocateMem(process->memState->mmapEnd, diff);
- process->memState->mmapEnd += diff;
+ process->allocateMem(mmap_end, diff);
+ mem_state->setMmapEnd(mmap_end + diff);
return start;
} else {
if (!use_provided_address && !(flags & OS::TGT_MREMAP_MAYMOVE)) {
@@ -897,7 +900,7 @@ mremapFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
return -ENOMEM;
} else {
uint64_t new_start = use_provided_address ?
- provided_address : process->memState->mmapEnd;
+ provided_address : mmap_end;
process->pTable->remap(start, old_length, new_start);
warn("mremapping to new vaddr %08p-%08p, adding %d\n",
new_start, new_start + new_length,
@@ -907,9 +910,9 @@ mremapFunc(SyscallDesc *desc, int callnum, Process *process, ThreadContext *tc)
new_length - old_length,
use_provided_address /* clobber */);
if (!use_provided_address)
- process->memState->mmapEnd += new_length;
+ mem_state->setMmapEnd(mmap_end + new_length);
if (use_provided_address &&
- new_start + new_length > process->memState->mmapEnd) {
+ new_start + new_length > mem_state->getMmapEnd()) {
// something fishy going on here, at least notify the user
// @todo: increase mmap_end?
warn("mmap region limit exceeded with MREMAP_FIXED\n");
@@ -1214,7 +1217,6 @@ cloneFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
pp->executable.assign(*(new std::string(p->progName())));
pp->cmd.push_back(*(new std::string(p->progName())));
pp->system = p->system;
- pp->maxStackSize = p->maxStackSize;
pp->cwd.assign(p->getcwd());
pp->input.assign("stdin");
pp->output.assign("stdout");
@@ -1457,9 +1459,13 @@ mmapImpl(SyscallDesc *desc, int num, Process *p, ThreadContext *tc,
// 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)) {
- Addr *end = &p->memState->mmapEnd;
- start = p->mmapGrowsDown() ? *end - length : *end;
- *end = p->mmapGrowsDown() ? start : *end + length;
+ std::shared_ptr<MemState> mem_state = p->memState;
+ Addr mmap_end = mem_state->getMmapEnd();
+
+ start = p->mmapGrowsDown() ? mmap_end - length : mmap_end;
+ mmap_end = p->mmapGrowsDown() ? start : mmap_end + length;
+
+ mem_state->setMmapEnd(mmap_end);
}
DPRINTF_SYSCALL(Verbose, " mmap range is 0x%x - 0x%x\n",
@@ -1768,7 +1774,6 @@ execveFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
pp->errout.assign("cerr");
pp->cwd.assign(p->getcwd());
pp->system = p->system;
- pp->maxStackSize = p->maxStackSize;
/**
* Prevent process object creation with identical PIDs (which will trip
* a fatal check in Process constructor). The execve call is supposed to