From 231dc99c840f3abff0c387287d5d5f995c209632 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 24 Oct 2019 16:14:32 -0700 Subject: [PATCH] fastmodel: Determine what space to use for breakpoints dynamically. This was hardcoded as 5, but should be determined based on the memory space IDs the fast model returns. What we do now is have a specific override for ARM (perhaps conceptually the A76) which looks for an address space called "Current" which seems to work well. It's possible that the appropriate address space for a different model might have a different number, or even a different name. This may need to be further specialized/parameterized in those cases. Change-Id: Ie1ef99675fd9bccab50b7fc7add16b82a93bd60b Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22143 Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini Tested-by: kokoro --- .../arm/fastmodel/iris/arm/thread_context.cc | 18 ++++++++++++++++++ .../arm/fastmodel/iris/arm/thread_context.hh | 3 +++ src/arch/arm/fastmodel/iris/thread_context.cc | 5 +++-- src/arch/arm/fastmodel/iris/thread_context.hh | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/arch/arm/fastmodel/iris/arm/thread_context.cc b/src/arch/arm/fastmodel/iris/arm/thread_context.cc index 181d2686d..8a36ce3d3 100644 --- a/src/arch/arm/fastmodel/iris/arm/thread_context.cc +++ b/src/arch/arm/fastmodel/iris/arm/thread_context.cc @@ -145,6 +145,22 @@ ArmThreadContext::nextInstAddr() const return pcState().nextInstAddr(); } +iris::MemorySpaceId +ArmThreadContext::getBpSpaceId(Addr pc) const +{ + if (bpSpaceId == iris::IRIS_UINT64_MAX) { + for (auto &space: memorySpaces) { + if (space.canonicalMsn == CurrentMsn) { + bpSpaceId = space.spaceId; + break; + } + } + panic_if(bpSpaceId == iris::IRIS_UINT64_MAX, + "Unable to find address space for breakpoints."); + } + return bpSpaceId; +} + uint64_t ArmThreadContext::readIntReg(RegIndex reg_idx) const { @@ -882,4 +898,6 @@ Iris::ThreadContext::IdxNameMap ArmThreadContext::vecRegIdxNameMap({ { 28, "V28" }, { 29, "V29" }, { 30, "V30" }, { 31, "V31" } }); +iris::MemorySpaceId ArmThreadContext::bpSpaceId = iris::IRIS_UINT64_MAX; + } // namespace Iris diff --git a/src/arch/arm/fastmodel/iris/arm/thread_context.hh b/src/arch/arm/fastmodel/iris/arm/thread_context.hh index 6e28c3b8c..c7f26e3bd 100644 --- a/src/arch/arm/fastmodel/iris/arm/thread_context.hh +++ b/src/arch/arm/fastmodel/iris/arm/thread_context.hh @@ -44,6 +44,7 @@ class ArmThreadContext : public Iris::ThreadContext static IdxNameMap intReg32IdxNameMap; static IdxNameMap intReg64IdxNameMap; static IdxNameMap vecRegIdxNameMap; + static iris::MemorySpaceId bpSpaceId; // Temporary holding places for the vector reg accessors to return. // These are not updated live, only when requested. @@ -71,6 +72,8 @@ class ArmThreadContext : public Iris::ThreadContext ResourceIds intReg64Ids; ResourceIds vecRegIds; + iris::MemorySpaceId getBpSpaceId(Addr pc) const override; + void setIntReg(RegIndex reg_idx, RegVal val) override; RegVal readIntReg(RegIndex reg_idx) const override; TheISA::ISA * diff --git a/src/arch/arm/fastmodel/iris/thread_context.cc b/src/arch/arm/fastmodel/iris/thread_context.cc index 872136615..ebcd2b89a 100644 --- a/src/arch/arm/fastmodel/iris/thread_context.cc +++ b/src/arch/arm/fastmodel/iris/thread_context.cc @@ -134,8 +134,9 @@ void ThreadContext::installBp(BpInfoIt it) { BpId id; - // Hard code address space 5 for now. - call().breakpoint_set_code(_instId, id, it->second->pc, 5, 0, true); + 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; } diff --git a/src/arch/arm/fastmodel/iris/thread_context.hh b/src/arch/arm/fastmodel/iris/thread_context.hh index 4175e9363..cab9ebc57 100644 --- a/src/arch/arm/fastmodel/iris/thread_context.hh +++ b/src/arch/arm/fastmodel/iris/thread_context.hh @@ -119,6 +119,8 @@ class ThreadContext : public ::ThreadContext void uninstallBp(BpInfoIt it); void delBp(BpInfoIt it); + virtual iris::MemorySpaceId getBpSpaceId(Addr pc) const = 0; + iris::IrisErrorCode instanceRegistryChanged( uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, -- 2.30.2