From b4add16f4923a782f79b478d980791ec1d0bee06 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Mon, 23 Mar 2020 12:41:05 -0700 Subject: Don't acquire load reservation in the event of a fault I think this bug wasn't caught because OS code never steps over faulting LR instructions in practice. The exception is either fatal (in which case the point is moot) or the LR is re-executed (in which case the point is also moot). Resolves #431 --- riscv/insns/lr_d.h | 3 ++- riscv/insns/lr_w.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/riscv/insns/lr_d.h b/riscv/insns/lr_d.h index 52090c3..3f3521b 100644 --- a/riscv/insns/lr_d.h +++ b/riscv/insns/lr_d.h @@ -1,4 +1,5 @@ require_extension('A'); require_rv64; +auto res = MMU.load_int64(RS1); MMU.acquire_load_reservation(RS1); -WRITE_RD(MMU.load_int64(RS1)); +WRITE_RD(res); diff --git a/riscv/insns/lr_w.h b/riscv/insns/lr_w.h index c5845a6..8605cc5 100644 --- a/riscv/insns/lr_w.h +++ b/riscv/insns/lr_w.h @@ -1,3 +1,4 @@ require_extension('A'); +auto res = MMU.load_int32(RS1); MMU.acquire_load_reservation(RS1); -WRITE_RD(MMU.load_int32(RS1)); +WRITE_RD(res); -- cgit v1.1