From 32b0eb07718ddac1cd6f0cc4c8a0c9b1d7765952 Mon Sep 17 00:00:00 2001 From: Hsuan Hsu Date: Tue, 3 Mar 2020 17:28:44 +0800 Subject: [PATCH] cpu-o3: Fix unset scoreboard in vector mode switching This is another fix for the AArch32-AArch64 interprocessing issue introduced in 3d15150d cpu, arch, arch-arm: Wire unused VecElem code in the O3 model. Register mapping between AArch32 and AArch64 is explicitly defined in ARMv8 manual. This allows software to read registers right after a state switch without writing them first, and it is indeed common for software to save registers to memory first before using them. In gem5's implementation of vector mode switching, however, vectors may not be marked as ready right after a state switch. Software reads toward vectors at this time will stall O3CPU forever. This patch fixes this by marking all mapped vectors (or vector elements, depending on AArch32 or AArch64) as ready right after switching vector mode. Change-Id: I609552c543dad8da66939c0a3079d73d48e92163 Signed-off-by: Hsuan Hsu Signed-off-by: Howard Wang Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26203 Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini Tested-by: kokoro --- src/cpu/o3/cpu.cc | 23 +++++++++++++++++++++++ src/cpu/o3/cpu.hh | 6 ++++++ 2 files changed, 29 insertions(+) diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index e2c727008..5f0a98b24 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -844,6 +844,28 @@ FullO3CPU::removeThread(ThreadID tid) */ } +template +void +FullO3CPU::setVectorsAsReady(ThreadID tid) +{ + if (vecMode == Enums::Elem) { + for (auto v = 0; v < TheISA::NumVecRegs; v++) + for (auto e = 0; e < TheISA::NumVecElemPerVecReg; e++) + scoreboard.setReg( + commitRenameMap[tid].lookup( + RegId(VecElemClass, v, e) + ) + ); + } else if (vecMode == Enums::Full) { + for (auto v = 0; v < TheISA::NumVecRegs; v++) + scoreboard.setReg( + commitRenameMap[tid].lookup( + RegId(VecRegClass, v) + ) + ); + } +} + template void FullO3CPU::switchRenameMode(ThreadID tid, UnifiedFreeList* freelist) @@ -860,6 +882,7 @@ FullO3CPU::switchRenameMode(ThreadID tid, UnifiedFreeList* freelist) renameMap[tid].switchMode(vecMode); commitRenameMap[tid].switchMode(vecMode); renameMap[tid].switchFreeList(freelist); + setVectorsAsReady(tid); } } diff --git a/src/cpu/o3/cpu.hh b/src/cpu/o3/cpu.hh index 01f58dfd3..c3d911b97 100644 --- a/src/cpu/o3/cpu.hh +++ b/src/cpu/o3/cpu.hh @@ -313,6 +313,12 @@ class FullO3CPU : public BaseO3CPU /** Traps to handle given fault. */ void trap(const Fault &fault, ThreadID tid, const StaticInstPtr &inst); + /** + * Mark vector fields in scoreboard as ready right after switching + * vector mode, since software may read vectors at this time. + */ + void setVectorsAsReady(ThreadID tid); + /** Check if a change in renaming is needed for vector registers. * The vecMode variable is updated and propagated to rename maps. * -- 2.30.2