From 808e573cda930258e306133369cfbe54ea224514 Mon Sep 17 00:00:00 2001 From: Sungkeun Kim Date: Sat, 22 Aug 2020 15:55:33 -0500 Subject: [PATCH] cpu: Failure to restore RAS during squash MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit During squash of branch predictor history, RAS recovery mess up the stack because of function "restore" in RAS (src/cpu/pred/ras.cc). In restore function, it does not update "usedEntries" variable resulting in restore failure. To be specific, in order to remove mispredicted call, it uses pop() and it updates tos. However in order to restore mispredicted ret instruction, it uses restore() but it does not update tos. This pair of function call mess up the RAS resulting in many misspeculation. The solution is to update usedEntries variable as “push” function does. This is possible because restoration is done with reverse order of push and pop. Jira Issue: https://gem5.atlassian.net/browse/GEM5-732 Change-Id: Ia14e71c26d20b2795fd55a6a0dd3284c03570614 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33214 Reviewed-by: Trivikram Reddy Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/cpu/pred/ras.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cpu/pred/ras.cc b/src/cpu/pred/ras.cc index e07ac6aa9..33eec0ea4 100644 --- a/src/cpu/pred/ras.cc +++ b/src/cpu/pred/ras.cc @@ -74,4 +74,8 @@ ReturnAddrStack::restore(unsigned top_entry_idx, tos = top_entry_idx; addrStack[tos] = restored; + + if (usedEntries != numEntries) { + ++usedEntries; + } } -- 2.30.2