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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 §ion);
|
||||
|
||||
Reference in New Issue
Block a user