From 6cbd2f85e783c64e9c5ae54e090308d13a08023d Mon Sep 17 00:00:00 2001 From: Aditya Badole Date: Wed, 27 Sep 2023 13:57:57 +0800 Subject: [PATCH] Fix bug with forwarded store using the wrong reqIdx Forwarded store should index into the data array with the store request's reqIdx Change-Id: I65a5e9a523061960849234d4cf030e3f75599c19 --- src/arch/riscvcapstone/o3/lsq_unit.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/arch/riscvcapstone/o3/lsq_unit.cc b/src/arch/riscvcapstone/o3/lsq_unit.cc index d4971fc6e3..245dea3c00 100644 --- a/src/arch/riscvcapstone/o3/lsq_unit.cc +++ b/src/arch/riscvcapstone/o3/lsq_unit.cc @@ -1557,9 +1557,12 @@ LSQUnit::read(LSQRequest *request, ssize_t load_idx) if (coverage == AddrRangeCoverage::FullAddrRangeCoverage) { DPRINTF(LSQUnit, "read: FullAddrRangeCoverage sn:%d\n", load_inst->seqNum); // Get shift amount for offset into the store's data. + // Will only work for insts with a single store int shift_amt = request->mainReq()->getVaddr() - store_it->instruction()->effAddr; + const LSQRequest* store_req = store_it->request(); + // Allocate memory if this is the first time a load is issued. if (!mem_data) { mem_data = @@ -1570,7 +1573,7 @@ LSQUnit::read(LSQRequest *request, ssize_t load_idx) request->mainReq()->getSize()); else memcpy(mem_data, - store_it->data(request->reqIdx) + shift_amt, + store_it->data(store_req->reqIdx) + shift_amt, request->mainReq()->getSize()); DPRINTF(LSQUnit, "Forwarding from store idx %i to load to "