fix shadow set bugs in MIPS code that caused out of bounds access...

panic rdpgpr/wrpgpr instructions until a better impl.
of MIPS shadow sets is available.
This commit is contained in:
Korey Sewell 2008-10-06 02:07:04 -04:00
parent b25755993b
commit 6c046a28dc
5 changed files with 27 additions and 21 deletions

View file

@ -603,7 +603,8 @@ decode OPCODE_HI default Unknown::unknown() {
0xA: rdpgpr({{ 0xA: rdpgpr({{
if(Config_AR >= 1) if(Config_AR >= 1)
{ // Rev 2 of the architecture { // Rev 2 of the architecture
Rd = xc->tcBase()->readIntReg(RT + NumIntRegs * SRSCtl_PSS); panic("Shadow Sets Not Fully Implemented.\n");
//Rd = xc->tcBase()->readIntReg(RT + NumIntRegs * SRSCtl_PSS);
} }
else else
{ {
@ -613,7 +614,8 @@ decode OPCODE_HI default Unknown::unknown() {
0xE: wrpgpr({{ 0xE: wrpgpr({{
if(Config_AR >= 1) if(Config_AR >= 1)
{ // Rev 2 of the architecture { // Rev 2 of the architecture
xc->tcBase()->setIntReg(RD + NumIntRegs * SRSCtl_PSS,Rt); panic("Shadow Sets Not Fully Implemented.\n");
//xc->tcBase()->setIntReg(RD + NumIntRegs * SRSCtl_PSS,Rt);
// warn("Writing %d to %d, PSS: %d, SRS: %x\n",Rt,RD + NumIntRegs * SRSCtl_PSS, SRSCtl_PSS,SRSCtl); // warn("Writing %d to %d, PSS: %d, SRS: %x\n",Rt,RD + NumIntRegs * SRSCtl_PSS, SRSCtl_PSS,SRSCtl);
} }
else else

View file

@ -181,6 +181,8 @@ namespace MipsISA
const int NumIntRegs = NumIntArchRegs*NumShadowRegSets + NumIntSpecialRegs; //HI & LO Regs const int NumIntRegs = NumIntArchRegs*NumShadowRegSets + NumIntSpecialRegs; //HI & LO Regs
const int NumFloatRegs = NumFloatArchRegs + NumFloatSpecialRegs;// const int NumFloatRegs = NumFloatArchRegs + NumFloatSpecialRegs;//
const int TotalArchRegs = NumIntArchRegs * NumShadowRegSets;
// Static instruction parameters // Static instruction parameters
const int MaxInstSrcRegs = 10; const int MaxInstSrcRegs = 10;
const int MaxInstDestRegs = 8; const int MaxInstDestRegs = 8;

View file

@ -44,6 +44,12 @@ IntRegFile::clear()
currShadowSet=0; currShadowSet=0;
} }
int
IntRegFile::readShadowSet()
{
return currShadowSet;
}
void void
IntRegFile::setShadowSet(int css) IntRegFile::setShadowSet(int css)
{ {
@ -54,21 +60,17 @@ IntRegFile::setShadowSet(int css)
IntReg IntReg
IntRegFile::readReg(int intReg) IntRegFile::readReg(int intReg)
{ {
if (intReg < NumIntRegs) { if (intReg < NumIntArchRegs) {
// Regular GPR Read // Regular GPR Read
DPRINTF(MipsPRA, "Reading Reg: %d, CurrShadowSet: %d\n", intReg, DPRINTF(MipsPRA, "Reading Reg: %d, CurrShadowSet: %d\n", intReg,
currShadowSet); currShadowSet);
if (intReg >= NumIntArchRegs * NumShadowRegSets) { return regs[intReg + NumIntArchRegs * currShadowSet];
return regs[intReg + NumIntRegs * currShadowSet];
} else { } else {
int index = intReg + NumIntArchRegs * currShadowSet; unsigned special_reg_num = intReg - NumIntArchRegs;
index = index % NumIntArchRegs;
return regs[index]; // Read A Special Reg
} return regs[TotalArchRegs + special_reg_num];
} else {
// Read from shadow GPR .. probably called by RDPGPR
return regs[intReg];
} }
} }
@ -76,13 +78,12 @@ Fault
IntRegFile::setReg(int intReg, const IntReg &val) IntRegFile::setReg(int intReg, const IntReg &val)
{ {
if (intReg != ZeroReg) { if (intReg != ZeroReg) {
if (intReg < NumIntRegs) { if (intReg < NumIntArchRegs) {
if (intReg >= NumIntArchRegs * NumShadowRegSets) regs[intReg + NumIntArchRegs * currShadowSet] = val;
regs[intReg] = val;
else
regs[intReg + NumIntRegs * currShadowSet] = val;
} else { } else {
regs[intReg] = val; unsigned special_reg_num = intReg - NumIntArchRegs;
regs[TotalArchRegs + special_reg_num] = val;
} }
} }

View file

@ -48,7 +48,7 @@ namespace MipsISA
} }
enum MiscIntRegNums { enum MiscIntRegNums {
LO = NumIntArchRegs*NumShadowRegSets, LO = NumIntArchRegs,
HI, HI,
DSPACX0, DSPACX0,
DSPLo1, DSPLo1,
@ -72,6 +72,7 @@ namespace MipsISA
int currShadowSet; int currShadowSet;
public: public:
void clear(); void clear();
int readShadowSet();
void setShadowSet(int css); void setShadowSet(int css);
IntReg readReg(int intReg); IntReg readReg(int intReg);
Fault setReg(int intReg, const IntReg &val); Fault setReg(int intReg, const IntReg &val);

View file

@ -40,7 +40,7 @@
#include "cpu/base.hh" #include "cpu/base.hh"
#include "cpu/exetrace.hh" #include "cpu/exetrace.hh"
#include "params/DerivO3CPU.hh" //#include "params/DerivO3CPU.hh"
using namespace std; using namespace std;