Skip to content

Commit

Permalink
LSU: trigger accessfault for vector mmio access request (#3168)
Browse files Browse the repository at this point in the history
This commit is to ensure robustness when vector instructions are used to
access MMIO regions by mistake. Currently, we do not support vector
instruction access to MMIO regions, and in order to handle the situation
when a vector instruction incorrectly accesses an MMIO region, an
accessfault exception is triggered when the MMIO region is accessed
using a vector instruction.
  • Loading branch information
weidingliu authored Jul 11, 2024
1 parent db00024 commit 11d5798
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main/scala/xiangshan/mem/pipeline/LoadUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,11 @@ class LoadUnit(implicit p: Parameters) extends XSModule
// will be force writebacked to rob
val s2_exception_vec = WireInit(s2_in.uop.exceptionVec)
when (!s2_in.delayedLoadError) {
s2_exception_vec(loadAccessFault) := (s2_in.uop.exceptionVec(loadAccessFault) || s2_pmp.ld ||
(io.dcache.resp.bits.tag_error && GatedValidRegNext(io.csrCtrl.cache_error_enable))) && s2_vecActive
s2_exception_vec(loadAccessFault) := (s2_in.uop.exceptionVec(loadAccessFault) ||
s2_pmp.ld ||
s2_isvec && s2_pmp.mmio && !s2_prf && !s2_in.tlbMiss ||
(io.dcache.resp.bits.tag_error && GatedValidRegNext(io.csrCtrl.cache_error_enable))
) && s2_vecActive
}

// soft prefetch will not trigger any exception (but ecc error interrupt may
Expand Down
5 changes: 4 additions & 1 deletion src/main/scala/xiangshan/mem/pipeline/StoreUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ class StoreUnit(implicit p: Parameters) extends XSModule
s2_out.af := s2_pmp.st && !s2_in.isvec
s2_out.mmio := s2_mmio && !s2_exception
s2_out.atomic := s2_in.atomic || s2_pmp.atomic
s2_out.uop.exceptionVec(storeAccessFault) := (s2_in.uop.exceptionVec(storeAccessFault) || s2_pmp.st) && s2_vecActive
s2_out.uop.exceptionVec(storeAccessFault) := (s2_in.uop.exceptionVec(storeAccessFault) ||
s2_pmp.st ||
(s2_in.isvec && s2_pmp.mmio && RegNext(s1_feedback.bits.hit))
) && s2_vecActive

// kill dcache write intent request when mmio or exception
io.dcache.s2_kill := (s2_mmio || s2_exception || s2_in.uop.robIdx.needFlush(io.redirect))
Expand Down

0 comments on commit 11d5798

Please sign in to comment.