summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Marinho <jose.marinho@arm.com>2017-06-21 13:41:04 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2017-07-20 09:38:47 +0000
commit8e8ad9daa3d7b35e0b570361dfce6f2ac1a8d8fe (patch)
tree73a2c207947a8a306885adde4af51de90a0ef806
parentc0875dfc398780a05dec68bbe36a17f73a98e030 (diff)
downloadgem5-8e8ad9daa3d7b35e0b570361dfce6f2ac1a8d8fe.tar.xz
sim: Prevent segfault in the wakeCpu m5op if id is invalid
Change-Id: I86229cedb206e10326cdee3f09a5c871e49c8d48 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/3965
-rw-r--r--src/sim/pseudo_inst.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index 8c2d26b00..778675fd3 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010-2012, 2015 ARM Limited
+ * Copyright (c) 2010-2012, 2015, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -285,6 +285,13 @@ wakeCPU(ThreadContext *tc, uint64_t cpuid)
{
DPRINTF(PseudoInst, "PseudoInst::wakeCPU(%i)\n", cpuid);
System *sys = tc->getSystemPtr();
+
+ if (sys->numContexts() <= cpuid) {
+ warn("PseudoInst::wakeCPU(%i), cpuid greater than number of contexts"
+ "(%i)\n",cpuid, sys->numContexts());
+ return;
+ }
+
ThreadContext *other_tc = sys->threadContexts[cpuid];
if (other_tc->status() == ThreadContext::Suspended)
other_tc->activate();