From daaccaa9aee4e7f5ae091ff88f9a747665610a15 Mon Sep 17 00:00:00 2001 From: Yu-hsin Wang Date: Wed, 2 Nov 2022 17:23:42 +0800 Subject: [PATCH] fastmodel: skip vector registers update in remote gdb iris::ThreadContext doesn't implement the write interface for vector registers. Skip that part in fastmodel remote_gdb to make updating common registers work at least. Change-Id: Ifa071f5dff4bdeee7361ae824b4b76e0b2805460 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69177 Maintainer: Gabe Black Reviewed-by: Gabe Black Tested-by: kokoro --- src/arch/arm/fastmodel/remote_gdb.cc | 40 +++++++++++++++++++++++++++- src/arch/arm/fastmodel/remote_gdb.hh | 14 ++++++++-- src/arch/arm/remote_gdb.hh | 24 ++++++++--------- src/base/remote_gdb.hh | 2 +- 4 files changed, 64 insertions(+), 16 deletions(-) diff --git a/src/arch/arm/fastmodel/remote_gdb.cc b/src/arch/arm/fastmodel/remote_gdb.cc index e13fee8d70..d8dddaddf9 100644 --- a/src/arch/arm/fastmodel/remote_gdb.cc +++ b/src/arch/arm/fastmodel/remote_gdb.cc @@ -27,13 +27,42 @@ #include "arch/arm/fastmodel/remote_gdb.hh" #include "arch/arm/fastmodel/iris/thread_context.hh" +#include "arch/arm/utility.hh" +#include "base/trace.hh" +#include "debug/GDBAcc.hh" namespace gem5 { +using namespace ArmISA; + namespace fastmodel { +void +FastmodelRemoteGDB::AArch64GdbRegCache::setRegs(ThreadContext *context) const +{ + DPRINTF(GDBAcc, "setRegs in remotegdb \n"); + + for (int i = 0; i < 31; ++i) + context->setReg(int_reg::x(i), r.x[i]); + auto pc_state = context->pcState().as(); + pc_state.set(r.pc); + context->pcState(pc_state); + context->setMiscRegNoEffect(MISCREG_CPSR, r.cpsr); + // Update the stack pointer. This should be done after + // updating CPSR/PSTATE since that might affect how SPX gets + // mapped. + context->setReg(int_reg::Spx, r.spx); + + // Remove the vector registers update in FastmodelRemoteGDB since it's not + // implemented in iris::ThreadContext. + warn("Skip update vector registers in remotegdb\n"); + + context->setMiscRegNoEffect(MISCREG_FPSR, r.fpsr); + context->setMiscRegNoEffect(MISCREG_FPCR, r.fpcr); +} + FastmodelRemoteGDB::FastmodelRemoteGDB(System *_system, int port) - : gem5::ArmISA::RemoteGDB(_system, port) + : gem5::ArmISA::RemoteGDB(_system, port), regCache64(this) { } @@ -57,5 +86,14 @@ FastmodelRemoteGDB::writeBlob(Addr vaddr, size_t size, const char *data) return true; } +BaseGdbRegCache* +FastmodelRemoteGDB::gdbRegs() +{ + if (inAArch64(context())) + return ®Cache64; + else + return ®Cache32; +} + } // namespace fastmodel } // namespace gem5 diff --git a/src/arch/arm/fastmodel/remote_gdb.hh b/src/arch/arm/fastmodel/remote_gdb.hh index 93cf882e21..75dc6580e3 100644 --- a/src/arch/arm/fastmodel/remote_gdb.hh +++ b/src/arch/arm/fastmodel/remote_gdb.hh @@ -36,14 +36,24 @@ namespace gem5 namespace fastmodel { -class FastmodelRemoteGDB : public gem5::ArmISA::RemoteGDB +class FastmodelRemoteGDB : public ArmISA::RemoteGDB { public: FastmodelRemoteGDB(System *_system, int port); - private: + protected: + class AArch64GdbRegCache : public ArmISA::RemoteGDB::AArch64GdbRegCache + { + using ArmISA::RemoteGDB::AArch64GdbRegCache::AArch64GdbRegCache; + public: + void setRegs(ThreadContext*) const override; + }; + bool readBlob(Addr vaddr, size_t size, char *data) override; bool writeBlob(Addr vaddr, size_t size, const char *data) override; + BaseGdbRegCache* gdbRegs() override; + + AArch64GdbRegCache regCache64; }; } // namespace fastmodel diff --git a/src/arch/arm/remote_gdb.hh b/src/arch/arm/remote_gdb.hh index 8e512a452f..aeb2db6754 100644 --- a/src/arch/arm/remote_gdb.hh +++ b/src/arch/arm/remote_gdb.hh @@ -68,7 +68,7 @@ class RemoteGDB : public BaseRemoteGDB class AArch32GdbRegCache : public BaseGdbRegCache { using BaseGdbRegCache::BaseGdbRegCache; - private: + protected: struct GEM5_PACKED { uint32_t gpr[16]; @@ -77,12 +77,12 @@ class RemoteGDB : public BaseRemoteGDB uint32_t fpscr; } r; public: - char *data() const { return (char *)&r; } - size_t size() const { return sizeof(r); } - void getRegs(ThreadContext*); - void setRegs(ThreadContext*) const; + char *data() const override { return (char *)&r; } + size_t size() const override { return sizeof(r); } + void getRegs(ThreadContext*) override; + void setRegs(ThreadContext*) const override; const std::string - name() const + name() const override { return gdb->name() + ".AArch32GdbRegCache"; } @@ -91,7 +91,7 @@ class RemoteGDB : public BaseRemoteGDB class AArch64GdbRegCache : public BaseGdbRegCache { using BaseGdbRegCache::BaseGdbRegCache; - private: + protected: struct GEM5_PACKED { uint64_t x[31]; @@ -103,12 +103,12 @@ class RemoteGDB : public BaseRemoteGDB uint32_t fpcr; } r; public: - char *data() const { return (char *)&r; } - size_t size() const { return sizeof(r); } - void getRegs(ThreadContext*); - void setRegs(ThreadContext*) const; + char *data() const override { return (char *)&r; } + size_t size() const override { return sizeof(r); } + void getRegs(ThreadContext*) override; + void setRegs(ThreadContext*) const override; const std::string - name() const + name() const override { return gdb->name() + ".AArch64GdbRegCache"; } diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh index 7981a13064..80c108ba22 100644 --- a/src/base/remote_gdb.hh +++ b/src/base/remote_gdb.hh @@ -188,7 +188,7 @@ class BaseRemoteGDB return nullptr; } - private: + protected: /* * Connection to the external GDB. */