cpu: Put in assertions to check for maximum supported LQ/SQ size
authorFaissal Sleiman <Faissal.Sleiman@arm.com>
Thu, 17 Oct 2013 15:20:45 +0000 (10:20 -0500)
committerFaissal Sleiman <Faissal.Sleiman@arm.com>
Thu, 17 Oct 2013 15:20:45 +0000 (10:20 -0500)
LSQSenderState represents the LQ/SQ index using uint8_t, which supports up to
 256 entries (including the sentinel entry). Sending packets to memory with a
higher index than 255 truncates the index, such that the response matches the
wrong entry. For instance, this can result in a deadlock if a store completion
does not clear the head entry.

src/cpu/o3/lsq_unit_impl.hh

index 077af1dd7a13b923be3b8b4b260fb4e7c9b75d4c..44b8e904176dac4d4588e08414074b7171be5aa0 100644 (file)
@@ -158,6 +158,10 @@ LSQUnit<Impl>::init(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params,
     LQEntries = maxLQEntries + 1;
     SQEntries = maxSQEntries + 1;
 
+    //Due to uint8_t index in LSQSenderState
+    assert(LQEntries <= 256);
+    assert(SQEntries <= 256);
+
     loadQueue.resize(LQEntries);
     storeQueue.resize(SQEntries);
 
@@ -306,6 +310,7 @@ LSQUnit<Impl>::resizeLQ(unsigned size)
         LQEntries = size_plus_sentinel;
     }
 
+    assert(LQEntries <= 256);
 }
 
 template<class Impl>
@@ -322,6 +327,8 @@ LSQUnit<Impl>::resizeSQ(unsigned size)
     } else {
         SQEntries = size_plus_sentinel;
     }
+
+    assert(SQEntries <= 256);
 }
 
 template <class Impl>