Skip to content

Commit

Permalink
Fix translation and node command issue for init cap
Browse files Browse the repository at this point in the history
Change-Id: I04a7d88402af91fdbbb460bf3300b467044d032c
  • Loading branch information
hakase56557 committed Sep 21, 2023
1 parent a725b76 commit 9187a2d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/arch/riscvcapstone/o3/cpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ CPU::startup()
ctrv.getRegVal().rawCapVal() = (uint128_t)*cap;
isa[tid]->setTaggedMiscReg(1, ctrv); //capmiscreg_cinit

cwrld[tid] = 0;
cwrld[tid] = 1;
}
}

Expand Down
68 changes: 35 additions & 33 deletions src/arch/riscvcapstone/o3/lsq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -848,42 +848,44 @@ LSQ::pushRequest(const DynInstPtr& inst, bool isLoad, uint8_t *data,
request->initiateTranslation();

/* This is the place were instructions get the effAddr. */
if (request->isMemAccessRequired()) {
if(isLoad) {
if (!inst->loadEffAddrValid()) {
inst->setLoadEffAddrs(request->getVaddr(), size);
}
// otherwise, assume that the instruction has set the addresses in advance
} else {
// store
if (!inst->effAddrValid())
{
inst->setEffAddrs(request->getVaddr(), size);
if (request->isTranslationComplete()) {
if (request->isMemAccessRequired()) {
if(isLoad) {
if (!inst->loadEffAddrValid()) {
inst->setLoadEffAddrs(request->getVaddr(), size);
}
// otherwise, assume that the instruction has set the addresses in advance
} else {
// store
if (!inst->effAddrValid())
{
inst->setEffAddrs(request->getVaddr(), size);
}
}
}

if (cpu->checker) {
inst->reqToVerify = std::make_shared<Request>(*request->req());
inst->reqIdxToVerify = request->reqIdx;
}
Fault fault;
if (isLoad)
fault = read(request, inst->lqIdx);
else {
++ inst->memWriteN;
fault = write(request, data, inst->sqIdx);
if (cpu->checker) {
inst->reqToVerify = std::make_shared<Request>(*request->req());
inst->reqIdxToVerify = request->reqIdx;
}
Fault fault;
if (isLoad)
fault = read(request, inst->lqIdx);
else {
++ inst->memWriteN;
fault = write(request, data, inst->sqIdx);
}
// inst->getFault() may have the first-fault of a
// multi-access split request at this point.
// Overwrite that only if we got another type of fault
// (e.g. re-exec).
if (fault != NoFault)
inst->getFault() = fault;
} else if (isLoad) {
inst->setMemAccPredicate(false);
// Commit will have to clean up whatever happened. Set this
// instruction as executed.
inst->setExecuted();
}
// inst->getFault() may have the first-fault of a
// multi-access split request at this point.
// Overwrite that only if we got another type of fault
// (e.g. re-exec).
if (fault != NoFault)
inst->getFault() = fault;
} else if (isLoad) {
inst->setMemAccPredicate(false);
// Commit will have to clean up whatever happened. Set this
// instruction as executed.
inst->setExecuted();
}

if (inst->traceData)
Expand Down
10 changes: 10 additions & 0 deletions src/arch/riscvcapstone/o3/ncq_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ NCQUnit::handleCacheResp(PacketPtr pkt) {
assert(it != packetIssuers.end());
PacketRecord& packet_record = it->second;
NodeCommandPtr node_cmd = packet_record.cmd;
//check if it was a command issued by cpu and not an inst
if(!packet_record.inst && node_cmd == nullptr) {
packetIssuers.erase(it);
delete pkt;
return true;
}
DPRINTF(NCQ, "Node cache response received for instruction %u, cmd beforeCommit = %u\n",
packet_record.inst->seqNum, node_cmd->beforeCommit());

Expand Down Expand Up @@ -301,6 +307,10 @@ NCQUnit::allocateInit() {
cpu->nodeController.setRoot(0);

if(pkt) {
packetIssuers[pkt->id] = PacketRecord {
.inst = nullptr,
.cmd = nullptr
};
ncq->trySendPacket(pkt, threadId);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/arch/riscvcapstone/tlb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,15 @@ TLB::translate(const RequestPtr &req, ThreadContext *tc,
{
delayed = false;

if(tc->cwrld() == 1) {
req->setPaddr(req->getVaddr());
return NoFault;
}

if (FullSystem) {
PrivilegeMode pmode = getMemPriv(tc, mode);
SATP satp = tc->readMiscReg(MISCREG_SATP).intVal();
if (pmode == PrivilegeMode::PRV_M || satp.mode == AddrXlateMode::BARE || tc->cwrld() == 1)
if (pmode == PrivilegeMode::PRV_M || satp.mode == AddrXlateMode::BARE)
req->setFlags(Request::PHYSICAL);

Fault fault;
Expand Down

0 comments on commit 9187a2d

Please sign in to comment.