misc: Merge branch release-staging-v21-2 into develop

Change-Id: I8200ac51c20117f63b51d555fa2f12e5dd35f22e
diff --git a/src/arch/arm/remote_gdb.cc b/src/arch/arm/remote_gdb.cc
index 2efa82f..6e8923e 100644
--- a/src/arch/arm/remote_gdb.cc
+++ b/src/arch/arm/remote_gdb.cc
@@ -168,6 +168,20 @@
 
 using namespace ArmISA;
 
+namespace
+{
+
+// https://sourceware.org/gdb/current/onlinedocs/gdb/ARM-Breakpoint-Kinds.html
+enum class ArmBpKind
+{
+    THUMB = 2,
+    THUMB_2 = 3,
+    ARM = 4,
+};
+
+} // namespace
+
+
 static bool
 tryTranslate(ThreadContext *tc, Addr addr)
 {
@@ -362,10 +376,16 @@
 }
 
 bool
-RemoteGDB::checkBpLen(size_t len)
+RemoteGDB::checkBpKind(size_t kind)
 {
-    // 2 for Thumb ISA, 4 for ARM ISA.
-    return len == 2 || len == 4;
+    switch (ArmBpKind(kind)) {
+      case ArmBpKind::THUMB:
+      case ArmBpKind::THUMB_2:
+      case ArmBpKind::ARM:
+        return true;
+      default:
+        return false;
+    }
 }
 
 } // namespace gem5
diff --git a/src/arch/arm/remote_gdb.hh b/src/arch/arm/remote_gdb.hh
index cff6d4a..8e512a4 100644
--- a/src/arch/arm/remote_gdb.hh
+++ b/src/arch/arm/remote_gdb.hh
@@ -120,7 +120,7 @@
   public:
     RemoteGDB(System *_system, int _port);
     BaseGdbRegCache *gdbRegs() override;
