ARM: Fixed register flattening logic (FP_Base_DepTag was set too low)
authorMin Kyu Jeong <minkyu.jeong@arm.com>
Thu, 26 Aug 2010 00:10:43 +0000 (19:10 -0500)
committerMin Kyu Jeong <minkyu.jeong@arm.com>
Thu, 26 Aug 2010 00:10:43 +0000 (19:10 -0500)
When decoding a srs instruction, invalid mode encoding returns invalid instruction.
This can happen when garbage instructions are fetched from mispredicted path

src/arch/alpha/registers.hh
src/arch/arm/registers.hh
src/arch/mips/registers.hh
src/arch/power/registers.hh
src/arch/sparc/registers.hh
src/arch/x86/registers.hh
src/cpu/o3/rename_impl.hh

index ec36ff751560d5bf4e00793d0d3afd2d6c6007cc..d8752d520724913810ba1df17ae88677f5cf173a 100644 (file)
@@ -101,7 +101,8 @@ enum DependenceTags {
     // 0..31 are the integer regs 0..31
     // 32..63 are the FP regs 0..31, i.e. use (reg + FP_Base_DepTag)
     FP_Base_DepTag = 40,
-    Ctrl_Base_DepTag = 72
+    Ctrl_Base_DepTag = 72,
+    Max_DepTag = Ctrl_Base_DepTag + NumMiscRegs + NumInternalProcRegs
 };
 
 } // namespace AlphaISA
index 444e979fb181eabb50ad9592c93f353fb97d0620..a568e4a9c3379669cb2b138eed3134f21b7212e2 100644 (file)
@@ -1,4 +1,16 @@
 /*
+ * Copyright (c) 2010 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder.  You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
  * Copyright (c) 2007-2008 The Florida State University
  * All rights reserved.
  *
@@ -59,9 +71,9 @@ const int NumFloatSpecialRegs = 8;
 
 const int NumIntRegs = NUM_INTREGS;
 const int NumFloatRegs = NumFloatArchRegs + NumFloatSpecialRegs;
-
 const int NumMiscRegs = NUM_MISCREGS;
 
+const int TotalNumRegs = NumIntRegs + NumFloatRegs + NumMiscRegs;
 
 // semantically meaningful register indices
 const int ReturnValueReg = 0;
@@ -85,6 +97,7 @@ const int SyscallSuccessReg = ReturnValueReg;
 // These help enumerate all the registers for dependence tracking.
 const int FP_Base_DepTag = NumIntRegs * (MODE_MAXMODE + 1);
 const int Ctrl_Base_DepTag = FP_Base_DepTag + NumFloatRegs;
+const int Max_DepTag = Ctrl_Base_DepTag + NumMiscRegs;
 
 typedef union {
     IntReg   intreg;
index 5cf76634d2d3e7445d56e67d4bda6edea252774a..dce7858bf545567ac85636e81a9549bd221563af 100644 (file)
@@ -283,6 +283,7 @@ enum MiscRegIndex{
 const int TotalDataRegs = NumIntRegs + NumFloatRegs;
 
 const int NumMiscRegs = MISCREG_NUMREGS;
+const int Max_DepTag = Ctrl_Base_DepTag + NumMiscRegs;
 
 const int TotalNumRegs = NumIntRegs + NumFloatRegs + NumMiscRegs;
 
index 5bcca36419122a2c185aed44f56b29c4f08883e6..59816a5993ac5bfe3f364e9ae181da0f3edf5718 100644 (file)
@@ -82,6 +82,7 @@ const int SyscallSuccessReg = 3;
 // These help enumerate all the registers for dependence tracking.
 const int FP_Base_DepTag = NumIntRegs;
 const int Ctrl_Base_DepTag = FP_Base_DepTag + NumFloatRegs;
+const int Max_DepTag = Ctrl_Base_DepTag + NumMiscRegs;
 
 typedef union {
     IntReg   intreg;
index 639b7a4879c7be89c0de0b8bcd45d50b7135c057..cf9f54b59c0c1ef44554c85628b0cd3c4b8512bb 100644 (file)
@@ -58,7 +58,8 @@ namespace SparcISA
     // These enumerate all the registers for dependence tracking.
     enum DependenceTags {
         FP_Base_DepTag = 32*3+9,
-        Ctrl_Base_DepTag = FP_Base_DepTag + 64
+        Ctrl_Base_DepTag = FP_Base_DepTag + 64,
+        Max_DepTag = Ctrl_Base_DepTag + NumMiscRegs
     };
 
     // semantically meaningful register indices
index e14b9a1ba3efe00be6e13bae3cb11c7efdbf58f8..ea737fa63c539950f36a3ad16570c9551863148f 100644 (file)
@@ -76,7 +76,8 @@ enum DependenceTags {
         //The microcode fp registers
         8 +
         //The indices that are mapped over the fp stack
-        8
+        8,
+    Max_DepTag = Ctrl_Base_DepTag + NumMiscRegs
 };
 
 // semantically meaningful register indices
index ce206435c0a9047afd0776714e9fdef8fe3cdaef..7f796c4c8ec0d6026015ad8ae9fdae999b663287 100644 (file)
@@ -966,9 +966,11 @@ DefaultRename<Impl>::renameSrcRegs(DynInstPtr &inst, ThreadID tid)
             src_reg = src_reg - TheISA::FP_Base_DepTag;
             flat_src_reg = inst->tcBase()->flattenFloatIndex(src_reg);
             flat_src_reg += TheISA::NumIntRegs;
-        } else {
+        } else if (src_reg < TheISA::Max_DepTag) {
             flat_src_reg = src_reg - TheISA::FP_Base_DepTag + TheISA::NumIntRegs;
             DPRINTF(Rename, "Adjusting reg index from %d to %d.\n", src_reg, flat_src_reg);
+        } else {
+            panic("Reg index is out of bound: %d.", src_reg);
         }
 
         inst->flattenSrcReg(src_idx, flat_src_reg);
@@ -1012,11 +1014,13 @@ DefaultRename<Impl>::renameDestRegs(DynInstPtr &inst, ThreadID tid)
             // Integer registers are flattened.
             flat_dest_reg = inst->tcBase()->flattenIntIndex(dest_reg);
             DPRINTF(Rename, "Flattening index %d to %d.\n", (int)dest_reg, (int)flat_dest_reg);
-        } else {
+        } else if (dest_reg < TheISA::Max_DepTag) {
             // Floating point and Miscellaneous registers need their indexes
             // adjusted to account for the expanded number of flattened int regs.
             flat_dest_reg = dest_reg - TheISA::FP_Base_DepTag + TheISA::NumIntRegs;
             DPRINTF(Rename, "Adjusting reg index from %d to %d.\n", dest_reg, flat_dest_reg);
+        } else {
+            panic("Reg index is out of bound: %d.", dest_reg);
         }
 
         inst->flattenDestReg(dest_idx, flat_dest_reg);