Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/25268 )

Change subject: fastmodel: Use all possible address spaces when setting up a bp.
......................................................................

fastmodel: Use all possible address spaces when setting up a bp.

gem5 does not historically distinguish between address spaces when
interacting with gdb, and gdb doesn't really give it any address space
information to work with. To ensure we catch whatever address space
we might be in by the time we get to the interesting address, we'll set
a breakpoint in all possible address spaces simultaneously with the
expectation that we'll hit one of them.

Change-Id: I9f4b93d04914db7a3c42be6236a523d35194afda
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/25268
Tested-by: kokoro <noreply+kok...@google.com>
Maintainer: Gabe Black <gabebl...@google.com>
Reviewed-by: Chun-Chen TK Hsu <chunchen...@google.com>
---
M src/arch/arm/fastmodel/CortexA76/thread_context.cc
M src/arch/arm/fastmodel/CortexA76/thread_context.hh
M src/arch/arm/fastmodel/iris/thread_context.cc
M src/arch/arm/fastmodel/iris/thread_context.hh
4 files changed, 31 insertions(+), 27 deletions(-)

Approvals:
  Chun-Chen TK Hsu: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/arch/arm/fastmodel/CortexA76/thread_context.cc b/src/arch/arm/fastmodel/CortexA76/thread_context.cc
index 6c4a4df..4016d2b 100644
--- a/src/arch/arm/fastmodel/CortexA76/thread_context.cc
+++ b/src/arch/arm/fastmodel/CortexA76/thread_context.cc
@@ -180,20 +180,23 @@
     Iris::ThreadContext::setCCRegFlat(idx, val);
 }

-iris::MemorySpaceId
-CortexA76TC::getBpSpaceId(Addr pc) const
+const std::vector<iris::MemorySpaceId> &
+CortexA76TC::getBpSpaceIds() const
 {
-    if (bpSpaceId == iris::IRIS_UINT64_MAX) {
+    if (bpSpaceIds.empty()) {
         for (auto &space: memorySpaces) {
-            if (space.canonicalMsn == Iris::CurrentMsn) {
-                bpSpaceId = space.spaceId;
-                break;
+            auto cmsn = space.canonicalMsn;
+            if (cmsn == Iris::SecureMonitorMsn ||
+                    cmsn == Iris::GuestMsn ||
+                    cmsn == Iris::NsHypMsn ||
+                    cmsn == Iris::HypAppMsn) {
+                bpSpaceIds.push_back(space.spaceId);
             }
         }
-        panic_if(bpSpaceId == iris::IRIS_UINT64_MAX,
-                "Unable to find address space for breakpoints.");
+        panic_if(bpSpaceIds.empty(),
+                "Unable to find address space(s) for breakpoints.");
     }
-    return bpSpaceId;
+    return bpSpaceIds;
 }

 Iris::ThreadContext::IdxNameMap CortexA76TC::miscRegIdxNameMap({
@@ -943,6 +946,6 @@
         { 28, "V28" }, { 29, "V29" }, { 30, "V30" }, { 31, "V31" }
 });

-iris::MemorySpaceId CortexA76TC::bpSpaceId = iris::IRIS_UINT64_MAX;
+std::vector<iris::MemorySpaceId> CortexA76TC::bpSpaceIds;

 } // namespace FastModel
diff --git a/src/arch/arm/fastmodel/CortexA76/thread_context.hh b/src/arch/arm/fastmodel/CortexA76/thread_context.hh
index 8f833e5..344a508 100644
--- a/src/arch/arm/fastmodel/CortexA76/thread_context.hh
+++ b/src/arch/arm/fastmodel/CortexA76/thread_context.hh
@@ -44,7 +44,7 @@
     static IdxNameMap flattenedIntIdxNameMap;
     static IdxNameMap ccRegIdxNameMap;
     static IdxNameMap vecRegIdxNameMap;
-    static iris::MemorySpaceId bpSpaceId;
+    static std::vector<iris::MemorySpaceId> bpSpaceIds;

   public:
     CortexA76TC(::BaseCPU *cpu, int id, System *system,
@@ -62,7 +62,7 @@
     RegVal readCCRegFlat(RegIndex idx) const override;
     void setCCRegFlat(RegIndex idx, RegVal val) override;

-    iris::MemorySpaceId getBpSpaceId(Addr pc) const override;
+    const std::vector<iris::MemorySpaceId> &getBpSpaceIds() const override;
 };

 } // namespace FastModel
