Skip to content

Commit

Permalink
arch-riscv: Fix bugs of h-ptw
Browse files Browse the repository at this point in the history
Change-Id: I8789d663029a46e14aa887f15082345bd7adbeec
  • Loading branch information
jueshiwenli committed Jan 21, 2025
1 parent 7c59164 commit 511caf6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/arch/riscv/pagetable_walker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ Walker::WalkerState::twoStageStepWalk(PacketPtr &write)
}

else if (l2_level == 1) {
inl2Entry.index =
(gPaddr >> (LEVEL_BITS + PageShift + L2TLB_BLK_OFFSET)) & (walker->tlb->L2TLB_L2_MASK);
walker->tlb->L2TLBInsert(inl2Entry.gpaddr, inl2Entry, l2_level, L_L2sp2, l2_i, false,
gstage);
} // hit level =1
Expand Down Expand Up @@ -917,11 +919,14 @@ Walker::WalkerState::twoStageWalk(PacketPtr &write)
inl2Entry.pte = l2pte;
inl2Entry.paddr = l2pte.ppn;
if (l2_level == 0) {
inl2Entry.index =
(gPaddr >> (L2TLB_BLK_OFFSET + PageShift)) & walker->tlb->L2TLB_L3_MASK;
inl2Entry.index = (inl2Entry.vaddr >> (L2TLB_BLK_OFFSET + PageShift)) &
walker->tlb->L2TLB_L3_MASK;
walker->tlb->L2TLBInsert(inl2Entry.vaddr, inl2Entry, l2_level, L_L2L3, l2_i, false,
vsstage);
} else if (l2_level == 1) {
inl2Entry.index =
(inl2Entry.vaddr >> (LEVEL_BITS + PageShift + L2TLB_BLK_OFFSET)) &
walker->tlb->L2TLB_L2_MASK;
walker->tlb->L2TLBInsert(inl2Entry.vaddr, inl2Entry, l2_level, L_L2sp2, l2_i,
false, vsstage);
} else if (l2_level == 2) {
Expand Down Expand Up @@ -1020,7 +1025,7 @@ Walker::WalkerState::twoStageWalk(PacketPtr &write)
walker->tlb->L2TLBInsert(inl2Entry.vaddr, inl2Entry, l2_level, L_L2L1, l2_i, false,
vsstage);
} else if (l2_level == 1) {
inl2Entry.index = (entry.vaddr >> (LEVEL_BITS + PageShift + L2TLB_BLK_OFFSET)) &
inl2Entry.index = (inl2Entry.vaddr>> (LEVEL_BITS + PageShift + L2TLB_BLK_OFFSET)) &
(walker->tlb->L2TLB_L2_MASK);
walker->tlb->L2TLBInsert(inl2Entry.vaddr, inl2Entry, l2_level, L_L2L2, l2_i, false,
vsstage);
Expand Down Expand Up @@ -1242,7 +1247,7 @@ Walker::WalkerState::stepWalk(PacketPtr &write)
direct);
}
if (l2_level == 1) {
inl2Entry.index = (entry.vaddr >> (LEVEL_BITS + PageShift + L2TLB_BLK_OFFSET)) &
inl2Entry.index = (inl2Entry.vaddr >> (LEVEL_BITS + PageShift + L2TLB_BLK_OFFSET)) &
(walker->tlb->L2TLB_L2_MASK);
walker->tlb->L2TLBInsert(inl2Entry.vaddr, inl2Entry, l2_level, L_L2L2, l2_i, false,
direct);
Expand Down
2 changes: 0 additions & 2 deletions src/arch/riscv/tlb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1984,8 +1984,6 @@ TLB::translate(const RequestPtr &req, ThreadContext *tc,
req->setFlags(Request::PHYSICAL);

Fault fault;
if (req->getVaddr() == 0)
warn("notice vaddr == 0 pc %lx \n", req->getPC());

if (req->getFlags() & Request::PHYSICAL) {
req->setTwoStageState(false, 0, 0);
Expand Down

0 comments on commit 511caf6

Please sign in to comment.