-    bool checkBpLen(size_t len) override;
+    bool checkBpKind(size_t kind) override;
     std::vector<std::string>
     availableFeatures() const override
     {
diff --git a/src/arch/riscv/decoder.cc b/src/arch/riscv/decoder.cc
index 4fbcc64..a02415f 100644
--- a/src/arch/riscv/decoder.cc
+++ b/src/arch/riscv/decoder.cc
@@ -105,8 +105,10 @@
 
     if (compressed(emi)) {
         next_pc.npc(next_pc.instAddr() + sizeof(machInst) / 2);
+        next_pc.compressed(true);
     } else {
         next_pc.npc(next_pc.instAddr() + sizeof(machInst));
+        next_pc.compressed(false);
     }
 
     return decode(emi, next_pc.instAddr());
diff --git a/src/arch/riscv/remote_gdb.hh b/src/arch/riscv/remote_gdb.hh
index 40fe821..753859f 100644
--- a/src/arch/riscv/remote_gdb.hh
+++ b/src/arch/riscv/remote_gdb.hh
@@ -56,7 +56,7 @@
 
     bool acc(Addr addr, size_t len) override;
     // A breakpoint will be 2 bytes if it is compressed and 4 if not
-    bool checkBpLen(size_t len) override { return len == 2 || len == 4; }
+    bool checkBpKind(size_t kind) override { return kind == 2 || kind == 4; }
 
     class RiscvGdbRegCache : public BaseGdbRegCache
     {
diff --git a/src/arch/x86/remote_gdb.hh b/src/arch/x86/remote_gdb.hh
index 62176a5..dfa9177 100644
--- a/src/arch/x86/remote_gdb.hh
+++ b/src/arch/x86/remote_gdb.hh
@@ -58,7 +58,7 @@
 {
   protected:
     bool acc(Addr addr, size_t len);
-    bool checkBpLen(size_t len) { return len == 1; }
+    bool checkBpKind(size_t kind) { return kind == 1; }
     class X86GdbRegCache : public BaseGdbRegCache
     {
       using BaseGdbRegCache::BaseGdbRegCache;
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 1437b75..798d09f 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -784,28 +784,28 @@
 }
 
 void
-BaseRemoteGDB::insertSoftBreak(Addr addr, size_t len)
+BaseRemoteGDB::insertSoftBreak(Addr addr, size_t kind)
 {
-    if (!checkBpLen(len))
-        throw BadClient("Invalid breakpoint length\n");
+    if (!checkBpKind(kind))
+        throw BadClient("Invalid breakpoint kind.\n");
 
-    return insertHardBreak(addr, len);
+    return insertHardBreak(addr, kind);
 }
 
 void
-BaseRemoteGDB::removeSoftBreak(Addr addr, size_t len)
+BaseRemoteGDB::removeSoftBreak(Addr addr, size_t kind)
 {
-    if (!checkBpLen(len))
-        throw BadClient("Invalid breakpoint length.\n");
+    if (!checkBpKind(kind))
+        throw BadClient("Invalid breakpoint kind.\n");
 
-    return removeHardBreak(addr, len);
+    return removeHardBreak(addr, kind);
 }
 
 void
-BaseRemoteGDB::insertHardBreak(Addr addr, size_t len)
+BaseRemoteGDB::insertHardBreak(Addr addr, size_t kind)
 {
-    if (!checkBpLen(len))
-        throw BadClient("Invalid breakpoint length\n");
+    if (!checkBpKind(kind))
+        throw BadClient("Invalid breakpoint kind.\n");
 
     DPRINTF(GDBMisc, "Inserting hardware breakpoint at %#x\n", addr);
 
@@ -817,10 +817,10 @@
 }
 
 void
-BaseRemoteGDB::removeHardBreak(Addr addr, size_t len)
+BaseRemoteGDB::removeHardBreak(Addr addr, size_t kind)
 {
-    if (!checkBpLen(len))
-        throw BadClient("Invalid breakpoint length\n");
+    if (!checkBpKind(kind))
+        throw BadClient("Invalid breakpoint kind.\n");
 
     DPRINTF(GDBMisc, "Removing hardware breakpoint at %#x\n", addr);
 
@@ -917,7 +917,7 @@
 };
 
 bool
-BaseRemoteGDB::checkBpLen(size_t len)
+BaseRemoteGDB::checkBpKind(size_t kind)
 {
     return true;
 }
@@ -1302,17 +1302,17 @@
     Addr addr = hex2i(&p);
     if (*p++ != ',')
         throw CmdError("E0D");
-    size_t len = hex2i(&p);
+    size_t kind = hex2i(&p);
 
-    DPRINTF(GDBMisc, "clear %s, addr=%#x, len=%d\n",
-            breakType(sub_cmd), addr, len);
+    DPRINTF(GDBMisc, "clear %s, addr=%#x, kind=%d\n",
+            breakType(sub_cmd), addr, kind);
 
     switch (sub_cmd) {
       case GdbSoftBp:
-        removeSoftBreak(addr, len);
+        removeSoftBreak(addr, kind);
         break;
       case GdbHardBp:
-        removeHardBreak(addr, len);
+        removeHardBreak(addr, kind);
         break;
       case GdbWriteWp:
       case GdbReadWp:
@@ -1335,17 +1335,17 @@
     Addr addr = hex2i(&p);
     if (*p++ != ',')
         throw CmdError("E0D");
-    size_t len = hex2i(&p);
+    size_t kind = hex2i(&p);
 
-    DPRINTF(GDBMisc, "set %s, addr=%#x, len=%d\n",
-            breakType(sub_cmd), addr, len);
+    DPRINTF(GDBMisc, "set %s, addr=%#x, kind=%d\n",
+            breakType(sub_cmd), addr, kind);
 
     switch (sub_cmd) {
       case GdbSoftBp:
-        insertSoftBreak(addr, len);
+        insertSoftBreak(addr, kind);
         break;
       case GdbHardBp:
-        insertHardBreak(addr, len);
+        insertHardBreak(addr, kind);
         break;
       case GdbWriteWp:
       case GdbReadWp:
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index 59bccc5..b297e08 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -313,10 +313,10 @@
     void descheduleInstCommitEvent(Event *ev);
 
     // Breakpoints.
-    void insertSoftBreak(Addr addr, size_t len);
-    void removeSoftBreak(Addr addr, size_t len);
-    void insertHardBreak(Addr addr, size_t len);
-    void removeHardBreak(Addr addr, size_t len);
+    void insertSoftBreak(Addr addr, size_t kind);
+    void removeSoftBreak(Addr addr, size_t kind);
+    void insertHardBreak(Addr addr, size_t kind);
+    void removeHardBreak(Addr addr, size_t kind);
 
     /*
      * GDB commands.
@@ -401,8 +401,10 @@
     void encodeXferResponse(const std::string &unencoded,
         std::string &encoded, size_t offset, size_t unencoded_length) const;
 
-    // To be implemented by subclasses.
-    virtual bool checkBpLen(size_t len);
+    // checkBpKind checks if a kind of breakpoint is legal. This function should
+    // be implemented by subclasses by arch. The "kind" is considered to be
+    // breakpoint size in some arch.
+    virtual bool checkBpKind(size_t kind);
 
     virtual BaseGdbRegCache *gdbRegs() = 0;
 
diff --git a/src/base/sat_counter.hh b/src/base/sat_counter.hh
index 6644b05..a607c4c 100644
--- a/src/base/sat_counter.hh
+++ b/src/base/sat_counter.hh
@@ -340,9 +340,6 @@
 typedef GenericSatCounter<uint64_t> SatCounter64;
 /** @} */
 
-[[deprecated("Use SatCounter8 (or variants) instead")]]
-typedef SatCounter8 SatCounter;
-
 } // namespace gem5
 
 #endif // __BASE_SAT_COUNTER_HH__
diff --git a/src/mem/cache/cache.cc b/src/mem/cache/cache.cc
index 3c24343..466aeec 100644
--- a/src/mem/cache/cache.cc
+++ b/src/mem/cache/cache.cc
@@ -693,11 +693,16 @@
     bool is_invalidate = pkt->isInvalidate() &&
         !mshr->wasWholeLineWrite;
 
+    bool from_core = false;
+    bool from_pref = false;
+
     MSHR::TargetList targets = mshr->extractServiceableTargets(pkt);
     for (auto &target: targets) {
         Packet *tgt_pkt = target.pkt;
         switch (target.source) {
           case MSHR::Target::FromCPU:
+            from_core = true;
+
             Tick completion_time;
             // Here we charge on completion_time the delay of the xbar if the
             // packet comes from it, charged on headerDelay.
@@ -852,8 +857,8 @@
 
           case MSHR::Target::FromPrefetcher:
             assert(tgt_pkt->cmd == MemCmd::HardPFReq);
-            if (blk)
-                blk->setPrefetched();
+            from_pref = true;
+
             delete tgt_pkt;
             break;
 
@@ -882,6 +887,10 @@
         }
     }
 
+    if (blk && !from_core && from_pref) {
+        blk->setPrefetched();
+    }
+
     maintainClusivity(targets.hasFromCache, blk);
 
     if (blk && blk->isValid()) {
diff --git a/src/mem/cache/noncoherent_cache.cc b/src/mem/cache/noncoherent_cache.cc
index 314025f..9e95a20 100644
--- a/src/mem/cache/noncoherent_cache.cc
+++ b/src/mem/cache/noncoherent_cache.cc
@@ -245,6 +245,9 @@
     // First offset for critical word first calculations
     const int initial_offset = mshr->getTarget()->pkt->getOffset(blkSize);
 
+    bool from_core = false;
+    bool from_pref = false;
+
     MSHR::TargetList targets = mshr->extractServiceableTargets(pkt);
     for (auto &target: targets) {
         Packet *tgt_pkt = target.pkt;
@@ -254,6 +257,8 @@
             // handle deferred requests comming from a cache or core
             // above
 
+            from_core = true;
+
             Tick completion_time;
             // Here we charge on completion_time the delay of the xbar if the
             // packet comes from it, charged on headerDelay.
@@ -292,8 +297,7 @@
             // attached to this cache
             assert(tgt_pkt->cmd == MemCmd::HardPFReq);
 
-            if (blk)
-                blk->setPrefetched();
+            from_pref = true;
 
             // We have filled the block and the prefetcher does not
             // require responses.
@@ -307,6 +311,10 @@
         }
     }
 
+    if (blk && !from_core && from_pref) {
+        blk->setPrefetched();
+    }
+
     // Reponses are filling and bring in writable blocks, therefore
     // there should be no deferred targets and all the non-deferred
     // targets are now serviced.
diff --git a/src/mem/cache/prefetch/queued.cc b/src/mem/cache/prefetch/queued.cc
index 597c88a..da9cbf4 100644
--- a/src/mem/cache/prefetch/queued.cc
+++ b/src/mem/cache/prefetch/queued.cc
@@ -210,6 +210,10 @@
 
         if (!samePage(addr_prio.first, pfi.getAddr())) {
             statsQueued.pfSpanPage += 1;
+
+            if (hasBeenPrefetched(pkt->getAddr(), pkt->isSecure())) {
+                statsQueued.pfUsefulSpanPage += 1;
+            }
         }
 
         bool can_cross_page = (tlb != nullptr);
@@ -272,7 +276,9 @@
     ADD_STAT(pfRemovedFull, statistics::units::Count::get(),
              "number of prefetches dropped due to prefetch queue size"),
     ADD_STAT(pfSpanPage, statistics::units::Count::get(),
-             "number of prefetches that crossed the page")
+             "number of prefetches that crossed the page"),
+    ADD_STAT(pfUsefulSpanPage, statistics::units::Count::get(),
+             "number of prefetches that is useful and crossed the page")
 {
 }
 
diff --git a/src/mem/cache/prefetch/queued.hh b/src/mem/cache/prefetch/queued.hh
index 1062630..c769b38 100644
--- a/src/mem/cache/prefetch/queued.hh
+++ b/src/mem/cache/prefetch/queued.hh
@@ -185,6 +185,7 @@
         statistics::Scalar pfRemovedDemand;
         statistics::Scalar pfRemovedFull;
         statistics::Scalar pfSpanPage;
+        statistics::Scalar pfUsefulSpanPage;
     } statsQueued;
   public:
     using AddrPriority = std::pair<Addr, int32_t>;
diff --git a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc
index d0f4119..6030096 100644
--- a/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc
+++ b/src/mem/cache/prefetch/spatio_temporal_memory_streaming.cc
@@ -55,7 +55,8 @@
                          p.pattern_sequence_table_replacement_policy,
                          ActiveGenerationTableEntry(
                              spatialRegionSize / blkSize)),
-    rmob(p.region_miss_order_buffer_entries)
+    rmob(p.region_miss_order_buffer_entries),
+    lastTriggerCounter(0)
 {
     fatal_if(!isPowerOf2(spatialRegionSize),
         "The spatial region size must be a power of 2.");
diff --git a/src/systemc/core/SConscript b/src/systemc/core/SConscript
index 8805e9b..45bad4f 100644
--- a/src/systemc/core/SConscript
+++ b/src/systemc/core/SConscript
@@ -39,7 +39,6 @@
     Source('object.cc')
     Source('port.cc')
     Source('process.cc')
-    Source('scheduler.cc')
     Source('sched_event.cc')
     Source('sensitivity.cc')
     Source('time.cc')
@@ -72,3 +71,11 @@
                     append['CCFLAGS'] = [flag]
                     break
         Source('sc_time_python.cc', append=append)
+
+    # Disable the false positive warning for the event members of the scheduler.
+    with gem5_scons.Configure(main) as conf:
+        flag = '-Wno-free-nonheap-object'
+        append = {}
+        if conf.CheckCxxFlag(flag, autoadd=False):
+            append['CCFLAGS'] = [flag]
+        Source('scheduler.cc', append=append)
diff --git a/util/dockerfiles/gcn-gpu/Dockerfile b/util/dockerfiles/gcn-gpu/Dockerfile
index 4102d68..50d34bd 100644
--- a/util/dockerfiles/gcn-gpu/Dockerfile
+++ b/util/dockerfiles/gcn-gpu/Dockerfile
@@ -105,11 +105,11 @@
 RUN git clone -b rocm-4.0.0 \
     https://github.com/ROCmSoftwarePlatform/rocBLAS.git && mkdir rocBLAS/build
 
-ENV HCC_AMDGPU_TARGET=gfx801
+ENV HCC_AMDGPU_TARGET=gfx801,gfx803,gfx900,gfx902
 WORKDIR rocBLAS
-# rocBLAS needs to be built from source otherwise gfx801 gets an error in HIP
+# rocBLAS needs to be built from source otherwise certain gfx versions get errors in HIP
 # about there being no GPU binary available
-RUN ./install.sh -d -a all -i
+RUN ./install.sh -d -i
 WORKDIR /
 
 # MIOpen dependencies + MIOpen