arch-arm: Override ISA::takeOverFrom for the Arm ISA
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Tue, 7 Apr 2020 13:01:56 +0000 (14:01 +0100)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Wed, 15 Apr 2020 07:34:09 +0000 (07:34 +0000)
This is fixing switcheroo tests when using a PMU/GICv3.  When you switch
cpus you usually instantiate multiple cpus at the beginning and you
switch them at runtime with the m5.switchCpus function.

Every cpu will have its own set of ThreadContexts/ISAs.
When you switch cpu/tc/isa, you need to update the tc/isa pointer
cached in the device model otherwise those will still reference
the switched out cpu.

Change-Id: I3aeee890286851189c3a8a4d378c83f32e973361
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27713
Reviewed-by: Ciro Santilli <ciro.santilli@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/arm/isa.cc
src/arch/arm/isa.hh

index a3e0ce6c2b32a1df3a39c6ec5d0f392af67d7146..b3d6726d9292d42b193a032ebe1924fa86ccc6ee 100644 (file)
@@ -437,6 +437,16 @@ ISA::startup(ThreadContext *tc)
     afterStartup = true;
 }
 
+void
+ISA::takeOverFrom(ThreadContext *new_tc, ThreadContext *old_tc)
+{
+    pmu->setThreadContext(new_tc);
+
+    if (system && gicv3CpuInterface) {
+        gicv3CpuInterface->setISA(this);
+        gicv3CpuInterface->setThreadContext(new_tc);
+    }
+}
 
 RegVal
 ISA::readMiscRegNoEffect(int misc_reg) const
index 8f2e0d26b4f3cad7a70718a22c4286f4148a51a6..5fec2dbb94027841c2301d556e496b1d22e800e9 100644 (file)
@@ -743,6 +743,9 @@ namespace ArmISA
 
         void startup(ThreadContext *tc);
 
+        void takeOverFrom(ThreadContext *new_tc,
+                          ThreadContext *old_tc) override;
+
         Enums::DecoderFlavor decoderFlavor() const { return _decoderFlavor; }
 
         /** Returns true if the ISA has a GICv3 cpu interface */