diff options
author | Alec Roelke <ar4jc@virginia.edu> | 2017-03-21 12:58:25 -0400 |
---|---|---|
committer | Alec Roelke <ar4jc@virginia.edu> | 2017-04-05 20:21:59 +0000 |
commit | a8f1f9811c3fdb1cf59f6d37540ad40e4699561f (patch) | |
tree | 2fea02557b6c8d72b1c6c5a411f97fd567c67b50 /tests | |
parent | 6b7d30688d44952fcbb98b3e0f2bfc5155f1f9a5 (diff) | |
download | gem5-a8f1f9811c3fdb1cf59f6d37540ad40e4699561f.tar.xz |
riscv: fix Linux problems with LR and SC ops
Some of the functions in the Linux toolchain that allocate memory make
use of paired LR and SC instructions, which didn't work properly for
that toolchain. This patch fixes that so attempting to use those
functions doesn't cause an endless loop of failed SC instructions.
Change-Id: If27696323dd6229a0277818e3744fbdf7180fca7
Reviewed-on: https://gem5-review.googlesource.com/2340
Maintainer: Alec Roelke <ar4jc@virginia.edu>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-progs/insttest/src/riscv/rv64a.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/tests/test-progs/insttest/src/riscv/rv64a.cpp b/tests/test-progs/insttest/src/riscv/rv64a.cpp index 55150fbc3..a6e226c04 100644 --- a/tests/test-progs/insttest/src/riscv/rv64a.cpp +++ b/tests/test-progs/insttest/src/riscv/rv64a.cpp @@ -40,12 +40,16 @@ int main() using namespace insttest; // Memory (LR.W, SC.W) - expect<pair<int64_t, uint64_t>>({-1, 0}, []{ + expect<pair<int64_t, int64_t>>({-1, 256}, []{ int32_t mem = -1; int64_t rs2 = 256; - int64_t rd = A::lr_w(mem); - pair<int64_t, uint64_t> result = A::sc_w(rs2, mem); - return pair<int64_t, uint64_t>(rd, result.second); + int64_t rd; + pair<int64_t, uint64_t> result; + do { + rd = A::lr_w(mem); + result = A::sc_w(rs2, mem); + } while (result.second == 1); + return pair<int64_t, uint64_t>(rd, result.first); }, "lr.w/sc.w"); expect<pair<bool, int64_t>>({true, 200}, []{ int32_t mem = 200; @@ -130,12 +134,16 @@ int main() "amomaxu.w, sign extend"); // Memory (LR.D, SC.D) - expect<pair<int64_t, uint64_t>>({-1, 0}, []{ + expect<pair<int64_t, int64_t>>({-1, 256}, []{ int64_t mem = -1; int64_t rs2 = 256; - int64_t rd = A::lr_d(mem); - pair<int64_t, uint64_t> result = A::sc_d(rs2, mem); - return pair<int64_t, uint64_t>(rd, result.second); + int64_t rd; + pair<int64_t, uint64_t> result; + do { + rd = A::lr_d(mem); + result = A::sc_d(rs2, mem); + } while (result.second == 1); + return pair<int64_t, uint64_t>(rd, result.first); }, "lr.d/sc.d"); expect<pair<bool, int64_t>>({true, 200}, []{ int64_t mem = 200; |