diff --git a/src/arch/arm/fastmodel/iris/thread_context.cc b/src/arch/arm/fastmodel/iris/thread_context.cc
index 547a4c4..98fc09e 100644
--- a/src/arch/arm/fastmodel/iris/thread_context.cc
+++ b/src/arch/arm/fastmodel/iris/thread_context.cc
@@ -132,18 +132,21 @@
 void
 ThreadContext::installBp(BpInfoIt it)
 {
-    BpId id;
     Addr pc = it->second->pc;
-    auto space_id = getBpSpaceId(pc);
-    call().breakpoint_set_code(_instId, id, pc, space_id, 0, true);
-    it->second->id = id;
+    const auto &space_ids = getBpSpaceIds();
+    for (auto sid: space_ids) {
+        BpId id;
+        call().breakpoint_set_code(_instId, id, pc, sid, 0, true);
+        it->second->ids.push_back(id);
+    }
 }

 void
 ThreadContext::uninstallBp(BpInfoIt it)
 {
-    call().breakpoint_delete(_instId, it->second->id);
-    it->second->clearId();
+    for (auto id: it->second->ids)
+        call().breakpoint_delete(_instId, id);
+    it->second->clearIds();
 }

 void
@@ -152,7 +155,7 @@
     panic_if(!it->second->empty(),
              "BP info still had events associated with it.");

-    if (it->second->validId())
+    if (it->second->validIds())
         uninstallBp(it);

     bps.erase(it);
@@ -322,7 +325,7 @@
     auto it = getOrAllocBp(e->pc());
     it->second->events->push_back(e);

-    if (_instId != iris::IRIS_UINT64_MAX && !it->second->validId())
+    if (_instId != iris::IRIS_UINT64_MAX && !it->second->validIds())
         installBp(it);

     return true;
diff --git a/src/arch/arm/fastmodel/iris/thread_context.hh b/src/arch/arm/fastmodel/iris/thread_context.hh
index 89b0004..d4e80f1 100644
--- a/src/arch/arm/fastmodel/iris/thread_context.hh
+++ b/src/arch/arm/fastmodel/iris/thread_context.hh
@@ -109,17 +109,15 @@
     struct BpInfo
     {
         Addr pc;
-        BpId id;
+        std::vector<BpId> ids;
         using EventList = std::list<PCEvent *>;
         std::shared_ptr<EventList> events;

-        BpInfo(Addr _pc) : pc(_pc), id(iris::IRIS_UINT64_MAX),
-                           events(new EventList)
-        {}
+        BpInfo(Addr _pc) : pc(_pc), events(new EventList) {}

         bool empty() const { return events->empty(); }
-        bool validId() const { return id != iris::IRIS_UINT64_MAX; }
-        void clearId() { id = iris::IRIS_UINT64_MAX; }
+        bool validIds() const { return !ids.empty(); }
+        void clearIds() { ids.clear(); }
     };

     using BpInfoPtr = std::unique_ptr<BpInfo>;
@@ -134,7 +132,7 @@
     void uninstallBp(BpInfoIt it);
     void delBp(BpInfoIt it);

-    virtual iris::MemorySpaceId getBpSpaceId(Addr pc) const = 0;
+ virtual const std::vector<iris::MemorySpaceId> &getBpSpaceIds() const = 0;


     iris::IrisErrorCode instanceRegistryChanged(

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/25268
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I9f4b93d04914db7a3c42be6236a523d35194afda
Gerrit-Change-Number: 25268
Gerrit-PatchSet: 9
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Chun-Chen TK Hsu <chunchen...@google.com>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to