Skip to content

Commit

Permalink
Fix bug with forwarded store using the wrong reqIdx
Browse files Browse the repository at this point in the history
Forwarded store should index into the data array with the store request's reqIdx

Change-Id: I65a5e9a523061960849234d4cf030e3f75599c19
  • Loading branch information
hakase56557 committed Sep 27, 2023
1 parent 516f2ab commit 6cbd2f8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/arch/riscvcapstone/o3/lsq_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 "
Expand Down

0 comments on commit 6cbd2f8

Please sign in to comment.