summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2011-09-09 01:01:43 -0700
committerGabe Black <gblack@eecs.umich.edu>2011-09-09 01:01:43 -0700
commita1ad9e652a1a8b0b7d8c5dd2229324792010f6f3 (patch)
tree97577adc8e71a46e9d4b34d255c4fd84df3b88d0 /src/sim
parentf370ac5c186d063bd169c07ea89e1792617264cd (diff)
downloadgem5-a1ad9e652a1a8b0b7d8c5dd2229324792010f6f3.tar.xz
Stack: Tidy up some comments, a warning, and make stack extension consistent.
Do some minor cleanup of some recently added comments, a warning, and change other instances of stack extension to be like what's now being done for x86.
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/faults.cc2
-rw-r--r--src/sim/process.cc16
-rw-r--r--src/sim/process.hh6
3 files changed, 13 insertions, 11 deletions
diff --git a/src/sim/faults.cc b/src/sim/faults.cc
index 8e9b8e094..3f1369bcc 100644
--- a/src/sim/faults.cc
+++ b/src/sim/faults.cc
@@ -61,7 +61,7 @@ void GenericPageTableFault::invoke(ThreadContext *tc, StaticInstPtr inst)
{
Process *p = tc->getProcessPtr();
- if (!p->checkAndAllocNextPage(vaddr))
+ if (!p->fixupStackFault(vaddr))
panic("Page table fault when accessing virtual address %#x\n", vaddr);
}
diff --git a/src/sim/process.cc b/src/sim/process.cc
index bec33c70b..62b9b7002 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -329,29 +329,31 @@ Process::sim_fd_obj(int tgt_fd)
}
bool
-Process::checkAndAllocNextPage(Addr vaddr)
+Process::fixupStackFault(Addr vaddr)
{
- // if this is an initial write we might not have
+ // Check if this is already on the stack and there's just no page there
+ // yet.
if (vaddr >= stack_min && vaddr < stack_base) {
pTable->allocate(roundDown(vaddr, VMPageSize), VMPageSize);
return true;
}
- // We've accessed the next page of the stack, so extend the stack
- // to cover it.
+ // We've accessed the next page of the stack, so extend it to include
+ // this address.
if (vaddr < stack_min && vaddr >= stack_base - max_stack_size) {
while (vaddr < stack_min) {
stack_min -= TheISA::PageBytes;
- if(stack_base - stack_min > max_stack_size)
+ if (stack_base - stack_min > max_stack_size)
fatal("Maximum stack size exceeded\n");
- if(stack_base - stack_min > 8*1024*1024)
+ if (stack_base - stack_min > 8 * 1024 * 1024)
fatal("Over max stack size for one thread\n");
pTable->allocate(stack_min, TheISA::PageBytes);
inform("Increasing stack size by one page.");
};
return true;
}
- warn("Not increasing stack: requested vaddr is outside of stack range.");
+ warn("Not extending stack: address %#x isn't at the end of the stack.",
+ vaddr);
return false;
}
diff --git a/src/sim/process.hh b/src/sim/process.hh
index 94f6d1800..d48b1b463 100644
--- a/src/sim/process.hh
+++ b/src/sim/process.hh
@@ -212,9 +212,9 @@ class Process : public SimObject
virtual void syscall(int64_t callnum, ThreadContext *tc) = 0;
- // check if the this addr is on the next available page and allocate it
- // if it's not we'll panic
- bool checkAndAllocNextPage(Addr vaddr);
+ /// Attempt to fix up a fault at vaddr by allocating a page on the stack.
+ /// @return Whether the fault has been fixed.
+ bool fixupStackFault(Addr vaddr);
void serialize(std::ostream &os);
void unserialize(Checkpoint *cp, const std::string &section);