Hello Giacomo Travaglini,

I'd like you to do a code review. Please visit


to review the following change.

Change subject: dev-arm: Verify number of CPUs when restoring Generic Timer Cpts.

dev-arm: Verify number of CPUs when restoring Generic Timer Cpts.

When restoring a checkpoint containing a generic timer, the checkpoint
expects to connect the timer to the same number of CPUs that were
present when the checkpoint was taken. If the number of CPUs in the
new simulation is different, deserialization will fail. In the case
that the number of CPUs expected by the checkpoint is greater than the
number of CPUs present, this will cause a segmentation fault caused by
reading off the end of the list of Thread Contexts.

This commit fixes the problem by checking the number of CPUs present
in the simulation matches the number of CPUs expected by the generic
timer checkpoint. If there is a mismatch, a fatal error is triggered
with an informative message to the user.

Change-Id: Iff9ad68d64e67b3df51682b7e4e272e5f355bcd6
Reviewed-by: Giacomo Travaglini <giacomo.travagl...@arm.com>
M src/dev/arm/generic_timer.cc
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/dev/arm/generic_timer.cc b/src/dev/arm/generic_timer.cc
index 4f92dac..1701ccd 100644
--- a/src/dev/arm/generic_timer.cc
+++ b/src/dev/arm/generic_timer.cc
@@ -415,6 +415,13 @@
         cpu_count = OLD_CPU_MAX;

+    if (cpu_count != system.numContexts()) {
+        fatal("The simulated system has been initialized with %d CPUs, "
+              "but the Generic Timer checkpoint expects %d CPUs. Consider "
+              "restoring the checkpoint specifying %d CPUs.",
+              system.numContexts(), cpu_count, cpu_count);
+    }
     for (int i = 0; i < cpu_count; ++i) {
         CoreTimers &core(getTimers(i));
         core.unserializeSection(cp, csprintf("pe_implementation%d", i));

To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/30576
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Iff9ad68d64e67b3df51682b7e4e272e5f355bcd6
Gerrit-Change-Number: 30576
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Cooper <richard.coo...@arm.com>
Gerrit-Reviewer: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-MessageType: newchange
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to