summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/arch/alpha/faults.cc4
-rw-r--r--src/arch/sparc/faults.cc4
-rw-r--r--src/arch/x86/tlb.cc19
-rw-r--r--src/mem/translating_port.cc2
-rw-r--r--src/sim/faults.cc2
-rw-r--r--src/sim/process.cc16
-rw-r--r--src/sim/process.hh6
7 files changed, 22 insertions, 31 deletions
diff --git a/src/arch/alpha/faults.cc b/src/arch/alpha/faults.cc
index b6a0d965e..c66c6f8ab 100644
--- a/src/arch/alpha/faults.cc
+++ b/src/arch/alpha/faults.cc
@@ -201,8 +201,8 @@ NDtbMissFault::invoke(ThreadContext *tc, StaticInstPtr inst)
TlbEntry entry;
bool success = p->pTable->lookup(vaddr, entry);
if (!success) {
- p->checkAndAllocNextPage(vaddr);
- success = p->pTable->lookup(vaddr, entry);
+ if (p->fixupStackFault(vaddr))
+ success = p->pTable->lookup(vaddr, entry);
}
if (!success) {
panic("Tried to access unmapped address %#x.\n", (Addr)vaddr);
diff --git a/src/arch/sparc/faults.cc b/src/arch/sparc/faults.cc
index 814a33bd3..01d57e627 100644
--- a/src/arch/sparc/faults.cc
+++ b/src/arch/sparc/faults.cc
@@ -643,8 +643,8 @@ FastDataAccessMMUMiss::invoke(ThreadContext *tc, StaticInstPtr inst)
TlbEntry entry;
bool success = p->pTable->lookup(vaddr, entry);
if (!success) {
- p->checkAndAllocNextPage(vaddr);
- success = p->pTable->lookup(vaddr, entry);
+ if (p->fixupStackFault(vaddr))
+ success = p->pTable->lookup(vaddr, entry);
}
if (!success) {
panic("Tried to access unmapped address %#x.\n", vaddr);
diff --git a/src/arch/x86/tlb.cc b/src/arch/x86/tlb.cc
index 9ba20f8d7..9d02a00c7 100644
--- a/src/arch/x86/tlb.cc
+++ b/src/arch/x86/tlb.cc
@@ -619,22 +619,11 @@ TLB::translate(RequestPtr req, ThreadContext *tc, Translation *translation,
TlbEntry newEntry;
bool success = p->pTable->lookup(vaddr, newEntry);
if (!success && mode != Execute) {
- // This may fail because for some reason the requested
- // address is not allocatable on the stack. If it's a stack
- // address, then it's because the address fell outside of
- // max stack range and user should increase max size of
- // stack. Otherwise, it could be a random address that was
- // not in the page table and not on the stack. Either way,
- // you'll end up with a page fault.
- if (p->checkAndAllocNextPage(vaddr))
- // Might as well not check this if you failed to
- // allocate. Partially nested this just so code
- // maintainers can understand this is a separate and
- // necessary step not sufficient just by reading return
- // value of checkAndAlloc call because there is a side
- // effect. This call will populate (it's called by
- // reference).
+ // Check if we just need to grow the stack.
+ if (p->fixupStackFault(vaddr)) {
+ // If we did, lookup the entry for the new page.
success = p->pTable->lookup(vaddr, newEntry);
+ }
}
if (!success) {
return new PageFault(vaddr, true, mode, true, false);
diff --git a/src/mem/translating_port.cc b/src/mem/translating_port.cc
index 210f9beb3..80c68c6bd 100644
--- a/src/mem/translating_port.cc
+++ b/src/mem/translating_port.cc
@@ -90,7 +90,7 @@ TranslatingPort::tryWriteBlob(Addr addr, uint8_t *p, int size)
VMPageSize);
} else if (allocating == NextPage) {
// check if we've accessed the next page on the stack
- if (!process->checkAndAllocNextPage(gen.addr()))
+ if (!process->fixupStackFault(gen.addr()))
panic("Page table fault when accessing virtual address %#x "
"during functional write\n", gen.addr());
} else {
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);