O3: Make sure fetch doesn't go off into the weeds during speculation.
authorAli Saidi <Ali.Saidi@ARM.com>
Sun, 10 Jul 2011 17:56:08 +0000 (12:56 -0500)
committerAli Saidi <Ali.Saidi@ARM.com>
Sun, 10 Jul 2011 17:56:08 +0000 (12:56 -0500)
src/cpu/o3/cpu.cc
src/cpu/o3/cpu.hh
src/cpu/o3/fetch.hh
src/cpu/o3/fetch_impl.hh
src/python/m5/params.py
src/sim/System.py
src/sim/system.cc
src/sim/system.hh

index b19e4f4608a6e338adeb395b300730b294808e8c..cd4a3e867fabecf5102a0a8b0841a0cad664f98f 100644 (file)
 #include "enums/MemoryMode.hh"
 #include "sim/core.hh"
 #include "sim/stat_control.hh"
+#include "sim/system.hh"
 
 #if FULL_SYSTEM
 #include "cpu/quiesce_event.hh"
-#include "sim/system.hh"
 #else
 #include "sim/process.hh"
 #endif
@@ -204,9 +204,7 @@ FullO3CPU<Impl>::FullO3CPU(DerivO3CPUParams *params)
                   params->activity),
 
       globalSeqNum(1),
-#if FULL_SYSTEM
       system(params->system),
-#endif // FULL_SYSTEM
       drainCount(0),
       deferRegistration(params->defer_registration)
 {
@@ -1105,9 +1103,7 @@ FullO3CPU<Impl>::resume()
     if (_status == SwitchedOut || _status == Idle)
         return;
 
-#if FULL_SYSTEM
     assert(system->getMemoryMode() == Enums::timing);
-#endif
 
     if (!tickEvent.scheduled())
         schedule(tickEvent, nextCycle());
index 7e9c33717152f3af1f736dc3cb5f962054a18daf..43a2b100d200e03f5f592f968f33fff771964d83 100644 (file)
@@ -652,10 +652,8 @@ class FullO3CPU : public BaseO3CPU
     Checker<DynInstPtr> *checker;
 #endif
 
-#if FULL_SYSTEM
     /** Pointer to the system. */
     System *system;
-#endif
 
     /** Event to call process() on once draining has completed. */
     Event *drainEvent;
index 92affc6dbb15b69163e1f57948509f5752c7d739..90fe5334a2edec0d4bd6765501155dea9dc35ffd 100644 (file)
@@ -172,7 +172,8 @@ class DefaultFetch
         ItlbWait,
         IcacheWaitResponse,
         IcacheWaitRetry,
-        IcacheAccessComplete
+        IcacheAccessComplete,
+        NoGoodAddr
     };
 
     /** Fetching Policy, Add new policies here.*/
index 8b1797f111e713e8e048684f2fc84f8412a76496..118f132ca9d78162b22c85d1997ab77c0e1cb342 100644 (file)
@@ -633,6 +633,18 @@ DefaultFetch<Impl>::finishTranslation(Fault fault, RequestPtr mem_req)
 
     // If translation was successful, attempt to read the icache block.
     if (fault == NoFault) {
+        // Check that we're not going off into random memory
+        // If we have, just wait around for commit to squash something and put
+        // us on the right track
+        if (!cpu->system->isMemory(mem_req->getPaddr())) {
+            warn("Address %#x is outside of physical memory, stopping fetch\n",
+                    mem_req->getPaddr());
+            fetchStatus[tid] = NoGoodAddr;
+            delete mem_req;
+            memReq[tid] = NULL;
+            return;
+        }
+
         // Build packet here.
         PacketPtr data_pkt = new Packet(mem_req,
                                         MemCmd::ReadReq, Packet::Broadcast);
@@ -1162,9 +1174,13 @@ DefaultFetch<Impl>::fetch(bool &status_change)
         } else if (fetchStatus[tid] == TrapPending) {
             DPRINTF(Fetch, "[tid:%i]: Fetch is waiting for a pending trap\n",
                     tid);
+        } else if (fetchStatus[tid] == NoGoodAddr) {
+            DPRINTF(Fetch, "[tid:%i]: Fetch predicted non-executable address\n",
+                    tid);
         }
 
 
+
         // Status is Idle, Squashing, Blocked, ItlbWait or IcacheWaitResponse
         // so fetch should do nothing.
         return;
index 4dd8797836e1168dcfd54e7e00cb0eb4d128e11d..1b5fbf226f57cc56c5c06fddcfd193456c47c098 100644 (file)
@@ -184,7 +184,7 @@ class VectorParamValue(list):
         return [ v.getValue() for v in self ]
 
     def unproxy(self, base):
-        if len(self) == 1 and isinstance(self[0], AllProxy):
+        if len(self) == 1 and isinstance(self[0], proxy.AllProxy):
             return self[0].unproxy(base)
         else:
              return [v.unproxy(base) for v in self]
index fd707c353079c7ec7e3ef9f0c290fdffe2464684..a6897d8344b25ab58d6470cc0ed098c3bfd6b191 100644 (file)
@@ -44,8 +44,9 @@ class System(SimObject):
     def swig_objdecls(cls, code):
         code('%include "python/swig/system.i"')
 
-    physmem = Param.PhysicalMemory(Parent.any, "physical memory")
+    physmem = Param.PhysicalMemory("Physical Memory")
     mem_mode = Param.MemoryMode('atomic', "The mode the memory system is in")
+    memories = VectorParam.PhysicalMemory(Self.all, "All memories is the system")
 
     work_item_id = Param.Int(-1, "specific work item id")
     work_begin_cpu_id_exit = Param.Int(-1,
index bb8eccf148e908519d16d9a10c25c74661b0f28b..81a8a05742b405e45552eb5c5f9773226fce52b0 100644 (file)
@@ -83,6 +83,16 @@ System::System(Params *p)
     // add self to global system list
     systemList.push_back(this);
 
+    /** Keep track of all memories we can execute code out of
+     * in our system
+     */
+    for (int x = 0; x < p->memories.size(); x++) {
+        if (!p->memories[x])
+            continue;
+        memRanges.push_back(RangeSize(p->memories[x]->start(),
+                                      p->memories[x]->size()));
+    }
+
 #if FULL_SYSTEM
     kernelSymtab = new SymbolTable;
     if (!debugSymbolTable)
@@ -288,6 +298,17 @@ System::freeMemSize()
 
 #endif
 
+bool
+System::isMemory(const Addr addr) const
+{
+    std::list<Range<Addr> >::const_iterator i;
+    for (i = memRanges.begin(); i != memRanges.end(); i++) {
+        if (*i == addr)
+            return true;
+    }
+    return false;
+}
+
 void
 System::resume()
 {
index 0be16247fd8a911291b060af5f51cd0fbec108bd..a6bc47fc0b62137ceab10abb9a63d0415d2b8732 100644 (file)
@@ -105,6 +105,14 @@ class System : public SimObject
      * system.  These threads could be Active or Suspended. */
     int numRunningContexts();
 
+    /** List to store ranges of memories in this system */
+    AddrRangeList memRanges;
+
+    /** check if an address points to valid system memory
+     * and thus we can fetch instructions out of it
+     */
+    bool isMemory(const Addr addr) const;
+
 #if FULL_SYSTEM
     Platform *platform;
     uint64_t init_param;