* Gabe Black
*/
+#include "sim/faults.hh"
+
#include "arch/isa_traits.hh"
#include "base/misc.hh"
-#include "cpu/thread_context.hh"
#include "cpu/base.hh"
-#include "sim/faults.hh"
-#include "sim/process.hh"
+#include "cpu/thread_context.hh"
+#include "debug/Fault.hh"
#include "mem/page_table.hh"
+#include "sim/full_system.hh"
+#include "sim/process.hh"
-#if !FULL_SYSTEM
-void FaultBase::invoke(ThreadContext * tc)
+void FaultBase::invoke(ThreadContext * tc, const StaticInstPtr &inst)
{
- fatal("fault (%s) detected @ PC %p", name(), tc->readPC());
+ if (FullSystem) {
+ DPRINTF(Fault, "Fault %s at PC: %s\n", name(), tc->pcState());
+ } else {
+ panic("fault (%s) detected @ PC %s", name(), tc->pcState());
+ }
}
-#else
-void FaultBase::invoke(ThreadContext * tc)
-{
- DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), tc->readPC());
- tc->getCpuPtr()->recordEvent(csprintf("Fault %s", name()));
- assert(!tc->misspeculating());
+void UnimpFault::invoke(ThreadContext * tc, const StaticInstPtr &inst)
+{
+ panic("Unimpfault: %s\n", panicStr.c_str());
}
-#endif
-void UnimpFault::invoke(ThreadContext * tc)
+void ReExec::invoke(ThreadContext *tc, const StaticInstPtr &inst)
{
- panic("Unimpfault: %s\n", panicStr.c_str());
+ tc->pcState(tc->pcState());
}
-#if !FULL_SYSTEM
-void PageTableFault::invoke(ThreadContext *tc)
+
+void SyscallRetryFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
{
- Process *p = tc->getProcessPtr();
+ tc->pcState(tc->pcState());
+}
- // We've accessed the next page of the stack, so extend the stack
- // to cover it.
- if(vaddr < p->stack_min && vaddr >= p->stack_min - TheISA::PageBytes)
- {
- p->stack_min -= TheISA::PageBytes;
- if(p->stack_base - p->stack_min > 8*1024*1024)
- fatal("Over max stack size for one thread\n");
- p->pTable->allocate(p->stack_min, TheISA::PageBytes);
- warn("Increasing stack size by one page.");
+void GenericPageTableFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
+{
+ bool handled = false;
+ if (!FullSystem) {
+ Process *p = tc->getProcessPtr();
+ handled = p->fixupStackFault(vaddr);
}
- // Otherwise, we have an unexpected page fault. Report that fact,
- // and what address was accessed to cause the fault.
- else
- {
+ if (!handled)
panic("Page table fault when accessing virtual address %#x\n", vaddr);
- }
+
+}
+
+void GenericAlignmentFault::invoke(ThreadContext *tc, const StaticInstPtr &inst)
+{
+ panic("Alignment fault when accessing virtual address %#x\n", vaddr);
}
-#endif