Skip to content

Commit

Permalink
fix(IFU): mark mmio mismatch exception only on the second line (#3963)
Browse files Browse the repository at this point in the history
When mmio mismatch happens, we can still fetch inst from the first page.
So we can just mark the exception on the second cacheline.

Also fixes a bug: when itlb page fault occurs only on the second page,
PMP check may return incorrect results (as the input paddr may be
incorrect), on which request the mmio mismatch check should not be
performed. (Here we still perform the check, but the result will be
ignored, since itlb exception has higher priority in
`ExceptionType.merge`)
  • Loading branch information
ngc7331 authored Dec 2, 2024
1 parent dc4fac1 commit 35850f1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/main/scala/xiangshan/frontend/IFU.scala
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,19 @@ class NewIFU(implicit p: Parameters) extends XSModule
val f2_isForVSnonLeafPTE = fromICache.bits.isForVSnonLeafPTE

// FIXME: raise af if one fetch block crosses the cacheable-noncacheable boundary, might not correct
val f2_mmio_mismatch_exception = VecInit(Seq.fill(2)(Mux(
// not double-line, skip check
!fromICache.bits.doubleline || (
// is double-line, ask for consistent pmp_mmio and itlb_pbmt value
fromICache.bits.pmp_mmio(0) === fromICache.bits.pmp_mmio(1) &&
fromICache.bits.itlb_pbmt(0) === fromICache.bits.itlb_pbmt(1)
),
ExceptionType.none,
ExceptionType.af
)))
val f2_mmio_mismatch_exception = VecInit(Seq(
ExceptionType.none, // mark the exception only on the second line
Mux(
// not double-line, skip check
!fromICache.bits.doubleline || (
// is double-line, ask for consistent pmp_mmio and itlb_pbmt value
fromICache.bits.pmp_mmio(0) === fromICache.bits.pmp_mmio(1) &&
fromICache.bits.itlb_pbmt(0) === fromICache.bits.itlb_pbmt(1)
),
ExceptionType.none,
ExceptionType.af
)
))

// merge exceptions
val f2_exception = ExceptionType.merge(f2_exception_in, f2_mmio_mismatch_exception)
Expand Down

0 comments on commit 35850f1

Please sign in to comment.