06-16-09-Rollback

From Msim

Jump to: navigation, search

This section refers to changes made to the rollback logic to handle recovery of the FPCR regiser as well as handle recovery of STQ_C and STL_C instructions - these change a register as part of lock detection/handling.

FPCR

The instruction, mt_fpcr, sets the FPCR register with the data from RA. FPCR is recovered properly during rollback (it is part of regs_C), however, during detection of recovery data, mt_fpcr has a invalid destination register (FPCR is detected as register 64 or OUT==-1). No actual data needs to be recovered, however, we provide for recovery of RA. In register_rename, during assignment of rollback values for floating point instructions in sim-outorder.c (new code is bold):

  
  //Special case, if op==MT_FPCR (mt_fpcr $fX -> fpcr = $fX)
  //The regs_index is -1 (fpcr is 64) which doesn't match any expected destinations
  if(out1==DFPCR)
  {
   //FPCR is already preserved by regs_C. We want to nop the rollback here
   rs->regs_index = Rlist[2];
   //This register didn't change anyway. Now it matches and we don't have to alter the rollback code
  }
  
 assert(rs->regs_index==Rlist[2]);
 rs->regs_F = regs_F[2];
 }
//This lets us keep track of FP via regs_index.
rs->regs_index+=32;


Store_C

Currently (this will probably be changed) STQ_C and STL_C do not use a phyiscal register and therefore do not rollback properly with the current "walk through the ROB" mechanism. Therefore, if we are rolling back an STQ_C or STL_C instruction we need to restore the changed register value.
In rollback, here is the detection code for cmp.c (new code is bold):

//STQ_C and STL_C do not have a physical register but need to rollback RA
if(target.ROB[ROB_index].op == STQ_C || target.ROB[ROB_index].op == STL_C)
{
 int index = target.ROB[ROB_index].regs_index;
 target.regs.regs_R[index] = target.ROB[ROB_index].regs_R;
}

//release physical registers

We must also store the prior register data during register rename in sim-outorder.c (new code is bold):

rs->L1_miss = rs->L2_miss = rs->L3_miss = 0;

//Rollback support
//STQ_C and STL_C do not have an output register but technically, it overwrites RA with "lock_flag"
if(op == STQ_C || op == STL_C)
{
 rs->regs_index = Rlist[0];
 rs->regs_R = regs_R[0];
}

if((out1 != 0) && (out1 != 32))


Traps

The code that checked if a Trap instruction was rolled back is removed. Since Traps do not enter the pipeline when other instructions are in-flight, the only time this can occur is if the Trap caused a rollback.

if(MD_OP_FLAGS(target.ROB[ROB_index].spec_mode) & F_TRAP)
{
 if(!target.ROB[ROB_index].spec_mode)
 {
  std::cout << "Possible System Call was rollbacked unsafely!" << std::endl;
 }
}
Personal tools