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

Change-Id: Icc03e585d87cf89ed844a0249c365cc296fa2d14
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/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/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/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)