summaryrefslogtreecommitdiff
path: root/src/arch/generic
diff options
context:
space:
mode:
authorGabor Dozsa <gabor.dozsa@arm.com>2017-11-07 14:05:00 +0000
committerAndreas Sandberg <andreas.sandberg@arm.com>2018-10-02 11:51:44 +0000
commit9c687a6f70a7b88b8e8c125421c5f5e765b928a5 (patch)
tree4ef5b305ce55d7afa1e7159cac5eb2177ed8a279 /src/arch/generic
parent3afece061e063db27798288ec8dc9a378a320e02 (diff)
downloadgem5-9c687a6f70a7b88b8e8c125421c5f5e765b928a5.tar.xz
arch: Fix unserialization of VectorReg value
Change-Id: Iba01ae60e10703877eae299ba924fa1f04a4a387 Signed-off-by: Giacomo Gabrielli <giacomo.gabrielli@arm.com> Reviewed-on: https://gem5-review.googlesource.com/13104 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/arch/generic')
-rw-r--r--src/arch/generic/vec_reg.hh15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/arch/generic/vec_reg.hh b/src/arch/generic/vec_reg.hh
index b68a5886d..7145af4cf 100644
--- a/src/arch/generic/vec_reg.hh
+++ b/src/arch/generic/vec_reg.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015-2016 ARM Limited
+ * Copyright (c) 2015-2016, 2018 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -635,11 +635,14 @@ template <size_t Sz>
inline bool
to_number(const std::string& value, VecRegContainer<Sz>& v)
{
- int i = 0;
- while (i < Sz) {
- std::string byte = value.substr(i<<1, 2);
- v.template raw_ptr<uint8_t>()[i] = stoul(byte, 0, 16);
- i++;
+ fatal_if(value.size() > 2 * VecRegContainer<Sz>::SIZE,
+ "Vector register value overflow at unserialize");
+
+ for (int i = 0; i < VecRegContainer<Sz>::SIZE; i++) {
+ uint8_t b = 0;
+ if (2 * i < value.size())
+ b = stoul(value.substr(i * 2, 2), nullptr, 16);
+ v.template raw_ptr<uint8_t>()[i] = b;
}
return true;
}