Skip to content

Commit

Permalink
fix(CSR): Debug Interrupt is not invisible to M-mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
wissygh committed Oct 31, 2024
1 parent cb62726 commit 8895fed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,12 @@ class InterruptFilter extends Module {

// support debug interrupt
// support smrnmi when NMIE is 0, all interrupt disable
val disableInterrupt = io.in.debugMode || (io.in.dcsr.STEP.asBool && !io.in.dcsr.STEPIE.asBool) || !io.in.mnstatusNMIE
val debugInterupt = ((io.in.debugIntr && !io.in.debugMode) << CSRConst.IRQ_DEBUG).asUInt
val disableDebugIntr = io.in.debugMode || (io.in.dcsr.STEP.asBool && !io.in.dcsr.STEPIE.asBool)
val disableAllIntr = disableDebugIntr || !io.in.mnstatusNMIE
val debugInterupt = ((io.in.debugIntr && !disableDebugIntr) << CSRConst.IRQ_DEBUG).asUInt

val normalIntrVec = mIRVec | hsIRVec | vsMapHostIRVec | debugInterupt
val intrVec = VecInit(Mux(io.in.nmi, io.in.nmiVec, normalIntrVec).asBools.map(IR => IR && !disableInterrupt)).asUInt
val normalIntrVec = mIRVec | hsIRVec | vsMapHostIRVec
val intrVec = VecInit(Mux(io.in.nmi, io.in.nmiVec, normalIntrVec).asBools.map(IR => IR && !disableAllIntr)).asUInt | debugInterupt

// virtual interrupt with hvictl injection
val vsIRModeCond = privState.isModeVS && vsstatusSIE || privState < PrivState.ModeVS
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/xiangshan/backend/fu/NewCSR/NewCSR.scala
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ class NewCSR(implicit val p: Parameters) extends Module
println(mod.dumpFields)
}

trapEntryMNEvent.valid := ((hasTrap && nmi) || dbltrpToMN) && !debugMode && mnstatus.regOut.NMIE
trapEntryMNEvent.valid := ((hasTrap && nmi) || dbltrpToMN) && !entryDebugMode && !debugMode && mnstatus.regOut.NMIE
trapEntryMEvent .valid := hasTrap && entryPrivState.isModeM && !dbltrpToMN && !entryDebugMode && !debugMode && !nmi && mnstatus.regOut.NMIE
trapEntryHSEvent.valid := hasTrap && entryPrivState.isModeHS && !entryDebugMode && !debugMode && mnstatus.regOut.NMIE
trapEntryVSEvent.valid := hasTrap && entryPrivState.isModeVS && !entryDebugMode && !debugMode && mnstatus.regOut.NMIE
Expand Down Expand Up @@ -1032,7 +1032,7 @@ class NewCSR(implicit val p: Parameters) extends Module
debugMod.io.in.tdata1Wdata := wdata
debugMod.io.in.triggerCanRaiseBpExp := triggerCanRaiseBpExp

entryDebugMode := debugMod.io.out.hasDebugTrap && !debugMode && !nmi
entryDebugMode := debugMod.io.out.hasDebugTrap && !debugMode

trapEntryDEvent.valid := entryDebugMode
trapEntryDEvent.in.hasDebugIntr := debugMod.io.out.hasDebugIntr
Expand Down

0 comments on commit 8895fed

Please sign in to comment.