From a8f1f9811c3fdb1cf59f6d37540ad40e4699561f Mon Sep 17 00:00:00 2001 From: Alec Roelke Date: Tue, 21 Mar 2017 12:58:25 -0400 Subject: 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 Reviewed-by: Jason Lowe-Power --- tests/test-progs/insttest/src/riscv/rv64a.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'tests') 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>({-1, 0}, []{ + expect>({-1, 256}, []{ int32_t mem = -1; int64_t rs2 = 256; - int64_t rd = A::lr_w(mem); - pair result = A::sc_w(rs2, mem); - return pair(rd, result.second); + int64_t rd; + pair result; + do { + rd = A::lr_w(mem); + result = A::sc_w(rs2, mem); + } while (result.second == 1); + return pair(rd, result.first); }, "lr.w/sc.w"); expect>({true, 200}, []{ int32_t mem = 200; @@ -130,12 +134,16 @@ int main() "amomaxu.w, sign extend"); // Memory (LR.D, SC.D) - expect>({-1, 0}, []{ + expect>({-1, 256}, []{ int64_t mem = -1; int64_t rs2 = 256; - int64_t rd = A::lr_d(mem); - pair result = A::sc_d(rs2, mem); - return pair(rd, result.second); + int64_t rd; + pair result; + do { + rd = A::lr_d(mem); + result = A::sc_d(rs2, mem); + } while (result.second == 1); + return pair(rd, result.first); }, "lr.d/sc.d"); expect>({true, 200}, []{ int64_t mem = 200; -- cgit v1.2.3