Some clean up work with faults.
arch/alpha/faults.cc: Renamed the _stat stat to a more descriptive _count, got rid of some old commented out code, and moved common fault handling code, ie recording that the fault happend and that it wasn't mispeculated, into the FaultBase class. arch/alpha/faults.hh: Renamed the _stat stat to the more descriptive _count, and renamed the appropriate accessor functions. kern/kernel_stats.cc: kern/kernel_stats.hh: The fault statistics are now handled by the fault classes themselves. sim/faults.cc: The default implementation of the "invoke" method now does what all faults should do first, ie record that the fault happened, and make sure the fault isn't being executed on a mispeculated execution path. sim/faults.hh: There is now a default implementation of invoke, and the stat function is taken care of in the architecture specific fault classes. --HG-- extra : convert_revision : f6656fbea991df9addf85cad740ac37b1036b71a
This commit is contained in:
parent
b7ebc2d97f
commit
b511128507
6 changed files with 63 additions and 108 deletions
|
@ -30,84 +30,80 @@
|
|||
#include "cpu/exec_context.hh"
|
||||
#include "cpu/base.hh"
|
||||
#include "base/trace.hh"
|
||||
#include "kern/kernel_stats.hh"
|
||||
|
||||
namespace AlphaISA
|
||||
{
|
||||
|
||||
FaultName MachineCheckFault::_name = "mchk";
|
||||
FaultVect MachineCheckFault::_vect = 0x0401;
|
||||
FaultStat MachineCheckFault::_stat;
|
||||
FaultStat MachineCheckFault::_count;
|
||||
|
||||
FaultName AlignmentFault::_name = "unalign";
|
||||
FaultVect AlignmentFault::_vect = 0x0301;
|
||||
FaultStat AlignmentFault::_stat;
|
||||
FaultStat AlignmentFault::_count;
|
||||
|
||||
FaultName ResetFault::_name = "reset";
|
||||
FaultVect ResetFault::_vect = 0x0001;
|
||||
FaultStat ResetFault::_stat;
|
||||
FaultStat ResetFault::_count;
|
||||
|
||||
FaultName ArithmeticFault::_name = "arith";
|
||||
FaultVect ArithmeticFault::_vect = 0x0501;
|
||||
FaultStat ArithmeticFault::_stat;
|
||||
FaultStat ArithmeticFault::_count;
|
||||
|
||||
FaultName InterruptFault::_name = "interrupt";
|
||||
FaultVect InterruptFault::_vect = 0x0101;
|
||||
FaultStat InterruptFault::_stat;
|
||||
FaultStat InterruptFault::_count;
|
||||
|
||||
FaultName NDtbMissFault::_name = "dtb_miss_single";
|
||||
FaultVect NDtbMissFault::_vect = 0x0201;
|
||||
FaultStat NDtbMissFault::_stat;
|
||||
FaultStat NDtbMissFault::_count;
|
||||
|
||||
FaultName PDtbMissFault::_name = "dtb_miss_double";
|
||||
FaultVect PDtbMissFault::_vect = 0x0281;
|
||||
FaultStat PDtbMissFault::_stat;
|
||||
FaultStat PDtbMissFault::_count;
|
||||
|
||||
FaultName DtbPageFault::_name = "dfault";
|
||||
FaultVect DtbPageFault::_vect = 0x0381;
|
||||
FaultStat DtbPageFault::_stat;
|
||||
FaultStat DtbPageFault::_count;
|
||||
|
||||
FaultName DtbAcvFault::_name = "dfault";
|
||||
FaultVect DtbAcvFault::_vect = 0x0381;
|
||||
FaultStat DtbAcvFault::_stat;
|
||||
FaultStat DtbAcvFault::_count;
|
||||
|
||||
FaultName ItbMissFault::_name = "itbmiss";
|
||||
FaultVect ItbMissFault::_vect = 0x0181;
|
||||
FaultStat ItbMissFault::_stat;
|
||||
FaultStat ItbMissFault::_count;
|
||||
|
||||
FaultName ItbPageFault::_name = "itbmiss";
|
||||
FaultVect ItbPageFault::_vect = 0x0181;
|
||||
FaultStat ItbPageFault::_stat;
|
||||
FaultStat ItbPageFault::_count;
|
||||
|
||||
FaultName ItbAcvFault::_name = "iaccvio";
|
||||
FaultVect ItbAcvFault::_vect = 0x0081;
|
||||
FaultStat ItbAcvFault::_stat;
|
||||
FaultStat ItbAcvFault::_count;
|
||||
|
||||
FaultName UnimplementedOpcodeFault::_name = "opdec";
|
||||
FaultVect UnimplementedOpcodeFault::_vect = 0x0481;
|
||||
FaultStat UnimplementedOpcodeFault::_stat;
|
||||
FaultStat UnimplementedOpcodeFault::_count;
|
||||
|
||||
FaultName FloatEnableFault::_name = "fen";
|
||||
FaultVect FloatEnableFault::_vect = 0x0581;
|
||||
FaultStat FloatEnableFault::_stat;
|
||||
FaultStat FloatEnableFault::_count;
|
||||
|
||||
FaultName PalFault::_name = "pal";
|
||||
FaultVect PalFault::_vect = 0x2001;
|
||||
FaultStat PalFault::_stat;
|
||||
FaultStat PalFault::_count;
|
||||
|
||||
FaultName IntegerOverflowFault::_name = "intover";
|
||||
FaultVect IntegerOverflowFault::_vect = 0x0501;
|
||||
FaultStat IntegerOverflowFault::_stat;
|
||||
FaultStat IntegerOverflowFault::_count;
|
||||
|
||||
#if FULL_SYSTEM
|
||||
|
||||
void AlphaFault::invoke(ExecContext * xc)
|
||||
{
|
||||
DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), xc->regs.pc);
|
||||
xc->cpu->recordEvent(csprintf("Fault %s", name()));
|
||||
|
||||
assert(!xc->misspeculating());
|
||||
xc->kernelStats->fault(this);
|
||||
FaultBase::invoke(xc);
|
||||
countStat()++;
|
||||
|
||||
// exception restart address
|
||||
if (setRestartAddress() || !xc->inPalMode())
|
||||
|
@ -128,43 +124,11 @@ void AlphaFault::invoke(ExecContext * xc)
|
|||
|
||||
void ArithmeticFault::invoke(ExecContext * xc)
|
||||
{
|
||||
DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), xc->regs.pc);
|
||||
xc->cpu->recordEvent(csprintf("Fault %s", name()));
|
||||
|
||||
assert(!xc->misspeculating());
|
||||
xc->kernelStats->fault(this);
|
||||
|
||||
FaultBase::invoke(xc);
|
||||
panic("Arithmetic traps are unimplemented!");
|
||||
}
|
||||
|
||||
|
||||
/*void ArithmeticFault::invoke(ExecContext * xc)
|
||||
{
|
||||
panic("Arithmetic traps are unimplemented!");
|
||||
}*/
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace AlphaISA
|
||||
|
||||
/*Fault * ListOfFaults[] = {
|
||||
(Fault *)&NoFault,
|
||||
(Fault *)&ResetFault,
|
||||
(Fault *)&MachineCheckFault,
|
||||
(Fault *)&ArithmeticFault,
|
||||
(Fault *)&InterruptFault,
|
||||
(Fault *)&NDtbMissFault,
|
||||
(Fault *)&PDtbMissFault,
|
||||
(Fault *)&AlignmentFault,
|
||||
(Fault *)&DtbPageFault,
|
||||
(Fault *)&DtbAcvFault,
|
||||
(Fault *)&ItbMissFault,
|
||||
(Fault *)&ItbPageFault,
|
||||
(Fault *)&ItbAcvFault,
|
||||
(Fault *)&UnimplementedOpcodeFault,
|
||||
(Fault *)&FloatEnableFault,
|
||||
(Fault *)&PalFault,
|
||||
(Fault *)&IntegerOverflowFault,
|
||||
};
|
||||
|
||||
int NumFaults = sizeof(ListOfFaults) / sizeof(Fault *);*/
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace AlphaISA
|
|||
|
||||
typedef const Addr FaultVect;
|
||||
|
||||
class AlphaFault : public virtual FaultBase
|
||||
class AlphaFault : public FaultBase
|
||||
{
|
||||
protected:
|
||||
virtual bool skipFaultingInstruction() {return false;}
|
||||
|
@ -48,6 +48,7 @@ class AlphaFault : public virtual FaultBase
|
|||
void invoke(ExecContext * xc);
|
||||
#endif
|
||||
virtual FaultVect vect() = 0;
|
||||
virtual FaultStat & countStat() = 0;
|
||||
};
|
||||
|
||||
class MachineCheckFault : public AlphaFault
|
||||
|
@ -55,11 +56,11 @@ class MachineCheckFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
bool isMachineCheckFault() {return true;}
|
||||
};
|
||||
|
||||
|
@ -68,11 +69,11 @@ class AlignmentFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
bool isAlignmentFault() {return true;}
|
||||
};
|
||||
|
||||
|
@ -91,11 +92,11 @@ class ResetFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class ArithmeticFault : public AlphaFault
|
||||
|
@ -105,11 +106,11 @@ class ArithmeticFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
#if FULL_SYSTEM
|
||||
void invoke(ExecContext * xc);
|
||||
#endif
|
||||
|
@ -122,11 +123,11 @@ class InterruptFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class NDtbMissFault : public AlphaFault
|
||||
|
@ -134,11 +135,11 @@ class NDtbMissFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class PDtbMissFault : public AlphaFault
|
||||
|
@ -146,11 +147,11 @@ class PDtbMissFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class DtbPageFault : public AlphaFault
|
||||
|
@ -158,11 +159,11 @@ class DtbPageFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class DtbAcvFault : public AlphaFault
|
||||
|
@ -170,11 +171,11 @@ class DtbAcvFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class ItbMissFault : public AlphaFault
|
||||
|
@ -182,11 +183,11 @@ class ItbMissFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class ItbPageFault : public AlphaFault
|
||||
|
@ -194,11 +195,11 @@ class ItbPageFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class ItbAcvFault : public AlphaFault
|
||||
|
@ -206,11 +207,11 @@ class ItbAcvFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class UnimplementedOpcodeFault : public AlphaFault
|
||||
|
@ -218,11 +219,11 @@ class UnimplementedOpcodeFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class FloatEnableFault : public AlphaFault
|
||||
|
@ -230,11 +231,11 @@ class FloatEnableFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class PalFault : public AlphaFault
|
||||
|
@ -244,11 +245,11 @@ class PalFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
class IntegerOverflowFault : public AlphaFault
|
||||
|
@ -256,11 +257,11 @@ class IntegerOverflowFault : public AlphaFault
|
|||
private:
|
||||
static FaultName _name;
|
||||
static FaultVect _vect;
|
||||
static FaultStat _stat;
|
||||
static FaultStat _count;
|
||||
public:
|
||||
FaultName name() {return _name;}
|
||||
FaultVect vect() {return _vect;}
|
||||
FaultStat & stat() {return _stat;}
|
||||
FaultStat & countStat() {return _count;}
|
||||
};
|
||||
|
||||
} // AlphaISA namespace
|
||||
|
|
|
@ -136,19 +136,6 @@ Statistics::regStats(const string &_name)
|
|||
}
|
||||
}
|
||||
|
||||
/* _faults
|
||||
.init(NumFaults)
|
||||
.name(name() + ".faults")
|
||||
.desc("number of faults")
|
||||
.flags(total | pdf | nozero | nonan)
|
||||
;
|
||||
|
||||
for (int i = 1; i < NumFaults; ++i) {
|
||||
const char *str = (*ListOfFaults[i])->name;
|
||||
if (str)
|
||||
_faults.subname(i, str);
|
||||
}*/
|
||||
|
||||
_mode
|
||||
.init(cpu_mode_num)
|
||||
.name(name() + ".mode_switch")
|
||||
|
|
|
@ -176,11 +176,6 @@ class Statistics : public Serializable
|
|||
void ivlb() { _ivlb++; }
|
||||
void ivle() { _ivle++; }
|
||||
void hwrei() { _hwrei++; }
|
||||
void fault(Fault fault)
|
||||
{
|
||||
if(fault != NoFault)
|
||||
fault->stat()++;
|
||||
}// FIXME: When there are no generic system fault objects, this will go back to _faults[fault]++; }
|
||||
void swpipl(int ipl);
|
||||
void mode(cpu_mode newmode);
|
||||
void context(Addr oldpcbb, Addr newpcbb);
|
||||
|
|
|
@ -28,10 +28,19 @@
|
|||
|
||||
#include "sim/faults.hh"
|
||||
#include "cpu/exec_context.hh"
|
||||
#include "cpu/base.hh"
|
||||
|
||||
#if !FULL_SYSTEM
|
||||
void FaultBase::invoke(ExecContext * xc)
|
||||
{
|
||||
fatal("fault (%s) detected @ PC 0x%08p", name(), xc->readPC());
|
||||
}
|
||||
#else
|
||||
void FaultBase::invoke(ExecContext * xc)
|
||||
{
|
||||
DPRINTF(Fault, "Fault %s at PC: %#x\n", name(), xc->regs.pc);
|
||||
xc->cpu->recordEvent(csprintf("Fault %s", name()));
|
||||
|
||||
assert(!xc->misspeculating());
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -51,9 +51,8 @@ class FaultBase : public RefCounted
|
|||
{
|
||||
public:
|
||||
virtual FaultName name() = 0;
|
||||
virtual FaultStat & stat() = 0;
|
||||
#if FULL_SYSTEM
|
||||
virtual void invoke(ExecContext * xc) = 0;
|
||||
virtual void invoke(ExecContext * xc);
|
||||
#else
|
||||
virtual void invoke(ExecContext * xc);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue