提交 0fedb24c 编写于 作者: W William Wang

Fix atom inst pmp inplementation (#1813)

* atom: fix atom inst storeAccessFault gen logic

* atom, pmp: atom access !r addr should raise SAF

* atom: lr should raise load access fault
上级 b8f6ff86
......@@ -379,8 +379,8 @@ class PMPRespBundle(implicit p: Parameters) extends PMPBundle {
trait PMPCheckMethod extends PMPConst {
def pmp_check(cmd: UInt, cfg: PMPConfig) = {
val resp = Wire(new PMPRespBundle)
resp.ld := TlbCmd.isRead(cmd) && !TlbCmd.isAtom(cmd) && !cfg.r
resp.st := (TlbCmd.isWrite(cmd) || TlbCmd.isAtom(cmd)) && !cfg.w
resp.ld := TlbCmd.isRead(cmd) && !TlbCmd.isAmo(cmd) && !cfg.r
resp.st := (TlbCmd.isWrite(cmd) || TlbCmd.isAmo(cmd)) && !cfg.w
resp.instr := TlbCmd.isExec(cmd) && !cfg.x
resp.mmio := false.B
resp
......
......@@ -127,9 +127,8 @@ class AtomicsUnit(implicit p: Parameters) extends XSModule with MemoryOpConstant
// keep firing until tlb hit
io.dtlb.req.valid := true.B
io.dtlb.req.bits.vaddr := in.src(0)
val is_lr = in.uop.ctrl.fuOpType === LSUOpType.lr_w || in.uop.ctrl.fuOpType === LSUOpType.lr_d
io.dtlb.req.bits.cmd := Mux(is_lr, TlbCmd.atom_read, TlbCmd.atom_write)
io.dtlb.req.bits.debug.robIdx := in.uop.robIdx
io.dtlb.resp.ready := true.B
io.dtlb.req.bits.cmd := Mux(isLr, TlbCmd.atom_read, TlbCmd.atom_write)
io.dtlb.req.bits.debug.pc := in.uop.cf.pc
io.dtlb.req.bits.debug.isFirstIssue := false.B
......@@ -179,7 +178,7 @@ class AtomicsUnit(implicit p: Parameters) extends XSModule with MemoryOpConstant
// NOTE: only handle load/store exception here, if other exception happens, don't send here
val exception_va = exceptionVec(storePageFault) || exceptionVec(loadPageFault) ||
exceptionVec(storeAccessFault) || exceptionVec(loadAccessFault)
val exception_pa = pmp.st
val exception_pa = pmp.st || pmp.ld
when (exception_va || exception_pa) {
state := s_finish
out_valid := true.B
......@@ -188,6 +187,9 @@ class AtomicsUnit(implicit p: Parameters) extends XSModule with MemoryOpConstant
// if sbuffer has been flushed, go to query dcache, otherwise wait for sbuffer.
state := Mux(sbuffer_empty, s_cache_req, s_wait_flush_sbuffer_resp);
}
// update storeAccessFault bit
exceptionVec(loadAccessFault) := exceptionVec(loadAccessFault) || pmp.ld && isLr
exceptionVec(storeAccessFault) := exceptionVec(storeAccessFault) || pmp.st || pmp.ld && !isLr
}
when (state === s_wait_flush_sbuffer_resp) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册