From c3acfdc9b89b60cfd6a426af24d25c5cf58ef2ae Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Wed, 18 Oct 2023 10:51:37 -0700 Subject: [PATCH] arch-riscv: Copy Misc Regs when swiching cpus (#479) Misc Regs might contain rather important information about the state of a core, e.g., information in CSR registers. This patch enforces copying the CSR registers when switching cpus. The bug and the proposed fix are reported here [1]. [1] https://github.com/gem5/gem5/issues/451 Change-Id: I611782e6e3bcd5530ddac346342a9e0e44b0f757 Signed-off-by: Hoa Nguyen --- src/arch/riscv/isa.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arch/riscv/isa.cc b/src/arch/riscv/isa.cc index 4cb5082cad..a1f4056bf5 100644 --- a/src/arch/riscv/isa.cc +++ b/src/arch/riscv/isa.cc @@ -294,6 +294,10 @@ ISA::copyRegsFrom(ThreadContext *src) tc->setReg(id, &vc); } + // Copying Misc Regs + for (int i = 0; i < NUM_MISCREGS; i++) + tc->setMiscRegNoEffect(i, src->readMiscRegNoEffect(i)); + // Lastly copy PC/NPC tc->pcState(src->pcState()); }