From dca55a2b35fcbd5913d30faee878c6b999cb00f0 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 9 Jun 2016 12:41:52 -0700 Subject: [PATCH] Respect breakpoint privilege settings --- rocket/src/main/scala/breakpoint.scala | 9 ++++++--- rocket/src/main/scala/rocket.scala | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rocket/src/main/scala/breakpoint.scala b/rocket/src/main/scala/breakpoint.scala index 92c2430d..7254b756 100644 --- a/rocket/src/main/scala/breakpoint.scala +++ b/rocket/src/main/scala/breakpoint.scala @@ -19,6 +19,7 @@ class BPControl extends Bundle { class BreakpointUnit(implicit p: Parameters) extends CoreModule()(p) { val io = new Bundle { + val status = new MStatus().asInput val bpcontrol = Vec(p(NBreakpoints), new BPControl).asInput val bpaddress = Vec(p(NBreakpoints), UInt(width = vaddrBits)).asInput val pc = UInt(INPUT, vaddrBits) @@ -38,8 +39,10 @@ class BreakpointUnit(implicit p: Parameters) extends CoreModule()(p) { mask = Cat(mask(i-1) && bpa(i-1), mask) def matches(x: UInt) = (~x | mask) === (~bpa | mask) - when (matches(io.pc) && bpc.x) { io.xcpt_if := true } - when (matches(io.ea) && bpc.r) { io.xcpt_ld := true } - when (matches(io.ea) && bpc.w) { io.xcpt_st := true } + when (Cat(bpc.m, bpc.h, bpc.s, bpc.u)(io.status.prv)) { + when (matches(io.pc) && bpc.x) { io.xcpt_if := true } + when (matches(io.ea) && bpc.r) { io.xcpt_ld := true } + when (matches(io.ea) && bpc.w) { io.xcpt_st := true } + } } } diff --git a/rocket/src/main/scala/rocket.scala b/rocket/src/main/scala/rocket.scala index 50f45f77..60ed1634 100644 --- a/rocket/src/main/scala/rocket.scala +++ b/rocket/src/main/scala/rocket.scala @@ -227,6 +227,7 @@ class Rocket(implicit p: Parameters) extends CoreModule()(p) { id_mem_busy && (id_ctrl.amo && id_amo_aq || id_ctrl.fence_i || id_reg_fence && (id_ctrl.mem || id_ctrl.rocc) || id_csr_en) val bpu = Module(new BreakpointUnit) + bpu.io.status := csr.io.status bpu.io.bpcontrol := csr.io.bpcontrol bpu.io.bpaddress := csr.io.bpaddress bpu.io.pc := id_pc